diff --git a/include/prereq-build.mk b/include/prereq-build.mk index a04a093450e..0bb5d8df3e4 100644 --- a/include/prereq-build.mk +++ b/include/prereq-build.mk @@ -69,12 +69,6 @@ $(eval $(call TestHostCommand,zlib, \ echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 0; }' | \ gcc -include zlib.h -x c -o $(TMP_DIR)/a.out - -lz)) -$(eval $(call TestHostCommand,libssl, \ - Please install the openssl library (with development headers), \ - echo 'int main(int argc, char **argv) { SSL_library_init(); return 0; }' | \ - gcc $(HOST_CFLAGS) -include openssl/ssl.h -x c -o $(TMP_DIR)/a.out - -lcrypto -lssl $(HOST_LDFLAGS))) - - $(eval $(call SetupHostCommand,tar,Please install GNU 'tar', \ gtar --version 2>&1 | grep GNU, \ gnutar --version 2>&1 | grep GNU, \ @@ -155,9 +149,6 @@ $(eval $(call SetupHostCommand,git,Please install Git (git-core) >= 1.6.5, \ $(eval $(call SetupHostCommand,file,Please install the 'file' package, \ file --version 2>&1 | grep file)) -$(eval $(call SetupHostCommand,openssl,Please install the 'openssl' utility, \ - openssl version | grep OpenSSL)) - # Install ldconfig stub $(eval $(call TestHostCommand,ldconfig-stub,Failed to install stub, \ diff --git a/package/libs/libjson-c/Makefile b/package/libs/libjson-c/Makefile index 0010b42d9b8..0f13883a3bd 100644 --- a/package/libs/libjson-c/Makefile +++ b/package/libs/libjson-c/Makefile @@ -8,35 +8,33 @@ include $(TOPDIR)/rules.mk PKG_NAME:=json-c -PKG_VERSION:=0.12 -PKG_RELEASE:=1 +PKG_VERSION:=0.15 +PKG_RELEASE:=2 -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-nodoc.tar.gz PKG_SOURCE_URL:=https://s3.amazonaws.com/json-c_releases/releases/ -PKG_MD5SUM:=3ca4bbb881dfc4017e8021b5e0a8c491 +PKG_HASH:=99bca4f944b8ced8ae0bbc6310d6a3528ca715e69541793a1ef51f8c5b4b0878 +PKG_MAINTAINER:=Felix Fietkau PKG_LICENSE:=MIT PKG_LICENSE_FILES:=COPYING +PKG_CPE_ID:=cpe:/a:json-c_project:json-c -PKG_FIXUP:=autoreconf -PKG_INSTALL:=1 - -PKG_MAINTAINER:=Felix Fietkau +HOST_BUILD_PREFIX:=$(STAGING_DIR_HOST) include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/host-build.mk +include $(INCLUDE_DIR)/cmake.mk -TARGET_CFLAGS += $(FPIC) - -CONFIGURE_ARGS += \ - ac_cv_func_strdup=yes \ - ac_cv_func_strncasecmp=yes \ - ac_cv_func_snprintf=yes +CMAKE_HOST_OPTIONS += \ + -DBUILD_SHARED_LIBS=FALSE define Package/libjson-c SECTION:=libs CATEGORY:=Libraries TITLE:=javascript object notation - URL:=http://oss.metaparadigm.com/json-c/ + URL:=https://json-c.github.io/json-c/ + ABI_VERSION:=5 endef define Package/libjson-c/description @@ -44,12 +42,9 @@ define Package/libjson-c/description endef define Build/InstallDev - $(INSTALL_DIR) $(1)/usr/include - $(CP) $(PKG_INSTALL_DIR)/usr/include/json-c $(1)/usr/include/ - $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/usr/lib/libjson-c.{a,so*} $(1)/usr/lib/ - $(INSTALL_DIR) $(1)/usr/lib/pkgconfig - $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/json-c.pc $(1)/usr/lib/pkgconfig/ + $(call Build/InstallDev/cmake,$(1)) + $(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/json-c.pc + $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/json-c.pc endef define Package/libjson-c/install @@ -58,3 +53,4 @@ define Package/libjson-c/install endef $(eval $(call BuildPackage,libjson-c)) +$(eval $(call HostBuild)) diff --git a/package/libs/libjson-c/patches/000-libm.patch b/package/libs/libjson-c/patches/000-libm.patch deleted file mode 100644 index 45adb0597f2..00000000000 --- a/package/libs/libjson-c/patches/000-libm.patch +++ /dev/null @@ -1,50 +0,0 @@ ---- a/configure.ac -+++ b/configure.ac -@@ -43,12 +43,6 @@ - AC_FUNC_MALLOC - AC_FUNC_REALLOC - AC_CHECK_FUNCS(strcasecmp strdup strerror snprintf vsnprintf vasprintf open vsyslog strncasecmp setlocale) --AC_CHECK_DECLS([INFINITY], [], [], [[#include ]]) --AC_CHECK_DECLS([nan], [], [], [[#include ]]) --AC_CHECK_DECLS([isnan], [], [], [[#include ]]) --AC_CHECK_DECLS([isinf], [], [], [[#include ]]) --AC_CHECK_DECLS([_isnan], [], [], [[#include ]]) --AC_CHECK_DECLS([_finite], [], [], [[#include ]]) - - #check if .section.gnu.warning accepts long strings (for __warn_references) - AC_LANG_PUSH([C]) ---- a/math_compat.h -+++ b/math_compat.h -@@ -1,28 +1,9 @@ - #ifndef __math_compat_h - #define __math_compat_h - --/* Define isnan and isinf on Windows/MSVC */ -- --#ifndef HAVE_DECL_ISNAN --# ifdef HAVE_DECL__ISNAN --#include --#define isnan(x) _isnan(x) --# endif --#endif -- --#ifndef HAVE_DECL_ISINF --# ifdef HAVE_DECL__FINITE --#include --#define isinf(x) (!_finite(x)) --# endif --#endif -- --#ifndef HAVE_DECL_NAN --#error This platform does not have nan() --#endif -- --#ifndef HAVE_DECL_INFINITY --#error This platform does not have INFINITY --#endif -+#undef isnan -+#define isnan(x) __builtin_isnan(x) -+#undef isinf -+#define isinf(x) __builtin_isinf(x) - - #endif diff --git a/package/libs/libjson-c/patches/001-backport_compile_fix.patch b/package/libs/libjson-c/patches/001-backport_compile_fix.patch deleted file mode 100644 index e83f5d28a34..00000000000 --- a/package/libs/libjson-c/patches/001-backport_compile_fix.patch +++ /dev/null @@ -1,23 +0,0 @@ -commit 3859e99f50abe11a8dade28efa9ea3d99dfaac11 -Author: Petar Koretić -Date: Fri Apr 11 10:03:40 2014 +0200 - - Remove unused variable 'size' - -diff --git a/json_tokener.c b/json_tokener.c -index 19de8ef..9a76293 100644 ---- a/json_tokener.c -+++ b/json_tokener.c -@@ -352,12 +352,10 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, - - case json_tokener_state_inf: /* aka starts with 'i' */ - { -- int size; - int size_inf; - int is_negative = 0; - - printbuf_memappend_fast(tok->pb, &c, 1); -- size = json_min(tok->st_pos+1, json_null_str_len); - size_inf = json_min(tok->st_pos+1, json_inf_str_len); - char *infbuf = tok->pb->buf; - if (*infbuf == '-') diff --git a/package/libs/libjson-c/patches/001-dont-build-docs.patch b/package/libs/libjson-c/patches/001-dont-build-docs.patch new file mode 100644 index 00000000000..1aa0da4f598 --- /dev/null +++ b/package/libs/libjson-c/patches/001-dont-build-docs.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -401,8 +401,6 @@ set(JSON_C_SOURCES + include_directories(${PROJECT_SOURCE_DIR}) + include_directories(${PROJECT_BINARY_DIR}) + +-add_subdirectory(doc) +- + # uninstall + add_custom_target(uninstall + COMMAND cat ${PROJECT_BINARY_DIR}/install_manifest.txt | xargs rm diff --git a/package/libs/libjson-c/patches/010-clang.patch b/package/libs/libjson-c/patches/010-clang.patch new file mode 100644 index 00000000000..9ef73f1a82e --- /dev/null +++ b/package/libs/libjson-c/patches/010-clang.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -265,7 +265,7 @@ message(STATUS "Wrote ${PROJECT_BINARY_D + configure_file(${PROJECT_SOURCE_DIR}/cmake/json_config.h.in ${PROJECT_BINARY_DIR}/json_config.h) + message(STATUS "Wrote ${PROJECT_BINARY_DIR}/json_config.h") + +-if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") ++if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections") + if ("${DISABLE_WERROR}" STREQUAL "OFF") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") diff --git a/package/network/config/netifd/patches/001-is_error_func_replaced.patch b/package/network/config/netifd/patches/001-is_error_func_replaced.patch new file mode 100644 index 00000000000..8578f56c946 --- /dev/null +++ b/package/network/config/netifd/patches/001-is_error_func_replaced.patch @@ -0,0 +1,12 @@ +diff -aur a/handler.c b/handler.c +--- a/handler.c 2022-09-07 20:55:07.966501377 +0300 ++++ b/handler.c 2022-09-07 21:14:06.713596580 +0300 +@@ -105,7 +105,7 @@ + tok = json_tokener_new(); + + obj = json_tokener_parse_ex(tok, start, len); +- if (!is_error(obj)) { ++ if (obj != NULL) { + netifd_init_script_handler(name, obj, cb); + json_object_put(obj); + json_tokener_free(tok); diff --git a/qca/feeds/nss-host/qca-nss-clients/Makefile b/qca/feeds/nss-host/qca-nss-clients/Makefile index 5ecd15ec761..29c7dc589e8 100644 --- a/qca/feeds/nss-host/qca-nss-clients/Makefile +++ b/qca/feeds/nss-host/qca-nss-clients/Makefile @@ -457,6 +457,7 @@ endef EXTRA_CFLAGS+= \ -I$(STAGING_DIR)/usr/include/qca-nss-drv \ + -I$(STAGING_DIR)/usr/include/qca-nss-ecm \ -I$(STAGING_DIR)/usr/include/qca-nss-crypto \ -I$(STAGING_DIR)/usr/include/qca-nss-cfi \ -I$(STAGING_DIR)/usr/include/qca-nss-gmac \ diff --git a/qca/feeds/packages/lang/python/Makefile b/qca/feeds/packages/lang/python/Makefile index b27507f1b52..aa3357572be 100644 --- a/qca/feeds/packages/lang/python/Makefile +++ b/qca/feeds/packages/lang/python/Makefile @@ -16,8 +16,7 @@ PKG_RELEASE:=1 PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=https://www.python.org/ftp/python/$(PKG_VERSION) -PKG_MD5SUM:=53b43534153bb2a0363f08bae8b9d990 -PKG_HASH:=35d543986882f78261f97787fd3e06274bfa6df29fac9b4a94f73930ff98f731 +PKG_MD5SUM:=57dffcee9cee8bb2ab5f82af1d8e9a69 PKG_LICENSE:=PSF PKG_LICENSE_FILES:=LICENSE Modules/_ctypes/libffi_msvc/LICENSE Modules/_ctypes/darwin/LICENSE Modules/_ctypes/libffi/LICENSE Modules/_ctypes/libffi_osx/LICENSE Tools/pybench/LICENSE @@ -30,7 +29,7 @@ PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION) HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION) PKG_BUILD_DEPENDS:=python/host -HOST_BUILD_DEPENDS:=bzip2/host expat/host libffi/host +HOST_BUILD_DEPENDS:=bzip2/host expat/host include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/package.mk @@ -217,14 +216,14 @@ endef HOST_CFLAGS+= \ -I/usr/include/ncursesw \ - -I/usr/include/ncurses + -I/usr/include/ncurses \ + -I/usr/include/tirpc HOST_CONFIGURE_ARGS+= \ --without-cxx-main \ --without-pymalloc \ --with-threads \ --with-system-expat=$(STAGING_DIR_HOST) \ - --with-system-ffi=$(STAGING_DIR_HOST) \ --prefix=$(STAGING_DIR_HOST) \ --with-ensurepip=upgrade \ CONFIG_SITE= \ diff --git a/qca/feeds/packages/lang/python/files/python-package.mk b/qca/feeds/packages/lang/python/files/python-package.mk index 5613908e86c..368dbaa7c93 100644 --- a/qca/feeds/packages/lang/python/files/python-package.mk +++ b/qca/feeds/packages/lang/python/files/python-package.mk @@ -6,7 +6,7 @@ # PYTHON_VERSION:=2.7 -PYTHON_VERSION_MICRO:=13 +PYTHON_VERSION_MICRO:=12 PYTHON_DIR:=$(STAGING_DIR)/usr PYTHON_BIN_DIR:=$(PYTHON_DIR)/bin diff --git a/qca/feeds/packages/libs/libgpg-error/Makefile b/qca/feeds/packages/libs/libgpg-error/Makefile index 27e5e0954ec..1db835715ea 100644 --- a/qca/feeds/packages/libs/libgpg-error/Makefile +++ b/qca/feeds/packages/libs/libgpg-error/Makefile @@ -8,15 +8,22 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libgpg-error -PKG_VERSION:=1.12 -PKG_RELEASE:=1 +PKG_VERSION:=1.45 +PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 -PKG_SOURCE_URL:=ftp://ftp.gnupg.org/gcrypt/libgpg-error -PKG_MD5SUM:=8f0eb41a344d19ac2aa9bd101dfb9ce6 +PKG_SOURCE_URL:=https://mirrors.dotsrc.org/gcrypt/libgpg-error \ + http://ring.ksc.gr.jp/archives/net/gnupg/libgpg-error \ + https://www.gnupg.org/ftp/gcrypt/libgpg-error +PKG_HASH:=570f8ee4fb4bff7b7495cff920c275002aea2147e9a1d220c068213267f80a26 -PKG_BUILD_PARALLEL:=1 +PKG_MAINTAINER:=W. Michael Petullo +PKG_LICENSE:=LGPL-2.1-or-later +PKG_LICENSE_FILES:=COPYING + +PKG_FIXUP:=autoreconf PKG_INSTALL:=1 +PKG_BUILD_PARALLEL:=1 include $(INCLUDE_DIR)/package.mk @@ -24,8 +31,7 @@ define Package/libgpg-error SECTION:=libs CATEGORY:=Libraries TITLE:=GnuPG error handling helper library - URL:=http://www.gnupg.org/related_software/libgpg-error/ - MAINTAINER:=W. Michael Petullo + URL:=https://www.gnupg.org/related_software/libgpg-error/ endef define Package/libgpg-error/description @@ -36,12 +42,13 @@ define Package/libgpg-error/description future. endef -TARGET_CFLAGS += $(FPIC) - CONFIGURE_ARGS += \ --enable-shared \ --enable-static \ - --disable-rpath + --disable-doc \ + --disable-languages \ + --disable-rpath \ + --disable-tests define Build/InstallDev $(INSTALL_DIR) $(2)/bin $(1)/usr/bin @@ -53,11 +60,23 @@ define Build/InstallDev $(2)/bin/gpg-error-config ln -sf $(STAGING_DIR)/host/bin/gpg-error-config $(1)/usr/bin/gpg-error-config + $(INSTALL_BIN) \ + $(PKG_INSTALL_DIR)/usr/bin/gpgrt-config \ + $(2)/bin/ + $(SED) \ + 's,^\(prefix\|exec_prefix\)=.*,\1=$(STAGING_DIR)/usr,g' \ + $(2)/bin/gpgrt-config + ln -sf $(STAGING_DIR)/host/bin/gpgrt-config $(1)/usr/bin/gpgrt-config + $(INSTALL_DIR) $(1)/usr/include $(INSTALL_DATA) \ $(PKG_INSTALL_DIR)/usr/include/gpg-error.h \ $(1)/usr/include/ + $(INSTALL_DATA) \ + $(PKG_INSTALL_DIR)/usr/include/gpgrt.h \ + $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib $(CP) \ $(PKG_INSTALL_DIR)/usr/lib/libgpg-error.{la,a,so*} \ @@ -67,6 +86,10 @@ define Build/InstallDev $(INSTALL_DATA) \ $(PKG_INSTALL_DIR)/usr/share/aclocal/gpg-error.m4 \ $(1)/usr/share/aclocal/ + + $(INSTALL_DATA) \ + $(PKG_INSTALL_DIR)/usr/share/aclocal/gpgrt.m4 \ + $(1)/usr/share/aclocal/ endef define Package/libgpg-error/install diff --git a/qca/feeds/packages/libs/libgpg-error/patches/001-cross-compile-fix.patch b/qca/feeds/packages/libs/libgpg-error/patches/001-cross-compile-fix.patch new file mode 100644 index 00000000000..606cdd37858 --- /dev/null +++ b/qca/feeds/packages/libs/libgpg-error/patches/001-cross-compile-fix.patch @@ -0,0 +1,24 @@ +--- a/configure.ac ++++ b/configure.ac +@@ -74,6 +74,21 @@ AM_SILENT_RULES + AC_CANONICAL_HOST + AB_INIT + ++case "${host}" in ++ x86_64-openwrt-linux-gnu|i?86-openwrt-linux-gnu) ++ host=$(echo $host | sed 's/openwrt/pc/g') ++ ;; ++ arm-openwrt-linux-gnu|armeb-openwrt-linux-gnu) ++ host=arm-unknown-linux-gnueabi ++ ;; ++ mips64-openwrt-linux-gnu) ++ host=mips64el-unknown-linux-gnuabi64 ++ ;; ++ *) ++ host=$(echo $host | sed 's/openwrt/unknown/g') ++ ;; ++esac ++ + # Checks for programs. + AC_PROG_CC + AM_PROG_CC_C_O diff --git a/qca/feeds/packages/libs/libgpg-error/patches/001-gcc5.patch b/qca/feeds/packages/libs/libgpg-error/patches/001-gcc5.patch deleted file mode 100644 index 1d886ff9890..00000000000 --- a/qca/feeds/packages/libs/libgpg-error/patches/001-gcc5.patch +++ /dev/null @@ -1,54 +0,0 @@ -From: Daniel Kahn Gillmor -Date: Mon, 16 Mar 2015 17:40:12 +0000 (-0400) -Subject: Avoid breakage with gcc 5 -X-Git-Tag: libgpg-error-1.19~7 -X-Git-Url: http://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgpg-error.git;a=commitdiff_plain;h=c01c8f0c4f55d76b037c7f6aa44ad25ede18d38a - -Avoid breakage with gcc 5 - -* src/Makefile.am: Add -P to the C preprocessor when building -mkerrcodes.h, to avoid a noisy intermediate pipeline. - --- - -With gcc 5 without this patch, we see many errors like the following: - -gcc -I. -I. -o mkerrcodes ./mkerrcodes.c -In file included from ./mkerrcodes.c:26:0: -./mkerrcodes.h:9:5: error: expected expression before ‘,’ token - { , "GPG_ERR_E2BIG" }, - ^ -./mkerrcodes.h:10:5: error: expected expression before ‘,’ token - { , "GPG_ERR_EACCES" }, - ^ - -This patch cleans up the generated mkerrcodes.h by making the -intermediate stage clean for all the versions of gcc i tested (4.x and -5). - -Debian-Bug-Id: 777374 -Signed-Off-By: Daniel Kahn Gillmor ---- - ---- a/src/Makefile.am -+++ b/src/Makefile.am -@@ -140,7 +140,7 @@ code-to-errno.h: Makefile mkerrnos.awk e - # It is correct to use $(CPP). We want the host's idea of the error codes. - mkerrcodes.h: Makefile mkerrcodes.awk $(gpg_extra_headers) - $(AWK) -f $(srcdir)/mkerrcodes1.awk $(srcdir)/errnos.in >_$@ -- $(CPP) $(CPPFLAGS) $(extra_cppflags) _$@ | grep GPG_ERR_ | \ -+ $(CPP) $(CPPFLAGS) $(extra_cppflags) -P _$@ | grep GPG_ERR_ | \ - $(AWK) -f $(srcdir)/mkerrcodes.awk >$@ - -rm _$@ - ---- a/src/Makefile.in -+++ b/src/Makefile.in -@@ -979,7 +979,7 @@ code-to-errno.h: Makefile mkerrnos.awk e - # It is correct to use $(CPP). We want the host's idea of the error codes. - mkerrcodes.h: Makefile mkerrcodes.awk $(gpg_extra_headers) - $(AWK) -f $(srcdir)/mkerrcodes1.awk $(srcdir)/errnos.in >_$@ -- $(CPP) $(CPPFLAGS) $(extra_cppflags) _$@ | grep GPG_ERR_ | \ -+ $(CPP) $(CPPFLAGS) $(extra_cppflags) -P _$@ | grep GPG_ERR_ | \ - $(AWK) -f $(srcdir)/mkerrcodes.awk >$@ - -rm _$@ - diff --git a/qca/feeds/packages/libs/libgpg-error/patches/010-add-arc-support.patch b/qca/feeds/packages/libs/libgpg-error/patches/010-add-arc-support.patch new file mode 100644 index 00000000000..5ecf81c292c --- /dev/null +++ b/qca/feeds/packages/libs/libgpg-error/patches/010-add-arc-support.patch @@ -0,0 +1,64 @@ +From: Mylene Josserand + +DesignWare ARC Processors are a family of 32-bit CPUs from Synopsys. +This change allows us to build for and use libgpg-error on ARC cores. + +These values were obtained from a test application executed on ARC +in simulation this way: + +1. Instructions for cross-compilation used are here: + http://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgpg-error.git;a=blob;f=README + +2. Commands used on host: + # build="$(build-aux/config.guess)" + # ./configure --prefix=build/tmp-uclibc/sysroots/nsimhs/usr/ --host=arc-oe-linux-uclibc --build=$build + # cd src + # make gen-posix-lock-obj + +3. Commands used on target: + # ./gen-posix-lock-obj + +Signed-off-by: Mylene Josserand +Signed-off-by: Alexey Brodkin +--- + src/Makefile.am | 1 + + .../lock-obj-pub.arc-unknown-linux-gnu.h | 23 +++++++++++++++++++ + 2 files changed, 24 insertions(+) + create mode 100644 src/syscfg/lock-obj-pub.arc-unknown-linux-gnu.h + +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -48,6 +48,7 @@ lock_obj_pub = \ + syscfg/lock-obj-pub.aarch64-unknown-linux-gnu_ilp32.h \ + syscfg/lock-obj-pub.aarch64-apple-darwin.h \ + syscfg/lock-obj-pub.alpha-unknown-linux-gnu.h \ ++ syscfg/lock-obj-pub.arc-unknown-linux-gnu.h \ + syscfg/lock-obj-pub.arm-unknown-linux-androideabi.h \ + syscfg/lock-obj-pub.arm-unknown-linux-gnueabi.h \ + syscfg/lock-obj-pub.arm-apple-darwin.h \ +--- /dev/null ++++ b/src/syscfg/lock-obj-pub.arc-unknown-linux-gnu.h +@@ -0,0 +1,23 @@ ++## lock-obj-pub.arc-oe-linux-uclibc.h ++## File created by gen-posix-lock-obj - DO NOT EDIT ++## To be included by mkheader into gpg-error.h ++ ++typedef struct ++{ ++ long _vers; ++ union { ++ volatile char _priv[24]; ++ long _x_align; ++ long *_xp_align; ++ } u; ++} gpgrt_lock_t; ++ ++#define GPGRT_LOCK_INITIALIZER {1,{{0,0,0,0,0,0,0,0, \ ++ 0,0,0,0,0,0,0,0, \ ++ 0,0,0,0,0,0,0,0}}} ++## ++## Local Variables: ++## mode: c ++## buffer-read-only: t ++## End: ++## diff --git a/qca/feeds/packages/libs/libpam/Makefile b/qca/feeds/packages/libs/libpam/Makefile index e9c4a3c7017..7bc16dfcaef 100644 --- a/qca/feeds/packages/libs/libpam/Makefile +++ b/qca/feeds/packages/libs/libpam/Makefile @@ -8,17 +8,22 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libpam -PKG_VERSION:=1.1.8 -PKG_RELEASE:=4 +PKG_VERSION:=1.5.1 +PKG_RELEASE:=1 + +PKG_SOURCE:=Linux-PAM-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=https://github.com/linux-pam/linux-pam/releases/download/v$(PKG_VERSION) +PKG_HASH:=201d40730b1135b1b3cdea09f2c28ac634d73181ccd0172ceddee3649c5792fc +PKG_BUILD_DIR:=$(BUILD_DIR)/Linux-PAM-$(PKG_VERSION) -PKG_SOURCE:=Linux-PAM-$(PKG_VERSION).tar.bz2 -PKG_SOURCE_URL:=http://www.linux-pam.org/library/ -PKG_MD5SUM:=35b6091af95981b1b2cd60d813b5e4ee -PKG_INSTALL:=1 -PKG_FIXUP:=autoreconf PKG_MAINTAINER:=Nikos Mavrogiannopoulos +PKG_LICENSE:=BSD-3c GPL +PKG_LICENSE_FILES:=COPYING Copyright +PKG_CPE_ID:=cpe:/a:kernel:linux-pam -PKG_BUILD_DIR:=$(BUILD_DIR)/Linux-PAM-$(PKG_VERSION) +PKG_FIXUP:=autoreconf +PKG_INSTALL:=1 +PKG_BUILD_PARALLEL:=1 include $(INCLUDE_DIR)/package.mk @@ -33,38 +38,43 @@ define Package/libpam/description The Linux-PAM Pluggable Authentication Modules. endef -TARGET_CFLAGS += $(FPIC) - -define Build/Configure - $(call Build/Configure/Default, \ - --enable-shared \ - --enable-static \ - --enable-pamlocking \ - --disable-prelude \ - --disable-lckpwdf \ - --disable-selinux \ - --disable-nls \ - --disable-rpath \ - --enable-db=no \ - ) -endef +CONFIGURE_ARGS += \ + --enable-pamlocking \ + --enable-shared \ + --enable-static \ + --disable-audit \ + --disable-cracklib \ + --disable-db \ + --disable-debug \ + --disable-doc \ + --disable-econf \ + --disable-lckpwdf \ + --disable-nis \ + --disable-prelude \ + --disable-regenerate-docu \ + --disable-rpath \ + --disable-selinux \ + --disable-Werror \ + --with-gnu-ld \ + --without-mailspool \ + --without-xauth define Build/InstallDev - $(INSTALL_DIR) $(1)/lib $(INSTALL_DIR) $(1)/usr/include - $(CP) $(PKG_INSTALL_DIR)/lib/* $(1)/lib/ + $(INSTALL_DIR) $(1)/usr/lib $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib/ endef define Package/libpam/install - $(INSTALL_DIR) $(1)/lib $(1)/lib/security $(1)/lib/security/pam_filter $(INSTALL_DIR) $(1)/etc $(1)/etc/pam.d + $(INSTALL_DIR) $(1)/usr/lib $(1)/usr/lib/security $(1)/usr/lib/security/pam_filter $(INSTALL_DIR) $(1)/usr/sbin - $(CP) $(PKG_INSTALL_DIR)/lib/*.so* $(1)/lib/ - $(CP) $(PKG_INSTALL_DIR)/lib/security/*.so* $(1)/lib/security/ - $(CP) $(PKG_INSTALL_DIR)/lib/security/pam_filter/* $(1)/lib/security/pam_filter/ $(CP) $(PKG_INSTALL_DIR)/etc/* $(1)/etc/ $(CP) ./files/* $(1)/etc/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/security/*.so* $(1)/usr/lib/security/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/security/pam_filter/* $(1)/usr/lib/security/pam_filter/ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/* $(1)/usr/sbin/ endef diff --git a/qca/feeds/packages/libs/libpam/patches/000-OE-libpam-xtests.patch b/qca/feeds/packages/libs/libpam/patches/000-OE-libpam-xtests.patch deleted file mode 100644 index 19fbaa29bd1..00000000000 --- a/qca/feeds/packages/libs/libpam/patches/000-OE-libpam-xtests.patch +++ /dev/null @@ -1,35 +0,0 @@ -This patch is used to create a new sub package libpam-xtests to do more checks. - -Upstream-Status: Pending - -Signed-off-by: Kang Kai ---- a/xtests/Makefile.am -+++ b/xtests/Makefile.am -@@ -7,7 +7,7 @@ AM_CFLAGS = -DLIBPAM_COMPILE -I$(top_src - LDADD = $(top_builddir)/libpam/libpam.la \ - $(top_builddir)/libpam_misc/libpam_misc.la - --CLEANFILES = *~ $(XTESTS) -+CLEANFILES = *~ - - EXTRA_DIST = run-xtests.sh tst-pam_dispatch1.pamd tst-pam_dispatch2.pamd \ - tst-pam_dispatch3.pamd tst-pam_dispatch4.pamd \ -@@ -51,3 +51,18 @@ EXTRA_PROGRAMS = $(XTESTS) - - xtests: $(XTESTS) run-xtests.sh - "$(srcdir)"/run-xtests.sh "$(srcdir)" ${XTESTS} ${NOSRCTESTS} -+ -+all: $(XTESTS) -+ -+install: install_xtests -+ -+install_xtests: -+ $(INSTALL) -d $(DESTDIR)$(pkgdatadir)/xtests -+ for file in $(EXTRA_DIST) ; do \ -+ $(INSTALL) $$file $(DESTDIR)$(pkgdatadir)/xtests ; \ -+ done -+ for file in $(XTESTS); do \ -+ $(INSTALL) .libs/$$file $(DESTDIR)$(pkgdatadir)/xtests ; \ -+ done -+ -+.PHONY: all install_xtests diff --git a/qca/feeds/packages/libs/libpam/patches/000-OE-pam-no-innetgr.patch b/qca/feeds/packages/libs/libpam/patches/000-OE-pam-no-innetgr.patch deleted file mode 100644 index f7f5b4897ec..00000000000 --- a/qca/feeds/packages/libs/libpam/patches/000-OE-pam-no-innetgr.patch +++ /dev/null @@ -1,85 +0,0 @@ -innetgr may not be there so make sure that when innetgr is not present -then we inform about it and not use it. - --Khem ---- a/modules/pam_group/pam_group.c -+++ b/modules/pam_group/pam_group.c -@@ -656,7 +656,11 @@ static int check_account(pam_handle_t *p - } - /* If buffer starts with @, we are using netgroups */ - if (buffer[0] == '@') -+#ifdef HAVE_INNETGR - good &= innetgr (&buffer[1], NULL, user, NULL); -+#else -+ pam_syslog (pamh, LOG_ERR, "pam_group does not have netgroup support"); -+#endif - /* otherwise, if the buffer starts with %, it's a UNIX group */ - else if (buffer[0] == '%') - good &= pam_modutil_user_in_group_nam_nam(pamh, user, &buffer[1]); ---- a/modules/pam_time/pam_time.c -+++ b/modules/pam_time/pam_time.c -@@ -555,9 +555,13 @@ check_account(pam_handle_t *pamh, const - } - /* If buffer starts with @, we are using netgroups */ - if (buffer[0] == '@') -- good &= innetgr (&buffer[1], NULL, user, NULL); -+#ifdef HAVE_INNETGR -+ good &= innetgr (&buffer[1], NULL, user, NULL); -+#else -+ pam_syslog (pamh, LOG_ERR, "pam_time does not have netgroup support"); -+#endif - else -- good &= logic_field(pamh, user, buffer, count, is_same); -+ good &= logic_field(pamh, user, buffer, count, is_same); - D(("with user: %s", good ? "passes":"fails" )); - - /* here we get the time field */ ---- a/modules/pam_succeed_if/pam_succeed_if.c -+++ b/modules/pam_succeed_if/pam_succeed_if.c -@@ -231,18 +231,27 @@ evaluate_notingroup(pam_handle_t *pamh, - } - /* Return PAM_SUCCESS if the (host,user) is in the netgroup. */ - static int --evaluate_innetgr(const char *host, const char *user, const char *group) -+evaluate_innetgr(const pam_handle_t* pamh, const char *host, const char *user, const char *group) - { -+#ifdef HAVE_INNETGR - if (innetgr(group, host, user, NULL) == 1) - return PAM_SUCCESS; -+#else -+ pam_syslog (pamh, LOG_ERR, "pam_succeed_if does not have netgroup support"); -+#endif -+ - return PAM_AUTH_ERR; - } - /* Return PAM_SUCCESS if the (host,user) is NOT in the netgroup. */ - static int --evaluate_notinnetgr(const char *host, const char *user, const char *group) -+evaluate_notinnetgr(const pam_handle_t* pamh, const char *host, const char *user, const char *group) - { -+#ifdef HAVE_INNETGR - if (innetgr(group, host, user, NULL) == 0) - return PAM_SUCCESS; -+#else -+ pam_syslog (pamh, LOG_ERR, "pam_succeed_if does not have netgroup support"); -+#endif - return PAM_AUTH_ERR; - } - -@@ -387,14 +396,14 @@ evaluate(pam_handle_t *pamh, int debug, - const void *rhost; - if (pam_get_item(pamh, PAM_RHOST, &rhost) != PAM_SUCCESS) - rhost = NULL; -- return evaluate_innetgr(rhost, user, right); -+ return evaluate_innetgr(pamh, rhost, user, right); - } - /* (Rhost, user) is not in this group. */ - if (strcasecmp(qual, "notinnetgr") == 0) { - const void *rhost; - if (pam_get_item(pamh, PAM_RHOST, &rhost) != PAM_SUCCESS) - rhost = NULL; -- return evaluate_notinnetgr(rhost, user, right); -+ return evaluate_notinnetgr(pamh, rhost, user, right); - } - /* Fail closed. */ - return PAM_SERVICE_ERR; diff --git a/qca/feeds/packages/libs/libpam/patches/0001-build-always-use-lib-instead-of-lib64.patch b/qca/feeds/packages/libs/libpam/patches/0001-build-always-use-lib-instead-of-lib64.patch new file mode 100644 index 00000000000..a40274f776f --- /dev/null +++ b/qca/feeds/packages/libs/libpam/patches/0001-build-always-use-lib-instead-of-lib64.patch @@ -0,0 +1,11 @@ +--- a/configure.ac ++++ b/configure.ac +@@ -25,7 +25,7 @@ dnl If we use /usr as prefix, use /etc f + then + sysconfdir="/etc" + fi +- if test ${libdir} = '${exec_prefix}/lib' ++ if false + then + case "$host_cpu" in + x86_64|ppc64|s390x|sparc64) diff --git a/qca/feeds/packages/libs/libpam/patches/001-no_nis.patch b/qca/feeds/packages/libs/libpam/patches/001-no_nis.patch deleted file mode 100644 index c9988c7fbd7..00000000000 --- a/qca/feeds/packages/libs/libpam/patches/001-no_nis.patch +++ /dev/null @@ -1,68 +0,0 @@ ---- a/modules/pam_access/pam_access.c -+++ b/modules/pam_access/pam_access.c -@@ -44,7 +44,7 @@ - #include - #include - #include --#ifdef HAVE_RPCSVC_YPCLNT_H -+#ifdef HAVE_RPCSVC_YPCLNT_H && USE_NIS - #include - #endif - #ifdef HAVE_LIBAUDIT ---- a/modules/pam_unix/pam_unix_passwd.c -+++ b/modules/pam_unix/pam_unix_passwd.c -@@ -79,18 +79,18 @@ - #include "passverify.h" - #include "bigcrypt.h" - --#if (HAVE_YP_GET_DEFAULT_DOMAIN || HAVE_GETDOMAINNAME) && HAVE_YP_MASTER -+#if (HAVE_YP_GET_DEFAULT_DOMAIN || HAVE_GETDOMAINNAME) && HAVE_YP_MASTER && USE_NIS - # define HAVE_NIS - #endif - - #ifdef HAVE_NIS - # include - --# if HAVE_RPCSVC_YP_PROT_H -+# if HAVE_RPCSVC_YP_PROT_H && USE_NIS - # include - # endif - --# if HAVE_RPCSVC_YPCLNT_H -+# if HAVE_RPCSVC_YPCLNT_H && USE_NIS - # include - # endif - ---- a/modules/pam_unix/support.c -+++ b/modules/pam_unix/support.c -@@ -19,7 +19,7 @@ - #include - #include - #include --#ifdef HAVE_RPCSVC_YPCLNT_H -+#ifdef HAVE_RPCSVC_YPCLNT_H && USE_NIS - #include - #endif - -@@ -402,7 +402,7 @@ int _unix_getpwnam(pam_handle_t *pamh, c - } - } - --#if defined(HAVE_YP_GET_DEFAULT_DOMAIN) && defined (HAVE_YP_BIND) && defined (HAVE_YP_MATCH) && defined (HAVE_YP_UNBIND) -+#if defined(HAVE_YP_GET_DEFAULT_DOMAIN) && defined (HAVE_YP_BIND) && defined (HAVE_YP_MATCH) && defined (HAVE_YP_UNBIND) && (USE_NIS) - if (!matched && nis) { - char *userinfo = NULL, *domain = NULL; - int len = 0, i; ---- a/modules/pam_unix/yppasswd_xdr.c -+++ b/modules/pam_unix/yppasswd_xdr.c -@@ -15,6 +15,10 @@ - #ifdef HAVE_RPC_RPC_H - - #include -+#ifdef USE_NIS -+#include -+#include -+#endif - #include "yppasswd.h" - - bool_t diff --git a/qca/feeds/packages/libs/libpam/patches/002-no_yywrap.patch b/qca/feeds/packages/libs/libpam/patches/002-no_yywrap.patch deleted file mode 100644 index 0d73e4be053..00000000000 --- a/qca/feeds/packages/libs/libpam/patches/002-no_yywrap.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/conf/pam_conv1/pam_conv_l.c -+++ b/conf/pam_conv1/pam_conv_l.c -@@ -534,7 +534,9 @@ void yyset_lineno (int line_number ); - #ifdef __cplusplus - extern "C" int yywrap (void ); - #else --extern int yywrap (void ); -+int yywrap (void ) { -+ return 1; -+} - #endif - #endif - ---- a/doc/specs/parse_l.c -+++ b/doc/specs/parse_l.c -@@ -520,7 +520,9 @@ void yyset_lineno (int line_number ); - #ifdef __cplusplus - extern "C" int yywrap (void ); - #else --extern int yywrap (void ); -+int yywrap (void ) { -+ return 1; -+} - #endif - #endif - diff --git a/qca/feeds/packages/libs/libpam/patches/003-no_doc.patch b/qca/feeds/packages/libs/libpam/patches/003-no_doc.patch deleted file mode 100644 index d36621514ff..00000000000 --- a/qca/feeds/packages/libs/libpam/patches/003-no_doc.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/Makefile.am -+++ b/Makefile.am -@@ -4,7 +4,7 @@ - - AUTOMAKE_OPTIONS = 1.9 gnu dist-bzip2 check-news - --SUBDIRS = libpam tests libpamc libpam_misc modules po conf doc examples xtests -+SUBDIRS = libpam tests libpamc libpam_misc modules po conf examples xtests - - CLEANFILES = *~ - ---- a/Makefile.in -+++ b/Makefile.in -@@ -288,7 +288,7 @@ top_build_prefix = @top_build_prefix@ - top_builddir = @top_builddir@ - top_srcdir = @top_srcdir@ - AUTOMAKE_OPTIONS = 1.9 gnu dist-bzip2 check-news --SUBDIRS = libpam tests libpamc libpam_misc modules po conf doc examples xtests -+SUBDIRS = libpam tests libpamc libpam_misc modules po conf examples xtests - CLEANFILES = *~ - EXTRA_DIST = pgp.keys.asc CHANGELOG ChangeLog-CVS Copyright Make.xml.rules - ACLOCAL_AMFLAGS = -I m4 diff --git a/qca/feeds/packages/libs/libpam/patches/004-fix_lib64.patch b/qca/feeds/packages/libs/libpam/patches/004-fix_lib64.patch deleted file mode 100644 index 5605d8298bf..00000000000 --- a/qca/feeds/packages/libs/libpam/patches/004-fix_lib64.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/configure.in -+++ b/configure.in -@@ -28,12 +28,7 @@ dnl If we use /usr as prefix, use /etc f - fi - if test ${libdir} = '${exec_prefix}/lib' - then -- case "`uname -m`" in -- x86_64|ppc64|s390x|sparc64) -- libdir="/lib64" ;; -- *) -- libdir="/lib" ;; -- esac -+ libdir="/lib" - fi - if test ${sbindir} = '${exec_prefix}/sbin' - then diff --git a/qca/feeds/packages/libs/libpam/patches/005-fix_ruserok.patch b/qca/feeds/packages/libs/libpam/patches/005-fix_ruserok.patch deleted file mode 100644 index 1f0f4633719..00000000000 --- a/qca/feeds/packages/libs/libpam/patches/005-fix_ruserok.patch +++ /dev/null @@ -1,364 +0,0 @@ ---- a/modules/pam_rhosts/pam_rhosts.c -+++ b/modules/pam_rhosts/pam_rhosts.c -@@ -43,6 +43,361 @@ - #include - #include - -+#ifdef __UCLIBC__ -+ -+#include -+#include -+ -+ -+int __check_rhosts_file = 1; -+ -+/* Extremely paranoid file open function. */ -+static FILE * -+iruserfopen (const char *file, uid_t okuser) -+{ -+ struct stat st; -+ char *cp = NULL; -+ FILE *res = NULL; -+ -+ /* If not a regular file, if owned by someone other than user or -+ root, if writeable by anyone but the owner, or if hardlinked -+ anywhere, quit. */ -+ if (lstat (file, &st)) -+ cp = "lstat failed"; -+ else if (!S_ISREG (st.st_mode)) -+ cp = "not regular file"; -+ else -+ { -+ res = fopen (file, "r"); -+ if (!res) -+ cp = "cannot open"; -+ else if (fstat (fileno (res), &st) < 0) -+ cp = "fstat failed"; -+ else if (st.st_uid && st.st_uid != okuser) -+ cp = "bad owner"; -+ else if (st.st_mode & (S_IWGRP|S_IWOTH)) -+ cp = "writeable by other than owner"; -+ else if (st.st_nlink > 1) -+ cp = "hard linked somewhere"; -+ } -+ -+ /* If there were any problems, quit. */ -+ if (cp != NULL) -+ { -+ if (res) -+ fclose (res); -+ return NULL; -+ } -+ -+ return res; -+} -+ -+/* -+ * Returns 1 for blank lines (or only comment lines) and 0 otherwise -+ */ -+static int -+__isempty(char *p) -+{ -+ while (*p && isspace (*p)) { -+ ++p; -+ } -+ -+ return (*p == '\0' || *p == '#') ? 1 : 0 ; -+} -+ -+/* Returns 1 on positive match, 0 on no match, -1 on negative match. */ -+static int -+__icheckhost (u_int32_t raddr, char *lhost, const char *rhost) -+{ -+ struct hostent *hp; -+ u_int32_t laddr; -+ int negate=1; /* Multiply return with this to get -1 instead of 1 */ -+ char **pp; -+ -+#ifdef __UCLIBC_HAS_REENTRANT_RPC__ -+ int save_errno; -+ size_t buflen; -+ char *buffer; -+ struct hostent hostbuf; -+ int herr; -+#endif -+ -+#ifdef HAVE_NETGROUP -+ /* Check nis netgroup. */ -+ if (strncmp ("+@", lhost, 2) == 0) -+ return innetgr (&lhost[2], rhost, NULL, NULL); -+ -+ if (strncmp ("-@", lhost, 2) == 0) -+ return -innetgr (&lhost[2], rhost, NULL, NULL); -+#endif /* HAVE_NETGROUP */ -+ -+ /* -host */ -+ if (strncmp ("-", lhost,1) == 0) { -+ negate = -1; -+ lhost++; -+ } else if (strcmp ("+",lhost) == 0) { -+ return 1; /* asking for trouble, but ok.. */ -+ } -+ -+ /* Try for raw ip address first. */ -+ if (isdigit (*lhost) && (laddr = inet_addr (lhost)) != INADDR_NONE) -+ return negate * (! (raddr ^ laddr)); -+ -+ /* Better be a hostname. */ -+#ifdef __UCLIBC_HAS_REENTRANT_RPC__ -+ buflen = 1024; -+ buffer = malloc(buflen); -+ save_errno = errno; -+ -+ while (gethostbyname_r (lhost, &hostbuf, buffer, buflen, &hp, &herr) -+ != 0) { -+ free(buffer); -+ return (0); -+ } -+ free(buffer); -+ __set_errno (save_errno); -+#else -+ hp = gethostbyname(lhost); -+#endif /* __UCLIBC_HAS_REENTRANT_RPC__ */ -+ -+ if (hp == NULL) -+ return 0; -+ -+ /* Spin through ip addresses. */ -+ for (pp = hp->h_addr_list; *pp; ++pp) -+ if (!memcmp (&raddr, *pp, sizeof (u_int32_t))) -+ return negate; -+ -+ /* No match. */ -+ return (0); -+} -+ -+/* Returns 1 on positive match, 0 on no match, -1 on negative match. */ -+static int -+__icheckuser (const char *luser, const char *ruser) -+{ -+ -+ /* -+ luser is user entry from .rhosts/hosts.equiv file -+ ruser is user id on remote host -+ */ -+ -+#ifdef HAVE_NETGROUP -+ /* [-+]@netgroup */ -+ if (strncmp ("+@", luser, 2) == 0) -+ return innetgr (&luser[2], NULL, ruser, NULL); -+ -+ if (strncmp ("-@", luser,2) == 0) -+ return -innetgr (&luser[2], NULL, ruser, NULL); -+#endif /* HAVE_NETGROUP */ -+ -+ /* -user */ -+ if (strncmp ("-", luser, 1) == 0) -+ return -(strcmp (&luser[1], ruser) == 0); -+ -+ /* + */ -+ if (strcmp ("+", luser) == 0) -+ return 1; -+ -+ /* simple string match */ -+ return strcmp (ruser, luser) == 0; -+} -+ -+/* -+ * Returns 0 if positive match, -1 if _not_ ok. -+ */ -+static int -+__ivaliduser2(FILE *hostf, u_int32_t raddr, const char *luser, -+ const char *ruser, const char *rhost) -+{ -+ register const char *user; -+ register char *p; -+ int hcheck, ucheck; -+ char *buf = NULL; -+ size_t bufsize = 0; -+ int retval = -1; -+ -+ while (getline (&buf, &bufsize, hostf) > 0) { -+ buf[bufsize - 1] = '\0'; /* Make sure it's terminated. */ -+ p = buf; -+ -+ /* Skip empty or comment lines */ -+ if (__isempty (p)) { -+ continue; -+ } -+ -+ /* Skip lines that are too long. */ -+ if (strchr (p, '\n') == NULL) { -+ int ch = getc_unlocked (hostf); -+ -+ while (ch != '\n' && ch != EOF) -+ ch = getc_unlocked (hostf); -+ continue; -+ } -+ -+ for (;*p && !isspace(*p); ++p) { -+ *p = tolower (*p); -+ } -+ -+ /* Next we want to find the permitted name for the remote user. */ -+ if (*p == ' ' || *p == '\t') { -+ /* terminate hostname and skip spaces */ -+ for (*p++='\0'; *p && isspace (*p); ++p); -+ -+ user = p; /* this is the user's name */ -+ while (*p && !isspace (*p)) -+ ++p; /* find end of user's name */ -+ } else -+ user = p; -+ -+ *p = '\0'; /* terminate username (+host?) */ -+ -+ /* buf -> host(?) ; user -> username(?) */ -+ -+ /* First check host part */ -+ hcheck = __icheckhost (raddr, buf, rhost); -+ -+ if (hcheck < 0) -+ break; -+ -+ if (hcheck) { -+ /* Then check user part */ -+ if (! (*user)) -+ user = luser; -+ -+ ucheck = __icheckuser (user, ruser); -+ -+ /* Positive 'host user' match? */ -+ if (ucheck > 0) { -+ retval = 0; -+ break; -+ } -+ -+ /* Negative 'host -user' match? */ -+ if (ucheck < 0) -+ break; -+ -+ /* Neither, go on looking for match */ -+ } -+ } -+ -+ free (buf); -+ -+ return retval; -+} -+ -+static int -+iruserok2 (u_int32_t raddr, int superuser, const char *ruser, const char *luser, -+ const char *rhost) -+{ -+ FILE *hostf = NULL; -+ int isbad = -1; -+ -+ if (!superuser) -+ hostf = iruserfopen (_PATH_HEQUIV, 0); -+ -+ if (hostf) { -+ isbad = __ivaliduser2 (hostf, raddr, luser, ruser, rhost); -+ fclose (hostf); -+ -+ if (!isbad) -+ return 0; -+ } -+ -+ if (__check_rhosts_file || superuser) { -+ char *pbuf; -+ struct passwd *pwd; -+ size_t dirlen; -+ uid_t uid; -+ -+#ifdef __UCLIBC_HAS_REENTRANT_RPC__ -+ size_t buflen = sysconf (_SC_GETPW_R_SIZE_MAX); -+ struct passwd pwdbuf; -+ char *buffer = stack_heap_alloc(buflen); -+ -+ if (getpwnam_r (luser, &pwdbuf, buffer, -+ buflen, &pwd) != 0 || pwd == NULL) -+ { -+ stack_heap_free(buffer); -+ return -1; -+ } -+ stack_heap_free(buffer); -+#else -+ if ((pwd = getpwnam(luser)) == NULL) -+ return -1; -+#endif -+ -+ dirlen = strlen (pwd->pw_dir); -+ pbuf = malloc (dirlen + sizeof "/.rhosts"); -+ strcpy (pbuf, pwd->pw_dir); -+ strcat (pbuf, "/.rhosts"); -+ -+ /* Change effective uid while reading .rhosts. If root and -+ reading an NFS mounted file system, can't read files that -+ are protected read/write owner only. */ -+ uid = geteuid (); -+ seteuid (pwd->pw_uid); -+ hostf = iruserfopen (pbuf, pwd->pw_uid); -+ free(pbuf); -+ -+ if (hostf != NULL) { -+ isbad = __ivaliduser2 (hostf, raddr, luser, ruser, rhost); -+ fclose (hostf); -+ } -+ -+ seteuid (uid); -+ return isbad; -+ } -+ return -1; -+} -+ -+int ruserok(const char *rhost, int superuser, const char *ruser, -+ const char *luser) -+{ -+ struct hostent *hp; -+ u_int32_t addr; -+ char **ap; -+#ifdef __UCLIBC_HAS_REENTRANT_RPC__ -+ size_t buflen; -+ char *buffer; -+ int herr; -+ struct hostent hostbuf; -+#endif -+ -+#ifdef __UCLIBC_HAS_REENTRANT_RPC__ -+ buflen = 1024; -+ buffer = stack_heap_alloc(buflen); -+ -+ while (gethostbyname_r (rhost, &hostbuf, buffer, -+ buflen, &hp, &herr) != 0 || hp == NULL) -+ { -+ if (herr != NETDB_INTERNAL || errno != ERANGE) { -+ stack_heap_free(buffer); -+ return -1; -+ } else -+ { -+ /* Enlarge the buffer. */ -+ buflen *= 2; -+ stack_heap_free(buffer); -+ buffer = stack_heap_alloc(buflen); -+ } -+ } -+ stack_heap_free(buffer); -+#else -+ if ((hp = gethostbyname(rhost)) == NULL) { -+ return -1; -+ } -+#endif -+ for (ap = hp->h_addr_list; *ap; ++ap) { -+ memmove(&addr, *ap, sizeof(addr)); -+ if (iruserok2(addr, superuser, ruser, luser, rhost) == 0) -+ return 0; -+ } -+ return -1; -+} -+ -+#endif /* __UCLIBC__ */ -+ - PAM_EXTERN - int pam_sm_authenticate (pam_handle_t *pamh, int flags, int argc, - const char **argv) diff --git a/qca/feeds/packages/libs/libpam/patches/006-fix_xdr.patch b/qca/feeds/packages/libs/libpam/patches/006-fix_xdr.patch deleted file mode 100644 index 97695060891..00000000000 --- a/qca/feeds/packages/libs/libpam/patches/006-fix_xdr.patch +++ /dev/null @@ -1,271 +0,0 @@ ---- a/modules/pam_unix/yppasswd_xdr.c -+++ b/modules/pam_unix/yppasswd_xdr.c -@@ -21,6 +21,268 @@ - #endif - #include "yppasswd.h" - -+#ifdef __UCLIBC__ -+ -+static const char xdr_zero[BYTES_PER_XDR_UNIT] = {0, 0, 0, 0}; -+ -+/* -+ * XDR integers -+ */ -+bool_t -+xdr_int (XDR *xdrs, int *ip) -+{ -+ -+#if INT_MAX < LONG_MAX -+ long l; -+ -+ switch (xdrs->x_op) -+ { -+ case XDR_ENCODE: -+ l = (long) *ip; -+ return XDR_PUTLONG (xdrs, &l); -+ -+ case XDR_DECODE: -+ if (!XDR_GETLONG (xdrs, &l)) -+ { -+ return FALSE; -+ } -+ *ip = (int) l; -+ case XDR_FREE: -+ return TRUE; -+ } -+ return FALSE; -+#elif INT_MAX == LONG_MAX -+ return xdr_long (xdrs, (long *) ip); -+#elif INT_MAX == SHRT_MAX -+ return xdr_short (xdrs, (short *) ip); -+#else -+#error unexpected integer sizes in xdr_int() -+#endif -+} -+ -+/* -+ * XDR null terminated ASCII strings -+ * xdr_string deals with "C strings" - arrays of bytes that are -+ * terminated by a NULL character. The parameter cpp references a -+ * pointer to storage; If the pointer is null, then the necessary -+ * storage is allocated. The last parameter is the max allowed length -+ * of the string as specified by a protocol. -+ */ -+bool_t -+xdr_string (XDR *xdrs, char **cpp, u_int maxsize) -+{ -+ char *sp = *cpp; /* sp is the actual string pointer */ -+ u_int size; -+ u_int nodesize; -+ -+ /* -+ * first deal with the length since xdr strings are counted-strings -+ */ -+ switch (xdrs->x_op) -+ { -+ case XDR_FREE: -+ if (sp == NULL) -+ { -+ return TRUE; /* already free */ -+ } -+ /* fall through... */ -+ case XDR_ENCODE: -+ if (sp == NULL) -+ return FALSE; -+ size = strlen (sp); -+ break; -+ case XDR_DECODE: -+ break; -+ } -+ if (!xdr_u_int (xdrs, &size)) -+ { -+ return FALSE; -+ } -+ if (size > maxsize) -+ { -+ return FALSE; -+ } -+ nodesize = size + 1; -+ -+ /* -+ * now deal with the actual bytes -+ */ -+ switch (xdrs->x_op) -+ { -+ case XDR_DECODE: -+ if (nodesize == 0) -+ { -+ return TRUE; -+ } -+ if (sp == NULL) -+ *cpp = sp = (char *) mem_alloc (nodesize); -+ if (sp == NULL) -+ { -+#ifdef USE_IN_LIBIO -+ if (_IO_fwide (stderr, 0) > 0) -+ (void) fwprintf (stderr, L"%s", -+ _("xdr_string: out of memory\n")); -+ else -+#endif -+ (void) fputs (_("xdr_string: out of memory\n"), stderr); -+ return FALSE; -+ } -+ sp[size] = 0; -+ /* fall into ... */ -+ -+ case XDR_ENCODE: -+ return xdr_opaque (xdrs, sp, size); -+ -+ case XDR_FREE: -+ mem_free (sp, nodesize); -+ *cpp = NULL; -+ return TRUE; -+ } -+ return FALSE; -+} -+ -+/* -+ * XDR long integers -+ * The definition of xdr_long() is kept for backward -+ * compatibility. Instead xdr_int() should be used. -+ */ -+bool_t -+xdr_long (XDR *xdrs, long *lp) -+{ -+ if (xdrs->x_op == XDR_ENCODE -+ && (sizeof (int32_t) == sizeof (long) -+ || (int32_t) *lp == *lp)) -+ return XDR_PUTLONG (xdrs, lp); -+ -+ if (xdrs->x_op == XDR_DECODE) -+ return XDR_GETLONG (xdrs, lp); -+ -+ if (xdrs->x_op == XDR_FREE) -+ return TRUE; -+ -+ return FALSE; -+} -+ -+/* -+ * XDR unsigned integers -+ */ -+bool_t -+xdr_u_int (XDR *xdrs, u_int *up) -+{ -+#if UINT_MAX < ULONG_MAX -+ u_long l; -+ -+ switch (xdrs->x_op) -+ { -+ case XDR_ENCODE: -+ l = (u_long) * up; -+ return XDR_PUTLONG (xdrs, (long *) &l); -+ -+ case XDR_DECODE: -+ if (!XDR_GETLONG (xdrs, (long *) &l)) -+ { -+ return FALSE; -+ } -+ *up = (u_int) l; -+ case XDR_FREE: -+ return TRUE; -+ } -+ return FALSE; -+#elif UINT_MAX == ULONG_MAX -+ return xdr_u_long (xdrs, (u_long *) up); -+#elif UINT_MAX == USHRT_MAX -+ return xdr_short (xdrs, (short *) up); -+#else -+#error unexpected integer sizes in xdr_u_int() -+#endif -+} -+ -+/* -+ * XDR opaque data -+ * Allows the specification of a fixed size sequence of opaque bytes. -+ * cp points to the opaque object and cnt gives the byte length. -+ */ -+bool_t -+xdr_opaque (XDR *xdrs, caddr_t cp, u_int cnt) -+{ -+ u_int rndup; -+ static char crud[BYTES_PER_XDR_UNIT]; -+ -+ /* -+ * if no data we are done -+ */ -+ if (cnt == 0) -+ return TRUE; -+ -+ /* -+ * round byte count to full xdr units -+ */ -+ rndup = cnt % BYTES_PER_XDR_UNIT; -+ if (rndup > 0) -+ rndup = BYTES_PER_XDR_UNIT - rndup; -+ -+ switch (xdrs->x_op) -+ { -+ case XDR_DECODE: -+ if (!XDR_GETBYTES (xdrs, cp, cnt)) -+ { -+ return FALSE; -+ } -+ if (rndup == 0) -+ return TRUE; -+ return XDR_GETBYTES (xdrs, (caddr_t)crud, rndup); -+ -+ case XDR_ENCODE: -+ if (!XDR_PUTBYTES (xdrs, cp, cnt)) -+ { -+ return FALSE; -+ } -+ if (rndup == 0) -+ return TRUE; -+ return XDR_PUTBYTES (xdrs, xdr_zero, rndup); -+ -+ case XDR_FREE: -+ return TRUE; -+ } -+ return FALSE; -+} -+ -+/* -+ * XDR unsigned long integers -+ * The definition of xdr_u_long() is kept for backward -+ * compatibility. Instead xdr_u_int() should be used. -+ */ -+bool_t -+xdr_u_long (XDR *xdrs, u_long *ulp) -+{ -+ switch (xdrs->x_op) -+ { -+ case XDR_DECODE: -+ { -+ long int tmp; -+ -+ if (XDR_GETLONG (xdrs, &tmp) == FALSE) -+ return FALSE; -+ -+ *ulp = (uint32_t) tmp; -+ return TRUE; -+ } -+ -+ case XDR_ENCODE: -+ if (sizeof (uint32_t) != sizeof (u_long) -+ && (uint32_t) *ulp != *ulp) -+ return FALSE; -+ -+ return XDR_PUTLONG (xdrs, (long *) ulp); -+ -+ case XDR_FREE: -+ return TRUE; -+ } -+ return FALSE; -+} -+ -+#endif /* UCLIBC */ -+ - bool_t - xdr_xpasswd(XDR * xdrs, xpasswd * objp) - { diff --git a/qca/feeds/packages/libs/libpam/patches/007-cve-2014-2583.patch b/qca/feeds/packages/libs/libpam/patches/007-cve-2014-2583.patch deleted file mode 100644 index 8d24bead657..00000000000 --- a/qca/feeds/packages/libs/libpam/patches/007-cve-2014-2583.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 9dcead87e6d7f66d34e7a56d11a30daca367dffb Mon Sep 17 00:00:00 2001 -From: "Dmitry V. Levin" -Date: Wed, 26 Mar 2014 22:17:23 +0000 -Subject: pam_timestamp: fix potential directory traversal issue (ticket #27) - -pam_timestamp uses values of PAM_RUSER and PAM_TTY as components of -the timestamp pathname it creates, so extra care should be taken to -avoid potential directory traversal issues. - -* modules/pam_timestamp/pam_timestamp.c (check_tty): Treat -"." and ".." tty values as invalid. -(get_ruser): Treat "." and ".." ruser values, as well as any ruser -value containing '/', as invalid. - -Fixes CVE-2014-2583. - -Reported-by: Sebastian Krahmer - -diff --git a/modules/pam_timestamp/pam_timestamp.c b/modules/pam_timestamp/pam_timestamp.c -index 5193733..b3f08b1 100644 ---- a/modules/pam_timestamp/pam_timestamp.c -+++ b/modules/pam_timestamp/pam_timestamp.c -@@ -158,7 +158,7 @@ check_tty(const char *tty) - tty = strrchr(tty, '/') + 1; - } - /* Make sure the tty wasn't actually a directory (no basename). */ -- if (strlen(tty) == 0) { -+ if (!strlen(tty) || !strcmp(tty, ".") || !strcmp(tty, "..")) { - return NULL; - } - return tty; -@@ -243,6 +243,17 @@ get_ruser(pam_handle_t *pamh, char *ruserbuf, size_t ruserbuflen) - if (pwd != NULL) { - ruser = pwd->pw_name; - } -+ } else { -+ /* -+ * This ruser is used by format_timestamp_name as a component -+ * of constructed timestamp pathname, so ".", "..", and '/' -+ * are disallowed to avoid potential path traversal issues. -+ */ -+ if (!strcmp(ruser, ".") || -+ !strcmp(ruser, "..") || -+ strchr(ruser, '/')) { -+ ruser = NULL; -+ } - } - if (ruser == NULL || strlen(ruser) >= ruserbuflen) { - *ruserbuf = '\0'; --- -cgit v0.10.2 - diff --git a/qca/feeds/packages/net/mosquitto/Makefile b/qca/feeds/packages/net/mosquitto/Makefile index 26393512162..0c768dbd3d0 100644 --- a/qca/feeds/packages/net/mosquitto/Makefile +++ b/qca/feeds/packages/net/mosquitto/Makefile @@ -180,8 +180,9 @@ define Build/InstallDev $(INSTALL_DIR) $(1)/usr/include $(CP) $(PKG_BUILD_DIR)/lib/mosquitto.h $(1)/usr/include $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_BUILD_DIR)/lib/libmosquitto.so.1 $(1)/usr/lib/ - $(LN) libmosquitto.so.1 $(1)/usr/lib/libmosquitto.so + $(CP) $(PKG_BUILD_DIR)/lib/libmosquitto.so.1 $(1)/usr/lib/libmosquitto-$(BUILD_VARIANT).so.1 + $(CP) $(PKG_BUILD_DIR)/lib/libmosquitto.a $(1)/usr/lib/libmosquitto-$(BUILD_VARIANT).a + $(LN) libmosquitto.so.1 $(1)/usr/lib/libmosquitto-$(BUILD_VARIANT).so endef # This installs files on the target. Compare with Build/InstallDev @@ -193,9 +194,9 @@ endef Package/libmosquitto-nossl/install = $(Package/libmosquitto/install) # Applies to all... -MAKE_FLAGS += WITH_DOCS=no +MAKE_FLAGS += WITH_DOCS=no WITH_STATIC_LIBRARIES=yes ifeq ($(BUILD_VARIANT),nossl) - MAKE_FLAGS += WITH_TLS=no WITH_WEBSOCKETS=no + MAKE_FLAGS += WITH_TLS=no WITH_WEBSOCKETS=no else MAKE_FLAGS += WITH_WEBSOCKETS=$(if $(CONFIG_MOSQUITTO_LWS),"yes","no") endif diff --git a/qca/feeds/packages/net/openssh/Config.in b/qca/feeds/packages/net/openssh/Config.in new file mode 100644 index 00000000000..3690ced2bd2 --- /dev/null +++ b/qca/feeds/packages/net/openssh/Config.in @@ -0,0 +1,12 @@ +if PACKAGE_openssh-server + +config OPENSSH_LIBFIDO2 + bool + default y + prompt "Include libfido2 support in openssh-server" + help + OpenSSH version 8.2 added two new ssh authentication methods, + namely `ecdsa_sk` and `ed25519_sk`. These two methods make use + of hardware keys that implement the FIDO and FIDO2 protocols. + In order to use these two types, libfido2 is required. +endif diff --git a/qca/feeds/packages/net/openssh/Makefile b/qca/feeds/packages/net/openssh/Makefile index ccf5b71a4d6..e574e91767d 100644 --- a/qca/feeds/packages/net/openssh/Makefile +++ b/qca/feeds/packages/net/openssh/Makefile @@ -8,19 +8,24 @@ include $(TOPDIR)/rules.mk PKG_NAME:=openssh -PKG_VERSION:=7.1p2 -PKG_RELEASE:=1 +PKG_VERSION:=8.9p1 +PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/ \ - http://ftp.belnet.be/pub/OpenBSD/OpenSSH/portable/ -PKG_MD5SUM:=4d8547670e2a220d5ef805ad9e47acf2 +PKG_SOURCE_URL:=https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/ \ + https://ftp.spline.de/pub/OpenBSD/OpenSSH/portable/ +PKG_HASH:=fd497654b7ab1686dac672fb83dfb4ba4096e8b5ffcdaccd262380ae58bec5e7 PKG_LICENSE:=BSD ISC PKG_LICENSE_FILES:=LICENCE +PKG_CPE_ID:=cpe:/a:openssh:openssh +PKG_FIXUP:=autoreconf +PKG_REMOVE_FILES:= +PKG_CONFIG_DEPENDS := \ + CONFIG_OPENSSH_LIBFIDO2 -PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION) +PKG_BUILD_DEPENDS += OPENSSH_LIBFIDO2:libfido2 include $(INCLUDE_DIR)/package.mk @@ -48,6 +53,9 @@ endef define Package/openssh-client $(call Package/openssh/Default) TITLE+= client + ALTERNATIVES:=\ + 200:/usr/bin/ssh:/usr/libexec/ssh-openssh \ + 200:/usr/bin/scp:/usr/libexec/scp-openssh endef define Package/openssh-client/description @@ -79,17 +87,25 @@ endef define Package/openssh-server $(call Package/openssh/Default) - DEPENDS+= +openssh-keygen + DEPENDS+= +openssh-keygen +OPENSSH_LIBFIDO2:libfido2 TITLE+= server USERID:=sshd=22:sshd=22 endef +define Package/openssh-server/config + source "$(SOURCE)/Config.in" +endef + define Package/openssh-server/description OpenSSH server. endef define Package/openssh-server/conffiles /etc/ssh/sshd_config +/etc/ssh/ssh_host_ed25519_key +/etc/ssh/ssh_host_ed25519_key.pub +/etc/ssh/ssh_host_rsa_key +/etc/ssh/ssh_host_rsa_key.pub endef define Package/openssh-server-pam @@ -107,7 +123,7 @@ endef define Package/openssh-server-pam/conffiles /etc/pam.d/sshd /etc/security/access-sshd-local.conf -/etc/ssh/sshd_config +$(Package/openssh-server/conffiles) endef define Package/openssh-sftp-client @@ -122,8 +138,6 @@ endef define Package/openssh-sftp-server $(call Package/openssh/Default) TITLE+= SFTP server - # Strip dependencies to avoid pulling in OpenSSL etc. - DEPENDS:= endef define Package/openssh-sftp-server/description @@ -145,14 +159,10 @@ define Package/openssh-sftp-avahi-service/conffiles /etc/avahi/services/sftp-ssh.service endef -CONFIGURE_ARGS+= \ - $(DISABLE_NLS) \ +CONFIGURE_ARGS += \ --sysconfdir=/etc/ssh \ --with-privsep-user=sshd \ --with-privsep-path=/var/empty \ - --enable-shared \ - --disable-static \ - --disable-debug \ --disable-strip \ --disable-etc-default-login \ --disable-lastlog \ @@ -162,8 +172,10 @@ CONFIGURE_ARGS+= \ --disable-wtmpx \ --without-bsd-auth \ --without-kerberos5 \ - --without-x - + --with-stackprotect \ + --with$(if $(CONFIG_OPENSSL_ENGINE),,out)-ssl-engine \ + --with$(if $(CONFIG_OPENSSH_LIBFIDO2),,out)-security-key-builtin + ifeq ($(BUILD_VARIANT),with-pam) CONFIGURE_ARGS += \ --with-pam @@ -172,63 +184,30 @@ CONFIGURE_ARGS += \ --without-pam endif -ifeq ($(CONFIG_OPENSSL_ENGINE),y) -CONFIGURE_ARGS+= \ - --with-ssl-engine -endif - -ifneq ($(CONFIG_SSP_SUPPORT),y) -CONFIGURE_ARGS += \ - --without-stackprotect -endif - -CONFIGURE_VARS += LD="$(TARGET_CC)" +CONFIGURE_VARS += LD="$(TARGET_CC)" PATH_PASSWD_PROG="/bin/passwd" ifeq ($(BUILD_VARIANT),with-pam) TARGET_LDFLAGS += -lpthread endif define Build/Compile - $(MAKE) -C $(PKG_BUILD_DIR) \ - DESTDIR="$(PKG_INSTALL_DIR)" \ - LIBS="" \ - sftp-server $(MAKE) -C $(PKG_BUILD_DIR) \ DESTDIR="$(PKG_INSTALL_DIR)" \ STRIP_OPT="" \ all install endef -define Package/openssh-client/preinst -#!/bin/sh -if [ -L $${IPKG_INSTROOT}/usr/bin/ssh ] && [ -L $${IPKG_INSTROOT}/usr/bin/scp ]; then - rm -f $${IPKG_INSTROOT}/usr/bin/ssh $${IPKG_INSTROOT}/usr/bin/scp; -fi -exit 0 -endef - -define Package/openssh-client/postrm -#!/bin/sh -rm -f $${IPKG_INSTROOT}/usr/bin/ssh $${IPKG_INSTROOT}/usr/bin/scp; -if [ -x $${IPKG_INSTROOT}/usr/sbin/dropbear ] ; then - ln -s /usr/sbin/dropbear $${IPKG_INSTROOT}/usr/bin/ssh; - ln -s /usr/sbin/dropbear $${IPKG_INSTROOT}/usr/bin/scp; -fi -exit 0 -endef - define Package/openssh-moduli/install - $(INSTALL_DIR) $(1)/etc/ssh + install -d -m0700 $(1)/etc/ssh $(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/ssh/moduli $(1)/etc/ssh/ endef define Package/openssh-client/install - $(INSTALL_DIR) $(1)/etc/ssh - chmod 0700 $(1)/etc/ssh + install -d -m0700 $(1)/etc/ssh $(CP) $(PKG_INSTALL_DIR)/etc/ssh/ssh_config $(1)/etc/ssh/ - $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ssh $(1)/usr/bin/ - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/scp $(1)/usr/bin/ + $(INSTALL_DIR) $(1)/usr/libexec + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ssh $(1)/usr/libexec/ssh-openssh + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/scp $(1)/usr/libexec/scp-openssh endef define Package/openssh-client-utils/install @@ -242,11 +221,13 @@ define Package/openssh-keygen/install endef define Package/openssh-server/install - $(INSTALL_DIR) $(1)/etc/ssh - chmod 0700 $(1)/etc/ssh + install -d -m0700 $(1)/etc/ssh $(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/ssh/sshd_config $(1)/etc/ssh/ + sed -r -i 's,^#(HostKey /etc/ssh/ssh_host_(rsa|ed25519)_key)$$$$,\1,' $(1)/etc/ssh/sshd_config $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_BIN) ./files/sshd.init $(1)/etc/init.d/sshd + $(INSTALL_DIR) $(1)/lib/preinit + $(INSTALL_BIN) ./files/sshd.failsafe $(1)/lib/preinit/99_10_failsafe_sshd $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/sshd $(1)/usr/sbin/ endef diff --git a/qca/feeds/packages/net/openssh/files/sshd.failsafe b/qca/feeds/packages/net/openssh/files/sshd.failsafe new file mode 100755 index 00000000000..a95745d096d --- /dev/null +++ b/qca/feeds/packages/net/openssh/files/sshd.failsafe @@ -0,0 +1,28 @@ +#!/bin/sh + +failsafe_sshd () { + + # if dropbear is executable it can handle failsafe + [ -x /usr/sbin/dropbear ] && return + + sshd_tmpdir=/tmp/sshd + mkdir $sshd_tmpdir + + for type in ed25519; do + key=$sshd_tmpdir/ssh_host_${type}_key + ssh-keygen -N '' -t ${type} -f ${key} + done + + mkdir -m 0700 -p /var/empty + + cat > $sshd_tmpdir/sshd_config <&- >&- } } - }; done + done mkdir -m 0700 -p /var/empty + local lport=$(awk '/^Port / { print $2; exit }' /etc/ssh/sshd_config) + [ -z "$lport" ] && lport=22 + procd_open_instance + procd_add_mdns "ssh" "tcp" "$lport" procd_set_param command $PROG -D procd_close_instance } shutdown() { local pid - local pids - local pid_mine stop # kill active clients - pid_mine="$$" - pids="$(pidof sshd)" - for pid in $pids; do - [ "$pid" = "$pid_mine" ] && continue + for pid in $(pidof sshd) + do + [ "$pid" = "$$" ] && continue [ -e "/proc/$pid/stat" ] && kill $pid done } diff --git a/qca/feeds/packages/net/openssh/patches/010-32bit-seccomp.patch b/qca/feeds/packages/net/openssh/patches/010-32bit-seccomp.patch new file mode 100644 index 00000000000..f8f95760ef7 --- /dev/null +++ b/qca/feeds/packages/net/openssh/patches/010-32bit-seccomp.patch @@ -0,0 +1,24 @@ +From 995cf19fbef0b10dbcf1dd8d6382cec9194e08c5 Mon Sep 17 00:00:00 2001 +From: Darren Tucker +Date: Sat, 26 Feb 2022 14:06:14 +1100 +Subject: [PATCH] Allow ppoll_time64 in seccomp sandbox. + +Should fix sandbox violations on (some? at least i386 and armhf) 32bit +Linux platforms. Patch from chutzpahu at gentoo.org and cjwatson at +debian.org via bz#3396. +--- + sandbox-seccomp-filter.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/sandbox-seccomp-filter.c ++++ b/sandbox-seccomp-filter.c +@@ -276,6 +276,9 @@ static const struct sock_filter preauth_ + #ifdef __NR_ppoll + SC_ALLOW(__NR_ppoll), + #endif ++#ifdef __NR_ppoll_time64 ++ SC_ALLOW(__NR_ppoll_time64), ++#endif + #ifdef __NR_poll + SC_ALLOW(__NR_poll), + #endif diff --git a/qca/feeds/packages/net/openssh/patches/020-improve-detection-of-fzero-call-used-regs.patch b/qca/feeds/packages/net/openssh/patches/020-improve-detection-of-fzero-call-used-regs.patch new file mode 100644 index 00000000000..345bfa30dd1 --- /dev/null +++ b/qca/feeds/packages/net/openssh/patches/020-improve-detection-of-fzero-call-used-regs.patch @@ -0,0 +1,30 @@ +From 6c4a67ece33d9551429490898bb3c793a689e913 Mon Sep 17 00:00:00 2001 +From: Colin Watson +Date: Thu, 24 Feb 2022 16:04:18 +0000 +Subject: [PATCH] Improve detection of -fzero-call-used-regs=all support + +GCC doesn't tell us whether this option is supported unless it runs into +the situation where it would need to emit corresponding code. +--- + m4/openssh.m4 | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/m4/openssh.m4 ++++ b/m4/openssh.m4 +@@ -14,6 +14,8 @@ AC_DEFUN([OSSH_CHECK_CFLAG_COMPILE], [{ + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ + #include + #include ++/* Trivial function to help test for -fzero-call-used-regs */ ++void f(int n) {} + int main(int argc, char **argv) { + (void)argv; + /* Some math to catch -ftrapv problems in the toolchain */ +@@ -21,6 +23,7 @@ int main(int argc, char **argv) { + float l = i * 2.1; + double m = l / 0.5; + long long int n = argc * 12345LL, o = 12345LL * (long long int)argc; ++ f(0); + printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o); + /* + * Test fallthrough behaviour. clang 10's -Wimplicit-fallthrough does diff --git a/qca/feeds/packages/net/openssh/patches/100-no_cast_fix.patch b/qca/feeds/packages/net/openssh/patches/100-no_cast_fix.patch deleted file mode 100644 index 5a4ecb1223e..00000000000 --- a/qca/feeds/packages/net/openssh/patches/100-no_cast_fix.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/cipher.c -+++ b/cipher.c -@@ -88,8 +88,10 @@ static const struct sshcipher ciphers[] - { "3des-cbc", SSH_CIPHER_SSH2, 8, 24, 0, 0, 0, 1, EVP_des_ede3_cbc }, - { "blowfish-cbc", - SSH_CIPHER_SSH2, 8, 16, 0, 0, 0, 1, EVP_bf_cbc }, -+#ifndef OPENSSL_NO_CAST - { "cast128-cbc", - SSH_CIPHER_SSH2, 8, 16, 0, 0, 0, 1, EVP_cast5_cbc }, -+#endif - { "arcfour", SSH_CIPHER_SSH2, 8, 16, 0, 0, 0, 0, EVP_rc4 }, - { "arcfour128", SSH_CIPHER_SSH2, 8, 16, 0, 0, 1536, 0, EVP_rc4 }, - { "arcfour256", SSH_CIPHER_SSH2, 8, 32, 0, 0, 1536, 0, EVP_rc4 }, diff --git a/qca/feeds/packages/net/openssh/patches/130-implicit_memset_decl_fix.patch b/qca/feeds/packages/net/openssh/patches/130-implicit_memset_decl_fix.patch deleted file mode 100644 index 7d46d20d3a0..00000000000 --- a/qca/feeds/packages/net/openssh/patches/130-implicit_memset_decl_fix.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/includes.h -+++ b/includes.h -@@ -60,6 +60,9 @@ - /* - *-*-nto-qnx needs these headers for strcasecmp and LASTLOG_FILE respectively - */ -+#ifdef HAVE_STRING_H -+# include -+#endif - #ifdef HAVE_STRINGS_H - # include - #endif diff --git a/qca/feeds/packages/net/openssh/patches/140-pam_uclibc_pthreads_fix.patch b/qca/feeds/packages/net/openssh/patches/140-pam_uclibc_pthreads_fix.patch deleted file mode 100644 index 1319b524a58..00000000000 --- a/qca/feeds/packages/net/openssh/patches/140-pam_uclibc_pthreads_fix.patch +++ /dev/null @@ -1,84 +0,0 @@ ---- a/auth-pam.c -+++ b/auth-pam.c -@@ -159,7 +159,7 @@ sshpam_sigchld_handler(int sig) - } - if (WIFSIGNALED(sshpam_thread_status) && - WTERMSIG(sshpam_thread_status) == SIGTERM) -- return; /* terminated by pthread_cancel */ -+ return; /* terminated by pthread2_cancel */ - if (!WIFEXITED(sshpam_thread_status)) - sigdie("PAM: authentication thread exited unexpectedly"); - if (WEXITSTATUS(sshpam_thread_status) != 0) -@@ -168,14 +168,14 @@ sshpam_sigchld_handler(int sig) - - /* ARGSUSED */ - static void --pthread_exit(void *value) -+pthread2_exit(void *value) - { - _exit(0); - } - - /* ARGSUSED */ - static int --pthread_create(sp_pthread_t *thread, const void *attr, -+pthread2_create(sp_pthread_t *thread, const void *attr, - void *(*thread_start)(void *), void *arg) - { - pid_t pid; -@@ -201,7 +201,7 @@ pthread_create(sp_pthread_t *thread, con - } - - static int --pthread_cancel(sp_pthread_t thread) -+pthread2_cancel(sp_pthread_t thread) - { - signal(SIGCHLD, sshpam_oldsig); - return (kill(thread, SIGTERM)); -@@ -209,7 +209,7 @@ pthread_cancel(sp_pthread_t thread) - - /* ARGSUSED */ - static int --pthread_join(sp_pthread_t thread, void **value) -+pthread2_join(sp_pthread_t thread, void **value) - { - int status; - -@@ -510,7 +510,7 @@ sshpam_thread(void *ctxtp) - /* XXX - can't do much about an error here */ - ssh_msg_send(ctxt->pam_csock, sshpam_err, &buffer); - buffer_free(&buffer); -- pthread_exit(NULL); -+ pthread2_exit(NULL); - - auth_fail: - buffer_put_cstring(&buffer, -@@ -521,7 +521,7 @@ sshpam_thread(void *ctxtp) - else - ssh_msg_send(ctxt->pam_csock, PAM_AUTH_ERR, &buffer); - buffer_free(&buffer); -- pthread_exit(NULL); -+ pthread2_exit(NULL); - - return (NULL); /* Avoid warning for non-pthread case */ - } -@@ -533,8 +533,8 @@ sshpam_thread_cleanup(void) - - debug3("PAM: %s entering", __func__); - if (ctxt != NULL && ctxt->pam_thread != 0) { -- pthread_cancel(ctxt->pam_thread); -- pthread_join(ctxt->pam_thread, NULL); -+ pthread2_cancel(ctxt->pam_thread); -+ pthread2_join(ctxt->pam_thread, NULL); - close(ctxt->pam_psock); - close(ctxt->pam_csock); - memset(ctxt, 0, sizeof(*ctxt)); -@@ -698,7 +698,7 @@ sshpam_init_ctx(Authctxt *authctxt) - } - ctxt->pam_psock = socks[0]; - ctxt->pam_csock = socks[1]; -- if (pthread_create(&ctxt->pam_thread, NULL, sshpam_thread, ctxt) == -1) { -+ if (pthread2_create(&ctxt->pam_thread, NULL, sshpam_thread, ctxt) == -1) { - error("PAM: failed to start authentication thread: %s", - strerror(errno)); - close(socks[0]); diff --git a/qca/feeds/packages/net/openssh/patches/200-dscp-qos.patch b/qca/feeds/packages/net/openssh/patches/200-dscp-qos.patch deleted file mode 100644 index 827a6689dce..00000000000 --- a/qca/feeds/packages/net/openssh/patches/200-dscp-qos.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/ssh_config -+++ b/ssh_config -@@ -46,3 +46,6 @@ - # VisualHostKey no - # ProxyCommand ssh -q -W %h:%p gateway.example.com - # RekeyLimit 1G 1h -+ -+# enable DSCP QoS values (per RFC-4594) -+#IPQoS AF21 AF11 ---- a/sshd_config -+++ b/sshd_config -@@ -122,6 +122,9 @@ UsePrivilegeSeparation sandbox # Defaul - # no default banner path - #Banner none - -+# enable DSCP QoS values (per RFC-4594) -+#IPQoS AF21 AF11 -+ - # override default of no subsystems - Subsystem sftp /usr/libexec/sftp-server - diff --git a/qca/feeds/platform_utils/qrtr/Makefile b/qca/feeds/platform_utils/qrtr/Makefile index 81d6e25cf7a..bb2b4133e31 100644 --- a/qca/feeds/platform_utils/qrtr/Makefile +++ b/qca/feeds/platform_utils/qrtr/Makefile @@ -6,8 +6,8 @@ PKG_VERSION:=2019-07-24 PKG_RELEASE:=$(PKG_SOURCE_VERSION) PKG_SOURCE_PROTO:=git -PKG_SOURCE_URL:=git://github.com/andersson/qrtr.git -PKG_SOURCE_VERSION:=cd6bedd5d00f211e6c1e3803ff2f9f53c246435e +PKG_SOURCE_URL:=https://github.com/andersson/qrtr.git +PKG_SOURCE_VERSION:=9dc7a88548c27983e06465d3fbba2ba27d4bc050 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz include $(INCLUDE_DIR)/package.mk @@ -28,8 +28,8 @@ define Build/Compile CC="$(TARGET_CC)" \ LD="$(TARGET_CC)" \ LDFLAGS="$(TARGET_LDFLAGS)" \ - CFLAGS="$(TARGET_CFLAGS) -I$(LINUX_DIR)/user_headers/include -I$(LINUX_DIR)/include/uapi/ -Ilib" \ - all + CFLAGS="$(TARGET_CFLAGS) -I$(LINUX_DIR)/user_headers/include -I$(LINUX_DIR)/include/uapi/ \ + -I$(LINUX_DIR)/include -Ilib" all endef define Package/$(PKG_NAME)/install diff --git a/qca/src/linux-4.4/Makefile b/qca/src/linux-4.4/Makefile index 8ba808a7528..ceade76da82 100644 --- a/qca/src/linux-4.4/Makefile +++ b/qca/src/linux-4.4/Makefile @@ -125,6 +125,8 @@ endif PHONY := _all _all: + + # Cancel implicit rules on top Makefile $(CURDIR)/Makefile Makefile: ; @@ -390,18 +392,21 @@ LINUXINCLUDE := \ -Iinclude \ $(USERINCLUDE) -KBUILD_CPPFLAGS := -D__KERNEL__ +KBUILD_CPPFLAGS := -D__KERNEL__ $(call cc-option, -fno-pie) KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -fno-strict-aliasing -fno-common \ -Werror-implicit-function-declaration \ -Wno-format-security \ - -std=gnu89 $(call cc-option,-fno-PIE) + -std=gnu89 \ + $(call cc-option, -no-pie)\ + $(call cc-option, -fno-pie) + -KBUILD_AFLAGS_KERNEL := +KBUILD_AFLAGS_KERNEL := KBUILD_CFLAGS_KERNEL := -KBUILD_AFLAGS := -D__ASSEMBLY__ $(call cc-option,-fno-PIE) +KBUILD_AFLAGS := -D__ASSEMBLY__ $(call cc-option, -fno-pie) KBUILD_AFLAGS_MODULE := -DMODULE KBUILD_CFLAGS_MODULE := -DMODULE KBUILD_LDFLAGS_MODULE = -T $(srctree)/scripts/module-common.lds diff --git a/qca/src/linux-4.4/arch/arm/boot/dts/Makefile b/qca/src/linux-4.4/arch/arm/boot/dts/Makefile index 67342b9a5de..98193733d98 100644 --- a/qca/src/linux-4.4/arch/arm/boot/dts/Makefile +++ b/qca/src/linux-4.4/arch/arm/boot/dts/Makefile @@ -559,6 +559,7 @@ dtb-$(CONFIG_ARCH_QCOM) += \ qcom-ipq6018-cp01-c4.dtb \ qcom-ipq6018-cp02-c1.dtb \ qcom-ipq6018-cp03-c1.dtb \ + qcom-ipq6018-ax840.dtb \ qcom-ipq6018-8dev-mango.dtb \ qcom-ipq807x-hk01.dtb \ qcom-ipq807x-hk01.c2.dtb \ diff --git a/qca/src/linux-4.4/arch/arm/boot/dts/qcom-ipq6018-ax840.dts b/qca/src/linux-4.4/arch/arm/boot/dts/qcom-ipq6018-ax840.dts new file mode 100644 index 00000000000..dd231ece3ba --- /dev/null +++ b/qca/src/linux-4.4/arch/arm/boot/dts/qcom-ipq6018-ax840.dts @@ -0,0 +1,299 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +// Copyright (c) 2021 AmadeusGhost + +//#include "qcom-ipq6018-glinet.dtsi" +#include "qcom-ipq6018-cp03-c1.dts" + +/ { + model = "Qualcomm Technologies, Inc. IPQ6018/AP-CP03-C1"; + compatible = "qcom,ipq6018-cp03\0qcom,ipq6018"; + + qcom,msm-id = <0x192 0x00>; + + aliases { + ethernet0 = "/soc/dp1"; + ethernet1 = "/soc/dp2"; + }; + + pmu { + compatible = "arm,armv8-pmuv3"; + }; + + reserved-memory { + tzapp:tzapp@49B00000 { /* TZAPPS */ + no-map; + reg = <0x0 0x49B00000 0x0 0x00600000>; + }; + }; + +}; + +&soc { + ess-switch@3a000000 { + switch_cpu_bmp = <0x1>; /* cpu port bitmap */ + switch_lan_bmp = <0x10>; /* lan port bitmap */ + switch_wan_bmp = <0x20>; /* wan port bitmap */ + switch_inner_bmp = <0x80>; + switch_mac_mode = <0x00>; + switch_mac_mode1 = <0xff>; + switch_mac_mode2 = <0xff>; + + + qcom,port_phyinfo { + port@3 { + port_id = <0x04>; + phy_address = <0x03>; + }; + + port@4 { + port_id = <0x05>; + phy_address = <0x04>; + }; + }; + }; + + leds { + pinctrl-0 = <&leds_pins>; + compatible = "gpio-leds"; + pinctrl-names = "default"; + + led@32 { + gpio = <&tlmm 32 GPIO_ACTIVE_HIGH>; + label = "led_sys"; + default-state = "on"; + linux,default-trigger = "led_sys"; + }; + + led@35 { + gpios = <&tlmm 35 GPIO_ACTIVE_HIGH>; + label = "led_5g"; + default-state = "off"; + linux,default-trigger = "led_5g"; + }; + + led@37 { + gpios = <&tlmm 37 GPIO_ACTIVE_HIGH>; + label = "led_2g"; + default-state = "off"; + linux,default-trigger = "led_2g"; + }; + }; + + dp1 { + reg = <0x3a001600 0x200>; + qcom,phy-mdio-addr = <0x03>; + qcom,link-poll = <0x01>; + compatible = "qcom,nss-dp"; + local-mac-address = [44 d1 fa bc 0e 5c]; + phy-mode = "sgmii"; + device_type = "network"; + qcom,mactype = <0x00>; + qcom,id = <0x04>; + }; + + dp2 { + reg = <0x3a001800 0x200>; + qcom,phy-mdio-addr = <0x04>; + qcom,link-poll = <0x01>; + compatible = "qcom,nss-dp"; + local-mac-address = [44 d1 fa bc 0e 5d]; + phy-mode = "sgmii"; + device_type = "network"; + qcom,mactype = <0x00>; + qcom,id = <0x05>; + }; + + gpio_keys { + pinctrl-0 = <&button_pins>; + compatible = "gpio-keys"; + pinctrl-names = "default"; + + reset { + gpios = <&tlmm 19 GPIO_ACTIVE_LOW>; + label = "reset"; + debounce-interval = <0x3c>; + linux,code = <0x74>; + linux,input-type = <0x01>; + }; + }; + +}; + + +&spi_0 { + pinctrl-0 = <&spi_0_pins>; + pinctrl-names = "default"; + status = "ok"; + + m25p80@0 { + #address-cells = <1>; + #size-cells = <1>; + reg = <0>; + density = <0x1000000>; + + sector-size = <0x10000>; + + partition@110000 { + reg = <0x110000 0x1a0000>; + label = "0:QSEE_1"; + }; + + partition@450000 { + reg = <0x450000 0x10000>; + label = "0:DEVCFG_1"; + }; + + partition@460000 { + reg = <0x460000 0x10000>; + label = "0:DEVCFG"; + }; + + partition@470000 { + reg = <0x470000 0x40000>; + label = "0:RPM_1"; + }; + + partition@500000 { + reg = <0x500000 0x10000>; + label = "0:CDT"; + }; + + partition@510000 { + reg = <0x510000 0x10000>; + label = "0:APPSBLENV"; + }; + + partition@520000 { + reg = <0x520000 0xa0000>; + label = "0:APPSBL_1"; + }; + + partition@660000 { + reg = <0x660000 0x40000>; + label = "0:ART"; + }; + + partition@2b0000 { + reg = <0x2b0000 0x1a0000>; + label = "0:QSEE"; + }; + + partition@4b0000 { + reg = <0x4b0000 0x40000>; + label = "0:RPM"; + }; + + partition@4f0000 { + reg = <0x4f0000 0x10000>; + label = "0:CDT_1"; + }; + + partition@5c0000 { + reg = <0x5c0000 0xa0000>; + label = "0:APPSBL"; + }; + + partition@0 { + reg = <0x00 0xc0000>; + label = "0:SBL1"; + }; + + partition@c0000 { + reg = <0xc0000 0x10000>; + label = "0:MIBIB"; + }; + + partition@d0000 { + reg = <0xd0000 0x20000>; + label = "0:BOOTCONFIG"; + }; + + partition@f0000 { + reg = <0xf0000 0x20000>; + label = "0:BOOTCONFIG1"; + }; + }; +}; + + + +&leds_pins { + + led_sys { + pins = "gpio32"; + function = "gpio"; + drive-strength = <0x08>; + bias-pull-down; + }; + + led_2g { + pins = "gpio37"; + function = "gpio"; + drive-strength = <0x08>; + bias-pull-down; + }; + + led_5g { + pins = "gpio35"; + function = "gpio"; + drive-strength = <0x08>; + bias-pull-down; + }; +}; + + +&spi_0_pins { + pins = "gpio38", "gpio39", "gpio40", "gpio41"; + function = "blsp0_spi"; + drive-strength = <8>; + bias-pull-down; +}; + +&button_pins { + + reset_button { + pins = "gpio19"; + function = "gpio"; + drive-strength = <0x08>; + bias-pull-down; + }; +}; + +&nand { + pinctrl-0 = <&qpic_pins>; + pinctrl-names = "default"; + status = "ok"; + nandcs@0 { + partition@0 { + reg = <0x00 0x3c00000>; + label = "rootfs_1"; + }; + + partition@3c00000 { + reg = <0x3c00000 0x3c00000>; + label = "rootfs"; + }; + }; +}; + + +&qseecom { + mem-start = <0x49b00000>; + status = "ok"; + mem-size = <0x600000>; +}; + + +&pcie_phy { + status = "ok"; +}; + +&pcie0 { + status = "ok"; +}; + + +&q6_region { + no-map; + reg = <0x00 0x4ab00000 0x00 0x5500000>; +}; diff --git a/qca/src/linux-4.4/scripts/dtc/dtc-lexer.l b/qca/src/linux-4.4/scripts/dtc/dtc-lexer.l index 0ee1caf03dd..a9b58b71e25 100644 --- a/qca/src/linux-4.4/scripts/dtc/dtc-lexer.l +++ b/qca/src/linux-4.4/scripts/dtc/dtc-lexer.l @@ -38,7 +38,6 @@ LINECOMMENT "//".*\n #include "srcpos.h" #include "dtc-parser.tab.h" -YYLTYPE yylloc; extern bool treesource_error; /* CAUTION: this will stop working if we ever use yyless() or yyunput() */ diff --git a/qca/src/linux-4.4/scripts/dtc/dtc-lexer.lex.c_shipped b/qca/src/linux-4.4/scripts/dtc/dtc-lexer.lex.c_shipped index 11cd78e7230..26932b00cf2 100644 --- a/qca/src/linux-4.4/scripts/dtc/dtc-lexer.lex.c_shipped +++ b/qca/src/linux-4.4/scripts/dtc/dtc-lexer.lex.c_shipped @@ -637,7 +637,6 @@ char *yytext; #include "srcpos.h" #include "dtc-parser.tab.h" -YYLTYPE yylloc; extern bool treesource_error; /* CAUTION: this will stop working if we ever use yyless() or yyunput() */ diff --git a/qca/src/linux-4.4/user_headers/.gitignore b/qca/src/linux-4.4/user_headers/.gitignore new file mode 100644 index 00000000000..ee03f8721ff --- /dev/null +++ b/qca/src/linux-4.4/user_headers/.gitignore @@ -0,0 +1,3 @@ +** +.** +!.gitignore diff --git a/qca/src/qca-psdk/cli/include/api_access.h b/qca/src/qca-psdk/cli/include/api_access.h new file mode 100755 index 00000000000..806c24dea0c --- /dev/null +++ b/qca/src/qca-psdk/cli/include/api_access.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2014, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + + +#ifndef _API_ACCESS_H +#define _API_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + sw_api_func_t * + sw_api_func_find(a_uint32_t api_id); + + sw_api_param_t * + sw_api_param_find(a_uint32_t api_id); + + a_uint32_t + sw_api_param_nums(a_uint32_t api_id); + + sw_error_t + sw_api_get(sw_api_t *sw_api); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _API_ACCESS_H */ diff --git a/qca/src/qca-psdk/cli/include/api_desc.h b/qca/src/qca-psdk/cli/include/api_desc.h new file mode 100644 index 00000000000..070e1b7d461 --- /dev/null +++ b/qca/src/qca-psdk/cli/include/api_desc.h @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef _API_DESC_H_ +#define _API_DESC_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define SW_API_PT_DUPLEX_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_DUPLEX_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_DUPLEX_GET, SW_UINT32, 4, SW_PARAM_IN, "Port No."), \ + SW_PARAM_DEF(SW_API_PT_DUPLEX_GET, SW_DUPLEX, sizeof(fal_port_duplex_t), SW_PARAM_PTR|SW_PARAM_OUT, \ + "duplex"), + +#define SW_API_PT_DUPLEX_SET_DESC \ + SW_PARAM_DEF(SW_API_PT_DUPLEX_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_DUPLEX_SET, SW_UINT32, 4, SW_PARAM_IN, "Port No."), \ + SW_PARAM_DEF(SW_API_PT_DUPLEX_SET, SW_DUPLEX, sizeof(fal_port_duplex_t), SW_PARAM_IN, \ + "duplex"), + +#define SW_API_PT_SPEED_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_SPEED_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_SPEED_GET, SW_UINT32, 4, SW_PARAM_IN, "Port No."), \ + SW_PARAM_DEF(SW_API_PT_SPEED_GET, SW_SPEED, sizeof(fal_port_speed_t), SW_PARAM_PTR|SW_PARAM_OUT, \ + "speed"), + +#define SW_API_PT_SPEED_SET_DESC \ + SW_PARAM_DEF(SW_API_PT_SPEED_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_SPEED_SET, SW_UINT32, 4, SW_PARAM_IN, "Port No."), \ + SW_PARAM_DEF(SW_API_PT_SPEED_SET, SW_SPEED, sizeof(fal_port_speed_t), SW_PARAM_IN, \ + "speed"), + +#define SW_API_PT_AN_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_AN_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_AN_GET, SW_UINT32, 4, SW_PARAM_IN, "Port No."), \ + SW_PARAM_DEF(SW_API_PT_AN_GET, SW_ENABLE, 4, SW_PARAM_PTR|SW_PARAM_OUT, "autoneg"), + + +#define SW_API_PT_AN_ENABLE_DESC \ + SW_PARAM_DEF(SW_API_PT_AN_ENABLE, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_AN_ENABLE, SW_UINT32, 4, SW_PARAM_IN, "Port No."), + + +#define SW_API_PT_AN_RESTART_DESC \ + SW_PARAM_DEF(SW_API_PT_AN_RESTART, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_AN_RESTART, SW_UINT32, 4, SW_PARAM_IN, "Port No."), + +#define SW_API_PT_AN_ADV_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_AN_ADV_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_AN_ADV_GET, SW_UINT32, 4, SW_PARAM_IN, "Port No."), \ + SW_PARAM_DEF(SW_API_PT_AN_ADV_GET, SW_CAP, 4, SW_PARAM_PTR|SW_PARAM_OUT, "autoneg"), + +#define SW_API_PT_AN_ADV_SET_DESC \ + SW_PARAM_DEF(SW_API_PT_AN_ADV_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_AN_ADV_SET, SW_UINT32, 4, SW_PARAM_IN, "Port No."), \ + SW_PARAM_DEF(SW_API_PT_AN_ADV_SET, SW_CAP, 4, SW_PARAM_IN, "autoneg"), +#define SW_API_PT_HIBERNATE_SET_DESC \ + SW_PARAM_DEF(SW_API_PT_HIBERNATE_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_HIBERNATE_SET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_HIBERNATE_SET, SW_ENABLE, 4, SW_PARAM_IN, "Hibernate status"), + +#define SW_API_PT_HIBERNATE_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_HIBERNATE_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_HIBERNATE_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_HIBERNATE_GET, SW_ENABLE, 4, SW_PARAM_PTR|SW_PARAM_OUT, "Hibernate Status"), + +#define SW_API_PT_CDT_DESC \ + SW_PARAM_DEF(SW_API_PT_CDT, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_CDT, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_CDT, SW_UINT32, 4, SW_PARAM_IN, "MDI Pair ID"), \ + SW_PARAM_DEF(SW_API_PT_CDT, SW_CABLESTATUS, 4, SW_PARAM_PTR|SW_PARAM_OUT, "cable status"), \ + SW_PARAM_DEF(SW_API_PT_CDT, SW_CABLELEN, 4, SW_PARAM_PTR|SW_PARAM_OUT, "cable len"), +#define SW_API_PT_LINK_STATUS_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_LINK_STATUS_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_LINK_STATUS_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_LINK_STATUS_GET, SW_ENABLE, 4, SW_PARAM_PTR|SW_PARAM_OUT, "Status"), +#define SW_API_PT_8023AZ_SET_DESC \ + SW_PARAM_DEF(SW_API_PT_8023AZ_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_8023AZ_SET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_8023AZ_SET, SW_ENABLE, 4, SW_PARAM_IN, "8023az Status"), + +#define SW_API_PT_8023AZ_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_8023AZ_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_8023AZ_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_8023AZ_GET, SW_ENABLE, 4, SW_PARAM_PTR|SW_PARAM_OUT, "8023az Status"), + +#define SW_API_PT_MDIX_SET_DESC \ + SW_PARAM_DEF(SW_API_PT_MDIX_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_MDIX_SET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_MDIX_SET, SW_CROSSOVER_MODE, sizeof(fal_port_mdix_mode_t), SW_PARAM_IN, "Crossover Mode"), + + +#define SW_API_PT_MDIX_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_MDIX_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_MDIX_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_MDIX_GET, SW_CROSSOVER_MODE, sizeof(fal_port_mdix_mode_t), SW_PARAM_PTR|SW_PARAM_OUT, \ + "Crossover Mode"), + +#define SW_API_PT_MDIX_STATUS_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_MDIX_STATUS_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_MDIX_STATUS_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_MDIX_STATUS_GET, SW_CROSSOVER_STATUS, sizeof(fal_port_mdix_status_t), SW_PARAM_PTR|SW_PARAM_OUT, \ + "Crossover Status"), +#define SW_API_PT_LOCAL_LOOPBACK_SET_DESC \ + SW_PARAM_DEF(SW_API_PT_LOCAL_LOOPBACK_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_LOCAL_LOOPBACK_SET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_LOCAL_LOOPBACK_SET, SW_ENABLE, 4, SW_PARAM_IN, "Local Loopback Status"), + +#define SW_API_PT_LOCAL_LOOPBACK_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_LOCAL_LOOPBACK_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_LOCAL_LOOPBACK_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_LOCAL_LOOPBACK_GET, SW_ENABLE, 4, SW_PARAM_PTR|SW_PARAM_OUT, "Local Loopback Status"), + +#define SW_API_PT_REMOTE_LOOPBACK_SET_DESC \ + SW_PARAM_DEF(SW_API_PT_REMOTE_LOOPBACK_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_REMOTE_LOOPBACK_SET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_REMOTE_LOOPBACK_SET, SW_ENABLE, 4, SW_PARAM_IN, "Remote Loopback Status"), + +#define SW_API_PT_REMOTE_LOOPBACK_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_REMOTE_LOOPBACK_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_REMOTE_LOOPBACK_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_REMOTE_LOOPBACK_GET, SW_ENABLE, 4, SW_PARAM_PTR|SW_PARAM_OUT, "Remote Loopback Status"), + +#define SW_API_PT_RESET_DESC \ + SW_PARAM_DEF(SW_API_PT_RESET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_RESET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), + +#define SW_API_PT_POWER_OFF_DESC \ + SW_PARAM_DEF(SW_API_PT_POWER_OFF, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_POWER_OFF, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), + +#define SW_API_PT_POWER_ON_DESC \ + SW_PARAM_DEF(SW_API_PT_POWER_ON, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_POWER_ON, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), + +#define SW_API_PT_MAGIC_FRAME_MAC_SET_DESC \ + SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_SET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_SET, SW_MACADDR, sizeof(fal_mac_addr_t), SW_PARAM_PTR|SW_PARAM_IN, "[Magic mac]"), + +#define SW_API_PT_MAGIC_FRAME_MAC_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_GET, SW_MACADDR, sizeof(fal_mac_addr_t), SW_PARAM_PTR|SW_PARAM_OUT, "[Magic mac]"), + +#define SW_API_PT_PHY_ID_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_PHY_ID_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_PHY_ID_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_PHY_ID_GET, SW_UINT16, 2, SW_PARAM_PTR|SW_PARAM_OUT, "Org ID"), \ + SW_PARAM_DEF(SW_API_PT_PHY_ID_GET, SW_UINT16, 2, SW_PARAM_PTR|SW_PARAM_OUT, "Rev ID"), + +#define SW_API_PT_WOL_STATUS_SET_DESC \ + SW_PARAM_DEF(SW_API_PT_WOL_STATUS_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_WOL_STATUS_SET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_WOL_STATUS_SET, SW_ENABLE, 4, SW_PARAM_IN, "Wol Status"), + +#define SW_API_PT_WOL_STATUS_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_WOL_STATUS_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_WOL_STATUS_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_WOL_STATUS_GET, SW_ENABLE, 4, SW_PARAM_PTR|SW_PARAM_OUT, "Wol Status"), +#define SW_API_PT_INTERFACE_MODE_STATUS_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_INTERFACE_MODE_STATUS_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_INTERFACE_MODE_STATUS_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_INTERFACE_MODE_STATUS_GET, SW_INTERFACE_MODE, sizeof(fal_port_interface_mode_t), SW_PARAM_PTR|SW_PARAM_OUT, \ + "Interface Status"), + +#define SW_API_DEBUG_PHYCOUNTER_SET_DESC \ + SW_PARAM_DEF(SW_API_DEBUG_PHYCOUNTER_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_DEBUG_PHYCOUNTER_SET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_DEBUG_PHYCOUNTER_SET, SW_ENABLE, 4, SW_PARAM_IN, "Counter Status"), + +#define SW_API_DEBUG_PHYCOUNTER_GET_DESC \ + SW_PARAM_DEF(SW_API_DEBUG_PHYCOUNTER_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_DEBUG_PHYCOUNTER_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_DEBUG_PHYCOUNTER_GET, SW_ENABLE, 4, SW_PARAM_PTR|SW_PARAM_OUT, "Counter Status"), + +#define SW_API_DEBUG_PHYCOUNTER_SHOW_DESC \ + SW_PARAM_DEF(SW_API_DEBUG_PHYCOUNTER_SHOW, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_DEBUG_PHYCOUNTER_SHOW, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_DEBUG_PHYCOUNTER_SHOW, SW_COUNTER_INFO, sizeof(fal_port_counter_info_t), SW_PARAM_PTR|SW_PARAM_OUT, \ + "Phy Counter Statistics On port"), +#define SW_API_PHY_GET_DESC \ + SW_PARAM_DEF(SW_API_PHY_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"),\ + SW_PARAM_DEF(SW_API_PHY_GET, SW_UINT32, 4, SW_PARAM_IN, "Phy ID"),\ + SW_PARAM_DEF(SW_API_PHY_GET, SW_UINT32, 4, SW_PARAM_IN, "Reg ID"),\ + SW_PARAM_DEF(SW_API_PHY_GET, SW_UINT16, 2, SW_PARAM_PTR|SW_PARAM_OUT, "Data"), + + +#define SW_API_PHY_SET_DESC \ + SW_PARAM_DEF(SW_API_PHY_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"),\ + SW_PARAM_DEF(SW_API_PHY_SET, SW_UINT32, 4, SW_PARAM_IN, "Phy ID"),\ + SW_PARAM_DEF(SW_API_PHY_SET, SW_UINT32, 4, SW_PARAM_IN, "Reg ID"),\ + SW_PARAM_DEF(SW_API_PHY_SET, SW_UINT16, 2, SW_PARAM_IN, "Data"), +#define SW_API_DESC(api_id) api_id##_DESC + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _API_DESC_H_ */ diff --git a/qca/src/qca-psdk/cli/include/fal/fal.h b/qca/src/qca-psdk/cli/include/fal/fal.h new file mode 100644 index 00000000000..64c48927713 --- /dev/null +++ b/qca/src/qca-psdk/cli/include/fal/fal.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2014, 2017-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef _FAL_H +#define _FAL_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +#include "fal_port_ctrl.h" +#include "fal_reg_access.h" +#include "fal_init.h" +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _FAL_H */ diff --git a/qca/src/qca-psdk/cli/include/fal/fal_api.h b/qca/src/qca-psdk/cli/include/fal/fal_api.h new file mode 100644 index 00000000000..f730d9a3100 --- /dev/null +++ b/qca/src/qca-psdk/cli/include/fal/fal_api.h @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef _FAL_API_H_ +#define _FAL_API_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +#define PORTCONTROL_API \ + SW_API_DEF(SW_API_PT_DUPLEX_GET, fal_port_duplex_get), \ + SW_API_DEF(SW_API_PT_DUPLEX_SET, fal_port_duplex_set), \ + SW_API_DEF(SW_API_PT_SPEED_GET, fal_port_speed_get), \ + SW_API_DEF(SW_API_PT_SPEED_SET, fal_port_speed_set), \ + SW_API_DEF(SW_API_PT_AN_GET, fal_port_autoneg_status_get), \ + SW_API_DEF(SW_API_PT_AN_ENABLE, fal_port_autoneg_enable), \ + SW_API_DEF(SW_API_PT_AN_RESTART, fal_port_autoneg_restart), \ + SW_API_DEF(SW_API_PT_AN_ADV_GET, fal_port_autoneg_adv_get), \ + SW_API_DEF(SW_API_PT_AN_ADV_SET, fal_port_autoneg_adv_set), \ + SW_API_DEF(SW_API_PT_HIBERNATE_SET, fal_port_hibernate_set), \ + SW_API_DEF(SW_API_PT_HIBERNATE_GET, fal_port_hibernate_get), \ + SW_API_DEF(SW_API_PT_CDT, fal_port_cdt), \ + SW_API_DEF(SW_API_PT_LINK_STATUS_GET, fal_port_link_status_get), \ + SW_API_DEF(SW_API_PT_8023AZ_SET, fal_port_8023az_set), \ + SW_API_DEF(SW_API_PT_8023AZ_GET, fal_port_8023az_get), \ + SW_API_DEF(SW_API_PT_MDIX_SET, fal_port_mdix_set), \ + SW_API_DEF(SW_API_PT_MDIX_GET, fal_port_mdix_get), \ + SW_API_DEF(SW_API_PT_MDIX_STATUS_GET, fal_port_mdix_status_get), \ + SW_API_DEF(SW_API_PT_LOCAL_LOOPBACK_SET, fal_port_local_loopback_set), \ + SW_API_DEF(SW_API_PT_LOCAL_LOOPBACK_GET, fal_port_local_loopback_get), \ + SW_API_DEF(SW_API_PT_REMOTE_LOOPBACK_SET, fal_port_remote_loopback_set), \ + SW_API_DEF(SW_API_PT_REMOTE_LOOPBACK_GET, fal_port_remote_loopback_get), \ + SW_API_DEF(SW_API_PT_RESET, fal_port_reset), \ + SW_API_DEF(SW_API_PT_POWER_OFF, fal_port_power_off), \ + SW_API_DEF(SW_API_PT_POWER_ON, fal_port_power_on), \ + SW_API_DEF(SW_API_PT_MAGIC_FRAME_MAC_SET, fal_port_magic_frame_mac_set), \ + SW_API_DEF(SW_API_PT_MAGIC_FRAME_MAC_GET, fal_port_magic_frame_mac_get), \ + SW_API_DEF(SW_API_PT_PHY_ID_GET, fal_port_phy_id_get), \ + SW_API_DEF(SW_API_PT_WOL_STATUS_SET, fal_port_wol_status_set), \ + SW_API_DEF(SW_API_PT_WOL_STATUS_GET, fal_port_wol_status_get), \ + SW_API_DEF(SW_API_PT_INTERFACE_MODE_STATUS_GET, fal_port_interface_mode_status_get), \ + SW_API_DEF(SW_API_DEBUG_PHYCOUNTER_SET, fal_debug_phycounter_set), \ + SW_API_DEF(SW_API_DEBUG_PHYCOUNTER_GET, fal_debug_phycounter_get), \ + SW_API_DEF(SW_API_DEBUG_PHYCOUNTER_SHOW, fal_debug_phycounter_show),\ +/*end of PORTCONTROL_API*/ +#define PORTCONTROL_API_PARAM \ + SW_API_DESC(SW_API_PT_DUPLEX_GET) \ + SW_API_DESC(SW_API_PT_DUPLEX_SET) \ + SW_API_DESC(SW_API_PT_SPEED_GET) \ + SW_API_DESC(SW_API_PT_SPEED_SET) \ + SW_API_DESC(SW_API_PT_AN_GET) \ + SW_API_DESC(SW_API_PT_AN_ENABLE) \ + SW_API_DESC(SW_API_PT_AN_RESTART) \ + SW_API_DESC(SW_API_PT_AN_ADV_GET) \ + SW_API_DESC(SW_API_PT_AN_ADV_SET) \ + SW_API_DESC(SW_API_PT_HIBERNATE_SET) \ + SW_API_DESC(SW_API_PT_HIBERNATE_GET) \ + SW_API_DESC(SW_API_PT_CDT) \ + SW_API_DESC(SW_API_PT_LINK_STATUS_GET) \ + SW_API_DESC(SW_API_PT_8023AZ_SET) \ + SW_API_DESC(SW_API_PT_8023AZ_GET) \ + SW_API_DESC(SW_API_PT_MDIX_SET) \ + SW_API_DESC(SW_API_PT_MDIX_GET) \ + SW_API_DESC(SW_API_PT_MDIX_STATUS_GET) \ + SW_API_DESC(SW_API_PT_LOCAL_LOOPBACK_SET) \ + SW_API_DESC(SW_API_PT_LOCAL_LOOPBACK_GET) \ + SW_API_DESC(SW_API_PT_REMOTE_LOOPBACK_SET) \ + SW_API_DESC(SW_API_PT_REMOTE_LOOPBACK_GET) \ + SW_API_DESC(SW_API_PT_RESET) \ + SW_API_DESC(SW_API_PT_POWER_OFF) \ + SW_API_DESC(SW_API_PT_POWER_ON) \ + SW_API_DESC(SW_API_PT_MAGIC_FRAME_MAC_SET) \ + SW_API_DESC(SW_API_PT_MAGIC_FRAME_MAC_GET) \ + SW_API_DESC(SW_API_PT_PHY_ID_GET) \ + SW_API_DESC(SW_API_PT_WOL_STATUS_SET) \ + SW_API_DESC(SW_API_PT_WOL_STATUS_GET) \ + SW_API_DESC(SW_API_PT_INTERFACE_MODE_STATUS_GET) \ + SW_API_DESC(SW_API_DEBUG_PHYCOUNTER_SET) \ + SW_API_DESC(SW_API_DEBUG_PHYCOUNTER_GET) \ + SW_API_DESC(SW_API_DEBUG_PHYCOUNTER_SHOW)\ +/*end of PORTCONTROL_API_PARAM*/ +#define REG_API \ + SW_API_DEF(SW_API_PHY_GET, fal_phy_get), \ + SW_API_DEF(SW_API_PHY_SET, fal_phy_set), \ + /*end of REG_API*/ +#define REG_API_PARAM \ + SW_API_DESC(SW_API_PHY_GET) \ + SW_API_DESC(SW_API_PHY_SET)\ +/*end of REG_API_PARAM*/ +#define SSDK_API \ + PORTCONTROL_API \ + REG_API \ + SW_API_DEF(SW_API_MAX, NULL), + + +#define SSDK_PARAM \ + PORTCONTROL_API_PARAM \ + REG_API_PARAM \ + SW_PARAM_DEF(SW_API_MAX, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _FAL_API_H_ */ diff --git a/qca/src/qca-psdk/cli/include/fal/fal_init.h b/qca/src/qca-psdk/cli/include/fal/fal_init.h new file mode 100644 index 00000000000..ed98a3ccba8 --- /dev/null +++ b/qca/src/qca-psdk/cli/include/fal/fal_init.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2014, 2016-2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +/** + * @defgroup fal_init FAL_INIT + * @{ + */ +#ifndef _FAL_INIT_H_ +#define _FAL_INIT_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "ssdk_init.h" +sw_error_t fal_ssdk_cfg(a_uint32_t dev_id, ssdk_cfg_t *ssdk_cfg); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _FAL_INIT_H_ */ +/** + * @} + */ diff --git a/qca/src/qca-psdk/cli/include/fal/fal_port_ctrl.h b/qca/src/qca-psdk/cli/include/fal/fal_port_ctrl.h new file mode 100644 index 00000000000..e347318e170 --- /dev/null +++ b/qca/src/qca-psdk/cli/include/fal/fal_port_ctrl.h @@ -0,0 +1,371 @@ +/* + * Copyright (c) 2014, 2016-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +/** + * @defgroup fal_port_ctrl FAL_PORT_CONTROL + * @{ + */ +#ifndef _FAL_PORTCTRL_H_ +#define _FAL_PORTCTRL_H_ + +#ifdef __cplusplus +extern "c" { +#endif + +#include "sw.h" +#include "fal_type.h" + + typedef enum { + FAL_HALF_DUPLEX = 0, + FAL_FULL_DUPLEX, + FAL_DUPLEX_BUTT = 0xffff + } + fal_port_duplex_t; + + typedef enum + { + FAL_SPEED_10 = 10, + FAL_SPEED_100 = 100, + FAL_SPEED_1000 = 1000, + FAL_SPEED_2500 = 2500, + FAL_SPEED_5000 = 5000, + FAL_SPEED_10000 = 10000, + FAL_SPEED_BUTT = 0xffff, + } fal_port_speed_t; + + typedef enum + { + FAL_CABLE_STATUS_NORMAL = 0, + FAL_CABLE_STATUS_SHORT = 1, + FAL_CABLE_STATUS_OPENED = 2, + FAL_CABLE_STATUS_INVALID = 3, + FAL_CABLE_STATUS_CROSSOVERA = 4, + FAL_CABLE_STATUS_CROSSOVERB = 5, + FAL_CABLE_STATUS_CROSSOVERC = 6, + FAL_CABLE_STATUS_CROSSOVERD = 7, + FAL_CABLE_STATUS_LOW_MISMATCH = 8, + FAL_CABLE_STATUS_HIGH_MISMATCH = 9, + FAL_CABLE_STATUS_BUTT = 0xffff, + } fal_cable_status_t; + +#define FAL_ENABLE 1 +#define FAL_DISABLE 0 +#define FAL_MAX_PORT_NUMBER 8 + +//phy autoneg adv +#define FAL_PHY_ADV_10T_HD 0x01 +#define FAL_PHY_ADV_10T_FD 0x02 +#define FAL_PHY_ADV_100TX_HD 0x04 +#define FAL_PHY_ADV_100TX_FD 0x08 +//#define FAL_PHY_ADV_1000T_HD 0x100 +#define FAL_PHY_ADV_1000T_FD 0x200 +#define FAL_PHY_ADV_1000BX_HD 0x400 +#define FAL_PHY_ADV_1000BX_FD 0x800 +#define FAL_PHY_ADV_2500T_FD 0x1000 +#define FAL_PHY_ADV_5000T_FD 0x2000 +#define FAL_PHY_ADV_10000T_FD 0x4000 + +#define FAL_PHY_ADV_10G_R_FD 0x8000 + +#define FAL_PHY_ADV_FE_SPEED_ALL \ + (FAL_PHY_ADV_10T_HD | FAL_PHY_ADV_10T_FD | FAL_PHY_ADV_100TX_HD |\ + FAL_PHY_ADV_100TX_FD) + +#define FAL_PHY_ADV_GE_SPEED_ALL \ + (FAL_PHY_ADV_10T_HD | FAL_PHY_ADV_10T_FD | FAL_PHY_ADV_100TX_HD |\ + FAL_PHY_ADV_100TX_FD | FAL_PHY_ADV_1000T_FD) + +#define FAL_PHY_ADV_BX_SPEED_ALL \ + (FAL_PHY_ADV_1000BX_HD | FAL_PHY_ADV_1000BX_FD |FAL_PHY_ADV_10G_R_FD) + +#define FAL_PHY_ADV_XGE_SPEED_ALL \ + (FAL_PHY_ADV_2500T_FD | FAL_PHY_ADV_5000T_FD | FAL_PHY_ADV_10000T_FD) + +#define FAL_PHY_ADV_PAUSE 0x10 +#define FAL_PHY_ADV_ASY_PAUSE 0x20 +#define FAL_PHY_FE_ADV_ALL \ + (FAL_PHY_ADV_FE_SPEED_ALL | FAL_PHY_ADV_PAUSE | FAL_PHY_ADV_ASY_PAUSE) +#define FAL_PHY_GE_ADV_ALL \ + (FAL_PHY_ADV_GE_SPEED_ALL | FAL_PHY_ADV_PAUSE | FAL_PHY_ADV_ASY_PAUSE) + +#define FAL_PHY_COMBO_ADV_ALL \ + (FAL_PHY_ADV_BX_SPEED_ALL | FAL_PHY_ADV_GE_SPEED_ALL | FAL_PHY_ADV_XGE_SPEED_ALL |\ + FAL_PHY_ADV_PAUSE | FAL_PHY_ADV_ASY_PAUSE) + +//phy capablity +#define FAL_PHY_AUTONEG_CAPS 0x01 +#define FAL_PHY_100T2_HD_CAPS 0x02 +#define FAL_PHY_100T2_FD_CAPS 0x04 +#define FAL_PHY_10T_HD_CAPS 0x08 +#define FAL_PHY_10T_FD_CAPS 0x10 +#define FAL_PHY_100X_HD_CAPS 0x20 +#define FAL_PHY_100X_FD_CAPS 0x40 +#define FAL_PHY_100T4_CAPS 0x80 +//#define FAL_PHY_1000T_HD_CAPS 0x100 +#define FAL_PHY_1000T_FD_CAPS 0x200 +//#define FAL_PHY_1000X_HD_CAPS 0x400 +#define FAL_PHY_1000X_FD_CAPS 0x800 + +//phy partner capablity +#define FAL_PHY_PART_10T_HD 0x1 +#define FAL_PHY_PART_10T_FD 0x2 +#define FAL_PHY_PART_100TX_HD 0x4 +#define FAL_PHY_PART_100TX_FD 0x8 +//#define FAL_PHY_PART_1000T_HD 0x10 +#define FAL_PHY_PART_1000T_FD 0x20 + +//phy interrupt flag +#define FAL_PHY_INTR_SPEED_CHANGE 0x1 +#define FAL_PHY_INTR_DUPLEX_CHANGE 0x2 +#define FAL_PHY_INTR_STATUS_UP_CHANGE 0x4 +#define FAL_PHY_INTR_STATUS_DOWN_CHANGE 0x8 +#define FAL_PHY_INTR_BX_FX_STATUS_UP_CHANGE 0x10 +#define FAL_PHY_INTR_BX_FX_STATUS_DOWN_CHANGE 0x20 +#define FAL_PHY_INTR_MEDIA_STATUS_CHANGE 0x40 +#define FAL_PHY_INTR_WOL_STATUS 0x80 +#define FAL_PHY_INTR_POE_STATUS 0x100 + + typedef enum + { + FAL_NO_HEADER_EN = 0, + FAL_ONLY_MANAGE_FRAME_EN, + FAL_ALL_TYPE_FRAME_EN + } fal_port_header_mode_t; + + typedef struct + { + a_uint16_t pair_a_status; + a_uint16_t pair_b_status; + a_uint16_t pair_c_status; + a_uint16_t pair_d_status; + a_uint32_t pair_a_len; + a_uint32_t pair_b_len; + a_uint32_t pair_c_len; + a_uint32_t pair_d_len; + } fal_port_cdt_t; + +/*below is new add for malibu phy*/ + +/** Phy mdix mode */ +typedef enum { + PHY_MDIX_AUTO = 0, /**< Auto MDI/MDIX */ + PHY_MDIX_MDI = 1, /**< Fixed MDI */ + PHY_MDIX_MDIX = 2 /**< Fixed MDIX */ +} fal_port_mdix_mode_t; + +/** Phy mdix status */ +typedef enum { + PHY_MDIX_STATUS_MDI = 0, /**< Fixed MDI */ + PHY_MDIX_STATUS_MDIX = 1 /**< Fixed MDIX */ + +} fal_port_mdix_status_t; + +/** Phy master mode */ +typedef enum { + PHY_MASTER_MASTER = 0, /**< Phy manual MASTER configuration */ + PHY_MASTER_SLAVE = 1, /**< Phy manual SLAVE configuration */ + PHY_MASTER_AUTO = 2 /**< Phy automatic MASTER/SLAVE configuration */ +} fal_port_master_t; + +/** Phy interface mode */ + typedef enum { + PHY_PSGMII_BASET = 0, + /**< PSGMII mode */ + PHY_PSGMII_BX1000 = 1, + /**< PSGMII BX1000 mode */ + PHY_PSGMII_FX100 = 2, + /**< PSGMII FX100 mode */ + PHY_PSGMII_AMDET = 3, + /**< PSGMII Auto mode */ + PHY_SGMII_BASET = 4, + /**< SGMII mode */ + PORT_QSGMII, + /**>24)&0xff) +#define FAL_PORT_ID_VALUE(port_id) ((port_id)&0xffffff) +#define FAL_PORT_ID(type, value) (((type)<<24)|(value)) + +#define FAL_IS_PPORT(port_id) (((FAL_PORT_ID_TYPE(port_id))==FAL_PORT_TYPE_PPORT)?1:0) +#define FAL_IS_TRUNK(port_id) (((FAL_PORT_ID_TYPE(port_id))==FAL_PORT_TYPE_TRUNK)?1:0) +#define FAL_IS_VPORT(port_id) (((FAL_PORT_ID_TYPE(port_id))==FAL_PORT_TYPE_VPORT)?1:0) + + +#if (SW_MAX_NR_PORT <= 32) + typedef a_uint32_t fal_pbmp_t; +#else + typedef a_uint64_t fal_pbmp_t; +#endif + + typedef struct + { + a_uint8_t uc[6]; + } fal_mac_addr_t; + + typedef a_uint32_t fal_ip4_addr_t; + + typedef struct + { + a_uint32_t ul[4]; + } fal_ip6_addr_t; + + /** + @brief This enum defines several forwarding command type. + * Field description: + FAL_MAC_FRWRD - packets are normally forwarded + FAL_MAC_DROP - packets are dropped + FAL_MAC_CPY_TO_CPU - packets are copyed to cpu + FAL_MAC_RDT_TO_CPU - packets are redirected to cpu + */ + typedef enum + { + FAL_MAC_FRWRD = 0, /**< packets are normally forwarded */ + FAL_MAC_DROP, /**< packets are dropped */ + FAL_MAC_CPY_TO_CPU, /**< packets are copyed to cpu */ + FAL_MAC_RDT_TO_CPU /**< packets are redirected to cpu */ + } fal_fwd_cmd_t; + + typedef enum + { + FAL_BYTE_BASED = 0, + FAL_FRAME_BASED, + FAL_RATE_MODE_BUTT + } fal_traffic_unit_t; + + typedef a_uint32_t fal_queue_t; + +#define FAL_SVL_FID 0xffff + + + /** + @brief This enum defines packets transmitted out vlan tagged mode. + */ + typedef enum + { + FAL_EG_UNMODIFIED = 0, /**< egress transmit packets unmodified */ + FAL_EG_UNTAGGED, /**< egress transmit packets without vlan tag*/ + FAL_EG_TAGGED, /**< egress transmit packets with vlan tag */ + FAL_EG_HYBRID, /**< egress transmit packets in hybrid tag mode */ + FAL_EG_UNTOUCHED, + FAL_EG_MODE_BUTT + } fal_pt_1q_egmode_t; + +#define FAL_NEXT_ENTRY_FIRST_ID 0xffffffff + + typedef struct{ + a_uint32_t reg_count; + a_uint32_t reg_base; + a_uint32_t reg_end; + a_uint32_t reg_value[256]; + a_int8_t reg_name[32]; + }fal_reg_dump_t; + + typedef struct{ + a_uint32_t reg_count; + a_uint32_t reg_addr[32]; + a_uint32_t reg_value[32]; + a_int8_t reg_name[32]; + }fal_debug_reg_dump_t; + + typedef struct{ + a_uint32_t phy_count; + a_uint32_t phy_base; + a_uint32_t phy_end; + a_uint16_t phy_value[256]; + a_int8_t phy_name[32]; + }fal_phy_dump_t; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _FAL_TYPE_H_ */ +/** + * @} + */ diff --git a/qca/src/qca-psdk/cli/include/fal/fal_uk_if.h b/qca/src/qca-psdk/cli/include/fal/fal_uk_if.h new file mode 100755 index 00000000000..18a8bd761ee --- /dev/null +++ b/qca/src/qca-psdk/cli/include/fal/fal_uk_if.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014,2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + + +#ifndef _FAL_UK_IF_H_ +#define _FAL_UK_IF_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "sw.h" +#include "fal_type.h" +#include "ssdk_init.h" + + sw_error_t + sw_uk_exec(a_uint32_t api_id, ...); + + sw_error_t + ssdk_init(a_uint32_t dev_id, ssdk_init_cfg * cfg); + + sw_error_t + ssdk_cleanup(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _FAL_UK_IF_H_ */ + + diff --git a/qca/src/qca-psdk/cli/include/osal/aos_head.h b/qca/src/qca-psdk/cli/include/osal/aos_head.h new file mode 100644 index 00000000000..bad81b129e8 --- /dev/null +++ b/qca/src/qca-psdk/cli/include/osal/aos_head.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2014,2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include "aos_mem.h" +#include "aos_types.h" diff --git a/qca/src/qca-psdk/cli/include/osal/aos_mem.h b/qca/src/qca-psdk/cli/include/osal/aos_mem.h new file mode 100755 index 00000000000..0006bbc52f6 --- /dev/null +++ b/qca/src/qca-psdk/cli/include/osal/aos_mem.h @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2014,2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _AOS_MEM_H +#define _AOS_MEM_H + +#include "aos_types.h" +#ifdef KERNEL_MODULE +#include "aos_mem_pvt.h" +#else +#include "aos_mem_pvt.h" +#endif + +/** + * @g aos_mem mem + * @{ + * + * @ig shim_ext + */ + +/** + * @brief Allocate a memory buffer. Note it's a non-blocking call. + * This call can block. + * + * @param[in] size buffer size + * + * @return Buffer pointer or NULL if there's not enough memory. + */ +static inline void * +aos_mem_alloc(aos_size_t size) +{ + return __aos_mem_alloc(size); +} + +/** + * @brief Free malloc'ed buffer + * + * @param[in] buf buffer pointer allocated by aos_alloc() + * @param[in] size buffer size + */ +static inline void +aos_mem_free(void *buf) +{ + __aos_mem_free(buf); +} + +/** + * @brief Move a memory buffer + * + * @param[in] dst destination address + * @param[in] src source address + * @param[in] size buffer size + */ +static inline void +aos_mem_copy(void *dst, void *src, aos_size_t size) +{ + __aos_mem_copy(dst, src, size); +} + +/** + * @brief Fill a memory buffer + * + * @param[in] buf buffer to be filled + * @param[in] b byte to fill + * @param[in] size buffer size + */ +static inline void +aos_mem_set(void *buf, a_uint8_t b, aos_size_t size) +{ + __aos_mem_set(buf, b, size); +} + +/** + * @brief Zero a memory buffer + * + * @param[in] buf buffer to be zeroed + * @param[in] size buffer size + */ +static inline void +aos_mem_zero(void *buf, aos_size_t size) +{ + __aos_mem_zero(buf, size); +} + +/** + * @brief Compare two memory buffers + * + * @param[in] buf1 first buffer + * @param[in] buf2 second buffer + * @param[in] size buffer size + * + * @retval 0 equal + * @retval 1 not equal + */ +static inline int +aos_mem_cmp(void *buf1, void *buf2, aos_size_t size) +{ + return __aos_mem_cmp(buf1, buf2, size); +} + +/** + * @} + */ + +#endif diff --git a/qca/src/qca-psdk/cli/include/osal/aos_mem_pvt.h b/qca/src/qca-psdk/cli/include/osal/aos_mem_pvt.h new file mode 100755 index 00000000000..281e65dabb0 --- /dev/null +++ b/qca/src/qca-psdk/cli/include/osal/aos_mem_pvt.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2014, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _AOS_MEM_PVT_H +#define _AOS_MEM_PVT_H + +#include +#include + +static inline void *__aos_mem_alloc(aos_size_t size) +{ + return (malloc(size)); +} + +static inline void __aos_mem_free(void *buf) +{ + free(buf); +} + +/* move a memory buffer */ +static inline void +__aos_mem_copy(void *dst, void *src, aos_size_t size) +{ + memcpy(dst, src, size); +} + +/* set a memory buffer */ +static inline void +__aos_mem_set(void *buf, a_uint8_t b, aos_size_t size) +{ + memset(buf, b, size); +} + +/* zero a memory buffer */ +static inline void +__aos_mem_zero(void *buf, aos_size_t size) +{ + memset(buf, 0, size); +} + +/* compare two memory buffers */ +static inline int +__aos_mem_cmp(void *buf1, void *buf2, aos_size_t size) +{ + return (memcmp(buf1, buf2, size) == 0) ? 0 : 1; +} + + + +#endif /*_AOS_MEM_PVT_H*/ diff --git a/qca/src/qca-psdk/cli/include/osal/aos_types.h b/qca/src/qca-psdk/cli/include/osal/aos_types.h new file mode 100755 index 00000000000..a80e5d057ef --- /dev/null +++ b/qca/src/qca-psdk/cli/include/osal/aos_types.h @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2014,2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _AOS_TYPES_H +#define _AOS_TYPES_H + +#ifdef KERNEL_MODULE +#include "aos_types_pvt.h" +#else +#include "aos_types_pvt.h" +#endif + +#ifndef NULL +#define NULL 0 +#endif + +/** + * @g aos_types types + * @{ + * + * @ig shim_ext + */ +/* + *@ basic data types. + */ +typedef enum +{ + A_FALSE, + A_TRUE +} a_bool_t; + +typedef __a_uint8_t a_uint8_t; +typedef __a_int8_t a_int8_t; +typedef __a_uint16_t a_uint16_t; +typedef __a_int16_t a_int16_t; +typedef __a_uint32_t a_uint32_t; +typedef __a_int32_t a_int32_t; +typedef __a_uint64_t a_uint64_t; +typedef __a_int64_t a_int64_t; +typedef unsigned long a_ulong_t; +typedef char a_char_t; + +typedef void * acore_t; + +/** + * @brief Platform/bus generic handle. Used for bus specific functions. + */ +typedef __aos_device_t aos_device_t; + +/** + * @brief size of an object + */ +typedef __aos_size_t aos_size_t; + +/** + * @brief Generic status to be used by acore. + */ +typedef enum +{ + A_STATUS_OK, + A_STATUS_FAILED, + A_STATUS_ENOENT, + A_STATUS_ENOMEM, + A_STATUS_EINVAL, + A_STATUS_EINPROGRESS, + A_STATUS_ENOTSUPP, + A_STATUS_EBUSY, +} a_status_t; + +/* + * An ecore needs to provide a table of all pci device/vendor id's it + * supports + * + * This table should be terminated by a NULL entry , i.e. {0} + */ +typedef struct +{ + a_uint32_t vendor; + a_uint32_t device; + a_uint32_t subvendor; + a_uint32_t subdevice; +} aos_pci_dev_id_t; + +#define AOS_PCI_ANY_ID (~0) + +/* + * Typically core's can use this macro to create a table of various device + * ID's + */ +#define AOS_PCI_DEVICE(_vendor, _device) \ + (_vendor), (_device), AOS_PCI_ANY_ID, AOS_PCI_ANY_ID + + +typedef __aos_iomem_t aos_iomem_t; +/* + * These define the hw resources the OS has allocated for the device + * Note that start defines a mapped area. + */ +typedef enum +{ + AOS_RESOURCE_TYPE_MEM, + AOS_RESOURCE_TYPE_IO, +} aos_resource_type_t; + +typedef struct +{ + a_uint32_t start; + a_uint32_t end; + aos_resource_type_t type; +} aos_resource_t; + +#define AOS_DEV_ID_TABLE_MAX 256 + +typedef union +{ + aos_pci_dev_id_t *pci; + void *raw; +} aos_bus_reg_data_t; + +typedef void *aos_attach_data_t; + +#define AOS_REGIONS_MAX 5 + +typedef enum +{ + AOS_BUS_TYPE_PCI = 1, + AOS_BUS_TYPE_GENERIC, +} aos_bus_type_t; + +typedef enum +{ + AOS_IRQ_NONE, + AOS_IRQ_HANDLED, +} aos_irq_resp_t; + +typedef enum +{ + AOS_DMA_MASK_32BIT, + AOS_DMA_MASK_64BIT, +} aos_dma_mask_t; + + +/** + * @brief DMA directions + */ +typedef enum +{ + AOS_DMA_TO_DEVICE = 0, /**< Data is transfered from device to memory */ + AOS_DMA_FROM_DEVICE, /**< Data is transfered from memory to device */ +} aos_dma_dir_t; + +/* + * Protoypes shared between public and private headers + */ + + +/* + * work queue(kernel thread) function callback + */ +typedef void (*aos_work_func_t)(void *); + +/** + * @brief Prototype of the critical region function that is to be + * executed with spinlock held and interrupt disalbed + */ +typedef a_bool_t (*aos_irqlocked_func_t)(void *); + +/** + * @brief Prototype of timer function + */ +typedef void (*aos_timer_func_t)(void *); + +#endif diff --git a/qca/src/qca-psdk/cli/include/osal/aos_types_pvt.h b/qca/src/qca-psdk/cli/include/osal/aos_types_pvt.h new file mode 100755 index 00000000000..fc71a871f0a --- /dev/null +++ b/qca/src/qca-psdk/cli/include/osal/aos_types_pvt.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2014, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _AOS_PVTTYPES_H +#define _AOS_PVTTYPES_H + +#include +#include +/* + * Private definitions of general data types + */ + +typedef void* __aos_device_t; +typedef int __aos_size_t; +typedef int __aos_iomem_t; + +typedef __u8 __a_uint8_t; +typedef __s8 __a_int8_t; +typedef __u16 __a_uint16_t; +typedef __s16 __a_int16_t; +typedef __u32 __a_uint32_t; +typedef __s32 __a_int32_t; +typedef __u64 __a_uint64_t; +typedef __s64 __a_int64_t; + + +#define aos_printk printf + + +#endif diff --git a/qca/src/qca-psdk/cli/include/shared_func.h b/qca/src/qca-psdk/cli/include/shared_func.h new file mode 100755 index 00000000000..6b0d72587d4 --- /dev/null +++ b/qca/src/qca-psdk/cli/include/shared_func.h @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2014, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + + +#ifndef _SHARED_FUNC_H +#define _SHARED_FUNC_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define SW_RTN_ON_ERROR(rtn) \ + do { if (rtn != SW_OK) return(rtn); } while(0); + +#define SW_OUT_ON_ERROR(rtn) \ + do { \ + if (rtn != SW_OK) { \ + rv = rtn; \ + goto out;\ + } \ + } while(0); + +#define SW_RTN_ON_ERROR_EXCEPT_COND1(rtn, cond1) \ + do { \ + if ((rtn != SW_OK) && (rtn != cond1)) \ + return rtn; \ + }while(0); + +#define SW_RTN_ON_NULL(op) \ + do { \ + if ((op) == NULL) \ + return SW_NOT_INITIALIZED;\ + }while(0); + + /* register functions */ +#define SW_BIT_MASK_U32(nr) (~(0xFFFFFFFF << (nr))) + +#define SW_FIELD_MASK_U32(offset, len) \ + ((SW_BIT_MASK_U32(len) << (offset))) + +#define SW_FIELD_MASK_NOT_U32(offset,len) \ + (~(SW_BIT_MASK_U32(len) << (offset))) + +#define SW_FIELD_2_REG(field_val, bit_offset) \ + (field_val << (bit_offset) ) + +#define SW_REG_2_FIELD(reg_val, bit_offset, field_len) \ + (((reg_val) >> (bit_offset)) & ((1 << (field_len)) - 1)) + +#define SW_REG_SET_BY_FIELD_U32(reg_value, field_value, bit_offset, field_len)\ + do { \ + (reg_value) = \ + (((reg_value) & SW_FIELD_MASK_NOT_U32((bit_offset),(field_len))) \ + | (((field_value) & SW_BIT_MASK_U32(field_len)) << (bit_offset)));\ + } while (0) + +#define SW_FIELD_GET_BY_REG_U32(reg_value, field_value, bit_offset, field_len)\ + do { \ + (field_value) = \ + (((reg_value) >> (bit_offset)) & SW_BIT_MASK_U32(field_len)); \ + } while (0) + +#define SW_SWAP_BITS_U8(x) \ + ((((x)&0x80)>>7) | (((x)&0x40)>>5) | (((x)&0x20)>>3) | (((x)&0x10)>>1) \ + |(((x)&0x1)<<7) | (((x)&0x2)<<5) | (((x)&0x4)<<3) |(((x)&0x8)<<1) ) + + +#define SW_OFFSET_U8_2_U16(byte_offset) ((byte_offset) >> 1) + +#define SW_OFFSET_U16_2_U8(word16_offset) ((word16_offset) << 1) + +#define SW_OFFSET_BIT_2_U8_ALIGN16(bit_offset) (((bit_offset) / 16) * 2) + +#define SW_SET_REG_BY_FIELD(reg, field, field_value, reg_value) \ + SW_REG_SET_BY_FIELD_U32(reg_value, field_value, reg##_##field##_BOFFSET, \ + reg##_##field##_BLEN) + +#define SW_GET_FIELD_BY_REG(reg, field, field_value, reg_value) \ + SW_FIELD_GET_BY_REG_U32(reg_value, field_value, reg##_##field##_BOFFSET, \ + reg##_##field##_BLEN) + + /* port bitmap functions */ +#define SW_IS_PBMP_MEMBER(pbm, port) ((pbm & (1 << port)) ? A_TRUE: A_FALSE) +#define SW_IS_PBMP_EQ(pbm0, pbm1) ((pbm0 == pbm1) ? A_TRUE: A_FALSE) + +#define SW_PBMP_AND(pbm0, pbm1) ((pbm0) &= (pbm1)) +#define SW_PBMP_OR(pbm0, pbm1) ((pbm0) |= (pbm1)) +#define SW_IS_PBMP_INCLUDE(pbm0, pbm1) \ + ((pbm1 == SW_PBMP_AND(pbm0, pbm1)) ? A_TRUE: A_FALSE) + +#define SW_PBMP_CLEAR(pbm) ((pbm) = 0) +#define SW_PBMP_ADD_PORT(pbm, port) ((pbm) |= (1U << (port))) +#define SW_PBMP_DEL_PORT(pbm,port) ((pbm) &= ~(1U << (port))) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _SHARED_FUNC_H */ diff --git a/qca/src/qca-psdk/cli/include/shell/shell.h b/qca/src/qca-psdk/cli/include/shell/shell.h new file mode 100755 index 00000000000..1575e1b9bea --- /dev/null +++ b/qca/src/qca-psdk/cli/include/shell/shell.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2014, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _SW_SHELL_H +#define _SW_SHELL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "sw.h" +#include "sw_api.h" +#include "ssdk_init.h" + + extern a_ulong_t *ioctl_buf; + extern ssdk_init_cfg init_cfg; + extern ssdk_cfg_t ssdk_cfg; + +#define IOCTL_BUF_SIZE 2048 +#define CMDSTR_BUF_SIZE 1024 +#define CMDSTR_ARGS_MAX 128 +#define dprintf cmd_print + extern sw_error_t cmd_exec_api(a_ulong_t *arg_val); + extern void cmd_print(char *fmt, ...); + void cmd_print_error(sw_error_t rtn); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _SW_SHELL_H */ diff --git a/qca/src/qca-psdk/cli/include/shell/shell_config.h b/qca/src/qca-psdk/cli/include/shell/shell_config.h new file mode 100755 index 00000000000..8ddab7b685e --- /dev/null +++ b/qca/src/qca-psdk/cli/include/shell/shell_config.h @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2014, 2017, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _SHELL_CONFIG_H_ +#define _SHELL_CONFIG_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "sw.h" +#include "sw_ioctl.h" +#include "sw_api.h" + +#define SW_CMD_SET_DEVID (SW_API_MAX + 1) +#define SW_CMD_VLAN_SHOW (SW_API_MAX + 2) +#define SW_CMD_FDB_SHOW (SW_API_MAX + 3) +#define SW_CMD_RESV_FDB_SHOW (SW_API_MAX + 4) +#define SW_CMD_HOST_SHOW (SW_API_MAX + 5) +#define SW_CMD_NAT_SHOW (SW_API_MAX + 6) +#define SW_CMD_NAPT_SHOW (SW_API_MAX + 7) +#define SW_CMD_INTFMAC_SHOW (SW_API_MAX + 8) +#define SW_CMD_PUBADDR_SHOW (SW_API_MAX + 9) +#define SW_CMD_FLOW_SHOW (SW_API_MAX + 10) +#define SW_CMD_HOST_IPV4_SHOW (SW_API_MAX + 11) +#define SW_CMD_HOST_IPV6_SHOW (SW_API_MAX + 12) +#define SW_CMD_HOST_IPV4M_SHOW (SW_API_MAX + 13) +#define SW_CMD_HOST_IPV6M_SHOW (SW_API_MAX + 14) +#define SW_CMD_CTRLPKT_SHOW (SW_API_MAX + 15) +#define SW_CMD_FLOW_IPV43T_SHOW (SW_API_MAX + 16) +#define SW_CMD_FLOW_IPV63T_SHOW (SW_API_MAX + 17) +#define SW_CMD_FLOW_IPV45T_SHOW (SW_API_MAX + 18) +#define SW_CMD_FLOW_IPV65T_SHOW (SW_API_MAX + 19) +#define SW_CMD_PT_VLAN_TRANS_ADV_SHOW (SW_API_MAX + 20) +#define SW_CMD_MAX (SW_API_MAX + 21) + +#define MAX_SUB_CMD_DES_NUM 120 + +#define SW_API_INVALID 0 + + struct sub_cmd_des_t + { + char *sub_name; + char *sub_act; + char *sub_memo; + char *sub_usage; + int sub_api; + sw_error_t (*sub_func) (); + }; + struct cmd_des_t + { + char *name; + char *memo; + struct sub_cmd_des_t sub_cmd_des[MAX_SUB_CMD_DES_NUM]; + }; + extern struct cmd_des_t gcmd_des[]; + +#define GCMD_DES gcmd_des + +#define GCMD_NAME(cmd_nr) GCMD_DES[cmd_nr].name +#define GCMD_MEMO(cmd_nr) GCMD_DES[cmd_nr].memo + +#define GCMD_SUB_NAME(cmd_nr, sub_cmd_nr) GCMD_DES[cmd_nr].sub_cmd_des[sub_cmd_nr].sub_name +#define GCMD_SUB_ACT(cmd_nr, sub_cmd_nr) GCMD_DES[cmd_nr].sub_cmd_des[sub_cmd_nr].sub_act +#define GCMD_SUB_MEMO(cmd_nr, sub_cmd_nr) GCMD_DES[cmd_nr].sub_cmd_des[sub_cmd_nr].sub_memo +#define GCMD_SUB_USAGE(cmd_nr, sub_cmd_nr) GCMD_DES[cmd_nr].sub_cmd_des[sub_cmd_nr].sub_usage +#define GCMD_SUB_API(cmd_nr, sub_cmd_nr) GCMD_DES[cmd_nr].sub_cmd_des[sub_cmd_nr].sub_api +#define GCMD_SUB_FUNC(cmd_nr, sub_cmd_nr) GCMD_DES[cmd_nr].sub_cmd_des[sub_cmd_nr].sub_func + +#define GCMD_DESC_VALID(cmd_nr) GCMD_NAME(cmd_nr) +#define GCMD_SUB_DESC_VALID(cmd_nr, sub_cmd_nr) GCMD_SUB_API(cmd_nr, sub_cmd_nr) + + +#define GCMD_DESC_NO_MATCH 0xffffffff + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _SHELL_CONFIG_H_ */ diff --git a/qca/src/qca-psdk/cli/include/shell/shell_io.h b/qca/src/qca-psdk/cli/include/shell/shell_io.h new file mode 100644 index 00000000000..9e92cd9a847 --- /dev/null +++ b/qca/src/qca-psdk/cli/include/shell/shell_io.h @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef _SHELL_IO_H +#define _SHELL_IO_H + +#include "sw.h" +#include "sw_api.h" +#include "fal.h" +#define SW_TYPE_DEF(type, parser, show) {type, parser, show} +typedef struct +{ + sw_data_type_e data_type; + sw_error_t(*param_check) (); + void (*show_func) (); +} sw_data_type_t; + +void set_talk_mode(int mode); +int get_talk_mode(void); +void set_full_cmdstrp(char **cmdstrp); +int +get_jump(void); +sw_data_type_t * cmd_data_type_find(sw_data_type_e type); +void cmd_strtol(char *str, a_uint32_t * arg_val); + +sw_error_t __cmd_data_check_complex(char *info, char *defval, char *usage, + sw_error_t(*chk_func)(), void *arg_val, + a_uint32_t size); + +sw_error_t cmd_data_check_portid(char *cmdstr, fal_port_t * val, a_uint32_t size); + +sw_error_t cmd_data_check_portmap(char *cmdstr, fal_pbmp_t * val, a_uint32_t size); +sw_error_t cmd_data_check_confirm(char *cmdstr, a_bool_t def, a_bool_t * val, a_uint32_t size); + +sw_error_t cmd_data_check_uint64(char *cmd_str, a_uint64_t * arg_val, + a_uint32_t size); +sw_error_t cmd_data_check_uint32(char *cmd_str, a_uint32_t * arg_val, + a_uint32_t size); +sw_error_t cmd_data_check_uint16(char *cmd_str, a_uint32_t * arg_val, + a_uint32_t size); +sw_error_t cmd_data_check_uint8(char *cmd_str, a_uint32_t * arg_val, + a_uint32_t size); +sw_error_t cmd_data_check_enable(char *cmd_str, a_uint32_t * arg_val, + a_uint32_t size); +sw_error_t cmd_data_check_pbmp(char *cmd_str, a_uint32_t * arg_val, + a_uint32_t size); +sw_error_t cmd_data_check_duplex(char *cmd_str, a_uint32_t * arg_val, + a_uint32_t size); +sw_error_t cmd_data_check_speed(char *cmd_str, a_uint32_t * arg_val, + a_uint32_t size); +sw_error_t cmd_data_check_capable(char *cmd_str, a_uint32_t * arg_val, + a_uint32_t size); +sw_error_t cmd_data_check_macaddr(char *cmdstr, void *val, a_uint32_t size); + +void cmd_data_print_uint64(a_uint8_t * param_name, a_uint64_t * buf, + a_uint32_t size); +void cmd_data_print_uint32(a_char_t * param_name, a_uint32_t * buf, + a_uint32_t size); +void cmd_data_print_uint16(a_char_t * param_name, a_uint32_t * buf, + a_uint32_t size); +void cmd_data_print_uint8(a_uint8_t * param_name, a_uint32_t * buf, + a_uint32_t size); +void cmd_data_print_enable(a_char_t * param_name, a_uint32_t * buf, + a_uint32_t size); +void cmd_data_print_pbmp(a_uint8_t * param_name, a_uint32_t * buf, + a_uint32_t size); +void cmd_data_print_duplex(a_uint8_t * param_name, a_uint32_t * buf, + a_uint32_t size); +void cmd_data_print_speed(a_uint8_t * param_name, a_uint32_t * buf, + a_uint32_t size); +void cmd_data_print_capable(a_uint8_t * param_name, a_uint32_t * buf, + a_uint32_t size); +void cmd_data_print_macaddr(a_char_t * param_name, a_uint32_t * buf, + a_uint32_t size); +void +cmd_data_print_cable_status(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size); +void +cmd_data_print_cable_len(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size); +void +cmd_data_print_ssdk_cfg(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size); +sw_error_t +cmd_data_check_crossover_mode(char *cmd_str, a_uint32_t * arg_val, a_uint32_t size); + +sw_error_t +cmd_data_check_crossover_status(char *cmd_str, a_uint32_t * arg_val, a_uint32_t size); +sw_error_t +cmd_data_check_interface_mode(char *cmd_str, a_uint32_t * arg_val, a_uint32_t size); +void +cmd_data_print_crossover_mode(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size); + +void +cmd_data_print_crossover_status(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size); + +void +cmd_data_print_interface_mode(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size); + +void +cmd_data_print_counter_info(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size); + +void +cmd_data_print_register_info(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size); + +void +cmd_data_print_phy_register_info(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size); + +void +cmd_data_print_debug_register_info(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size); +#endif diff --git a/qca/src/qca-psdk/cli/include/shell/shell_lib.h b/qca/src/qca-psdk/cli/include/shell/shell_lib.h new file mode 100755 index 00000000000..a6f824a97dd --- /dev/null +++ b/qca/src/qca-psdk/cli/include/shell/shell_lib.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2014, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _SW_SHELL_LIB_H +#define _SW_SHELL_LIB_H + +#ifdef __cplusplus +extern "C" { +#endif + + int next_cmd(char *out_cmd); + ssize_t getline(char **lineptr, size_t *n, FILE *stream); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _SW_SHELL_LIB_H */ + diff --git a/qca/src/qca-psdk/cli/include/shell/shell_sw.h b/qca/src/qca-psdk/cli/include/shell/shell_sw.h new file mode 100644 index 00000000000..91b190b0a29 --- /dev/null +++ b/qca/src/qca-psdk/cli/include/shell/shell_sw.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2014, 2017-2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef _SHELL_SW_H_ +#define _SHELL_SW_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "sw.h" + + int get_devid(void); + int set_devid(int dev_id); + sw_error_t cmd_set_devid(a_ulong_t *arg_val); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _SHELL_SW_H_ */ diff --git a/qca/src/qca-psdk/cli/include/ssdk_init.h b/qca/src/qca-psdk/cli/include/ssdk_init.h new file mode 100644 index 00000000000..6e0a97c0a21 --- /dev/null +++ b/qca/src/qca-psdk/cli/include/ssdk_init.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2014, 2017-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef _SSDK_INIT_H_ +#define _SSDK_INIT_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "sw.h" + typedef enum { + HSL_MDIO = 1, + HSL_HEADER, + } + hsl_access_mode; + + typedef enum + { + HSL_NO_CPU = 0, + HSL_CPU_1, + HSL_CPU_2, + HSL_CPU_1_PLUS, + } hsl_init_mode; + typedef sw_error_t + (*mdio_reg_set) (a_uint32_t dev_id, a_uint32_t phy_addr, a_uint32_t reg, + a_uint16_t data); + + typedef sw_error_t + (*mdio_reg_get) (a_uint32_t dev_id, a_uint32_t phy_addr, a_uint32_t reg, + a_uint16_t * data); + + typedef sw_error_t + (*i2c_reg_set) (a_uint32_t dev_id, a_uint32_t phy_addr, a_uint32_t reg, + a_uint16_t data); + + typedef sw_error_t + (*i2c_reg_get) (a_uint32_t dev_id, a_uint32_t phy_addr, a_uint32_t reg, + a_uint16_t * data); + typedef struct + { + mdio_reg_set mdio_set; + mdio_reg_get mdio_get; + i2c_reg_set i2c_set; + i2c_reg_get i2c_get; + } hsl_reg_func; + typedef enum + { + CHIP_UNSPECIFIED = 0, + CHIP_ATHENA, + CHIP_GARUDA, + CHIP_SHIVA, + CHIP_HORUS, + CHIP_ISIS, + CHIP_ISISC, + CHIP_DESS, + CHIP_HPPE, + } ssdk_chip_type; +typedef struct +{ + hsl_init_mode cpu_mode; + hsl_access_mode reg_mode; + hsl_reg_func reg_func; + + ssdk_chip_type chip_type; + a_uint32_t chip_revision; + /* os specific parameter */ + /* when uk_if based on netlink, it's netlink protocol type*/ + /* when uk_if based on ioctl, it's minor device number, major number + is always 10(misc device) */ + a_uint32_t nl_prot; + /* chip specific parameter */ + void * chip_spec_cfg; + a_uint32_t phy_id; + a_uint32_t mac_mode1; + a_uint32_t mac_mode2; +} ssdk_init_cfg; +#define def_init_cfg {.reg_mode = HSL_MDIO, .cpu_mode = HSL_CPU_2}; +#define CFG_STR_SIZE 20 + typedef struct + { + a_uint8_t build_ver[CFG_STR_SIZE]; + a_uint8_t build_date[CFG_STR_SIZE]; + + a_uint8_t chip_type[CFG_STR_SIZE]; //GARUDA + a_uint8_t cpu_type[CFG_STR_SIZE]; //mips + a_uint8_t os_info[CFG_STR_SIZE]; //OS=linux OS_VER=2_6 + + a_bool_t fal_mod; + a_bool_t kernel_mode; + a_bool_t uk_if; + ssdk_init_cfg init_cfg; + } ssdk_cfg_t; + sw_error_t + ssdk_init(a_uint32_t dev_id, ssdk_init_cfg *cfg); +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _SSDK_INIT_H */ diff --git a/qca/src/qca-psdk/cli/include/sw.h b/qca/src/qca-psdk/cli/include/sw.h new file mode 100755 index 00000000000..2793cd20587 --- /dev/null +++ b/qca/src/qca-psdk/cli/include/sw.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2014,2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + + +#ifndef _SW_H_ +#define _SW_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "sw_config.h" +#include "aos_head.h" +#include "sw_error.h" +#include "shared_func.h" + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _SW_H_ */ + diff --git a/qca/src/qca-psdk/cli/include/sw_api.h b/qca/src/qca-psdk/cli/include/sw_api.h new file mode 100755 index 00000000000..4717a6f03fe --- /dev/null +++ b/qca/src/qca-psdk/cli/include/sw_api.h @@ -0,0 +1,282 @@ +/* + * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + + +#ifndef _SW_API_H +#define _SW_API_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "sw.h" +#include "sw_ioctl.h" + +#define SW_MAX_API_BUF 2048 +#define SW_MAX_API_PARAM 12 /* cmd type + return value + ten parameters */ +#define SW_MAX_PAYLOAD (SW_MAX_API_PARAM << 2) /* maximum payload size for netlink msg*/ +#define SW_PARAM_IN 0x1 +#define SW_PARAM_OUT 0x2 +#define SW_PARAM_PTR 0x4 + +#define SW_API_DEF(ioctl, name) {ioctl, name} +#if (!defined(KERNEL_MODULE)) +#define SW_PARAM_DEF(ioctl, data, size, type, name) \ + {ioctl, size, data, type, name} +#else +#define SW_PARAM_DEF(ioctl, data, size, type, name) {ioctl, size, data, type} +#endif + +typedef enum +{ + SW_UINT8 = 1, + SW_INT8, + SW_UINT16, + SW_INT16, + SW_UINT32, + SW_INT32, + SW_UINT64, + SW_INT64, + SW_ENABLE, + SW_SPEED, + SW_DUPLEX, + SW_1QMODE, + SW_EGMODE, + SW_CAP, + SW_VLAN, + SW_LAN_WAN_CFG, + SW_PBMP, + SW_MIB, + SW_MIB_CNTR, + SW_XGMIB, + SW_MACADDR, + SW_FDBENTRY, + SW_MACLIMIT_CTRL, + SW_SCH, + SW_QOS, + SW_STORM, + SW_STP, + SW_LEAKY, + SW_MACCMD, + SW_FLOWTYPE, + SW_FLOWCMD, + SW_UINT_A, + SW_ACLRULE, + SW_LEDPATTERN, + SW_INVLAN, + SW_VLANPROPAGATION, + SW_VLANTRANSLATION, + SW_QINQMODE, + SW_QINQROLE, + SW_CABLESTATUS, + SW_CABLELEN, + SW_SSDK_CFG, + SW_HDRMODE, + SW_FDBOPRATION, + SW_PPPOE, + SW_PPPOE_LESS, + SW_ACL_UDF_TYPE, + SW_IP_HOSTENTRY, + SW_ARP_LEARNMODE, + SW_IP_GUARDMODE, + SW_NATENTRY, + SW_NAPTENTRY, + SW_FLOWENTRY, + SW_NAPTMODE, + SW_IP4ADDR, + SW_IP6ADDR, + SW_INTFMACENTRY, + SW_PUBADDRENTRY, + SW_INGPOLICER, + SW_EGSHAPER, + SW_ACLPOLICER, + SW_MACCONFIG, + SW_PHYCONFIG, + SW_DATA_MAX, + SW_FDBSMODE, + SW_FDB_CTRL_MODE, + SW_FX100CONFIG, + SW_SGENTRY, + SW_SEC_MAC, + SW_SEC_IP, + SW_SEC_IP4, + SW_SEC_IP6, + SW_SEC_TCP, + SW_SEC_UDP, + SW_SEC_ICMP4, + SW_SEC_ICMP6, + SW_REMARKENTRY, + SW_SGINFOENTRY, + SW_DEFAULT_ROUTE_ENTRY, + SW_HOST_ROUTE_ENTRY, + SW_IP_WCMP_ENTRY, + SW_IP_RFS_IP4, + SW_IP_RFS_IP6, + SW_FLOWCOOKIE, + SW_FDB_RFS, + SW_FLOWRFS, + SW_CROSSOVER_MODE, + SW_CROSSOVER_STATUS, + SW_PREFER_MEDIUM, + SW_FIBER_MODE, + SW_INTERFACE_MODE, + SW_COUNTER_INFO, + SW_REG_DUMP, + SW_DBG_REG_DUMP, + SW_VSI_NEWADDR_LRN, + SW_VSI_STAMOVE, + SW_VSI_MEMBER, + SW_VSI_COUNTER, + SW_MTU_INFO, + SW_MRU_INFO, + SW_MTU_ENTRY, + SW_MRU_ENTRY, + SW_ARP_SG_CFG, + SW_IP_NETWORK_ROUTE, + SW_IP_INTF, + SW_IP_VSI_INTF, + SW_IP_NEXTHOP, + SW_UCAST_QUEUE_MAP, + SW_UCAST_PRI_CLASS, + SW_MCAST_PRI_CLASS, + SW_IP_SG, + SW_IP_PUB, + SW_IP_PORTMAC, + SW_IP_MCMODE, + SW_FLOW_AGE, + SW_FLOW_CTRL, + SW_AC_CTRL, + SW_AC_OBJ, + SW_STATIC_THRESH, + SW_DYNAMIC_THRESH, + SW_GROUP_BUFFER, + SW_FLOW_ENTRY, + SW_FLOW_HOST, + SW_IP_GLOBAL, + SW_FLOW_GLOBAL, + SW_GLOBAL_QINQMODE, + SW_PT_QINQMODE, + SW_TPID, + SW_INGRESS_FILTER, + SW_PT_DEF_VID_EN, + SW_PT_VLAN_TAG, + SW_PT_VLAN_DIRECTION, + SW_PT_VLAN_TRANS_ADV_RULE, + SW_PT_VLAN_TRANS_ADV_ACTION, + SW_PT_VLAN_COUNTER, + SW_DEBUG_COUNTER_EN, + SW_TAG_PROPAGATION, + SW_EGRESS_DEFAULT_VID, + SW_EGRESS_MODE, + SW_CTRLPKT_PROFILE, + SW_SERVCODE_CONFIG, + SW_RSS_HASH_MODE, + SW_RSS_HASH_CONFIG, + SW_PTP_CONFIG, + SW_PTP_REFERENCE_CLOCK, + SW_PTP_RX_TIMESTAMP_MODE, + SW_PTP_DIRECTION, + SW_PTP_PKT_INFO, + SW_PTP_TIME, + SW_PTP_GRANDMASTER_MODE, + SW_PTP_SECURITY, + SW_PTP_PPS_SIGNAL_CONTROL, + SW_PTP_ASYM_CORRECTION, + SW_PTP_OUTPUT_WAVEFORM, + SW_PTP_TOD_UART, + SW_PTP_ENHANCED_TS_ENGINE, + SW_PTP_TRIGGER, + SW_PTP_CAPTURE, + SW_PTP_INTERRUPT, + SW_MIRR_ANALYSIS_CONFIG, + SW_MIRR_DIRECTION, + SW_L3_PARSER, + SW_L4_PARSER, + SW_EXP_CTRL, + SW_ACL_UDF_PKT_TYPE, + SW_PORTGROUP, + SW_PORTPRI, + SW_PORTREMARK, + SW_COSMAP, + SW_SCHEDULER, + SW_QUEUEBMP, + SW_PORT_SHAPER_TOKEN_CONFIG, + SW_SHAPER_TOKEN_CONFIG, + SW_PORT_SHAPER_CONFIG, + SW_SHAPER_CONFIG, + SW_BMSTHRESH, + SW_BMDTHRESH, + SW_BMPORTCNT, + SW_MODULE, + SW_FUNC_CTRL, + SW_QM_CNT, + SW_POLICER_COUNTER, + SW_POLICER_PORT_CONFIG, + SW_POLICER_ACL_CONFIG, + SW_POLICER_CMD_CONFIG, + SW_POLICER_GLOBAL_COUNTER, + SW_PHY_DUMP, + SW_RESOURCE_SCHE, + SW_PORT_EEE_CONFIG, + SW_SRC_FILTER_CONFIG, + SW_PORT_LOOPBACK_CONFIG, + SW_SFP_DATA, + SW_SFP_DEV_TYPE, + SW_SFP_TRANSC_CODE, + SW_SFP_RATE_ENCODE, + SW_SFP_LINK_LENGTH, + SW_SFP_VENDOR_INFO, + SW_SFP_LASER_WAVELENGTH, + SW_SFP_OPTION, + SW_SFP_CTRL_RATE, + SW_SFP_ENHANCED_CFG, + SW_SFP_DIAG_THRESHOLD, + SW_SFP_DIAG_CAL_CONST, + SW_SFP_DIAG_REALTIME, + SW_SFP_CTRL_STATUS, + SW_SFP_ALARM_WARN_FLAG, + SW_SFP_CCODE_TYPE, +} sw_data_type_e; + + typedef struct + { + a_uint32_t api_id; + void *func; + } sw_api_func_t; + + typedef struct + { + a_uint32_t api_id; + a_uint16_t data_size; + a_uint8_t data_type; + a_uint8_t param_type; +#if (!defined(KERNEL_MODULE)) + a_uint8_t param_name[30]; +#endif + } sw_api_param_t; + + typedef struct + { + a_uint32_t api_id; + sw_api_func_t *api_fp; + sw_api_param_t *api_pp; + a_uint32_t api_nr; + } sw_api_t; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _SW_API_H */ diff --git a/qca/src/qca-psdk/cli/include/sw_api_us.h b/qca/src/qca-psdk/cli/include/sw_api_us.h new file mode 100755 index 00000000000..d589d59fd21 --- /dev/null +++ b/qca/src/qca-psdk/cli/include/sw_api_us.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2014, 2017-2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + + +#ifndef _SW_API_US_H +#define _SW_API_US_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "sw.h" + + sw_error_t sw_uk_init(a_uint32_t nl_prot); + + sw_error_t sw_uk_cleanup(void); + + sw_error_t sw_uk_if(unsigned long arg_val[SW_MAX_API_PARAM]); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _SW_API_INTERFACE_H */ diff --git a/qca/src/qca-psdk/cli/include/sw_config.h b/qca/src/qca-psdk/cli/include/sw_config.h new file mode 100755 index 00000000000..7809571fc74 --- /dev/null +++ b/qca/src/qca-psdk/cli/include/sw_config.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2014, 2017, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + + +#ifndef _SW_CONFIG_H +#define _SW_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define SW_MAX_NR_DEV 3 +#define SW_MAX_NR_PORT 16 + +#ifdef HSL_STANDALONG +#define HSL_LOCAL +#else +#define HSL_LOCAL static +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/qca/src/qca-psdk/cli/include/sw_error.h b/qca/src/qca-psdk/cli/include/sw_error.h new file mode 100755 index 00000000000..e6cb2d20bae --- /dev/null +++ b/qca/src/qca-psdk/cli/include/sw_error.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2014, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + + +#ifndef _SW_ERROR_H +#define _SW_ERROR_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + typedef enum { + SW_OK = 0, /* Operation succeeded */ + SW_FAIL = -1, /* Operation failed */ + SW_BAD_VALUE = -2, /* Illegal value */ + SW_OUT_OF_RANGE = -3, /* Value is out of range */ + SW_BAD_PARAM = -4, /* Illegal parameter(s) */ + SW_BAD_PTR = -5, /* Illegal pointer value */ + SW_BAD_LEN = -6, /* Wrong length */ + SW_BAD_STATE = -7, /* Wrong state of state machine */ + SW_READ_ERROR = -8, /* Read operation failed */ + SW_WRITE_ERROR = -9, /* Write operation failed */ + SW_CREATE_ERROR = -10, /* Fail in creating an entry */ + SW_DELETE_ERROR = -11, /* Fail in deleteing an entry */ + SW_NOT_FOUND = -12, /* Entry not found */ + SW_NO_CHANGE = -13, /* The parameter(s) is the same */ + SW_NO_MORE = -14, /* No more entry found */ + SW_NO_SUCH = -15, /* No such entry */ + SW_ALREADY_EXIST = -16, /* Tried to create existing entry */ + SW_FULL = -17, /* Table is full */ + SW_EMPTY = -18, /* Table is empty */ + SW_NOT_SUPPORTED = -19, /* This request is not support */ + SW_NOT_IMPLEMENTED = -20, /* This request is not implemented */ + SW_NOT_INITIALIZED = -21, /* The item is not initialized */ + SW_BUSY = -22, /* Operation is still running */ + SW_TIMEOUT = -23, /* Operation Time Out */ + SW_DISABLE = -24, /* Operation is disabled */ + SW_NO_RESOURCE = -25, /* Resource not available (memory ...) */ + SW_INIT_ERROR = -26, /* Error occured while INIT process */ + SW_NOT_READY = -27, /* The other side is not ready yet */ + SW_OUT_OF_MEM = -28, /* Cpu memory allocation failed. */ + SW_ABORTED = -29 /* Operation has been aborted. */ + } sw_error_t; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _SW_ERROR_H */ + diff --git a/qca/src/qca-psdk/cli/include/sw_ioctl.h b/qca/src/qca-psdk/cli/include/sw_ioctl.h new file mode 100644 index 00000000000..eeaac9c34ef --- /dev/null +++ b/qca/src/qca-psdk/cli/include/sw_ioctl.h @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef _SW_IOCTL_H_ +#define _SW_IOCTL_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + /*init*/ +#define SW_API_INIT_OFFSET 10 +#define SW_API_SWITCH_INIT (0 + SW_API_INIT_OFFSET) +#define SW_API_SWITCH_RESET (1 + SW_API_INIT_OFFSET) +#define SW_API_SSDK_CFG (2 + SW_API_INIT_OFFSET) +#define SW_API_MODULE_FUNC_CTRL_SET (3 + SW_API_INIT_OFFSET) +#define SW_API_MODULE_FUNC_CTRL_GET (4 + SW_API_INIT_OFFSET) + + /*port ctrl*/ +#define SW_API_PORT_OFFSET 30 +#define SW_API_PT_DUPLEX_GET (0 + SW_API_PORT_OFFSET) +#define SW_API_PT_DUPLEX_SET (1 + SW_API_PORT_OFFSET) +#define SW_API_PT_SPEED_GET (2 + SW_API_PORT_OFFSET) +#define SW_API_PT_SPEED_SET (3 + SW_API_PORT_OFFSET) +#define SW_API_PT_AN_ADV_GET (4 + SW_API_PORT_OFFSET) +#define SW_API_PT_AN_ADV_SET (5 + SW_API_PORT_OFFSET) +#define SW_API_PT_AN_GET (6 + SW_API_PORT_OFFSET) +#define SW_API_PT_AN_ENABLE (7 + SW_API_PORT_OFFSET) +#define SW_API_PT_AN_RESTART (8 + SW_API_PORT_OFFSET) +#define SW_API_PT_HIBERNATE_SET (17 + SW_API_PORT_OFFSET) +#define SW_API_PT_HIBERNATE_GET (18 + SW_API_PORT_OFFSET) +#define SW_API_PT_CDT (19 + SW_API_PORT_OFFSET) +#define SW_API_PT_LINK_STATUS_GET (38 + SW_API_PORT_OFFSET) +#define SW_API_PT_8023AZ_SET (46 + SW_API_PORT_OFFSET) +#define SW_API_PT_8023AZ_GET (47 + SW_API_PORT_OFFSET) +#define SW_API_PT_MDIX_SET (48 + SW_API_PORT_OFFSET) +#define SW_API_PT_MDIX_GET (49 + SW_API_PORT_OFFSET) +#define SW_API_PT_MDIX_STATUS_GET (50 + SW_API_PORT_OFFSET) +#define SW_API_PT_LOCAL_LOOPBACK_SET (56 + SW_API_PORT_OFFSET) +#define SW_API_PT_LOCAL_LOOPBACK_GET (57 + SW_API_PORT_OFFSET) +#define SW_API_PT_REMOTE_LOOPBACK_SET (58 + SW_API_PORT_OFFSET) +#define SW_API_PT_REMOTE_LOOPBACK_GET (59 + SW_API_PORT_OFFSET) +#define SW_API_PT_RESET (60 + SW_API_PORT_OFFSET) +#define SW_API_PT_POWER_OFF (61 + SW_API_PORT_OFFSET) +#define SW_API_PT_POWER_ON (62 + SW_API_PORT_OFFSET) +#define SW_API_PT_MAGIC_FRAME_MAC_SET (63 + SW_API_PORT_OFFSET) +#define SW_API_PT_MAGIC_FRAME_MAC_GET (64 + SW_API_PORT_OFFSET) +#define SW_API_PT_PHY_ID_GET (65 + SW_API_PORT_OFFSET) +#define SW_API_PT_WOL_STATUS_SET (66 + SW_API_PORT_OFFSET) +#define SW_API_PT_WOL_STATUS_GET (67 + SW_API_PORT_OFFSET) +#define SW_API_PT_INTERFACE_MODE_STATUS_GET (70 + SW_API_PORT_OFFSET) +#define SW_API_DEBUG_PHYCOUNTER_SET (71 + SW_API_PORT_OFFSET) +#define SW_API_DEBUG_PHYCOUNTER_GET (72 + SW_API_PORT_OFFSET) +#define SW_API_DEBUG_PHYCOUNTER_SHOW (73 + SW_API_PORT_OFFSET) + /*debug*/ +#define SW_API_DEBUG_OFFSET 10000 +#define SW_API_PHY_GET (0 + SW_API_DEBUG_OFFSET) +#define SW_API_PHY_SET (1 + SW_API_DEBUG_OFFSET) +#define SW_API_MAX 0xffff +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _SW_IOCTL_H_ */ diff --git a/qca/src/qca-psdk/cli/src/api_access.c b/qca/src/qca-psdk/cli/src/api_access.c new file mode 100644 index 00000000000..f8816cb9688 --- /dev/null +++ b/qca/src/qca-psdk/cli/src/api_access.c @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2014,2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include "sw.h" +#include "fal.h" +#include "sw_api.h" +#include "api_desc.h" +#include "fal_api.h" +static sw_api_func_t sw_api_func[] = { + SSDK_API }; +static sw_api_param_t sw_api_param[] = { + SSDK_PARAM }; + +sw_api_func_t * +sw_api_func_find(a_uint32_t api_id) +{ + a_uint32_t i = 0; + static a_uint32_t save = 0; + + if(api_id == sw_api_func[save].api_id) + return &sw_api_func[save]; + + do + { + if (api_id == sw_api_func[i].api_id) + { + save = i; + return &sw_api_func[i]; + } + + } + while (++i < (sizeof(sw_api_func)/sizeof(sw_api_func[0]))); + + return NULL; +} + +sw_api_param_t * +sw_api_param_find(a_uint32_t api_id) +{ + a_uint32_t i = 0; + static a_uint32_t save = 0; + + if(api_id == sw_api_param[save].api_id) + return &sw_api_param[save]; + + do + { + if (api_id == sw_api_param[i].api_id) + { + save = i; + return &sw_api_param[i]; + } + } + while (++i < (sizeof(sw_api_param)/sizeof(sw_api_param[0]))); + + return NULL; +} + +a_uint32_t +sw_api_param_nums(a_uint32_t api_id) +{ + a_uint32_t i = 0; + sw_api_param_t *p = NULL; + static sw_api_param_t *savep = NULL; + static a_uint32_t save = 0; + + p = sw_api_param_find(api_id); + if (!p) + { + return 0; + } + + if (p == savep) + { + return save; + } + + savep = p; + while (api_id == p->api_id) + { + p++; + i++; + } + + /*error*/ + if(i >= sizeof(sw_api_param)/sizeof(sw_api_param[0])) + { + savep = NULL; + save = 0; + return 0; + } + save = i; + + return i; +} + +sw_error_t +sw_api_get(sw_api_t *sw_api) +{ + if(!sw_api) + return SW_FAIL; + + if ((sw_api->api_fp = sw_api_func_find(sw_api->api_id)) == NULL) + return SW_NOT_SUPPORTED; + + if ((sw_api->api_pp = sw_api_param_find(sw_api->api_id)) == NULL) + return SW_NOT_SUPPORTED; + + if((sw_api->api_nr = sw_api_param_nums(sw_api->api_id)) == 0) + return SW_NOT_SUPPORTED; + + return SW_OK; +} diff --git a/qca/src/qca-psdk/cli/src/fal/fal_init.c b/qca/src/qca-psdk/cli/src/fal/fal_init.c new file mode 100644 index 00000000000..64f692f9fac --- /dev/null +++ b/qca/src/qca-psdk/cli/src/fal/fal_init.c @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2014, 2016-2017, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include "sw.h" +#include "sw_ioctl.h" +#include "ssdk_init.h" +#include "fal_init.h" +#include "fal_uk_if.h" +sw_error_t +fal_ssdk_cfg(a_uint32_t dev_id, ssdk_cfg_t *ssdk_cfg) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_SSDK_CFG, dev_id, ssdk_cfg); + return rv; +} diff --git a/qca/src/qca-psdk/cli/src/fal/fal_port_ctrl.c b/qca/src/qca-psdk/cli/src/fal/fal_port_ctrl.c new file mode 100644 index 00000000000..cf421fea554 --- /dev/null +++ b/qca/src/qca-psdk/cli/src/fal/fal_port_ctrl.c @@ -0,0 +1,359 @@ +/* + * Copyright (c) 2014,2016-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include "sw.h" +#include "sw_ioctl.h" +#include "fal_port_ctrl.h" +#include "fal_uk_if.h" + +sw_error_t +fal_port_duplex_set(a_uint32_t dev_id, fal_port_t port_id, + fal_port_duplex_t duplex) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_DUPLEX_SET, dev_id, port_id, + duplex); + return rv; +} + +sw_error_t +fal_port_duplex_get(a_uint32_t dev_id, fal_port_t port_id, + fal_port_duplex_t * pduplex) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_DUPLEX_GET, dev_id, port_id, pduplex); + return rv; +} + +sw_error_t +fal_port_speed_set(a_uint32_t dev_id, fal_port_t port_id, + fal_port_speed_t speed) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_SPEED_SET, dev_id, port_id, + speed); + return rv; +} + +sw_error_t +fal_port_speed_get(a_uint32_t dev_id, fal_port_t port_id, + fal_port_speed_t * pspeed) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_SPEED_GET, dev_id, port_id, pspeed); + return rv; +} + +sw_error_t +fal_port_autoneg_status_get(a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * status) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_AN_GET, dev_id, port_id, status); + return rv; +} + +sw_error_t +fal_port_autoneg_enable(a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_AN_ENABLE, dev_id, port_id); + return rv; +} + +sw_error_t +fal_port_autoneg_restart(a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_AN_RESTART, dev_id, port_id); + return rv; +} + +sw_error_t +fal_port_autoneg_adv_set(a_uint32_t dev_id, fal_port_t port_id, + a_uint32_t autoadv) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_AN_ADV_SET, dev_id, port_id, autoadv); + return rv; +} + +sw_error_t +fal_port_autoneg_adv_get(a_uint32_t dev_id, fal_port_t port_id, + a_uint32_t * autoadv) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_AN_ADV_GET, dev_id, port_id, autoadv); + return rv; +} +sw_error_t +fal_port_hibernate_set(a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_HIBERNATE_SET, dev_id, port_id, + enable); + return rv; +} + +sw_error_t +fal_port_hibernate_get(a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_HIBERNATE_GET, dev_id, port_id, enable); + return rv; +} + +sw_error_t +fal_port_cdt(a_uint32_t dev_id, fal_port_t port_id, a_uint32_t mdi_pair, + a_uint32_t *cable_status, a_uint32_t *cable_len) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_CDT, dev_id, port_id, mdi_pair, + cable_status, cable_len); + return rv; +} +sw_error_t +fal_port_link_status_get(a_uint32_t dev_id, fal_port_t port_id, a_bool_t * status) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_LINK_STATUS_GET, dev_id, port_id, status); + return rv; +} +sw_error_t +fal_port_8023az_set(a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_8023AZ_SET, dev_id, port_id, + enable); + return rv; +} + +sw_error_t +fal_port_8023az_get(a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_8023AZ_GET, dev_id, port_id, enable); + return rv; +} + +sw_error_t +fal_port_mdix_set(a_uint32_t dev_id, fal_port_t port_id, + fal_port_mdix_mode_t mode) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_MDIX_SET, dev_id, port_id, mode); + return rv; +} + +sw_error_t +fal_port_mdix_get(a_uint32_t dev_id, fal_port_t port_id, + fal_port_mdix_mode_t * mode) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_MDIX_GET, dev_id, port_id, mode); + return rv; +} + +sw_error_t +fal_port_mdix_status_get(a_uint32_t dev_id, fal_port_t port_id, + fal_port_mdix_status_t * mode) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_MDIX_STATUS_GET, dev_id, port_id, mode); + return rv; +} +sw_error_t +fal_port_local_loopback_set(a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_LOCAL_LOOPBACK_SET, dev_id, port_id, + enable); + return rv; +} + +sw_error_t +fal_port_local_loopback_get(a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_LOCAL_LOOPBACK_GET, dev_id, port_id, enable); + return rv; +} + +sw_error_t +fal_port_remote_loopback_set(a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_REMOTE_LOOPBACK_SET, dev_id, port_id, + enable); + return rv; +} + +sw_error_t +fal_port_remote_loopback_get(a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_REMOTE_LOOPBACK_GET, dev_id, port_id, enable); + return rv; +} + +sw_error_t +fal_port_reset(a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_RESET, dev_id, port_id); + return rv; +} + +sw_error_t +fal_port_power_off(a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_POWER_OFF, dev_id, port_id); + return rv; +} + +sw_error_t +fal_port_power_on(a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_POWER_ON, dev_id, port_id); + return rv; +} + + sw_error_t + fal_port_magic_frame_mac_set (a_uint32_t dev_id, fal_port_t port_id, + fal_mac_addr_t * mac) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_MAGIC_FRAME_MAC_SET, dev_id, port_id, mac); + return rv; + +} + + sw_error_t + fal_port_magic_frame_mac_get (a_uint32_t dev_id, fal_port_t port_id, + fal_mac_addr_t * mac) +{ + + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_MAGIC_FRAME_MAC_GET, dev_id, port_id, mac); + return rv; + + +} + sw_error_t + fal_port_phy_id_get (a_uint32_t dev_id, fal_port_t port_id, + a_uint16_t * org_id, a_uint16_t * rev_id) + { + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_PHY_ID_GET, dev_id, port_id, org_id, rev_id); + return rv; + } + sw_error_t + fal_port_wol_status_set (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_WOL_STATUS_SET, dev_id, port_id, enable); + return rv; + + } + sw_error_t + fal_port_wol_status_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) + + { + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_WOL_STATUS_GET, dev_id, port_id,enable); + return rv; + } +sw_error_t +fal_port_interface_mode_status_get (a_uint32_t dev_id, fal_port_t port_id, + fal_port_interface_mode_t * mode) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PT_INTERFACE_MODE_STATUS_GET, dev_id, port_id, mode); + return rv; +} + +sw_error_t +fal_debug_phycounter_set(a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_DEBUG_PHYCOUNTER_SET, dev_id, port_id, + enable); + return rv; +} + +sw_error_t +fal_debug_phycounter_get(a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_DEBUG_PHYCOUNTER_GET, dev_id, port_id, enable); + return rv; +} + +sw_error_t +fal_debug_phycounter_show(a_uint32_t dev_id, fal_port_t port_id, + fal_port_counter_info_t * port_counter_info) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_DEBUG_PHYCOUNTER_SHOW, dev_id, port_id, port_counter_info); + return rv; +} diff --git a/qca/src/qca-psdk/cli/src/fal/fal_reg_access.c b/qca/src/qca-psdk/cli/src/fal/fal_reg_access.c new file mode 100644 index 00000000000..a9d1968273b --- /dev/null +++ b/qca/src/qca-psdk/cli/src/fal/fal_reg_access.c @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2014, 2017-2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include "sw.h" +#include "sw_ioctl.h" +#include "fal_reg_access.h" +#include "fal_uk_if.h" + +sw_error_t +fal_phy_get(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg, a_uint16_t * value) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PHY_GET, dev_id, phy_addr, reg, value); + return rv; +} + +sw_error_t +fal_phy_set(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg, a_uint16_t value) +{ + sw_error_t rv; + + rv = sw_uk_exec(SW_API_PHY_SET, dev_id, phy_addr, reg, value); + return rv; +} diff --git a/qca/src/qca-psdk/cli/src/fal/fal_uk_if.c b/qca/src/qca-psdk/cli/src/fal/fal_uk_if.c new file mode 100755 index 00000000000..891ef938d04 --- /dev/null +++ b/qca/src/qca-psdk/cli/src/fal/fal_uk_if.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2014, 2017, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include +#include "sw.h" +#include "ssdk_init.h" +#include "sw_api.h" +#include "sw_api_us.h" +#include "api_access.h" + +sw_error_t +sw_uk_exec(a_uint32_t api_id, ...) +{ + unsigned long value[SW_MAX_API_PARAM] = { 0 }; + unsigned long rtn = SW_OK, i; + va_list arg_ptr; + a_uint32_t nr_param = 0; + + if((nr_param = sw_api_param_nums(api_id)) == 0) + { + return SW_NOT_SUPPORTED; + } + + value[0] = (unsigned long)api_id; + value[1] = (unsigned long)&rtn; + + va_start(arg_ptr, api_id); + for (i = 0; i < nr_param; i++) + { + value[i + 2] = va_arg(arg_ptr, unsigned long); + } + va_end(arg_ptr); + sw_uk_if(value); + + return rtn; +} + +sw_error_t +ssdk_init(a_uint32_t dev_id, ssdk_init_cfg * cfg) +{ + sw_error_t rv; + + rv = sw_uk_init(cfg->nl_prot); + return rv; +} + +sw_error_t +ssdk_cleanup(void) +{ + sw_error_t rv; + + rv = sw_uk_cleanup(); + return rv; +} + diff --git a/qca/src/qca-psdk/cli/src/shell/shell.c b/qca/src/qca-psdk/cli/src/shell/shell.c new file mode 100644 index 00000000000..65d6bce07c3 --- /dev/null +++ b/qca/src/qca-psdk/cli/src/shell/shell.c @@ -0,0 +1,848 @@ +/* + * Copyright (c) 2014, 2017-2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include +#include +#include +#include "shell.h" +#include "shell_io.h" +#include "shell_sw.h" +#include "shell_lib.h" +#include "shell_config.h" +#include "api_access.h" +#include "fal_uk_if.h" + +a_ulong_t *ioctl_buf = NULL; +ssdk_init_cfg init_cfg = def_init_cfg; +ssdk_cfg_t ssdk_cfg; +static a_uint32_t flag = 0; + +static a_ulong_t *ioctl_argp; +static FILE * out_fd; +char dev_id_path[] = "/sys/ssdk/dev_id"; +#ifndef SSDK_STR +#define SSDK_STR "SSDK" +#endif +static char *err_info[] = +{ + "Operation succeeded", /*SW_OK*/ + "Operation failed", /*SW_FAIL*/ + "Illegal value ", /*SW_BAD_VALUE*/ + "Value is out of range ", /*SW_OUT_OF_RANGE*/ + "Illegal parameter(s) ", /*SW_BAD_PARAM*/ + "Illegal pointer value ", /*SW_BAD_PTR*/ + "Wrong length", /*SW_BAD_LEN*/ + "Wrong state of state machine ", /*SW_BAD_STATE*/ + "Read operation failed ", /*SW_READ_ERROR*/ + "Write operation failed ", /*SW_WRITE_ERROR*/ + "Fail in creating an entry ", /*SW_CREATE_ERROR*/ + "Fail in deleteing an entry ", /*SW_DELETE_ERROR*/ + "Entry not found ", /*SW_NOT_FOUND*/ + "The parameter(s) is the same ", /*SW_NO_CHANGE*/ + "No more entry found ", /*SW_NO_MORE*/ + "No such entry ", /*SW_NO_SUCH*/ + "Tried to create existing entry ", /*SW_ALREADY_EXIST*/ + "Table is full ", /*SW_FULL*/ + "Table is empty ", /*SW_EMPTY*/ + "This request is not support ", /*SW_NOT_SUPPORTED*/ + "This request is not implemented", /*SW_NOT_IMPLEMENTED*/ + "The item is not initialized ", /*SW_NOT_INITIALIZED*/ + "Operation is still running", /*SW_BUSY*/ + "Operation Time Out ", /*SW_TIMEOUT*/ + "Operation is disabled ", /*SW_DISABLE*/ + "Resource not available (memory ...)", /*SW_NO_RESOURCE*/ + "Error occured while INIT process", /*SW_INIT_ERROR*/ + "The other side is not ready yet", /*SW_NOT_READY */ + "Cpu memory allocation failed. ", /*SW_OUT_OF_MEM */ + "Operation has been aborted. ", /*SW_ABORTED*/ +} ; + +void +cmd_print_error(sw_error_t rtn) +{ + dprintf("\n%s\n\n", err_info[abs(rtn)]); +} + +void +cmd_print(char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + if(out_fd) + vfprintf(out_fd, fmt, args); + else + vfprintf(stdout, fmt, args); + va_end(args); +} + +static sw_error_t +cmd_input_parser(a_ulong_t *arg_val, a_uint32_t arg_index, sw_api_param_t *pp) +{ + a_int16_t i; + a_ulong_t *pbuf; + a_uint16_t rtn_size = 1; + sw_api_param_t *pptmp = pp; + + pbuf = ioctl_buf + rtn_size; /*reserve for return value */ + + for (i = 0; i < arg_index; i++) + { + pptmp = pp + i; + if (pptmp->param_type & SW_PARAM_PTR) + { + pbuf += (pptmp->data_size + 3) / 4; + } + } + if ((pbuf - ioctl_buf + (pptmp->data_size + 3) / 4) > (IOCTL_BUF_SIZE/4)) + { + return SW_NO_RESOURCE; + } + + *arg_val = (a_ulong_t) pbuf; + + return SW_OK; +} + +static sw_error_t +cmd_api_func(sw_api_func_t *fp, a_uint32_t nr_param, a_ulong_t * args) +{ + a_ulong_t *p = &args[2]; + sw_error_t rv; + sw_error_t(*func) (); + + func = fp->func; + + switch (nr_param) + { + case 0: + rv = (func) (); + break; + case 1: + rv = (func) (p[0]); + break; + case 2: + rv = (func) (p[0], p[1]); + break; + case 3: + rv = (func) (p[0], p[1], p[2]); + break; + case 4: + rv = (func) (p[0], p[1], p[2], p[3]); + break; + case 5: + rv = (func) (p[0], p[1], p[2], p[3], p[4]); + break; + case 6: + rv = (func) (p[0], p[1], p[2], p[3], p[4], p[5]); + break; + case 7: + rv = (func) (p[0], p[1], p[2], p[3], p[4], p[5], p[6]); + break; + case 8: + rv = (func) (p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]); + break; + case 9: + rv = (func) (p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8]); + break; + case 10: + rv = (func) (p[0], p[1], p[2], p[3], p[4], p[5], + p[6], p[7], p[8], p[9]); + break; + default: + rv = SW_OUT_OF_RANGE; + } + + *(a_ulong_t *) args[1] = rv; + + return rv; +} + +static sw_error_t +cmd_api_output(sw_api_param_t *pp, a_uint32_t nr_param, a_ulong_t * args) +{ + a_uint16_t i; + a_ulong_t *pbuf; + a_uint16_t rtn_size = 1; + sw_error_t rtn = (sw_error_t) (*ioctl_buf); + sw_api_param_t *pptmp = NULL; + + if (rtn != SW_OK) + { + cmd_print_error(rtn); + return rtn; + } + + pbuf = ioctl_buf + rtn_size; + for (i = 0; i < nr_param; i++) + { + pptmp = pp + i; + if (pptmp->param_type & SW_PARAM_PTR) + { + + if (pptmp->param_type & SW_PARAM_OUT) + { + + sw_data_type_t *data_type; + if (!(data_type = cmd_data_type_find(pptmp->data_type))) + return SW_NO_SUCH; + + if (data_type->show_func) + { + data_type->show_func(pptmp->param_name, pbuf, pptmp->data_size); + } + else + { + dprintf("\n Error, not define output print function!"); + } + } + + if ((pbuf - ioctl_buf + + (pptmp->data_size + 3) / 4) > (IOCTL_BUF_SIZE/4)) + return SW_NO_RESOURCE; + + pbuf += (pptmp->data_size + 3) / 4; + + } + } + return SW_OK; +} + +void +cmd_strtol(char *str, a_uint32_t * arg_val) +{ + if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) + sscanf(str, "%x", arg_val); + else + sscanf(str, "%d", arg_val); +} + +static sw_error_t +cmd_parse_api(char **cmd_str, a_ulong_t * arg_val) +{ + char *tmp_str; + a_uint32_t arg_index, arg_start = 2, reserve_index = 1; /*reserve for dev_id */ + a_uint32_t last_param_in = 0; + a_ulong_t *temp; + void *pentry; + sw_api_param_t *pptmp = NULL; + sw_api_t sw_api; + a_uint32_t ignorecnt = 0, jump = 0; + sw_api.api_id = arg_val[0]; + SW_RTN_ON_ERROR(sw_api_get(&sw_api)); + + /*set device id */ + arg_val[arg_start] = get_devid(); + + for (arg_index = reserve_index; arg_index < sw_api.api_nr; arg_index++) + { + tmp_str = NULL; + pptmp = sw_api.api_pp + arg_index; + + if (!(pptmp->param_type & SW_PARAM_IN)) + { + ignorecnt++; + } + + if (pptmp->param_type & SW_PARAM_IN) + { + tmp_str = cmd_str[arg_index - reserve_index - ignorecnt + jump]; + last_param_in = arg_index; + if((pptmp->api_id == 314) && last_param_in == 2) last_param_in = 4;//SW_API_FDB_EXTEND_NEXT wr + if((pptmp->api_id == 327) && last_param_in == 2) last_param_in = 4;//SW_API_FDB_EXTEND_FIRST wr + } + temp = &arg_val[arg_start + arg_index]; + + sw_data_type_t *data_type; + if (!(data_type = cmd_data_type_find(pptmp->data_type))) + return SW_NO_SUCH; + + pentry = temp; + if (pptmp->param_type & SW_PARAM_PTR) + { + if (cmd_input_parser(temp, arg_index, sw_api.api_pp) != SW_OK) + return SW_NO_RESOURCE; + + pentry = (void *) *temp; + } + + if (pptmp->param_type & SW_PARAM_IN) + { +#if 1 + if(pptmp->param_type & SW_PARAM_PTR) //quiet mode + { + if(!get_talk_mode()) + set_full_cmdstrp((char **)(cmd_str + (last_param_in - reserve_index) + jump)); + } +#endif + /*check and convert input param */ + if (data_type->param_check != NULL) + { + if (data_type->param_check(tmp_str, pentry, pptmp->data_size) != SW_OK) + return SW_BAD_PARAM; + if(!get_talk_mode() && (pptmp->param_type & SW_PARAM_PTR)) { + if (get_jump()) + jump += get_jump() -1; + } + + } + } + } + + /*superfluous args */ + /* + if(cmd_str[last_param_in] != NULL) + return SW_BAD_PARAM; + */ + + return SW_OK; +} + +static sw_error_t +cmd_parse_sw(char **cmd_str, a_ulong_t * arg_val) +{ + char *tmp_str; + a_uint32_t arg_index = 0, tmp = 0; + a_uint32_t api_id = arg_val[0]; + + tmp_str = cmd_str[arg_index]; + while (tmp_str) + { + arg_index++; + cmd_strtol(tmp_str, &tmp); + arg_val[arg_index] = tmp; + tmp_str = cmd_str[arg_index]; + } + + /*args number check */ + if ( (arg_index == 0 && ( api_id == SW_CMD_VLAN_SHOW || + api_id == SW_CMD_FDB_SHOW || + api_id == SW_CMD_RESV_FDB_SHOW || + api_id == SW_CMD_HOST_SHOW || + api_id == SW_CMD_HOST_IPV4_SHOW || + api_id == SW_CMD_HOST_IPV6_SHOW || + api_id == SW_CMD_HOST_IPV4M_SHOW || + api_id == SW_CMD_HOST_IPV6M_SHOW || + api_id == SW_CMD_FLOW_IPV43T_SHOW || + api_id == SW_CMD_FLOW_IPV63T_SHOW || + api_id == SW_CMD_FLOW_IPV45T_SHOW || + api_id == SW_CMD_FLOW_IPV65T_SHOW || + api_id == SW_CMD_NAT_SHOW || + api_id == SW_CMD_NAPT_SHOW || + api_id == SW_CMD_FLOW_SHOW || + api_id == SW_CMD_CTRLPKT_SHOW || + api_id == SW_CMD_INTFMAC_SHOW || + api_id == SW_CMD_PUBADDR_SHOW )) || + ( arg_index == 1 && api_id == SW_CMD_SET_DEVID) || + ( arg_index == 2 && api_id == SW_CMD_PT_VLAN_TRANS_ADV_SHOW) ) + return SW_OK; + + return SW_BAD_PARAM; +} + +/*user command api*/ +sw_error_t +cmd_exec_api(a_ulong_t *arg_val) +{ + sw_error_t rv; + sw_api_t sw_api; + + sw_api.api_id = arg_val[0]; + SW_RTN_ON_ERROR(sw_api_get(&sw_api)); + + /*save cmd return value */ + arg_val[1] = (a_ulong_t) ioctl_buf; + /*save set device id */ + arg_val[2] = get_devid(); + + rv = cmd_api_func(sw_api.api_fp, sw_api.api_nr, arg_val); + SW_RTN_ON_ERROR(rv); + + rv = cmd_api_output(sw_api.api_pp, sw_api.api_nr, arg_val); + SW_RTN_ON_ERROR(rv); + + return rv; +} + + +void +cmd_print_usage (int cmd_index, int cmd_index_sub) +{ + if(GCMD_NAME(cmd_index)) + dprintf("usage: %s", GCMD_NAME(cmd_index)); + + if (GCMD_SUB_NAME(cmd_index, cmd_index_sub)) + dprintf(" %s", GCMD_SUB_NAME(cmd_index, cmd_index_sub)); + + if(GCMD_SUB_ACT(cmd_index, cmd_index_sub) && GCMD_SUB_USAGE(cmd_index, cmd_index_sub)) + dprintf(" %s %s\n\n", GCMD_SUB_ACT(cmd_index, cmd_index_sub), + GCMD_SUB_USAGE(cmd_index, cmd_index_sub)); +} +/* + main function + input args: + arg_val[0] = cmd_num + arg_val[1] = rtn_code + arg_val[2] = dev_id + arg_val[3] = dbg_cmd_num or other +*/ + +/*command string lookup*/ +a_uint32_t +cmd_lookup(char **cmd_str, int *cmd_index, int *cmd_index_sub) +{ + a_uint32_t no, sub_no; + a_uint32_t cmd_deepth = 0; + + *cmd_index = GCMD_DESC_NO_MATCH; + *cmd_index_sub = GCMD_DESC_NO_MATCH; + + if (cmd_str[0] == NULL) + return cmd_deepth; + + for (no = 0; GCMD_DESC_VALID(no); no++) + { + if (strcasecmp(cmd_str[0], GCMD_NAME(no))) + continue; + + for (sub_no = 0; GCMD_SUB_DESC_VALID(no, sub_no); sub_no++) + { + if (cmd_str[1] != NULL && cmd_str[2] != NULL) + { + + if (GCMD_SUB_NAME(no, sub_no) && GCMD_SUB_ACT(no, sub_no) + && !strcasecmp(cmd_str[1], GCMD_SUB_NAME(no, sub_no)) + && !strcasecmp(cmd_str[2], GCMD_SUB_ACT(no, sub_no))) + { + *cmd_index = no; + *cmd_index_sub = sub_no; + cmd_deepth = 3; + return cmd_deepth; + } + + else if (!GCMD_SUB_NAME(no, sub_no) && GCMD_SUB_ACT(no, sub_no) + && !strcasecmp(cmd_str[1], GCMD_SUB_ACT(no, sub_no))) + { + *cmd_index = no; + *cmd_index_sub = sub_no; + cmd_deepth = 2; + return cmd_deepth; + } + } + else if (cmd_str[1] != NULL && cmd_str[2] == NULL) + { + + if (!GCMD_SUB_NAME(no, sub_no) && GCMD_SUB_ACT(no, sub_no) + && !strcasecmp(cmd_str[1], GCMD_SUB_ACT(no, sub_no))) + { + *cmd_index = no; + *cmd_index_sub = sub_no; + cmd_deepth = 2; + return cmd_deepth; + } + } + } + } + + return cmd_deepth; +} + +static a_ulong_t * +cmd_parse(char *cmd_str, int *cmd_index, int *cmd_index_sub) +{ + int cmd_nr = 0; + a_ulong_t *arg_val = ioctl_argp; + char *tmp_str[CMDSTR_ARGS_MAX], *str_save; + + if (cmd_str == NULL) + return NULL; + + memset(arg_val, 0, CMDSTR_ARGS_MAX * sizeof (a_ulong_t)); + + /* split string into array */ + if ((tmp_str[cmd_nr] = (void *) strtok_r(cmd_str, " ", &str_save)) == NULL) + return NULL; + + /*handle help */ + if (!strcasecmp(tmp_str[cmd_nr], "help")) + { + dprintf("input ? get help\n\n"); + return NULL; + } + + while (tmp_str[cmd_nr]) + { + if (++cmd_nr == 3) + break; + tmp_str[cmd_nr] = (void *) strtok_r(NULL, " ", &str_save); + } + + /*commond string lookup */ + int cmd_depth = cmd_lookup(tmp_str, cmd_index, cmd_index_sub); + + if (*cmd_index == GCMD_DESC_NO_MATCH || *cmd_index_sub == GCMD_DESC_NO_MATCH) + { + dprintf("invalid or incomplete command.\n\n"); + return NULL; + } + + /*parse param */ + cmd_nr = 0; + if (cmd_depth == 2) + { + tmp_str[cmd_nr] = tmp_str[2]; + cmd_nr++; + } + + tmp_str[cmd_nr] = (void *) strtok_r(NULL, " ", &str_save); + while (tmp_str[cmd_nr]) + { + if (++cmd_nr == CMDSTR_ARGS_MAX) + break; + tmp_str[cmd_nr] = (void *) strtok_r(NULL, " ", &str_save); + } + + arg_val[0] = GCMD_SUB_API(*cmd_index, *cmd_index_sub); + arg_val[1] = (a_ulong_t) ioctl_buf; + + int rtn_code; + if (arg_val[0] < SW_API_MAX) + { + /*api command parse */ + rtn_code = cmd_parse_api(tmp_str, arg_val); + + } + else if (arg_val[0] > SW_API_MAX) + { + /*user command parse */ + rtn_code = cmd_parse_sw(tmp_str, arg_val); + + } + else + { + rtn_code = SW_BAD_PARAM; + } + + if(rtn_code != SW_OK) + { + cmd_print_error(rtn_code); + + if(rtn_code == SW_BAD_PARAM) + cmd_print_usage(*cmd_index, *cmd_index_sub); + + return NULL; + } + + return arg_val; +} + +static int +cmd_exec(a_ulong_t *arg_val, int cmd_index, int cmd_index_sub) +{ + a_uint32_t api_id = arg_val[0]; + sw_error_t rtn = SW_OK; + + if( api_id < SW_API_MAX ) + { + rtn = cmd_exec_api(arg_val); + + } + else if ((api_id > SW_API_MAX ) && (api_id < SW_CMD_MAX)) + { + if (GCMD_SUB_FUNC(cmd_index, cmd_index_sub)) + rtn = GCMD_SUB_FUNC(cmd_index, cmd_index_sub)(arg_val); + } + else + { + rtn = SW_BAD_PARAM; + } + + if(rtn != SW_OK) + cmd_print_error(rtn); + else + dprintf("\noperation done.\n\n"); + + return 0; +} + +static sw_error_t +cmd_socket_init(int dev_id) +{ + sw_error_t rv; + + init_cfg.cpu_mode = HSL_CPU_1; + init_cfg.reg_mode = HSL_MDIO; +#if defined UK_MINOR_DEV + init_cfg.nl_prot = UK_MINOR_DEV; +#else + init_cfg.nl_prot = 30; +#endif + init_cfg.chip_type=CHIP_UNSPECIFIED; + rv = ssdk_init(dev_id, &init_cfg); + if (SW_OK == rv) + { + dprintf("\n %s Init OK!", SSDK_STR); + } + else + { + dprintf("\n %s Init Fail! RV[%d]", SSDK_STR, rv); + } + + if (flag == 0) + { + aos_mem_set(&ssdk_cfg, 0 ,sizeof(ssdk_cfg_t)); + rv = sw_uk_exec(SW_API_SSDK_CFG, dev_id, &ssdk_cfg); + flag = 1; + } + return rv; +} + +static sw_error_t +cmd_init(void) +{ + ioctl_buf = (a_ulong_t *) malloc(IOCTL_BUF_SIZE); + ioctl_argp = (a_ulong_t *) malloc(CMDSTR_ARGS_MAX * sizeof (a_ulong_t)); + FILE *dev_id_fd = NULL; + int dev_id_value = 0; + if((dev_id_fd = fopen(dev_id_path, "r")) != NULL) + { + fscanf(dev_id_fd, "%d", &dev_id_value); + } + + set_devid(dev_id_value); + cmd_socket_init(dev_id_value); + + return SW_OK; +} + +static sw_error_t +cmd_exit(void) +{ + free(ioctl_buf); + free(ioctl_argp); + ssdk_cleanup(); + flag = 0; + return SW_OK; +} + +static sw_error_t +cmd_run_one(char *cmd_str) +{ + a_ulong_t *arg_list; + int cmd_index = 0, cmd_index_sub = 0; + + if ((arg_list = cmd_parse(cmd_str, &cmd_index, &cmd_index_sub)) != NULL) + { + cmd_exec(arg_list, cmd_index, cmd_index_sub); + } + + return SW_OK; +} + +int +cmd_is_batch(const char *cmd_str) +{ + char batch_cmd[] = "run"; + + if(!strncmp(cmd_str, batch_cmd, strlen(batch_cmd))) + return 1; + return 0; +} + +static void +cmd_batch_help(void) +{ + dprintf("usage:run \n"); +} + +static sw_error_t +cmd_run_batch (char *cmd_str) +{ + FILE *in_fd = NULL; + char * line = NULL, *str_save; + char *tmp_str[3]; + + if (cmd_str == NULL) + return SW_BAD_PARAM; + + /*usage: run cmd result*/ + if((tmp_str[0] = (void *) strtok_r(cmd_str, " ", &str_save)) == NULL) + return SW_BAD_PARAM; + + /*check again*/ + if(!cmd_is_batch(tmp_str[0])) + return SW_BAD_PARAM; + + if((tmp_str[1] = (void *) strtok_r(NULL, " ", &str_save))== NULL) + return SW_BAD_PARAM; + if((tmp_str[2] = (void *) strtok_r(NULL, " ", &str_save))== NULL) + return SW_BAD_PARAM; + + if((in_fd = fopen(tmp_str[1], "r")) == NULL) + { + dprintf("can't open cmd file %s\n", tmp_str[1]); + return SW_FAIL; + } + if((out_fd = fopen(tmp_str[2], "w+")) == NULL) + { + dprintf("can't open result file %s\n", tmp_str[2]); + return SW_FAIL; + } + + size_t len = 0; + ssize_t read; + + set_talk_mode(0); + while ((read = getline(&line, &len, in_fd)) != -1) + { + //dprintf("(%d)%s",read, line); + if (read <= 1 ) + { + continue; + } + + if (line[strlen(line)-1] == '\n') + { + line[strlen(line)-1] = '\0'; + } + + if (!strncmp(line, "echo", 4)) + { + dprintf("%s\n", line+strlen("echo ")); + continue; + } + else + { + dprintf("%s\n", line); + } + cmd_run_one(line); + } + set_talk_mode(1); + + if (line) free(line); + + fclose(out_fd); + fclose(in_fd); + out_fd = 0; + in_fd =0; + + return SW_OK; + +} + +static sw_error_t +cmd_args(char *cmd_str, int argc, const char *argv[]) +{ + /*quiet mode*/ + set_talk_mode(0); + + if(cmd_is_batch(argv[1])) + { + if(argc != 4) + { + cmd_batch_help(); + return SW_FAIL; + } + + snprintf(cmd_str, CMDSTR_BUF_SIZE, "%s %s %s", argv[1], argv[2], argv[3]); + cmd_run_batch(cmd_str); + + } + else + { + int argi; + for(argi = 1; argi < argc; argi++) + { + strlcat(cmd_str, argv[argi], CMDSTR_BUF_SIZE); + strlcat(cmd_str, " ", CMDSTR_BUF_SIZE); + } + cmd_run_one(cmd_str); + } + + return SW_OK; +} + +int +cmd_is_exit(char *cmd_str) +{ + if ((!strcasecmp(cmd_str, "q")) || (!strcasecmp(cmd_str, "quit"))) + { + return 1; + } + return 0; +} + +void cmd_welcome() +{ + char *ver = "", *date = ""; +#ifdef VERSION + ver = VERSION; +#endif + +#ifdef BUILD_DATE + date = BUILD_DATE; +#endif + dprintf("\n Welcome to %s Shell version: %s, at %s.\n", SSDK_STR, ver, date); +} + +/* Dummy function to avoid linker complaints */ +void __aeabi_unwind_cpp_pr0(void) +{ +}; +void __aeabi_unwind_cpp_pr1(void) +{ +}; + +int +main(int argc, const char *argv[]) +{ + char cmd_str[CMDSTR_BUF_SIZE]; + cmd_init(); + + if(argc > 1) + { + memset(cmd_str, 0, sizeof(cmd_str)); + cmd_args(cmd_str, argc, argv); + cmd_exit(); + return 0; + } + + cmd_welcome(); + + /*main loop*/ + while (1) + { + memset(cmd_str, 0, sizeof(cmd_str)); + + if(next_cmd(cmd_str) == 0)/*loop through if '\n'*/ + continue; + + if (cmd_is_exit(cmd_str)) + break; + + if(cmd_is_batch(cmd_str)) + { + if(cmd_run_batch(cmd_str)!= SW_OK) + cmd_batch_help(); + } + else + { + cmd_run_one(cmd_str); + } + } + + cmd_exit(); + return 0; +} diff --git a/qca/src/qca-psdk/cli/src/shell/shell_config.c b/qca/src/qca-psdk/cli/src/shell/shell_config.c new file mode 100644 index 00000000000..de967b730bf --- /dev/null +++ b/qca/src/qca-psdk/cli/src/shell/shell_config.c @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include "shell_config.h" +#include "shell_sw.h" + + +/*cmdline tree descript*/ +struct cmd_des_t gcmd_des[] = +{ + /*port ctrl*/ + { + "port", "config port control", + { + {"duplex", "get", "get duplex mode of a port", "" , SW_API_PT_DUPLEX_GET, + NULL}, + {"duplex", "set", "set duplex mode of a port", " ", + SW_API_PT_DUPLEX_SET, NULL}, + {"speed", "get", "get speed mode of a port", "", SW_API_PT_SPEED_GET, + NULL}, + {"speed", "set", "set speed mode of a port", + " <10|100|1000|2500|5000|10000>", SW_API_PT_SPEED_SET, NULL}, + {"autoAdv", "get", "get auto-negotiation advertisement of a port", "", + SW_API_PT_AN_ADV_GET, NULL}, + {"autoAdv", "set", "set auto-negotiation advertisement of a port", + " ", SW_API_PT_AN_ADV_SET, NULL}, + {"autoNeg", "get", "get auto-negotiation status of a port", "", + SW_API_PT_AN_GET, NULL}, + {"autoNeg", "enable", "enable auto-negotiation of a port", "", + SW_API_PT_AN_ENABLE, NULL}, + {"autoNeg", "restart", "restart auto-negotiation process of a port", "", + SW_API_PT_AN_RESTART, NULL}, + {"hibernate", "set", "set hibernate status of a port", + " ", SW_API_PT_HIBERNATE_SET, NULL}, + {"hibernate", "get", "get hibernate status of a port", "", + SW_API_PT_HIBERNATE_GET, NULL}, + {"cdt", "run", "run cable diagnostic test of a port", + " ", SW_API_PT_CDT, NULL}, + {"linkstatus", "get", "get link status of a port", "", + SW_API_PT_LINK_STATUS_GET, NULL}, + {"Ieee8023az", "set", "set 8023az status of a port", " ", + SW_API_PT_8023AZ_SET, NULL}, + {"Ieee8023az", "get", "get 8023az status of a port", "", + SW_API_PT_8023AZ_GET, NULL}, + {"crossover", "set", "set crossover mode of a port", " ", + SW_API_PT_MDIX_SET, NULL}, + {"crossover", "get", "get crossover mode of a port", "", + SW_API_PT_MDIX_GET, NULL}, + {"crossover", "status", "get current crossover status of a port", "", + SW_API_PT_MDIX_STATUS_GET, NULL}, + {"localLoopback", "set", "set local loopback of a port", + " ", SW_API_PT_LOCAL_LOOPBACK_SET, NULL}, + {"localLoopback", "get", "get local loopback of a port", "", + SW_API_PT_LOCAL_LOOPBACK_GET, NULL}, + {"remoteLoopback", "set", "set remote loopback of a port", + " ", SW_API_PT_REMOTE_LOOPBACK_SET, NULL}, + {"remoteLoopback", "get", "get remote loopback of a port", "", + SW_API_PT_REMOTE_LOOPBACK_GET, NULL}, + {"reset", "set", "reset phy of a port", "", SW_API_PT_RESET, NULL}, + {"poweroff", "set", "power off phy of a port", "", + SW_API_PT_POWER_OFF, NULL}, + {"poweron", "set", "power on phy of a port", "", SW_API_PT_POWER_ON, NULL}, + {"magicFrameMac", "set", "set magic frame mac address of a port", + " ", SW_API_PT_MAGIC_FRAME_MAC_SET, NULL}, + {"magicFrameMac", "get", "get magic frame mac address of a port", "", + SW_API_PT_MAGIC_FRAME_MAC_GET, NULL}, + {"phyId", "get", "get phy id of a port", "", SW_API_PT_PHY_ID_GET, NULL}, + {"wolstatus", "set", "set wol status of a port", " ", + SW_API_PT_WOL_STATUS_SET, NULL}, + {"wolstatus", "get", "get wol status of a port", "", + SW_API_PT_WOL_STATUS_GET, NULL}, + {"interfaceMode", "status", "get current interface mode of phy", "", + SW_API_PT_INTERFACE_MODE_STATUS_GET, NULL}, + {NULL, NULL, NULL, NULL, SW_API_INVALID, NULL},/*end of desc*/ + }, + }, + /* debug */ + { + "debug", "read/write register", + { + {"phy", "get", "read phy register", " ", SW_API_PHY_GET, NULL}, + {"phy", "set", "write phy register", " ", SW_API_PHY_SET, NULL}, + {"phycounter", "set", "set counter status of a port", " ", SW_API_DEBUG_PHYCOUNTER_SET, NULL}, + {"phycounter", "get", "get counter status of a port", "", SW_API_DEBUG_PHYCOUNTER_GET, NULL}, + {"phycounter", "show", "show counter of a port", "", SW_API_DEBUG_PHYCOUNTER_SHOW, NULL}, + {NULL, NULL, NULL, NULL, SW_API_INVALID, NULL}/*end of desc*/ + }, + }, + {"help", "type ? get help", {{NULL, NULL, NULL, NULL, SW_API_INVALID, NULL}/*end of desc*/}}, + + {"quit", "type quit/q quit shell", {{NULL, NULL, NULL, NULL, SW_API_INVALID, NULL}/*end of desc*/}}, + + {NULL, NULL, {{NULL, NULL, NULL, NULL, SW_API_INVALID, NULL}}} /*end of desc*/ +}; diff --git a/qca/src/qca-psdk/cli/src/shell/shell_io.c b/qca/src/qca-psdk/cli/src/shell/shell_io.c new file mode 100644 index 00000000000..658cac7d047 --- /dev/null +++ b/qca/src/qca-psdk/cli/src/shell/shell_io.c @@ -0,0 +1,1334 @@ +/* + * Copyright (c) 2014-2020, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include +#include "shell_io.h" +#include "shell.h" + +#define SW_RTN_ON_NULL_PARAM(rtn) \ + do { if ((rtn) == NULL) return SW_BAD_PARAM; } while(0); + +#define DEFAULT_FLAG "default" +static char **full_cmdstrp; +static int talk_mode = 1; + +char g_aclcmd[500] = "\0"; +a_uint32_t g_aclcmd_len = 0;; + +void append_acl_cmd(char * cmd) +{ + if(500 > (g_aclcmd_len+1)) { + g_aclcmd_len += snprintf(g_aclcmd+g_aclcmd_len, 500-g_aclcmd_len, "%s", cmd); + g_aclcmd_len += snprintf(g_aclcmd+g_aclcmd_len, 500-g_aclcmd_len, "%s", " "); + } +} + +int +get_talk_mode(void) +{ + return talk_mode ; +} + +void +set_talk_mode(int mode) +{ + talk_mode = mode; +} + +char ** full_cmdstrp_bak; + +void +set_full_cmdstrp(char **cmdstrp) +{ + full_cmdstrp = cmdstrp; + full_cmdstrp_bak = cmdstrp; +} + +int +get_jump(void) +{ + return (full_cmdstrp-full_cmdstrp_bak); +} + +static char * +get_cmd_buf(char *tag, char *defval) +{ + if(!full_cmdstrp || !(*full_cmdstrp)) + { + dprintf("parameter (%s) or default (%s) absent\n", tag, defval); + exit(1); + } + + if (!strcasecmp(*(full_cmdstrp), DEFAULT_FLAG)) + { + full_cmdstrp++; + return defval; + } + else + { + return *(full_cmdstrp++); + } +} + +static char * +get_cmd_stdin(char *tag, char *defval) +{ + static char gsubcmdstr[256]; + int pos = 0; + int c; + + if(defval) + { + dprintf("%s(%s): ", tag, defval); + } + else + { + dprintf("%s: ", tag); + } + + fflush(stdout); + memset(gsubcmdstr, 0, sizeof(gsubcmdstr)); + + while ((c = getchar()) != '\n') + { + gsubcmdstr[pos++] = c; + if (pos == (sizeof(gsubcmdstr) - 1)) + { + dprintf("too long command\n"); + return NULL; + } + } + + gsubcmdstr[pos] = '\0'; + if ('\0' == gsubcmdstr[0]) + { + return defval; + } + else + { + return gsubcmdstr; + } +} + +static char * +get_sub_cmd(char *tag, char *defval) +{ + if(talk_mode) + return get_cmd_stdin(tag, defval); + else + return get_cmd_buf(tag, defval); +} + + +static inline a_bool_t +is_hex(char c) +{ + if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') + || (c >= 'A' && c <= 'F')) + return A_TRUE; + + return A_FALSE; +} + +static inline a_bool_t +is_dec(char c) +{ + if ((c >= '0') && (c <= '9')) + return A_TRUE; + + return A_FALSE; +} + +static sw_data_type_t sw_data_type[] = +{ + SW_TYPE_DEF(SW_UINT8, cmd_data_check_uint8, cmd_data_print_uint8), + SW_TYPE_DEF(SW_INT8, NULL, NULL), + SW_TYPE_DEF(SW_UINT16, cmd_data_check_uint16, cmd_data_print_uint16), + SW_TYPE_DEF(SW_INT16, NULL, NULL), + SW_TYPE_DEF(SW_UINT32, cmd_data_check_uint32, cmd_data_print_uint32), + SW_TYPE_DEF(SW_INT32, NULL, NULL), + SW_TYPE_DEF(SW_UINT64, cmd_data_check_uint64, cmd_data_print_uint64), + SW_TYPE_DEF(SW_INT64, NULL, NULL), + SW_TYPE_DEF(SW_CAP, cmd_data_check_capable, cmd_data_print_capable), + SW_TYPE_DEF(SW_DUPLEX, cmd_data_check_duplex, cmd_data_print_duplex), + SW_TYPE_DEF(SW_SPEED, cmd_data_check_speed, cmd_data_print_speed), + SW_TYPE_DEF(SW_PBMP, cmd_data_check_pbmp, cmd_data_print_pbmp), + SW_TYPE_DEF(SW_ENABLE, cmd_data_check_enable, cmd_data_print_enable), + SW_TYPE_DEF(SW_MACADDR, cmd_data_check_macaddr, cmd_data_print_macaddr), + SW_TYPE_DEF(SW_CABLESTATUS, NULL, cmd_data_print_cable_status), + SW_TYPE_DEF(SW_CABLELEN, NULL, cmd_data_print_cable_len), + SW_TYPE_DEF(SW_SSDK_CFG, NULL, cmd_data_print_ssdk_cfg), + SW_TYPE_DEF(SW_CROSSOVER_MODE, cmd_data_check_crossover_mode, cmd_data_print_crossover_mode), + SW_TYPE_DEF(SW_CROSSOVER_STATUS, cmd_data_check_crossover_status, cmd_data_print_crossover_status), + SW_TYPE_DEF(SW_INTERFACE_MODE, cmd_data_check_interface_mode, cmd_data_print_interface_mode), + SW_TYPE_DEF(SW_COUNTER_INFO, NULL, cmd_data_print_counter_info), + SW_TYPE_DEF(SW_REG_DUMP, NULL, cmd_data_print_register_info), + SW_TYPE_DEF(SW_PHY_DUMP, NULL, cmd_data_print_phy_register_info), + SW_TYPE_DEF(SW_DBG_REG_DUMP, NULL, cmd_data_print_debug_register_info), +}; + +sw_data_type_t * +cmd_data_type_find(sw_data_type_e type) +{ + a_uint16_t i = 0; + + do + { + if (type == sw_data_type[i].data_type) + return &sw_data_type[i]; + } + while ( ++i < sizeof(sw_data_type)/sizeof(sw_data_type[0])); + + return NULL; +} + +sw_error_t __cmd_data_check_quit_help(char *cmd, char *usage) +{ + sw_error_t ret = SW_OK; + + if (!strncasecmp(cmd, "quit", 4)) { + return SW_ABORTED; + } else if (!strncasecmp(cmd, "help", 4)) { + dprintf("%s", usage); + ret = SW_BAD_VALUE; + } + + return ret; +} + +sw_error_t __cmd_data_check_complex(char *info, char *defval, char *usage, + sw_error_t(*chk_func)(), void *arg_val, + a_uint32_t size) +{ + sw_error_t ret; + char *cmd; + + do { + cmd = get_sub_cmd(info, defval); + SW_RTN_ON_NULL_PARAM(cmd); + + ret = __cmd_data_check_quit_help(cmd, usage); + if (ret == SW_ABORTED) + return ret; + else if (ret == SW_OK) { + ret = chk_func(cmd, arg_val, size); + if (ret) + dprintf("%s", usage); + } + } while (talk_mode && (SW_OK != ret)); + + return SW_OK; +} + +sw_error_t +cmd_data_check_uint8(char *cmd_str, a_uint32_t *arg_val, a_uint32_t size) +{ + if (cmd_str == NULL) + return SW_BAD_PARAM; + + if (0 == cmd_str[0]) + { + return SW_BAD_VALUE; + } + + if (cmd_str[0] == '0' && (cmd_str[1] == 'x' || cmd_str[1] == 'X')) + sscanf(cmd_str, "%x", arg_val); + else + sscanf(cmd_str, "%d", arg_val); + + if (255 < *arg_val) + { + return SW_BAD_PARAM; + } + + return SW_OK; +} + +void +cmd_data_print_uint8(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size) +{ + dprintf("[%s]:0x%x", param_name, *(a_uint8_t *) buf); + +} + + +sw_error_t +cmd_data_check_uint32(char *cmd_str, a_uint32_t * arg_val, a_uint32_t size) +{ + if (cmd_str == NULL) + return SW_BAD_PARAM; + + if (0 == cmd_str[0]) + { + return SW_BAD_VALUE; + } + + if (strspn(cmd_str, "1234567890abcdefABCDEFXx") != strlen(cmd_str)){ + return SW_BAD_VALUE; + } + + if (cmd_str[0] == '0' && (cmd_str[1] == 'x' || cmd_str[1] == 'X')) + sscanf(cmd_str, "%x", arg_val); + else + sscanf(cmd_str, "%d", arg_val); + + return SW_OK; +} + +void +cmd_data_print_uint32(a_char_t * param_name, a_uint32_t * buf, a_uint32_t size) +{ + dprintf("[%s]:0x%x", param_name, *(a_uint32_t *) buf); +} + +sw_error_t +cmd_data_check_uint64(char *cmd_str, a_uint64_t * arg_val, a_uint32_t size) +{ + if (cmd_str == NULL) + return SW_BAD_PARAM; + + if (0 == cmd_str[0]) + { + return SW_BAD_VALUE; + } + + if (strspn(cmd_str, "1234567890abcdefABCDEFXx") != strlen(cmd_str)){ + return SW_BAD_VALUE; + } + + if (cmd_str[0] == '0' && (cmd_str[1] == 'x' || cmd_str[1] == 'X')) + sscanf(cmd_str, "%llx", arg_val); + else + sscanf(cmd_str, "%lld", arg_val); + + return SW_OK; +} + +void +cmd_data_print_uint64(a_uint8_t * param_name, a_uint64_t * buf, a_uint32_t size) +{ + dprintf("[%s]:0x%llx", param_name, *(a_uint64_t *) buf); +} + +sw_error_t +cmd_data_check_uint16(char *cmd_str, a_uint32_t *arg_val, a_uint32_t size) +{ + if (cmd_str == NULL) + return SW_BAD_PARAM; + + if (0 == cmd_str[0]) + { + return SW_BAD_VALUE; + } + + if (cmd_str[0] == '0' && (cmd_str[1] == 'x' || cmd_str[1] == 'X')) + sscanf(cmd_str, "%x", arg_val); + else + sscanf(cmd_str, "%d", arg_val); + + if (65535 < *arg_val) + { + return SW_BAD_PARAM; + } + + return SW_OK; +} + +void +cmd_data_print_uint16(a_char_t * param_name, a_uint32_t * buf, a_uint32_t size) +{ + dprintf("[%s]:0x%04x", param_name, *(a_uint16_t *) buf); + +} + +sw_error_t +cmd_data_check_pbmp(char *cmd_str, a_uint32_t * arg_val, a_uint32_t size) +{ + if (cmd_str == NULL) + return SW_BAD_PARAM; + + if (cmd_str[0] == '0' && (cmd_str[1] == 'x' || cmd_str[1] == 'X')) + sscanf(cmd_str, "%x", arg_val); + else + sscanf(cmd_str, "%d", arg_val); + + return SW_OK; + +} + +void +cmd_data_print_pbmp(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size) +{ + dprintf("[%s]:0x%x", param_name, *(a_uint32_t *) buf); + +} + +sw_error_t +cmd_data_check_enable(char *cmd_str, a_uint32_t * arg_val, a_uint32_t size) +{ + if (cmd_str == NULL) + return SW_BAD_PARAM; + + if (!strcasecmp(cmd_str, "disable")) + *arg_val = FAL_DISABLE; + else if (!strcasecmp(cmd_str, "enable")) + *arg_val = FAL_ENABLE; + else + { + //dprintf("input error"); + return SW_BAD_VALUE; + } + + return SW_OK; +} + +void +cmd_data_print_enable(a_char_t * param_name, a_uint32_t * buf, a_uint32_t size) +{ + dprintf("[%s]:", param_name); + if (*(a_uint32_t *) buf == 1) + { + dprintf("ENABLE"); + } + else if (*(a_uint32_t *) buf == 0) + { + dprintf("DISABLE"); + } + else + { + dprintf("UNKNOWN VALUE"); + } +} +/*port counter*/ +static char *counter_regname[] = +{ + "RxGoodFrame", + "RxBadCRC ", + "TxGoodFrame", + "TxBadCRC ", + "SysRxGoodFrame", + "SysRxBadCRC", + "SysTxGoodFrame", + "SysTxBadCRC", +}; + +void +cmd_data_print_counter_info(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size) +{ + dprintf("\n[%s] \n", param_name); + a_uint32_t offset = 0; + for (offset = 0; offset < (sizeof (fal_port_counter_info_t) / sizeof (a_uint32_t)); + offset++) + { + + dprintf("%s<0x%08x>\n", counter_regname[offset], *(buf + offset)); + + } +} + +void +cmd_data_print_debug_register_info(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size) +{ + dprintf("\n[%s]", param_name); + fal_debug_reg_dump_t * reg_dump = (fal_debug_reg_dump_t * )buf; + + a_uint32_t reg_count; + + dprintf("\n%s. ", reg_dump->reg_name); + + reg_count = 0; + dprintf("\n"); + for (;reg_count < reg_dump->reg_count;reg_count++) + { + dprintf("%08x:%08x ",reg_dump->reg_addr[reg_count], reg_dump->reg_value[reg_count]); + if ((reg_count + 1) % 4 == 0) + dprintf("\n"); + } + + dprintf("\n\n\n"); +} + + + +void +cmd_data_print_register_info(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size) +{ + dprintf("\n[%s]", param_name); + fal_reg_dump_t * reg_dump = (fal_reg_dump_t * )buf; + a_uint32_t n[8]={0,4,8,0xc,0x10,0x14,0x18,0x1c}; + a_uint32_t dump_addr, reg_count; + + dprintf("\n%s. ", reg_dump->reg_name); + dprintf("\n %8x %8x %8x %8x %8x %8x %8x %8x\n", + n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]); + dprintf(" [%04x] ", reg_dump->reg_base); + + reg_count = 0; + for (dump_addr = reg_dump->reg_base; + (dump_addr <= reg_dump->reg_end )&& (reg_count <= reg_dump->reg_count); + reg_count++) + { + dprintf("%08x ", reg_dump->reg_value[reg_count]); + dump_addr += 4; + if ((reg_count + 1) % 8 == 0) + dprintf("\n [%04x] ", dump_addr); + } + + dprintf("\n\n\n"); +} + +void +cmd_data_print_phy_register_info(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size) +{ + dprintf("\n[%s]", param_name); + fal_phy_dump_t * phy_dump = (fal_phy_dump_t * )buf; + + a_uint32_t n[8]={0,1,2,3,4,5,6,7}; + + a_uint32_t dump_addr, reg_count; + + dprintf("\n%s. ", phy_dump->phy_name); + dprintf("\n %8x %8x %8x %8x %8x %8x %8x %8x\n", + n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]); + dprintf(" [%04x] ", phy_dump->phy_base); + + reg_count = 0; + for (dump_addr = phy_dump->phy_base; + (dump_addr <= phy_dump->phy_end )&& (reg_count <= phy_dump->phy_count); + reg_count++) + { + dprintf("%08x ", phy_dump->phy_value[reg_count]); + dump_addr ++; + if ((reg_count + 1) % 8 == 0) + dprintf("\n [%04x] ", dump_addr); + } + + dprintf("\n\n\n"); +} + + +/*port ctrl*/ +sw_error_t +cmd_data_check_duplex(char *cmd_str, a_uint32_t * arg_val, a_uint32_t size) +{ + if (cmd_str == NULL) + return SW_BAD_PARAM; + + if (!strcasecmp(cmd_str, "half")) + *arg_val = FAL_HALF_DUPLEX; + else if (!strcasecmp(cmd_str, "full")) + *arg_val = FAL_FULL_DUPLEX; + else + { + //dprintf("input error \n"); + return SW_BAD_VALUE; + } + + return SW_OK; +} + +void +cmd_data_print_duplex(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size) +{ + dprintf("[%s]:", param_name); + if (*(a_uint32_t *) buf == 0) + { + dprintf("HALF"); + } + else if (*(a_uint32_t *) buf == 1) + { + dprintf("FULL"); + } + else + { + dprintf("UNKNOWN VALUE"); + } +} + +sw_error_t +cmd_data_check_speed(char *cmd_str, a_uint32_t * arg_val, a_uint32_t size) +{ + if (cmd_str == NULL) + return SW_BAD_PARAM; + + if (!strncasecmp(cmd_str, "10", 3)) + *arg_val = FAL_SPEED_10; + else if (!strncasecmp(cmd_str, "100", 4)) + *arg_val = FAL_SPEED_100; + else if (!strncasecmp(cmd_str, "1000", 5)) + *arg_val = FAL_SPEED_1000; + else if (!strncasecmp(cmd_str, "2500", 5)) + *arg_val = FAL_SPEED_2500; + else if (!strncasecmp(cmd_str, "5000", 5)) + *arg_val = FAL_SPEED_5000; + else if (!strncasecmp(cmd_str, "10000", 6)) + *arg_val = FAL_SPEED_10000; + else + { + //dprintf("input error \n"); + return SW_BAD_VALUE; + } + + return SW_OK; +} + +void +cmd_data_print_speed(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size) +{ + dprintf("[%s]:", param_name); + if (*(a_uint32_t *) buf == FAL_SPEED_10) + { + dprintf("10(Mbps)"); + } + else if (*(a_uint32_t *) buf == FAL_SPEED_100) + { + dprintf("100(Mbps)"); + } + else if (*(a_uint32_t *) buf == FAL_SPEED_1000) + { + dprintf("1000(Mbps)"); + } + else if (*(a_uint32_t *) buf == FAL_SPEED_2500) + { + dprintf("2500(Mbps)"); + } + else if (*(a_uint32_t *) buf == FAL_SPEED_5000) + { + dprintf("5000(Mbps)"); + } + else if (*(a_uint32_t *) buf == FAL_SPEED_10000) + { + dprintf("10000(Mbps)"); + } + else + { + dprintf("UNKNOWN VALUE"); + } +} + +sw_error_t +cmd_data_check_capable(char *cmd_str, a_uint32_t * arg_val, a_uint32_t size) +{ + if (cmd_str == NULL) + return SW_BAD_PARAM; + + cmd_strtol(cmd_str, arg_val); + if (*arg_val & (~FAL_PHY_COMBO_ADV_ALL)) + { + //dprintf("input error should be within 0x3f\n"); + return SW_BAD_VALUE; + } + + return SW_OK; +} + +void +cmd_data_print_capable(a_uint8_t * param_name, a_uint32_t * buf, + a_uint32_t size) +{ + dprintf("[%s]:", param_name); + + if (*(a_uint32_t *) buf == 0) + { + dprintf("None Capable"); + return; + } + + if (*(a_uint32_t *) buf & FAL_PHY_ADV_10000T_FD) + { + dprintf("10000TX_FD|"); + } + if (*(a_uint32_t *) buf & FAL_PHY_ADV_5000T_FD) + { + dprintf("5000TX_FD|"); + } + if (*(a_uint32_t *) buf & FAL_PHY_ADV_2500T_FD) + { + dprintf("2500TX_FD|"); + } + if (*(a_uint32_t *) buf & FAL_PHY_ADV_1000BX_FD) + { + dprintf("1000BX_FD|"); + } + if (*(a_uint32_t *) buf & FAL_PHY_ADV_1000BX_HD) + { + dprintf("1000BX_HD|"); + } + if (*(a_uint32_t *) buf & FAL_PHY_ADV_1000T_FD) + { + dprintf("1000T_FD|"); + } + if (*(a_uint32_t *) buf & FAL_PHY_ADV_100TX_FD) + { + dprintf("100TX_FD|"); + } + if (*(a_uint32_t *) buf & FAL_PHY_ADV_100TX_HD) + { + dprintf("100TX_HD|"); + } + if (*(a_uint32_t *) buf & FAL_PHY_ADV_10T_HD) + { + dprintf("10T_HD|"); + } + if (*(a_uint32_t *) buf & FAL_PHY_ADV_10T_FD) + { + dprintf("10T_FD|"); + } + if (*(a_uint32_t *) buf & FAL_PHY_ADV_PAUSE) + { + dprintf("PAUSE|"); + } + if (*(a_uint32_t *) buf & FAL_PHY_ADV_ASY_PAUSE) + { + dprintf("ASY_PAUSE|"); + } +} + +sw_error_t +cmd_data_check_crossover_mode(char *cmd_str, a_uint32_t * arg_val, a_uint32_t size) +{ + if (cmd_str == NULL) + return SW_BAD_PARAM; + + if (!strncasecmp(cmd_str, "auto", 5)) + *arg_val = PHY_MDIX_AUTO; + else if (!strncasecmp(cmd_str, "mdi", 4)) + *arg_val = PHY_MDIX_MDI; + else if (!strncasecmp(cmd_str, "mdix", 5)) + *arg_val = PHY_MDIX_MDIX; + else + { + //dprintf("input error \n"); + return SW_BAD_VALUE; + } + + return SW_OK; +} + +void +cmd_data_print_crossover_mode(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size) +{ + dprintf("[%s]:", param_name); + if (*(a_uint32_t *) buf == PHY_MDIX_AUTO) + { + dprintf("AUTO"); + } + else if (*(a_uint32_t *) buf == PHY_MDIX_MDI) + { + dprintf("MDI"); + } + else if (*(a_uint32_t *) buf == PHY_MDIX_MDIX) + { + dprintf("MDIX"); + } + else + { + dprintf("UNKNOWN VALUE"); + } +} + +sw_error_t +cmd_data_check_crossover_status(char *cmd_str, a_uint32_t * arg_val, a_uint32_t size) +{ + if (cmd_str == NULL) + return SW_BAD_PARAM; + if (!strncasecmp(cmd_str, "mdi", 4)) + *arg_val = PHY_MDIX_STATUS_MDI; + else if (!strncasecmp(cmd_str, "mdix", 5)) + *arg_val = PHY_MDIX_STATUS_MDIX; + else + { + //dprintf("input error \n"); + return SW_BAD_VALUE; + } + + return SW_OK; +} + +void +cmd_data_print_crossover_status(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size) +{ + dprintf("[%s]:", param_name); + if (*(a_uint32_t *) buf == PHY_MDIX_STATUS_MDI) + { + dprintf("MDI"); + } + else if (*(a_uint32_t *) buf == PHY_MDIX_STATUS_MDIX) + { + dprintf("MDIX"); + } + else + { + dprintf("UNKNOWN VALUE"); + } +} +sw_error_t +cmd_data_check_interface_mode(char *cmd_str, a_uint32_t * arg_val, a_uint32_t size) +{ + if (cmd_str == NULL) + return SW_BAD_PARAM; + + if (!strncasecmp(cmd_str, "psgmii_baset", 13)) + *arg_val = PHY_PSGMII_BASET; + else if (!strncasecmp(cmd_str, "psgmii_bx1000", 14)) + *arg_val = PHY_PSGMII_BX1000; + else if (!strncasecmp(cmd_str, "psgmii_fx100", 13)) + *arg_val = PHY_PSGMII_FX100; + else if (!strncasecmp(cmd_str, "psgmii_amdet", 13)) + *arg_val = PHY_PSGMII_AMDET; + else if (!strncasecmp(cmd_str, "rgmii_amdet", 13)) + *arg_val = PORT_RGMII_AMDET; + else if (!strncasecmp(cmd_str, "rgmii_baset", 13)) + *arg_val = PORT_RGMII_BASET; + else if (!strncasecmp(cmd_str, "rgmii_bx1000", 13)) + *arg_val = PORT_RGMII_BX1000; + else if (!strncasecmp(cmd_str, "rgmii_fx100", 13)) + *arg_val = PORT_RGMII_FX100; + else if (!strncasecmp(cmd_str, "sgmii_baset", 13)) + *arg_val = PHY_SGMII_BASET; + else if (!strncasecmp(cmd_str, "qsgmii", 13)) + *arg_val = PORT_QSGMII; + else if (!strncasecmp(cmd_str, "sgmii_plus", 13)) + *arg_val = PORT_SGMII_PLUS; + else if (!strncasecmp(cmd_str, "usxgmii", 13)) + *arg_val = PORT_USXGMII; + else if (!strncasecmp(cmd_str, "10gbase_r", 13)) + *arg_val = PORT_10GBASE_R; + else if (!strncasecmp(cmd_str, "sgmii_fiber", 20)) + *arg_val = PORT_SGMII_FIBER; + else if (!strncasecmp(cmd_str, "psgmii_fiber", 20)) + *arg_val = PHY_PSGMII_FIBER; + else if (!strncasecmp(cmd_str, "interfacemode_max", 20)) + *arg_val = PORT_INTERFACE_MODE_MAX; + else + { + //dprintf("input error \n"); + return SW_BAD_VALUE; + } + + return SW_OK; +} + +void +cmd_data_print_interface_mode(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size) +{ + dprintf("[%s]:", param_name); + if (*(a_uint32_t *) buf == PHY_PSGMII_BASET) + { + dprintf("PSGMII_BASET"); + } + else if (*(a_uint32_t *) buf == PHY_PSGMII_BX1000) + { + dprintf("PSGMII_BX1000"); + } + else if (*(a_uint32_t *) buf == PHY_PSGMII_FX100) + { + dprintf("PSGMII_FX100"); + } + else if (*(a_uint32_t *) buf == PHY_PSGMII_AMDET) + { + dprintf("PSGMII_AMDET"); + } + else if (*(a_uint32_t *) buf == PORT_RGMII_AMDET) + { + dprintf("RGMII_AMDET"); + } + else if (*(a_uint32_t *) buf == PORT_RGMII_BASET) + { + dprintf("RGMII_BASET"); + } + else if (*(a_uint32_t *) buf == PORT_RGMII_BX1000) + { + dprintf("RGMII_BX1000"); + } + else if (*(a_uint32_t *) buf == PORT_RGMII_FX100) + { + dprintf("RGMII_FX100"); + } + else if (*(a_uint32_t *) buf == PHY_SGMII_BASET) + { + dprintf("SGMII_BASET"); + } + else if (*(a_uint32_t *) buf == PORT_QSGMII) + { + dprintf("QSGMII"); + } + else if (*(a_uint32_t *) buf == PORT_SGMII_PLUS) + { + dprintf("SGMII PLUS"); + } + else if (*(a_uint32_t *) buf == PORT_USXGMII) + { + dprintf("USXGMII"); + } + else if (*(a_uint32_t *) buf == PORT_10GBASE_R) + { + dprintf("10gbase_r"); + } + else if (*(a_uint32_t *) buf == PORT_SGMII_FIBER) + { + dprintf("sgmii_fiber"); + } + else if (*(a_uint32_t *) buf == PHY_PSGMII_FIBER) + { + dprintf("psgmii_fiber"); + } + else if (*(a_uint32_t *) buf == PORT_INTERFACE_MODE_MAX) + { + dprintf("INTERFACEMODE_MAX"); + } + else + { + dprintf("UNKNOWN VALUE"); + } +} +sw_error_t +cmd_data_check_confirm(char *cmdstr, a_bool_t def, a_bool_t * val, + a_uint32_t size) +{ + if (0 == cmdstr[0]) + { + *val = def; + } + else if ((!strcasecmp(cmdstr, "yes")) || (!strcasecmp(cmdstr, "y"))) + { + *val = A_TRUE; + } + else if ((!strcasecmp(cmdstr, "no")) || (!strcasecmp(cmdstr, "n"))) + { + *val = A_FALSE; + } + else + { + return SW_BAD_VALUE; + } + + return SW_OK; +} + +void +cmd_data_print_confirm(char * param_name, a_bool_t val, a_uint32_t size) +{ + dprintf("%s", param_name); + if (A_TRUE == val) + { + dprintf("YES"); + } + else + { + dprintf("NO"); + } + + return; +} + +sw_error_t +cmd_data_check_portid(char *cmdstr, fal_port_t * val, a_uint32_t size) +{ + *val = 0; + //default input null + if(!strcasecmp(cmdstr, "null")) + { + if (ssdk_cfg.init_cfg.chip_type == CHIP_HPPE) + return SW_BAD_VALUE; + return SW_OK; + } + if (strstr(cmdstr, "0x") == NULL) + sscanf(cmdstr, "%d", val); + else + sscanf(cmdstr, "%x", val); + + return SW_OK; +} + +sw_error_t +cmd_data_check_portmap(char *cmdstr, fal_pbmp_t * val, a_uint32_t size) +{ + char *tmp = NULL, *str_save; + a_uint32_t port; + + *val = 0; + //default input null + if(!strcasecmp(cmdstr, "null")) + { + return SW_OK; + } + + tmp = (void *) strtok_r(cmdstr, ",", &str_save); + while (tmp) + { + sscanf(tmp, "%d", &port); + if (SW_MAX_NR_PORT <= port) + { + return SW_BAD_VALUE; + } + + *val |= (0x1 << port); + tmp = (void *) strtok_r(NULL, ",", &str_save); + } + + return SW_OK; +} + +void +cmd_data_print_portmap(char * param_name, fal_pbmp_t val, a_uint32_t size) +{ + a_uint32_t i; + char tmp[16]; + tmp[0] = '\0'; + + dprintf("%s", param_name); + for (i = 0; i < SW_MAX_NR_PORT; i++) + { + if (val & (0x1 << i)) + { + if(strlen(tmp) == 0) + snprintf(tmp, sizeof(tmp), "%d", i); + else + snprintf(tmp+strlen(tmp), sizeof(tmp+strlen(tmp)), ",%d", i); + } + } + dprintf("%s ", tmp); + return; +} + +sw_error_t +cmd_data_check_macaddr(char *cmdstr, void *val, a_uint32_t size) +{ + char *tmp = NULL, *str_save; + a_uint32_t i = 0, j; + a_uint32_t addr; + fal_mac_addr_t mac; + + memset(&mac, 0, sizeof (fal_mac_addr_t)); + if (NULL == cmdstr) + { + *(fal_mac_addr_t *) val = mac; + return SW_BAD_VALUE; /*was: SW_OK;*/ + } + + if (0 == cmdstr[0]) + { + *(fal_mac_addr_t *) val = mac; + return SW_OK; + } + + tmp = (void *) strtok_r(cmdstr, "-", &str_save); + while (tmp) + { + if (6 <= i) + { + return SW_BAD_VALUE; + } + + if ((2 < strlen(tmp)) || (0 == strlen(tmp))) + { + return SW_BAD_VALUE; + } + + for (j = 0; j < strlen(tmp); j++) + { + if (A_FALSE == is_hex(tmp[j])) + return SW_BAD_VALUE; + } + + sscanf(tmp, "%x", &addr); + if (0xff < addr) + { + return SW_BAD_VALUE; + } + + mac.uc[i++] = addr; + tmp = (void *) strtok_r(NULL, "-", &str_save); + } + + if (6 != i) + { + return SW_BAD_VALUE; + } + + *(fal_mac_addr_t *) val = mac; + return SW_OK; +} + +void +cmd_data_print_macaddr(a_char_t * param_name, a_uint32_t * buf, + a_uint32_t size) +{ + a_uint32_t i; + fal_mac_addr_t *val; + + val = (fal_mac_addr_t *) buf; + dprintf("%s", param_name); + for (i = 0; i < 5; i++) + { + dprintf("%02x-", val->uc[i]); + } + dprintf("%02x", val->uc[5]); + fflush(stdout); + +} + +#define cmd_data_check_element(info, defval, usage, chk_func, param) \ +{\ + sw_error_t ret;\ + do {\ + cmd = get_sub_cmd(info, defval);\ + SW_RTN_ON_NULL_PARAM(cmd);\ + \ + if (!strncasecmp(cmd, "quit", 4)) {\ + return SW_BAD_VALUE;\ + } else if (!strncasecmp(cmd, "help", 4)) {\ + dprintf("%s", usage);\ + ret = SW_BAD_VALUE;\ + } else {\ + ret = chk_func param; \ + if (SW_OK != ret)\ + dprintf("%s", usage);\ + else\ + append_acl_cmd(cmd);\ + }\ + } while (talk_mode && (SW_OK != ret));\ +} + +sw_error_t +cmd_data_check_integer(char *cmd_str, a_uint32_t * arg_val, a_uint32_t max_val, + a_uint32_t min_val) +{ + a_uint32_t tmp; + a_uint32_t i; + + if (NULL == cmd_str) + { + return SW_BAD_PARAM; + } + + if (0 == cmd_str[0]) + { + return SW_BAD_PARAM; + } + + if ((cmd_str[0] == '0') && ((cmd_str[1] == 'x') || (cmd_str[1] == 'X'))) + { + for (i = 2; i < strlen(cmd_str); i++) + { + if (A_FALSE == is_hex(cmd_str[i])) + { + return SW_BAD_VALUE; + } + } + sscanf(cmd_str, "%x", &tmp); + } + else + { + for (i = 0; i < strlen(cmd_str); i++) + { + if (A_FALSE == is_dec(cmd_str[i])) + { + return SW_BAD_VALUE; + } + } + sscanf(cmd_str, "%d", &tmp); + } + + if ((tmp > max_val) || (tmp < min_val)) + return SW_BAD_PARAM; + + *arg_val = tmp; + return SW_OK; +} +void +cmd_data_print_cable_status(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size) +{ + dprintf("[%s]:", param_name); + + if (*(a_uint32_t *) buf == FAL_CABLE_STATUS_NORMAL) + { + dprintf("NORMAL"); + } + else if (*(a_uint32_t *) buf == FAL_CABLE_STATUS_SHORT) + { + dprintf("SHORT"); + } + else if (*(a_uint32_t *) buf == FAL_CABLE_STATUS_OPENED) + { + dprintf("OPENED"); + } + else if (*(a_uint32_t *) buf == FAL_CABLE_STATUS_INVALID) + { + dprintf("INVALID"); + } + else if (*(a_uint32_t *) buf == FAL_CABLE_STATUS_CROSSOVERA) + { + dprintf("CROSSOVERA"); + } + else if (*(a_uint32_t *) buf == FAL_CABLE_STATUS_CROSSOVERB) + { + dprintf("CROSSOVERB"); + } + else if (*(a_uint32_t *) buf == FAL_CABLE_STATUS_CROSSOVERC) + { + dprintf("CROSSOVERC"); + } + else if (*(a_uint32_t *) buf == FAL_CABLE_STATUS_CROSSOVERD) + { + dprintf("CROSSOVERD"); + } + else if (*(a_uint32_t *) buf == FAL_CABLE_STATUS_LOW_MISMATCH) + { + dprintf("LOW_MISMATCH"); + } + else if (*(a_uint32_t *) buf == FAL_CABLE_STATUS_HIGH_MISMATCH) + { + dprintf("HIGH_MISMATCH"); + } + else + { + dprintf("UNKNOWN VALUE"); + } +} + +void +cmd_data_print_cable_len(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size) +{ + dprintf("[%s]:%d", param_name, *(a_uint32_t *) buf); +} + +char* +cmd_cpu_mode(hsl_init_mode mode) +{ + switch (mode) + { + case HSL_NO_CPU: + return "no_cpu"; + case HSL_CPU_1: + return "cpu_1"; + case HSL_CPU_2: + return "cpu_2"; + case HSL_CPU_1_PLUS: + return "cpu_1_plus"; + } + + return "unknow"; +} + +char* +cmd_access_mode(hsl_access_mode mode) +{ + switch (mode) + { + case HSL_MDIO: + return "mdio"; + case HSL_HEADER: + return "header"; + } + + return "unknow"; +} + +static void +_cmd_collect_shell_cfg(ssdk_cfg_t *shell_cfg) +{ + memset(shell_cfg, 0, sizeof(ssdk_cfg_t)); + shell_cfg->init_cfg = init_cfg; + +#ifdef VERSION + aos_mem_copy(shell_cfg->build_ver, VERSION, sizeof(VERSION)); +#endif + +#ifdef BUILD_DATE + aos_mem_copy(shell_cfg->build_date, BUILD_DATE, sizeof(BUILD_DATE)); +#endif + + if (ssdk_cfg.init_cfg.chip_type == CHIP_ATHENA) + aos_mem_copy(shell_cfg->chip_type, "athena", sizeof("athena")); + else if (ssdk_cfg.init_cfg.chip_type == CHIP_GARUDA) + aos_mem_copy(shell_cfg->chip_type, "garuda", sizeof("garuda")); + else if (ssdk_cfg.init_cfg.chip_type == CHIP_SHIVA) + aos_mem_copy(shell_cfg->chip_type, "shiva", sizeof("shiva")); + else if (ssdk_cfg.init_cfg.chip_type == CHIP_HORUS) + aos_mem_copy(shell_cfg->chip_type, "horus", sizeof("horus")); + else if (ssdk_cfg.init_cfg.chip_type == CHIP_ISIS) + aos_mem_copy(shell_cfg->chip_type, "isis", sizeof("isis")); + else if (ssdk_cfg.init_cfg.chip_type == CHIP_ISISC) + aos_mem_copy(shell_cfg->chip_type, "isisc", sizeof("isisc")); + +#ifdef CPU + aos_mem_copy(shell_cfg->cpu_type, CPU, sizeof(CPU)); +#endif + +#ifdef OS + aos_mem_copy(shell_cfg->os_info, OS, sizeof(OS)); +#if defined KVER26 + aos_mem_copy(shell_cfg->os_info+sizeof(OS)-1, " version 2.6", sizeof(" version 2.6")); +#elif defined KVER24 + aos_mem_copy(shell_cfg->os_info+sizeof(OS)-1, " version 2.4", sizeof(" version 2.4")); +#else + aos_mem_copy(shell_cfg->os_info+sizeof(OS)-1, " version unknown", sizeof(" version unknown")); +#endif +#endif + +#ifdef HSL_STANDALONG + shell_cfg->fal_mod = A_FALSE; +#else + shell_cfg->fal_mod = A_TRUE; +#endif + +#ifdef USER_MODE + shell_cfg->kernel_mode = A_FALSE; +#else + shell_cfg->kernel_mode = A_TRUE; +#endif + +#ifdef UK_IF + shell_cfg->uk_if = A_TRUE; +#else + shell_cfg->uk_if = A_FALSE; +#endif + + return; +} + +#define BOOL2STR(val_bool) (((val_bool)==A_TRUE)?"true":"false" ) +static void +_cmd_data_print_cfg(ssdk_cfg_t *entry) +{ + ssdk_init_cfg *init = &(entry->init_cfg); + + dprintf("[build verison]:%-10s [build date]:%s\n", entry->build_ver, entry->build_date); + dprintf("[chip type]:%-14s [arch]:%-12s [os]:%s\n", entry->chip_type, entry->cpu_type, entry->os_info); + dprintf("[fal]:%-20s [kernel mode]:%-5s [uk if]:%s\n", + BOOL2STR(entry->fal_mod), BOOL2STR(entry->kernel_mode), BOOL2STR(entry->uk_if)); + + dprintf("[cpu mode]:%-15s [reg access]:%-6s [ioctl minor]:%d\n", + cmd_cpu_mode(init->cpu_mode), cmd_access_mode(init->reg_mode), + init->nl_prot); +} + +void +cmd_data_print_ssdk_cfg(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size) +{ + ssdk_cfg_t *ssdk_cfg = (ssdk_cfg_t *) buf; + dprintf("1.SSDK CONFIGURATION:\n"); + _cmd_data_print_cfg(ssdk_cfg); + + dprintf("\n2.DEMO SHELL CONFIGURATION:\n"); + ssdk_cfg_t shell_cfg; + _cmd_collect_shell_cfg(&shell_cfg); + _cmd_data_print_cfg(&shell_cfg); + + dprintf("\n3.SSDK FEATURES LIST:\n"); + +} diff --git a/qca/src/qca-psdk/cli/src/shell/shell_lib.c b/qca/src/qca-psdk/cli/src/shell/shell_lib.c new file mode 100755 index 00000000000..db4e362f690 --- /dev/null +++ b/qca/src/qca-psdk/cli/src/shell/shell_lib.c @@ -0,0 +1,917 @@ +/* + * Copyright (c) 2014, 2017, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include "shell_config.h" +#include "shell.h" + +#define printc(isPrint, fmt, args...) if(isPrint == 1) printf(fmt, ##args) +#ifndef PROMPT_STR +#define PROMPT_STR "dev0@qca>" +#endif +static char *cmd_promptp = PROMPT_STR; /*command prompt pointer */ +static struct termios term_save; /* terminal setting saved */ +static int term_cursor; /*terminal position */ +static int cmd_cursor; /*command position */ +static char *cmd_strp; /*command string pointer */ +static int cmd_strlen; /*command string length */ + +#define HISTORY_MAX_SIZE 20 +static char *history_buf[HISTORY_MAX_SIZE + 1]; /* history buffer */ +static int history_nr; /* saved history lines */ +static int history_cur; /* current pointer to history line */ + +static void term_config(void); +static void term_restore(void); +static void term_sig_handler(int sig); +static void term_init(char *out_cmd); +static void term_echo(void); +static void cursor_backward(void); +static void cursor_forward(void); +static void handle_backward(void); +static void handle_delete(void); +static void handle_tab(void); +static void handle_up(void); +static void handle_down(void); +static void handle_left(void); +static void handle_right(void); +static void handle_normal(char *out_cmd, char c); +static void handle_help(void); +static void prompt_print(void); +static void out_cmd_print(void); +static int history_prev(void); +static int history_next(void); +static void history_record(char *out_cmd); + + +struct key_bind_t +{ + int is_eseq; /*is escape sequence */ + int key_last; /*relative key or escape sequence last character */ + void (*func) (); +}; + +struct key_bind_t key_bind[] = +{ + {0, '\b', handle_backward}, + {0, 127, handle_delete}, + {0, '\t', handle_tab}, + {0, '?', handle_help}, + {1, 'A', handle_up}, + {1, 'B', handle_down}, + {1, 'C', handle_right}, + {1, 'D', handle_left}, +}; + +/* saving orignal setting and set new attrib to terminal*/ +static void +term_config(void) +{ + struct termios term_tmp; + tcgetattr(0, (void *) &term_save); + memcpy(&term_tmp, &term_save, sizeof (struct termios)); + + /*unbuffered input and turn off echo */ + term_tmp.c_lflag &= ~(ICANON | ECHO | ECHONL); + + tcsetattr(0, TCSANOW, (void *) &term_tmp); +} + +/*restore termial setting*/ +static void +term_restore(void) +{ + tcsetattr(0, TCSANOW, (void *) &term_save); +} + +/*termial signal handler*/ +static void +term_sig_handler(int sig) +{ + switch (sig) + { + case SIGINT: + if (cmd_promptp) + printf("\n%s", cmd_promptp); + + while (cmd_strlen-- > 0) + cmd_strp[cmd_strlen] = '\0'; + + cmd_strp[0] = '\0'; + cmd_strlen = 0; + if (cmd_promptp) + term_cursor = strlen(cmd_promptp); + cmd_cursor = 0; + + fflush(stdout); + + break; + + case SIGUSR1: + case SIGKILL: + case SIGABRT: + case SIGTERM: + case SIGHUP: + printf("exit.\n"); + term_restore(); + exit(0); + default: + break; + } +} + +/*termial initial*/ +static void +term_init(char *out_cmd) +{ + term_cursor = 0; + cmd_cursor = 0; + + cmd_strp = out_cmd; + cmd_strlen = strlen(out_cmd); + + // Initialize signal + signal(SIGINT, term_sig_handler); + signal(SIGUSR1, term_sig_handler); + signal(SIGKILL, term_sig_handler); + signal(SIGABRT, term_sig_handler); + signal(SIGTERM, term_sig_handler); + signal(SIGHUP, term_sig_handler); + //signal(SIGQUIT, SIG_IGN); + + prompt_print(); +} + +/* printf current char*/ +static void +term_echo(void) +{ + + if (cmd_strp[cmd_cursor]) + { + putchar(cmd_strp[cmd_cursor]); + } + else + { + putchar(' '); + } + + fflush(stdout); + term_cursor++; + cmd_cursor++; +} + +/* cursor move back one character */ +static void +cursor_backward(void) +{ + if (cmd_cursor > 0 && term_cursor > 0) + { + cmd_cursor--; + term_cursor--; + putchar('\b'); + fflush(stdout); + } +} + +/* cursor move forward one character */ +static void +cursor_forward(void) +{ + if (cmd_cursor < cmd_strlen) + term_echo(); +} + +/* move backward one characters. */ +static void +handle_backward(void) +{ + if (cmd_cursor > 0) + { + cursor_backward(); + handle_delete(); + } +} + +/*delete one character in front of cursor */ +static void +handle_delete(void) +{ + int cur_tmp = cmd_cursor; + + /*when cursour at the end of string */ + if (cmd_cursor >= cmd_strlen) + return; + + /*delete one character from string */ + strlcpy(cmd_strp + cur_tmp, cmd_strp + cur_tmp + 1, CMDSTR_BUF_SIZE - cur_tmp); + cmd_strlen--; + + /*clear characters after cursor */ + printf("\033[J"); + + /*re-print from delete position */ + while (cmd_cursor <= cmd_strlen) + term_echo(); + + /*move cursor back to delete position */ + cur_tmp = cmd_cursor - cur_tmp; + while (cur_tmp--) + cursor_backward(); +} + +/* deal with up arrow*/ +static void +handle_up(void) +{ + /*get previous history */ + if (history_prev() < 0) + return; + + /*copy current history cmd to out_cmd */ + strlcpy(cmd_strp, history_buf[history_cur], CMDSTR_BUF_SIZE); + + /*print out_cmd */ + out_cmd_print(); +} + +/* deal with down arrow*/ +static void +handle_down(void) +{ + /*get previous history */ + if (history_next() < 0) + return; + + /*copy current history cmd to out_cmd */ + strlcpy(cmd_strp, history_buf[history_cur], CMDSTR_BUF_SIZE); + + /*print out_cmd */ + out_cmd_print(); +} + +/* deal with left arrow*/ +static void +handle_left(void) +{ + cursor_backward(); +} + +/* deal with right arrow*/ +static void +handle_right(void) +{ + cursor_forward(); +} + +static void +print_cmd_all (void) +{ + int cmd_no = 0; + for (cmd_no = 0; GCMD_DESC_VALID(cmd_no); cmd_no++) + { + if (!GCMD_NAME(cmd_no)) + continue; + + printf("%-10s%s\n", GCMD_NAME(cmd_no), GCMD_MEMO(cmd_no)); + } +} + + +static void +print_sub_all (int cmd_id) +{ + int cmd_sub_no = 0, cmd_sub_nr = 0; + for (cmd_sub_no = 0; GCMD_SUB_DESC_VALID(cmd_id, cmd_sub_no); cmd_sub_no++) + { + + if (!GCMD_SUB_NAME(cmd_id, cmd_sub_no)) + continue; + if(cmd_sub_no == 0 || strcasecmp(GCMD_SUB_NAME(cmd_id, cmd_sub_no), + GCMD_SUB_NAME(cmd_id, cmd_sub_no-1))) + { + printf("%-10s\t", GCMD_SUB_NAME(cmd_id, cmd_sub_no)); + if(cmd_sub_nr && !((cmd_sub_nr+1) %5)) + { + printf("\n"); + } + cmd_sub_nr++; + } + } + printf("\n"); +} + +/* +1. partly_cmd_nr = 0 && index = no match: none +2. partly_cmd_nr = 0 && index = matched: full matched +3. partly_cmd_nr = 1 && index = matched: partly matched & to be completed +4. partly_cmd_nr > 1 && index = matched: partly matched & to be list them +*/ +#define NONE_MATCHED(pmatch_nr, pmatch_id) ( (pmatch_nr == 0) && (pmatch_id == GCMD_DESC_NO_MATCH) ) +#define FULL_MATCHED(pmatch_nr, pmatch_id) ( (pmatch_nr == 0) && (pmatch_id != GCMD_DESC_NO_MATCH) ) +#define ONE_PART_MATCHED(pmatch_nr, pmatch_id) ( (pmatch_nr == 1) && (pmatch_id != GCMD_DESC_NO_MATCH) ) +#define MULTI_PART_MATCHED(pmatch_nr, pmatch_id) ( (pmatch_nr > 1 ) && (pmatch_id != GCMD_DESC_NO_MATCH) ) + + +static int +search_cmd_type(char *name, int *pmatch_id, int is_print) +{ + int cmd_no = 0, pmatch_nr = 0; + + *pmatch_id = GCMD_DESC_NO_MATCH; + + /*search type in glb_num_types print matched */ + for (cmd_no = 0; GCMD_DESC_VALID(cmd_no); cmd_no++) + { + + if (!GCMD_NAME(cmd_no)) + continue; + + if (!strcasecmp(name, GCMD_NAME(cmd_no))) + { + /*full matched */ + *pmatch_id = cmd_no; + break; + } + else if (!strncasecmp(name, GCMD_NAME(cmd_no), strlen(name))) + { + /*partly matched */ + printc(is_print, "%-10s%s\n", GCMD_NAME(cmd_no), GCMD_MEMO(cmd_no)); + pmatch_nr++; + *pmatch_id = cmd_no; + } + } + + return pmatch_nr; +} + +static int +search_cmd_sub(int cmd_id, int *pmatch_sub_id, char *sub_name, int is_print) +{ + + int cmd_sub_no, pmatch_sub_nr = 0, fmatch_sub_save = GCMD_DESC_NO_MATCH; + + *pmatch_sub_id = GCMD_DESC_NO_MATCH; + + /*search for full matched */ + for (cmd_sub_no = 0; GCMD_SUB_DESC_VALID(cmd_id, cmd_sub_no); cmd_sub_no++) + { + if (!GCMD_SUB_NAME(cmd_id, cmd_sub_no)) + continue; + + if (!strcasecmp(sub_name, GCMD_SUB_NAME(cmd_id, cmd_sub_no))) + { + /*full matched */ + printc(is_print, "%-10s\t%s\n", GCMD_SUB_ACT(cmd_id, cmd_sub_no), GCMD_SUB_MEMO(cmd_id, cmd_sub_no)); + //*pmatch_sub_id = cmd_sub_no; + if(fmatch_sub_save == GCMD_DESC_NO_MATCH) + { + *pmatch_sub_id = fmatch_sub_save = cmd_sub_no; + } + + } + else if (!strncasecmp(sub_name, GCMD_SUB_NAME(cmd_id, cmd_sub_no), strlen(sub_name))) + { + if(fmatch_sub_save != GCMD_DESC_NO_MATCH) + continue; + + /*partly matched */ + if (*pmatch_sub_id == GCMD_DESC_NO_MATCH || (GCMD_SUB_NAME(cmd_id, cmd_sub_no-1) && + strcasecmp(GCMD_SUB_NAME(cmd_id, cmd_sub_no), GCMD_SUB_NAME(cmd_id, cmd_sub_no-1)))) + { + printc(is_print, "%-10s\t", GCMD_SUB_NAME(cmd_id, cmd_sub_no)); + pmatch_sub_nr++; + *pmatch_sub_id = cmd_sub_no; + } + } + } + + if (pmatch_sub_nr > 1) + printc(is_print, "\n"); + + return pmatch_sub_nr; +} + +static int +search_cmd_action(int cmd_id, int *pmatch_act_id, char *sub_name, char *action, int is_print) +{ + int cmd_act_no = 0, pmatch_act_nr = 0; + + *pmatch_act_id = GCMD_DESC_NO_MATCH; + + /*search for full matched */ + for (cmd_act_no = 0; GCMD_SUB_DESC_VALID(cmd_id, cmd_act_no); cmd_act_no++) + { + + if (strcasecmp(sub_name, GCMD_SUB_NAME(cmd_id, cmd_act_no))) + continue; + + if (!GCMD_SUB_ACT(cmd_id, cmd_act_no)) + continue; + + if (!strcasecmp(action, GCMD_SUB_ACT(cmd_id, cmd_act_no))) + { + /*full matched */ + if (*pmatch_act_id == GCMD_DESC_NO_MATCH) + { + printc(is_print, "%-10s\n", GCMD_SUB_USAGE(cmd_id, cmd_act_no)); + } + + *pmatch_act_id = cmd_act_no; + break; + } + else if (!strncasecmp(action, GCMD_SUB_ACT(cmd_id, cmd_act_no), strlen(action))) + { + /*partly matched */ + if (*pmatch_act_id == GCMD_DESC_NO_MATCH ||( GCMD_SUB_ACT(cmd_id, cmd_act_no-1) && + strcasecmp(GCMD_SUB_ACT(cmd_id, cmd_act_no), GCMD_SUB_ACT(cmd_id, cmd_act_no-1)))) + { + printc(is_print, "%-10s\t%s\n", GCMD_SUB_ACT(cmd_id, cmd_act_no), GCMD_SUB_MEMO(cmd_id, cmd_act_no)); + pmatch_act_nr++; + *pmatch_act_id = cmd_act_no; + } + } + } + + return pmatch_act_nr; +} + +/*print help info*/ +static void +handle_help(void) +{ + int pmatch_id = GCMD_DESC_NO_MATCH, pmatch_sub_id = GCMD_DESC_NO_MATCH, pmatch_act_id = GCMD_DESC_NO_MATCH; + int cmd_nr = 0, pmatch_nr = 0, pmatch_sub_nr = 0; + char *tmp_str[3], *cmd_strp_cp = strdup(cmd_strp), *str_save; + + if (!cmd_strp_cp) + return; + + cmd_strp_cp[strlen(cmd_strp) - 1] = '\0'; + + /* split command string into temp array */ + tmp_str[cmd_nr] = (void *) strtok_r(cmd_strp_cp, " ", &str_save); + + while (tmp_str[cmd_nr]) + { + if (++cmd_nr == 3) + break; + tmp_str[cmd_nr] = (void *) strtok_r(NULL, " ", &str_save); + } + + /*echo input ? */ + printf("?\n"); + + int is_print = 0; + + /* print matched command */ + switch (cmd_nr) + { + case 3: + pmatch_nr = search_cmd_type(tmp_str[0], &pmatch_id, is_print); + if(FULL_MATCHED(pmatch_nr, pmatch_id)) + pmatch_sub_nr = search_cmd_sub(pmatch_id, &pmatch_sub_id, tmp_str[1], is_print); + + if(FULL_MATCHED(pmatch_sub_nr, pmatch_sub_id)) + { + is_print = 1; + search_cmd_action(pmatch_id, &pmatch_act_id, tmp_str[1], tmp_str[2], is_print); + } + break; + + case 2: + pmatch_nr = search_cmd_type(tmp_str[0], &pmatch_id, is_print); + if(FULL_MATCHED(pmatch_nr, pmatch_id)) + { + is_print = 1; + search_cmd_sub(pmatch_id, &pmatch_sub_id, tmp_str[1], is_print); + } + break; + + case 1: + is_print = 1; + pmatch_nr = search_cmd_type(tmp_str[0], &pmatch_id, is_print); + + if(NONE_MATCHED(pmatch_nr, pmatch_id)) + { + print_cmd_all(); + } + else if(FULL_MATCHED(pmatch_nr, pmatch_id)) + { + print_sub_all(pmatch_id); + } + break; + + case 0: + print_cmd_all(); + break; + + default: + break; + } + + printf("\n"); + + /* re-print prompt */ + prompt_print(); + + /* re-print from cursor */ + while (cmd_cursor < cmd_strlen) + term_echo(); + + if(cmd_strp_cp) + free(cmd_strp_cp); +} + +static void +_cmd_complete(char *matchBuf, char *fullName) +{ + //printf ("***%s-%s****", matchBuf, fullName); + int offset = cmd_strlen - cmd_cursor; + int diff = strlen(fullName) - strlen(matchBuf);; + + /*print prompt */ + if (cmd_promptp) + printf("\n%s", cmd_promptp); + + /*give position to new char */ + memmove(cmd_strp + cmd_cursor + diff, cmd_strp + cmd_cursor, offset); + /*insert new char */ + if (cmd_promptp) + memcpy(cmd_strp + cmd_cursor, fullName + strlen(matchBuf), diff); + else + memcpy(cmd_strp + cmd_cursor, fullName, diff); + /*caculate new cursor */ + cmd_cursor += diff; + + /*set new cursor and len */ + cmd_strlen = strlen(cmd_strp); + if (cmd_promptp) + term_cursor = cmd_strlen + strlen(cmd_promptp); + else + term_cursor = cmd_strlen; + + /*re-print command */ + printf("%s", cmd_strp); + + /*set terminal cursor */ + if (cmd_strlen - cmd_cursor) + printf("\033[%dD", cmd_strlen - cmd_cursor); /*move cursor left */ +} + +void _cursor_recover(void) +{ + if(strlen(cmd_strp) != cmd_cursor) + { + int clear = strlen(cmd_strp) - cmd_cursor; + while(clear--) + { + printf("\b"); + } + } +} + +/* deal with tab completion*/ +#define MATCH_BUF_MAX 100 +static void +handle_tab(void) +{ + + int cmd_nr = 0; + char matchBuf[MATCH_BUF_MAX]; + char *tmp_str[3], *str_save; + + memset(matchBuf, 0, MATCH_BUF_MAX); + + if(cmd_cursor < MATCH_BUF_MAX) + strlcpy(matchBuf, cmd_strp, cmd_cursor+1); + else + strlcpy(matchBuf, cmd_strp, MATCH_BUF_MAX); + + printf("\n"); + + /* split command string into temp array */ + tmp_str[cmd_nr] = (void *) strtok_r(matchBuf, " ", &str_save); + + if(!tmp_str[cmd_nr]) + { + print_cmd_all(); + if (cmd_promptp) + printf("\n%s%s", cmd_promptp, cmd_strp); + fflush(stdout); + _cursor_recover(); + return; + } + + while (tmp_str[cmd_nr]) + { + if (++cmd_nr == 3) + break; + tmp_str[cmd_nr] = (void *) strtok_r(NULL, " ", &str_save); + } + + int is_print = 1, is_completed = 0; + int pmatch_nr = 0, pmatch_id = GCMD_DESC_NO_MATCH; + + pmatch_nr = search_cmd_type(tmp_str[0], &pmatch_id, is_print); + + if (cmd_nr == 1) + { + if (ONE_PART_MATCHED(pmatch_nr, pmatch_id)) + { + _cmd_complete(tmp_str[0], GCMD_NAME(pmatch_id)); + is_completed = 1; + } + + if(NONE_MATCHED(pmatch_nr, pmatch_id)) + { + print_cmd_all(); + + } + else if(FULL_MATCHED(pmatch_nr, pmatch_id)) + { + print_sub_all(pmatch_id); + } + + } + else + { + if (FULL_MATCHED(pmatch_nr, pmatch_id)) + { + + int pmatch_sub_nr = 0, pmatch_sub_id = GCMD_DESC_NO_MATCH; + + if(cmd_nr == 3) is_print = 0; + pmatch_sub_nr = search_cmd_sub(pmatch_id, &pmatch_sub_id, tmp_str[1], is_print); + + if(cmd_nr == 2) + { + if (ONE_PART_MATCHED(pmatch_sub_nr, pmatch_sub_id)) + { + _cmd_complete(tmp_str[1], GCMD_SUB_NAME(pmatch_id, pmatch_sub_id)); + is_completed = 1; + } + + } + else + { + int pmatch_act_nr = 0, pmatch_act_id = GCMD_DESC_NO_MATCH; + pmatch_act_nr = search_cmd_action(pmatch_id, &pmatch_act_id, tmp_str[1], tmp_str[2], is_print); + + if (ONE_PART_MATCHED(pmatch_act_nr, pmatch_act_id)) + { + _cmd_complete(tmp_str[2], GCMD_SUB_ACT(pmatch_id, pmatch_act_id)); + is_completed = 1; + + } + else if (FULL_MATCHED(pmatch_act_nr, pmatch_act_id)) + { + is_print = 1; + printc(is_print, "%-10s\n", GCMD_SUB_USAGE(pmatch_id, pmatch_act_id)); + } + } + } + } + + if (is_completed == 0) + { + /*re-echo */ + if (cmd_promptp) + printf("\n%s%s", cmd_promptp, cmd_strp); + fflush(stdout); + _cursor_recover(); + } + //_cursor_recover(); +} + +/*deal with normal character*/ +static void +handle_normal(char *out_cmd, char c) +{ + int tmp_cursor = cmd_cursor; + + /*buffer full */ + if (++cmd_strlen > (MATCH_BUF_MAX - 2)) + return; + + /*append operation */ + if (cmd_cursor == (cmd_strlen - 1)) + { + *(out_cmd + cmd_cursor) = c; + *(out_cmd + cmd_cursor + 1) = 0; + term_echo(); + } + else + { + /* Insert operation */ + /*give position to new char */ + memmove(out_cmd + tmp_cursor + 1, out_cmd + tmp_cursor, + cmd_strlen - tmp_cursor); + *(out_cmd + tmp_cursor) = c; + + /* re-print from cursor */ + while (cmd_cursor < cmd_strlen) + term_echo(); + + /* restore curor to insert position */ + tmp_cursor = cmd_cursor - tmp_cursor - 1; + while (tmp_cursor--) + cursor_backward(); + } +} + +/*print prompt info*/ +static void +prompt_print(void) +{ + if (cmd_promptp) + { + printf("%s", cmd_promptp); + } + + if (cmd_promptp) + { + term_cursor = strlen(cmd_promptp); + } + cmd_cursor = 0; + fflush(stdout); +} + +/*print current output command*/ +static void +out_cmd_print(void) +{ + cmd_strlen = strlen(history_buf[history_cur]); + + putchar('\r'); + prompt_print(); + + while (cmd_cursor < cmd_strlen) + term_echo(); + + /*clear characters after cursor */ + printf("\033[J"); + +} + +/* get previous history command*/ +static int +history_prev(void) +{ + if (history_cur > 0) + { + /*record current*/ + if (cmd_strp[0] != 0 || history_buf[history_cur] == 0) + { + if(history_buf[history_cur]) + free(history_buf[history_cur]); + history_buf[history_cur] = strdup(cmd_strp); + } + history_cur--; + return 0; + } + + return -1; +} + +/* get next history command*/ +static int +history_next(void) +{ + if ((history_cur >= 0) && (history_cur < history_nr)) + { + history_cur++; + return 0; + } + + return -1; +} + +/*record history command*/ +static void +history_record(char *out_cmd) +{ + int i; + + /* cleanup may be saved current command line */ + if (cmd_strlen > 0) /* no put empty line */ + { + i = history_nr; + + free(history_buf[HISTORY_MAX_SIZE]); + history_buf[HISTORY_MAX_SIZE] = 0; + /* After max history, remove the oldest command */ + if (i >= HISTORY_MAX_SIZE) + { + free(history_buf[0]); + for (i = 0; i < (HISTORY_MAX_SIZE - 1); i++) + history_buf[i] = history_buf[i + 1]; + } + history_buf[i++] = strdup(out_cmd); + history_cur = i; + history_nr = i; + } +} + +int +_isspace(int ch) +{ + return (unsigned int) (ch - 9) < 5u || ch == ' '; +} + +/*call by main*/ +int +next_cmd(char *out_cmd) +{ + unsigned char c = 0; + int key_no = 0; + int seq_char = 0; + int str_valid = 0; + + /*set terminal new attrib */ + term_config(); + + /*termial initial */ + term_init(out_cmd); + + /*main loop */ + while ((c = getc(stdin)) != '\n') + { + key_no = 0; + seq_char = 0; + + if (!_isspace(c)) + { + str_valid = 1; + } + + if (c == 27) /*escape sequence */ + { + if ((c = getc(stdin)) == '[' || c == 'O') + { + c = getc(stdin); + seq_char = 1; + } + } + + /*search for bind key handle function */ + while (key_no < sizeof (key_bind) / sizeof (key_bind[0])) + { + if ((seq_char == key_bind[key_no].is_eseq) + && (c == key_bind[key_no].key_last)) + { + key_bind[key_no].func(); + break; + } + key_no++; + } + + if (key_no == sizeof (key_bind) / sizeof (key_bind[0])) + handle_normal(out_cmd, c); + + } + + /*handle enter when at the end of a line */ + if (term_cursor) + putchar('\n'); + + /* record command history without '\n' */ + history_record(out_cmd); +#if 0 + /* add '\n' to out_cmd */ + if (str_valid) + { + out_cmd[cmd_strlen++] = '\n'; + } + else + { + cmd_strlen = 0; + out_cmd[cmd_strlen++] = '\n'; + } + + if (cmd_strlen > 1 && out_cmd[cmd_strlen - 1] == '\n') + out_cmd[cmd_strlen - 1] = 0; +#else + if (!str_valid) + cmd_strlen = 0; +#endif + /*retore terminal to orginal status */ + term_restore(); + + fflush(stdout); + + return cmd_strlen; +} diff --git a/qca/src/qca-psdk/cli/src/shell/shell_sw.c b/qca/src/qca-psdk/cli/src/shell/shell_sw.c new file mode 100644 index 00000000000..83066351ce9 --- /dev/null +++ b/qca/src/qca-psdk/cli/src/shell/shell_sw.c @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2014, 2016-2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include +#include "shell.h" +#include "fal.h" + +static int sw_devid = 0; + +sw_error_t +cmd_set_devid(a_ulong_t *arg_val) +{ + sw_error_t rtn; + ssdk_cfg_t ssdk_cfg_new; + + if (arg_val[1] >= SW_MAX_NR_DEV) + { + dprintf("dev_id should be less than <%d>\n", SW_MAX_NR_DEV); + return SW_FAIL; + } + sw_devid = arg_val[1]; + + rtn = fal_ssdk_cfg(sw_devid, &ssdk_cfg_new); + if (rtn == SW_OK) + { + ssdk_cfg = ssdk_cfg_new; + } + + return rtn; +} + +int +get_devid(void) +{ + return sw_devid; +} + +int +set_devid(int dev_id) +{ + sw_devid = dev_id; + return SW_OK; +} diff --git a/qca/src/qca-psdk/cli/src/sw_api_us_ioctl.c b/qca/src/qca-psdk/cli/src/sw_api_us_ioctl.c new file mode 100755 index 00000000000..6e977726fcd --- /dev/null +++ b/qca/src/qca-psdk/cli/src/sw_api_us_ioctl.c @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2014, 2017-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "sw.h" +#include "sw_api.h" +#include "sw_api_us.h" + +#define MISC_CHR_DEV 10 +static int glb_socket_fd = 0; + +sw_error_t +sw_uk_if(unsigned long arg_val[SW_MAX_API_PARAM]) +{ + ioctl(glb_socket_fd, SIOCDEVPRIVATE, arg_val); + return SW_OK; +} + +#ifndef SHELL_DEV +#define SHELL_DEV "/dev/switch_ssdk" +#endif +#define MISC_DEV "/proc/misc" + +static int sw_device_minor_get(a_uint32_t *device_minor) +{ + char buf[200] = {0}; + FILE *fp; + char *p; + + fp = fopen(MISC_DEV, "r"); + if (!fp) { + printf("failed to open %s\n", MISC_DEV); + return -1; + } + fseek(fp, 0, SEEK_SET); + while (fgets(buf, 200, fp) != NULL) { + p = strstr(buf, "switch_ssdk"); + if (p) { + sscanf(buf,"%d",device_minor); + fclose(fp); + return 0; + } + } + + fclose(fp); + return -1; +} + +static void sw_device_check(void) +{ + struct stat buf; + a_uint32_t file_minor; + a_uint32_t device_minor; + int rv; + + memset(&buf, 0, sizeof(buf)); + + if (stat( SHELL_DEV, &buf) < 0) { + printf("failed to stat!\n"); + return; + } + if (S_ISCHR(buf.st_mode)) { + file_minor = minor(buf.st_rdev); + rv = sw_device_minor_get(&device_minor); + if (!rv) { + if (device_minor != file_minor) + printf("device:%x file:%x mismatch!\n", + device_minor, file_minor); + else + printf("device:%x file:%x match!\n", + device_minor, file_minor); + } + } + +} + + +sw_error_t +sw_uk_init(a_uint32_t nl_prot) +{ + if (!glb_socket_fd) + { + /* even mknod fail we not quit, perhaps the device node exist already */ +#if defined UK_MINOR_DEV + mknod(SHELL_DEV, S_IFCHR, makedev(MISC_CHR_DEV, UK_MINOR_DEV)); +#else + mknod(SHELL_DEV, S_IFCHR, makedev(MISC_CHR_DEV, nl_prot)); +#endif + if ((glb_socket_fd = open(SHELL_DEV, O_RDWR)) < 0) + { + sw_device_check(); + return SW_INIT_ERROR; + } + } + + return SW_OK; +} + +sw_error_t +sw_uk_cleanup(void) +{ + close(glb_socket_fd); + glb_socket_fd = 0; +#if 0 + remove("/dev/switch_ssdk"); +#endif + return SW_OK; +} + diff --git a/qca/src/qca-psdk/drv/include/api_access.h b/qca/src/qca-psdk/drv/include/api_access.h new file mode 100755 index 00000000000..78e9eb07bb4 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/api_access.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2012, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + + +#ifndef _API_ACCESS_H +#define _API_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + sw_api_func_t * + sw_api_func_find(a_uint32_t api_id); + + sw_api_param_t * + sw_api_param_find(a_uint32_t api_id); + + a_uint32_t + sw_api_param_nums(a_uint32_t api_id); + + sw_error_t + sw_api_get(sw_api_t *sw_api); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _API_ACCESS_H */ diff --git a/qca/src/qca-psdk/drv/include/api_desc.h b/qca/src/qca-psdk/drv/include/api_desc.h new file mode 100644 index 00000000000..d32477e7f06 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/api_desc.h @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2012, 2015-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef _API_DESC_H_ +#define _API_DESC_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define SW_API_PT_DUPLEX_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_DUPLEX_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_DUPLEX_GET, SW_UINT32, 4, SW_PARAM_IN, "Port No."), \ + SW_PARAM_DEF(SW_API_PT_DUPLEX_GET, SW_DUPLEX, \ + sizeof(fal_port_duplex_t), SW_PARAM_PTR|SW_PARAM_OUT, \ + "duplex"), + +#define SW_API_PT_DUPLEX_SET_DESC \ + SW_PARAM_DEF(SW_API_PT_DUPLEX_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_DUPLEX_SET, SW_UINT32, 4, SW_PARAM_IN, "Port No."), \ + SW_PARAM_DEF(SW_API_PT_DUPLEX_SET, SW_DUPLEX, \ + sizeof(fal_port_duplex_t), SW_PARAM_IN, \ + "duplex"), + +#define SW_API_PT_SPEED_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_SPEED_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_SPEED_GET, SW_UINT32, 4, SW_PARAM_IN, "Port No."), \ + SW_PARAM_DEF(SW_API_PT_SPEED_GET, SW_SPEED, \ + sizeof(fal_port_speed_t), SW_PARAM_PTR|SW_PARAM_OUT, \ + "speed"), + +#define SW_API_PT_SPEED_SET_DESC \ + SW_PARAM_DEF(SW_API_PT_SPEED_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_SPEED_SET, SW_UINT32, 4, SW_PARAM_IN, "Port No."), \ + SW_PARAM_DEF(SW_API_PT_SPEED_SET, SW_SPEED, \ + sizeof(fal_port_speed_t), SW_PARAM_IN, \ + "speed"), + +#define SW_API_PT_AN_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_AN_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_AN_GET, SW_UINT32, 4, SW_PARAM_IN, "Port No."), \ + SW_PARAM_DEF(SW_API_PT_AN_GET, SW_ENABLE, 4, SW_PARAM_PTR|SW_PARAM_OUT, "autoneg"), + + +#define SW_API_PT_AN_ENABLE_DESC \ + SW_PARAM_DEF(SW_API_PT_AN_ENABLE, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_AN_ENABLE, SW_UINT32, 4, SW_PARAM_IN, "Port No."), + + +#define SW_API_PT_AN_RESTART_DESC \ + SW_PARAM_DEF(SW_API_PT_AN_RESTART, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_AN_RESTART, SW_UINT32, 4, SW_PARAM_IN, "Port No."), + +#define SW_API_PT_AN_ADV_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_AN_ADV_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_AN_ADV_GET, SW_UINT32, 4, SW_PARAM_IN, "Port No."), \ + SW_PARAM_DEF(SW_API_PT_AN_ADV_GET, SW_CAP, 4, SW_PARAM_PTR|SW_PARAM_OUT, "autoneg"), + +#define SW_API_PT_AN_ADV_SET_DESC \ + SW_PARAM_DEF(SW_API_PT_AN_ADV_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_AN_ADV_SET, SW_UINT32, 4, SW_PARAM_IN, "Port No."), \ + SW_PARAM_DEF(SW_API_PT_AN_ADV_SET, SW_CAP, 4, SW_PARAM_IN, "autoneg"), +#define SW_API_PT_HIBERNATE_SET_DESC \ + SW_PARAM_DEF(SW_API_PT_HIBERNATE_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_HIBERNATE_SET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_HIBERNATE_SET, SW_ENABLE, 4, SW_PARAM_IN, "Hibernate status"), + +#define SW_API_PT_HIBERNATE_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_HIBERNATE_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_HIBERNATE_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_HIBERNATE_GET, SW_ENABLE, 4, SW_PARAM_PTR|SW_PARAM_OUT, "Hibernate Status"), + +#define SW_API_PT_CDT_DESC \ + SW_PARAM_DEF(SW_API_PT_CDT, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_CDT, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_CDT, SW_UINT32, 4, SW_PARAM_IN, "MDI Pair ID"), \ + SW_PARAM_DEF(SW_API_PT_CDT, SW_CABLESTATUS, 4, SW_PARAM_PTR|SW_PARAM_OUT, "cable status"), \ + SW_PARAM_DEF(SW_API_PT_CDT, SW_CABLELEN, 4, SW_PARAM_PTR|SW_PARAM_OUT, "cable len"), +#define SW_API_PT_LINK_STATUS_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_LINK_STATUS_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_LINK_STATUS_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_LINK_STATUS_GET, SW_ENABLE, 4, SW_PARAM_PTR|SW_PARAM_OUT, "Status"), +#define SW_API_PT_8023AZ_SET_DESC \ + SW_PARAM_DEF(SW_API_PT_8023AZ_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_8023AZ_SET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_8023AZ_SET, SW_ENABLE, 4, SW_PARAM_IN, "8023az Status"), + +#define SW_API_PT_8023AZ_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_8023AZ_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_8023AZ_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_8023AZ_GET, SW_ENABLE, 4, SW_PARAM_PTR|SW_PARAM_OUT, "8023az Status"), + +#define SW_API_PT_MDIX_SET_DESC \ + SW_PARAM_DEF(SW_API_PT_MDIX_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_MDIX_SET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_MDIX_SET, SW_CROSSOVER_MODE, \ + sizeof(fal_port_mdix_mode_t), SW_PARAM_IN, "Crossover Mode"), + + +#define SW_API_PT_MDIX_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_MDIX_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_MDIX_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_MDIX_GET, SW_CROSSOVER_MODE, \ + sizeof(fal_port_mdix_mode_t), SW_PARAM_PTR|SW_PARAM_OUT, \ + "Crossover Mode"), + +#define SW_API_PT_MDIX_STATUS_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_MDIX_STATUS_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_MDIX_STATUS_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_MDIX_STATUS_GET, SW_CROSSOVER_STATUS, \ + sizeof(fal_port_mdix_status_t), SW_PARAM_PTR|SW_PARAM_OUT, \ + "Crossover Status"), + +#define SW_API_PT_LOCAL_LOOPBACK_SET_DESC \ + SW_PARAM_DEF(SW_API_PT_LOCAL_LOOPBACK_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_LOCAL_LOOPBACK_SET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_LOCAL_LOOPBACK_SET, SW_ENABLE, 4, \ + SW_PARAM_IN, "Local Loopback Status"), + +#define SW_API_PT_LOCAL_LOOPBACK_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_LOCAL_LOOPBACK_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_LOCAL_LOOPBACK_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_LOCAL_LOOPBACK_GET, SW_ENABLE, 4, \ + SW_PARAM_PTR|SW_PARAM_OUT, "Local Loopback Status"), + +#define SW_API_PT_REMOTE_LOOPBACK_SET_DESC \ + SW_PARAM_DEF(SW_API_PT_REMOTE_LOOPBACK_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_REMOTE_LOOPBACK_SET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_REMOTE_LOOPBACK_SET, SW_ENABLE, 4, \ + SW_PARAM_IN, "Remote Loopback Status"), + +#define SW_API_PT_REMOTE_LOOPBACK_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_REMOTE_LOOPBACK_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_REMOTE_LOOPBACK_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_REMOTE_LOOPBACK_GET, SW_ENABLE, 4, \ + SW_PARAM_PTR|SW_PARAM_OUT, "Remote Loopback Status"), + +#define SW_API_PT_RESET_DESC \ + SW_PARAM_DEF(SW_API_PT_RESET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_RESET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), + +#define SW_API_PT_POWER_OFF_DESC \ + SW_PARAM_DEF(SW_API_PT_POWER_OFF, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_POWER_OFF, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), + +#define SW_API_PT_POWER_ON_DESC \ + SW_PARAM_DEF(SW_API_PT_POWER_ON, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_POWER_ON, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), + +#define SW_API_PT_MAGIC_FRAME_MAC_SET_DESC \ + SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_SET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_SET, SW_MACADDR, \ + sizeof(fal_mac_addr_t), SW_PARAM_PTR|SW_PARAM_IN, "[Magic mac]"), + +#define SW_API_PT_MAGIC_FRAME_MAC_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_GET, SW_MACADDR, \ + sizeof(fal_mac_addr_t), SW_PARAM_PTR|SW_PARAM_OUT, "[Magic mac]"), + +#define SW_API_PT_PHY_ID_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_PHY_ID_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_PHY_ID_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_PHY_ID_GET, SW_UINT16, 2, SW_PARAM_PTR|SW_PARAM_OUT, "Org ID"), \ + SW_PARAM_DEF(SW_API_PT_PHY_ID_GET, SW_UINT16, 2, SW_PARAM_PTR|SW_PARAM_OUT, "Rev ID"), + +#define SW_API_PT_WOL_STATUS_SET_DESC \ + SW_PARAM_DEF(SW_API_PT_WOL_STATUS_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_WOL_STATUS_SET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_WOL_STATUS_SET, SW_ENABLE, 4, SW_PARAM_IN, "Wol Status"), + +#define SW_API_PT_WOL_STATUS_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_WOL_STATUS_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_WOL_STATUS_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_WOL_STATUS_GET, SW_ENABLE, 4, SW_PARAM_PTR|SW_PARAM_OUT, "Wol Status"), +#define SW_API_PT_INTERFACE_MODE_STATUS_GET_DESC \ + SW_PARAM_DEF(SW_API_PT_INTERFACE_MODE_STATUS_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_PT_INTERFACE_MODE_STATUS_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_PT_INTERFACE_MODE_STATUS_GET, SW_INTERFACE_MODE, \ + sizeof(fal_port_interface_mode_t), SW_PARAM_PTR|SW_PARAM_OUT, \ + "Interface Status"), + +#define SW_API_DEBUG_PHYCOUNTER_SET_DESC \ + SW_PARAM_DEF(SW_API_DEBUG_PHYCOUNTER_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_DEBUG_PHYCOUNTER_SET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_DEBUG_PHYCOUNTER_SET, SW_ENABLE, 4, SW_PARAM_IN, "Counter Status"), + +#define SW_API_DEBUG_PHYCOUNTER_GET_DESC \ + SW_PARAM_DEF(SW_API_DEBUG_PHYCOUNTER_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_DEBUG_PHYCOUNTER_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_DEBUG_PHYCOUNTER_GET, SW_ENABLE, 4, \ + SW_PARAM_PTR|SW_PARAM_OUT, "Counter Status"), + +#define SW_API_DEBUG_PHYCOUNTER_SHOW_DESC \ + SW_PARAM_DEF(SW_API_DEBUG_PHYCOUNTER_SHOW, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \ + SW_PARAM_DEF(SW_API_DEBUG_PHYCOUNTER_SHOW, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \ + SW_PARAM_DEF(SW_API_DEBUG_PHYCOUNTER_SHOW, SW_COUNTER_INFO, \ + sizeof(fal_port_counter_info_t), SW_PARAM_PTR|SW_PARAM_OUT, \ + "Phy Counter Statistics On Port"), +#define SW_API_PHY_GET_DESC \ + SW_PARAM_DEF(SW_API_PHY_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"),\ + SW_PARAM_DEF(SW_API_PHY_GET, SW_UINT32, 4, SW_PARAM_IN, "Phy ID"),\ + SW_PARAM_DEF(SW_API_PHY_GET, SW_UINT32, 4, SW_PARAM_IN, "Reg ID"),\ + SW_PARAM_DEF(SW_API_PHY_GET, SW_UINT16, 2, SW_PARAM_PTR|SW_PARAM_OUT, "Data"), + + +#define SW_API_PHY_SET_DESC \ + SW_PARAM_DEF(SW_API_PHY_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"),\ + SW_PARAM_DEF(SW_API_PHY_SET, SW_UINT32, 4, SW_PARAM_IN, "Phy ID"),\ + SW_PARAM_DEF(SW_API_PHY_SET, SW_UINT32, 4, SW_PARAM_IN, "Reg ID"),\ + SW_PARAM_DEF(SW_API_PHY_SET, SW_UINT16, 2, SW_PARAM_IN, "Data"), + +#define SW_API_DESC(api_id) api_id##_DESC + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _API_DESC_H_ */ diff --git a/qca/src/qca-psdk/drv/include/fal/fal.h b/qca/src/qca-psdk/drv/include/fal/fal.h new file mode 100644 index 00000000000..f0f0038b5dc --- /dev/null +++ b/qca/src/qca-psdk/drv/include/fal/fal.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2012, 2017-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef _FAL_H +#define _FAL_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +#include "fal_port_ctrl.h" +#include "fal_reg_access.h" +#include "fal_init.h" +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _FAL_H */ diff --git a/qca/src/qca-psdk/drv/include/fal/fal_api.h b/qca/src/qca-psdk/drv/include/fal/fal_api.h new file mode 100644 index 00000000000..269dfebb595 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/fal/fal_api.h @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2012, 2015-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef _FAL_API_H_ +#define _FAL_API_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +#define PORTCONTROL_API \ + SW_API_DEF(SW_API_PT_DUPLEX_GET, fal_port_duplex_get), \ + SW_API_DEF(SW_API_PT_DUPLEX_SET, fal_port_duplex_set), \ + SW_API_DEF(SW_API_PT_SPEED_GET, fal_port_speed_get), \ + SW_API_DEF(SW_API_PT_SPEED_SET, fal_port_speed_set), \ + SW_API_DEF(SW_API_PT_AN_GET, fal_port_autoneg_status_get), \ + SW_API_DEF(SW_API_PT_AN_ENABLE, fal_port_autoneg_enable), \ + SW_API_DEF(SW_API_PT_AN_RESTART, fal_port_autoneg_restart), \ + SW_API_DEF(SW_API_PT_AN_ADV_GET, fal_port_autoneg_adv_get), \ + SW_API_DEF(SW_API_PT_AN_ADV_SET, fal_port_autoneg_adv_set), \ + SW_API_DEF(SW_API_PT_HIBERNATE_SET, fal_port_hibernate_set), \ + SW_API_DEF(SW_API_PT_HIBERNATE_GET, fal_port_hibernate_get), \ + SW_API_DEF(SW_API_PT_CDT, fal_port_cdt), \ + SW_API_DEF(SW_API_PT_LINK_STATUS_GET, fal_port_link_status_get), \ + SW_API_DEF(SW_API_PT_8023AZ_SET, fal_port_8023az_set), \ + SW_API_DEF(SW_API_PT_8023AZ_GET, fal_port_8023az_get), \ + SW_API_DEF(SW_API_PT_MDIX_SET, fal_port_mdix_set), \ + SW_API_DEF(SW_API_PT_MDIX_GET, fal_port_mdix_get), \ + SW_API_DEF(SW_API_PT_MDIX_STATUS_GET, fal_port_mdix_status_get), \ + SW_API_DEF(SW_API_PT_LOCAL_LOOPBACK_SET, fal_port_local_loopback_set), \ + SW_API_DEF(SW_API_PT_LOCAL_LOOPBACK_GET, fal_port_local_loopback_get), \ + SW_API_DEF(SW_API_PT_REMOTE_LOOPBACK_SET, fal_port_remote_loopback_set), \ + SW_API_DEF(SW_API_PT_REMOTE_LOOPBACK_GET, fal_port_remote_loopback_get), \ + SW_API_DEF(SW_API_PT_RESET, fal_port_reset), \ + SW_API_DEF(SW_API_PT_POWER_OFF, fal_port_power_off), \ + SW_API_DEF(SW_API_PT_POWER_ON, fal_port_power_on), \ + SW_API_DEF(SW_API_PT_MAGIC_FRAME_MAC_SET, fal_port_magic_frame_mac_set), \ + SW_API_DEF(SW_API_PT_MAGIC_FRAME_MAC_GET, fal_port_magic_frame_mac_get), \ + SW_API_DEF(SW_API_PT_PHY_ID_GET, fal_port_phy_id_get), \ + SW_API_DEF(SW_API_PT_WOL_STATUS_SET, fal_port_wol_status_set), \ + SW_API_DEF(SW_API_PT_WOL_STATUS_GET, fal_port_wol_status_get), \ + SW_API_DEF(SW_API_PT_INTERFACE_MODE_STATUS_GET, fal_port_interface_mode_status_get), \ + SW_API_DEF(SW_API_DEBUG_PHYCOUNTER_SET, fal_debug_phycounter_set), \ + SW_API_DEF(SW_API_DEBUG_PHYCOUNTER_GET, fal_debug_phycounter_get), \ + SW_API_DEF(SW_API_DEBUG_PHYCOUNTER_SHOW, fal_debug_phycounter_show),\ +/*end of PORTCONTROL_API*/ +#define PORTCONTROL_API_PARAM \ + SW_API_DESC(SW_API_PT_DUPLEX_GET) \ + SW_API_DESC(SW_API_PT_DUPLEX_SET) \ + SW_API_DESC(SW_API_PT_SPEED_GET) \ + SW_API_DESC(SW_API_PT_SPEED_SET) \ + SW_API_DESC(SW_API_PT_AN_GET) \ + SW_API_DESC(SW_API_PT_AN_ENABLE) \ + SW_API_DESC(SW_API_PT_AN_RESTART) \ + SW_API_DESC(SW_API_PT_AN_ADV_GET) \ + SW_API_DESC(SW_API_PT_AN_ADV_SET) \ + SW_API_DESC(SW_API_PT_HIBERNATE_SET) \ + SW_API_DESC(SW_API_PT_HIBERNATE_GET) \ + SW_API_DESC(SW_API_PT_CDT) \ + SW_API_DESC(SW_API_PT_LINK_STATUS_GET) \ + SW_API_DESC(SW_API_PT_8023AZ_SET) \ + SW_API_DESC(SW_API_PT_8023AZ_GET) \ + SW_API_DESC(SW_API_PT_MDIX_SET) \ + SW_API_DESC(SW_API_PT_MDIX_GET) \ + SW_API_DESC(SW_API_PT_MDIX_STATUS_GET) \ + SW_API_DESC(SW_API_PT_LOCAL_LOOPBACK_SET) \ + SW_API_DESC(SW_API_PT_LOCAL_LOOPBACK_GET) \ + SW_API_DESC(SW_API_PT_REMOTE_LOOPBACK_SET) \ + SW_API_DESC(SW_API_PT_REMOTE_LOOPBACK_GET) \ + SW_API_DESC(SW_API_PT_RESET) \ + SW_API_DESC(SW_API_PT_POWER_OFF) \ + SW_API_DESC(SW_API_PT_POWER_ON) \ + SW_API_DESC(SW_API_PT_MAGIC_FRAME_MAC_SET) \ + SW_API_DESC(SW_API_PT_MAGIC_FRAME_MAC_GET) \ + SW_API_DESC(SW_API_PT_PHY_ID_GET) \ + SW_API_DESC(SW_API_PT_WOL_STATUS_SET) \ + SW_API_DESC(SW_API_PT_WOL_STATUS_GET) \ + SW_API_DESC(SW_API_PT_INTERFACE_MODE_STATUS_GET) \ + SW_API_DESC(SW_API_DEBUG_PHYCOUNTER_SET) \ + SW_API_DESC(SW_API_DEBUG_PHYCOUNTER_GET) \ + SW_API_DESC(SW_API_DEBUG_PHYCOUNTER_SHOW) \ +/*end of PORTCONTROL_API_PARAM*/ +#define REG_API \ + SW_API_DEF(SW_API_PHY_GET, fal_phy_get), \ + SW_API_DEF(SW_API_PHY_SET, fal_phy_set), \ +/*end of REG_API*/ +#define REG_API_PARAM \ + SW_API_DESC(SW_API_PHY_GET) \ + SW_API_DESC(SW_API_PHY_SET) \ +/*end of REG_API_PARAM*/ +#define SSDK_API \ + PORTCONTROL_API \ + REG_API \ + SW_API_DEF(SW_API_MAX, NULL), + + +#define SSDK_PARAM \ + PORTCONTROL_API_PARAM \ + REG_API_PARAM \ + SW_PARAM_DEF(SW_API_MAX, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _FAL_API_H_ */ diff --git a/qca/src/qca-psdk/drv/include/fal/fal_init.h b/qca/src/qca-psdk/drv/include/fal/fal_init.h new file mode 100644 index 00000000000..637288e1e7b --- /dev/null +++ b/qca/src/qca-psdk/drv/include/fal/fal_init.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2012, 2016-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +/** + * @defgroup fal_init FAL_INIT + * @{ + */ +#ifndef _FAL_INIT_H_ +#define _FAL_INIT_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "ssdk_init.h" +sw_error_t fal_init(a_uint32_t dev_id, ssdk_init_cfg * cfg); +sw_error_t fal_cleanup(void); +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _FAL_INIT_H_ */ +/** + * @} + */ diff --git a/qca/src/qca-psdk/drv/include/fal/fal_port_ctrl.h b/qca/src/qca-psdk/drv/include/fal/fal_port_ctrl.h new file mode 100644 index 00000000000..a7303c06189 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/fal/fal_port_ctrl.h @@ -0,0 +1,445 @@ +/* + * Copyright (c) 2012, 2015-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +/** + * @defgroup fal_port_ctrl FAL_PORT_CONTROL + * @{ + */ +#ifndef _FAL_PORTCTRL_H_ +#define _FAL_PORTCTRL_H_ + +#ifdef __cplusplus +extern "c" { +#endif + +#include "sw.h" +#include "fal/fal_type.h" + + typedef enum { + FAL_HALF_DUPLEX = 0, + FAL_FULL_DUPLEX, + FAL_DUPLEX_BUTT = 0xffff + } fal_port_duplex_t; + + typedef enum { + FAL_SPEED_10 = 10, + FAL_SPEED_100 = 100, + FAL_SPEED_1000 = 1000, + FAL_SPEED_2500 = 2500, + FAL_SPEED_5000 = 5000, + FAL_SPEED_10000 = 10000, + FAL_SPEED_BUTT = 0xffff, + } fal_port_speed_t; + + typedef enum { + FAL_CABLE_STATUS_NORMAL = 0, + FAL_CABLE_STATUS_SHORT = 1, + FAL_CABLE_STATUS_OPENED = 2, + FAL_CABLE_STATUS_INVALID = 3, + FAL_CABLE_STATUS_CROSSOVERA = 4, + FAL_CABLE_STATUS_CROSSOVERB = 5, + FAL_CABLE_STATUS_CROSSOVERC = 6, + FAL_CABLE_STATUS_CROSSOVERD = 7, + FAL_CABLE_STATUS_LOW_MISMATCH =8, + FAL_CABLE_STATUS_HIGH_MISMATCH =9, + FAL_CABLE_STATUS_BUTT = 0xffff, + } fal_cable_status_t; + +struct port_phy_status +{ + a_uint32_t link_status; + fal_port_speed_t speed; + fal_port_duplex_t duplex; + a_bool_t tx_flowctrl; + a_bool_t rx_flowctrl; +}; + +#define FAL_ENABLE 1 +#define FAL_DISABLE 0 +#define FAL_MAX_PORT_NUMBER 8 +#define FAL_DEFAULT_LOOPBACK_RATE 14 + +//phy autoneg adv +#define FAL_PHY_ADV_10T_HD 0x01 +#define FAL_PHY_ADV_10T_FD 0x02 +#define FAL_PHY_ADV_100TX_HD 0x04 +#define FAL_PHY_ADV_100TX_FD 0x08 +//#define FAL_PHY_ADV_1000T_HD 0x100 +#define FAL_PHY_ADV_1000T_FD 0x200 +#define FAL_PHY_ADV_1000BX_HD 0x400 +#define FAL_PHY_ADV_1000BX_FD 0x800 +#define FAL_PHY_ADV_2500T_FD 0x1000 +#define FAL_PHY_ADV_5000T_FD 0x2000 +#define FAL_PHY_ADV_10000T_FD 0x4000 +#define FAL_PHY_ADV_10G_R_FD 0x8000 + +#define FAL_DEFAULT_MAX_FRAME_SIZE 0x5ee + +#define FAL_PHY_ADV_FE_SPEED_ALL \ + (FAL_PHY_ADV_10T_HD | FAL_PHY_ADV_10T_FD | FAL_PHY_ADV_100TX_HD |\ + FAL_PHY_ADV_100TX_FD) + +#define FAL_PHY_ADV_GE_SPEED_ALL \ + (FAL_PHY_ADV_10T_HD | FAL_PHY_ADV_10T_FD | FAL_PHY_ADV_100TX_HD |\ + FAL_PHY_ADV_100TX_FD | FAL_PHY_ADV_1000T_FD) + +#define FAL_PHY_ADV_BX_SPEED_ALL \ + (FAL_PHY_ADV_1000BX_HD | FAL_PHY_ADV_1000BX_FD |FAL_PHY_ADV_10G_R_FD) + +#define FAL_PHY_ADV_XGE_SPEED_ALL \ + (FAL_PHY_ADV_2500T_FD | FAL_PHY_ADV_5000T_FD | FAL_PHY_ADV_10000T_FD) + +#define FAL_PHY_ADV_PAUSE 0x10 +#define FAL_PHY_ADV_ASY_PAUSE 0x20 +#define FAL_PHY_FE_ADV_ALL \ + (FAL_PHY_ADV_FE_SPEED_ALL | FAL_PHY_ADV_PAUSE | FAL_PHY_ADV_ASY_PAUSE) +#define FAL_PHY_GE_ADV_ALL \ + (FAL_PHY_ADV_GE_SPEED_ALL | FAL_PHY_ADV_PAUSE | FAL_PHY_ADV_ASY_PAUSE) + +#define FAL_PHY_COMBO_ADV_ALL \ + (FAL_PHY_ADV_BX_SPEED_ALL | FAL_PHY_ADV_GE_SPEED_ALL | FAL_PHY_ADV_XGE_SPEED_ALL|\ +FAL_PHY_ADV_PAUSE | FAL_PHY_ADV_ASY_PAUSE) + +//phy capablity +#define FAL_PHY_AUTONEG_CAPS 0x01 +#define FAL_PHY_100T2_HD_CAPS 0x02 +#define FAL_PHY_100T2_FD_CAPS 0x04 +#define FAL_PHY_10T_HD_CAPS 0x08 +#define FAL_PHY_10T_FD_CAPS 0x10 +#define FAL_PHY_100X_HD_CAPS 0x20 +#define FAL_PHY_100X_FD_CAPS 0x40 +#define FAL_PHY_100T4_CAPS 0x80 +//#define FAL_PHY_1000T_HD_CAPS 0x100 +#define FAL_PHY_1000T_FD_CAPS 0x200 +//#define FAL_PHY_1000X_HD_CAPS 0x400 +#define FAL_PHY_1000X_FD_CAPS 0x800 + +//phy partner capablity +#define FAL_PHY_PART_10T_HD 0x1 +#define FAL_PHY_PART_10T_FD 0x2 +#define FAL_PHY_PART_100TX_HD 0x4 +#define FAL_PHY_PART_100TX_FD 0x8 +//#define FAL_PHY_PART_1000T_HD 0x10 +#define FAL_PHY_PART_1000T_FD 0x20 +#define FAL_PHY_PART_2500T_FD 0x40 +#define FAL_PHY_PART_5000T_FD 0x80 +#define FAL_PHY_PART_10000T_FD 0x100 + +//phy interrupt flag +#define FAL_PHY_INTR_SPEED_CHANGE 0x1 +#define FAL_PHY_INTR_DUPLEX_CHANGE 0x2 +#define FAL_PHY_INTR_STATUS_UP_CHANGE 0x4 +#define FAL_PHY_INTR_STATUS_DOWN_CHANGE 0x8 +#define FAL_PHY_INTR_BX_FX_STATUS_UP_CHANGE 0x10 +#define FAL_PHY_INTR_BX_FX_STATUS_DOWN_CHANGE 0x20 +#define FAL_PHY_INTR_MEDIA_STATUS_CHANGE 0x40 +#define FAL_PHY_INTR_WOL_STATUS 0x80 +#define FAL_PHY_INTR_POE_STATUS 0x100 + +/* phy eee */ +#define FAL_PHY_EEE_10BASE_T 0x1 +#define FAL_PHY_EEE_100BASE_T 0x2 +#define FAL_PHY_EEE_1000BASE_T 0x4 +#define FAL_PHY_EEE_2500BASE_T 0x8 +#define FAL_PHY_EEE_5000BASE_T 0x10 +#define FAL_PHY_EEE_10000BASE_T 0x20 + typedef enum { + FAL_NO_HEADER_EN = 0, + FAL_ONLY_MANAGE_FRAME_EN, + FAL_ALL_TYPE_FRAME_EN + } fal_port_header_mode_t; + + typedef struct { + a_uint16_t pair_a_status; + a_uint16_t pair_b_status; + a_uint16_t pair_c_status; + a_uint16_t pair_d_status; + a_uint32_t pair_a_len; + a_uint32_t pair_b_len; + a_uint32_t pair_c_len; + a_uint32_t pair_d_len; + } fal_port_cdt_t; + +/*below is new add for malibu phy*/ + +/** Phy mdix mode */ + typedef enum { + PHY_MDIX_AUTO = 0, + /**< Auto MDI/MDIX */ + PHY_MDIX_MDI = 1, + /**< Fixed MDI */ + PHY_MDIX_MDIX = 2 + /**< Fixed MDIX */ + } fal_port_mdix_mode_t; + +/** Phy mdix status */ + typedef enum { + PHY_MDIX_STATUS_MDI = 0, + /**< Fixed MDI */ + PHY_MDIX_STATUS_MDIX = 1 + /**< Fixed MDIX */ + } fal_port_mdix_status_t; + +/** Phy master mode */ + typedef enum { + PHY_MASTER_MASTER = 0, + /**< Phy manual MASTER configuration */ + PHY_MASTER_SLAVE = 1, + /**< Phy manual SLAVE configuration */ + PHY_MASTER_AUTO = 2 + /**< Phy automatic MASTER/SLAVE configuration */ + } fal_port_master_t; + +/** Phy preferred medium type */ + typedef enum { + PHY_MEDIUM_COPPER = 0, + /**< Copper */ + PHY_MEDIUM_FIBER = 1, + /**< Fiber */ + + } fal_port_medium_t; + +/** Phy pages */ + typedef enum { + PHY_SGBX_PAGES = 0, + /**< sgbx pages */ + PHY_COPPER_PAGES = 1 + /**< copper pages */ + } fal_port_reg_pages_t; + +/** Phy preferred Fiber mode */ + typedef enum { + PHY_FIBER_100FX = 0, + /**< 100FX fiber mode */ + PHY_FIBER_1000BX = 1, + /**< 1000BX fiber mode */ + PHY_FIBER_10G_R = 2, + } fal_port_fiber_mode_t; + +/** Phy reset status */ + typedef enum { + PHY_RESET_DONE = 0, + /**< Phy reset done */ + PHY_RESET_BUSY = 1 + /**< Phy still in reset process */ + } fal_port_reset_status_t; + +/** Phy auto-negotiation status */ + typedef enum { + PHY_AUTO_NEG_STATUS_BUSY = 0, + /**< Phy still in auto-negotiation process */ + PHY_AUTO_NEG_STATUS_DONE = 1 + /**< Phy auto-negotiation done */ + } fal_port_auto_neg_status_t; + + +/** Phy interface mode */ + typedef enum { + PHY_PSGMII_BASET = 0, + /**< PSGMII mode */ + PHY_PSGMII_BX1000 = 1, + /**< PSGMII BX1000 mode */ + PHY_PSGMII_FX100 = 2, + /**< PSGMII FX100 mode */ + PHY_PSGMII_AMDET = 3, + /**< PSGMII Auto mode */ + PHY_SGMII_BASET = 4, + /**< SGMII mode */ + PORT_QSGMII, + /**>24)&0xff) +#define FAL_PORT_ID_VALUE(port_id) ((port_id)&0xffffff) +#define FAL_PORT_ID(type, value) (((type)<<24)|(value)) + +#define FAL_IS_PPORT(port_id) (((FAL_PORT_ID_TYPE(port_id))==FAL_PORT_TYPE_PPORT)?1:0) +#define FAL_IS_TRUNK(port_id) (((FAL_PORT_ID_TYPE(port_id))==FAL_PORT_TYPE_TRUNK)?1:0) +#define FAL_IS_VPORT(port_id) (((FAL_PORT_ID_TYPE(port_id))==FAL_PORT_TYPE_VPORT)?1:0) + + +#if (SW_MAX_NR_PORT <= 32) + typedef a_uint32_t fal_pbmp_t; +#else + typedef a_uint64_t fal_pbmp_t; +#endif + + typedef struct + { + a_uint8_t uc[6]; + } fal_mac_addr_t; + + typedef a_uint32_t fal_ip4_addr_t; + + typedef struct + { + a_uint32_t ul[4]; + } fal_ip6_addr_t; + + /** + @brief This enum defines several forwarding command type. + * Field description: + FAL_MAC_FRWRD - packets are normally forwarded + FAL_MAC_DROP - packets are dropped + FAL_MAC_CPY_TO_CPU - packets are copyed to cpu + FAL_MAC_RDT_TO_CPU - packets are redirected to cpu + */ + typedef enum + { + FAL_MAC_FRWRD = 0, /**< packets are normally forwarded */ + FAL_MAC_DROP, /**< packets are dropped */ + FAL_MAC_CPY_TO_CPU, /**< packets are copyed to cpu */ + FAL_MAC_RDT_TO_CPU /**< packets are redirected to cpu */ + } fal_fwd_cmd_t; + + typedef enum + { + FAL_BYTE_BASED = 0, + FAL_FRAME_BASED, + FAL_RATE_MODE_BUTT + } fal_traffic_unit_t; + + typedef a_uint32_t fal_queue_t; + +#define FAL_SVL_FID 0xffff + + + /** + @brief This enum defines packets transmitted out vlan tagged mode. + */ + typedef enum + { + FAL_EG_UNMODIFIED = 0, /**< egress transmit packets unmodified */ + FAL_EG_UNTAGGED, /**< egress transmit packets without vlan tag*/ + FAL_EG_TAGGED, /**< egress transmit packets with vlan tag */ + FAL_EG_HYBRID, /**< egress transmit packets in hybrid tag mode */ + FAL_EG_UNTOUCHED, + FAL_EG_MODE_BUTT + } fal_pt_1q_egmode_t; + +#define FAL_NEXT_ENTRY_FIRST_ID 0xffffffff + + typedef struct{ + a_uint32_t reg_count; + a_uint32_t reg_base; + a_uint32_t reg_end; + a_uint32_t reg_value[256]; + a_int8_t reg_name[32]; + }fal_reg_dump_t; + + typedef struct{ + a_uint32_t reg_count; + a_uint32_t reg_addr[32]; + a_uint32_t reg_value[32]; + a_int8_t reg_name[32]; + }fal_debug_reg_dump_t; + +typedef struct{ + a_uint32_t phy_count; + a_uint32_t phy_base; + a_uint32_t phy_end; + a_uint16_t phy_value[256]; + a_int8_t phy_name[32]; +}fal_phy_dump_t; + + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _FAL_TYPE_H_ */ +/** + * @} + */ diff --git a/qca/src/qca-psdk/drv/include/hsl/hsl.h b/qca/src/qca-psdk/drv/include/hsl/hsl.h new file mode 100644 index 00000000000..135fdf5e306 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/hsl/hsl.h @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2012,2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef _HSL_H +#define _HSL_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "ssdk_init.h" + + typedef sw_error_t + (*hsl_acl_rule_copy) (a_uint32_t dev_id, a_uint32_t src_addr, + a_uint32_t dest_addr, a_uint32_t size); + + typedef sw_error_t + (*hsl_acl_rule_invalid) (a_uint32_t dev_id, a_uint32_t addr, + a_uint32_t size); + + typedef sw_error_t + (*hsl_acl_addr_update) (a_uint32_t dev_id, a_uint32_t old_addr, + a_uint32_t new_addr, a_uint32_t info); + + typedef struct + { + hsl_acl_rule_copy acl_rule_copy; + hsl_acl_rule_invalid acl_rule_invalid; + hsl_acl_addr_update acl_addr_update; + } hsl_acl_func_t; +extern sw_error_t reduce_hsl_phy_get(a_uint32_t dev,a_uint32_t phy_addr,a_uint32_t reg,a_uint16_t* value); +#define HSL_PHY_GET(rv, dev, phy_addr, reg, value) \ + rv = reduce_hsl_phy_get(dev,phy_addr,reg,value); + + +extern sw_error_t reduce_hsl_phy_set(a_uint32_t dev,a_uint32_t phy_addr,a_uint32_t reg,a_uint16_t value); +#define HSL_PHY_SET(rv, dev, phy_addr, reg, value) \ + rv = reduce_hsl_phy_set(dev,phy_addr,reg,value); + +extern sw_error_t hsl_phy_i2c_get(a_uint32_t dev,a_uint32_t phy_addr,a_uint32_t reg,a_uint16_t* value); +#define HSL_PHY_I2C_GET(rv, dev, phy_addr, reg, value) \ + rv = hsl_phy_i2c_get(dev,phy_addr,reg,value); + + +extern sw_error_t hsl_phy_i2c_set(a_uint32_t dev,a_uint32_t phy_addr,a_uint32_t reg,a_uint16_t value); +#define HSL_PHY_I2C_SET(rv, dev, phy_addr, reg, value) \ + rv = hsl_phy_i2c_set(dev,phy_addr,reg,value); +#if (defined(API_LOCK) \ +&& (defined(HSL_STANDALONG) || (defined(KERNEL_MODULE) && defined(USER_MODE)))) + extern aos_lock_t sw_hsl_api_lock; +#define HSL_API_LOCK aos_lock(&sw_hsl_api_lock) +#define HSL_API_UNLOCK aos_unlock(&sw_hsl_api_lock) +#else +#define HSL_API_LOCK +#define HSL_API_UNLOCK +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _HSL_H */ diff --git a/qca/src/qca-psdk/drv/include/hsl/hsl_api.h b/qca/src/qca-psdk/drv/include/hsl/hsl_api.h new file mode 100644 index 00000000000..18392e600fe --- /dev/null +++ b/qca/src/qca-psdk/drv/include/hsl/hsl_api.h @@ -0,0 +1,407 @@ +/* + * Copyright (c) 2012, 2015, 2017-2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef _HSL_API_H +#define _HSL_API_H + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#include "fal.h" + + /* Port Control */ +#define PORT_CONTROL_FUNC_PROTOTYPE_DEF + typedef sw_error_t + (*hsl_port_duplex_get) (a_uint32_t dev_id, fal_port_t port_id, + fal_port_duplex_t * pduplex); + + typedef sw_error_t + (*hsl_port_duplex_set) (a_uint32_t dev_id, fal_port_t port_id, + fal_port_duplex_t duplex); + + typedef sw_error_t + (*hsl_port_speed_get) (a_uint32_t dev_id, fal_port_t port_id, + fal_port_speed_t * pspeed); + + typedef sw_error_t + (*hsl_port_autoneg_status_get) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * status); + + typedef sw_error_t + (*hsl_port_speed_set) (a_uint32_t dev_id, fal_port_t port_id, + fal_port_speed_t speed); + + typedef sw_error_t + (*hsl_port_autoneg_enable) (a_uint32_t dev_id, fal_port_t port_id); + + typedef sw_error_t + (*hsl_port_autoneg_restart) (a_uint32_t dev_id, fal_port_t port_id); + + typedef sw_error_t + (*hsl_port_autoneg_adv_get) (a_uint32_t dev_id, fal_port_t port_id, + a_uint32_t * autoadv); + + typedef sw_error_t + (*hsl_port_autoneg_adv_set) (a_uint32_t dev_id, fal_port_t port_id, + a_uint32_t autoadv); + + typedef sw_error_t + (*hsl_port_hdr_status_set) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable); + + typedef sw_error_t + (*hsl_port_hdr_status_get) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable); + + typedef sw_error_t + (*hsl_port_flowctrl_set) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable); + + typedef sw_error_t + (*hsl_port_flowctrl_get) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable); +typedef sw_error_t + (*hsl_port_flowctrl_thresh_set) (a_uint32_t dev_id, fal_port_t port_id, + a_uint8_t on, a_uint8_t off); + + typedef sw_error_t + (*hsl_port_flowctrl_forcemode_set) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable); + + typedef sw_error_t + (*hsl_port_flowctrl_forcemode_get) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable); + + typedef sw_error_t + (*hsl_port_powersave_set) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable); + + + typedef sw_error_t + (*hsl_port_powersave_get) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable); + + + typedef sw_error_t + (*hsl_port_hibernate_set) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable); + + + typedef sw_error_t + (*hsl_port_hibernate_get) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable); + + + typedef sw_error_t + (*hsl_port_cdt) (a_uint32_t dev_id, fal_port_t port_id, + a_uint32_t mdi_pair, fal_cable_status_t * cable_status, + a_uint32_t * cable_len); + + typedef sw_error_t + (*hsl_port_rxhdr_mode_set) (a_uint32_t dev_id, fal_port_t port_id, + fal_port_header_mode_t mode); + + typedef sw_error_t + (*hsl_port_rxhdr_mode_get) (a_uint32_t dev_id, fal_port_t port_id, + fal_port_header_mode_t * mode); + + typedef sw_error_t + (*hsl_port_txhdr_mode_set) (a_uint32_t dev_id, fal_port_t port_id, + fal_port_header_mode_t mode); + + typedef sw_error_t + (*hsl_port_txhdr_mode_get) (a_uint32_t dev_id, fal_port_t port_id, + fal_port_header_mode_t * mode); + + typedef sw_error_t + (*hsl_header_type_set) (a_uint32_t dev_id, a_bool_t enable, + a_uint32_t type); + + typedef sw_error_t + (*hsl_header_type_get) (a_uint32_t dev_id, a_bool_t * enable, + a_uint32_t * type); + + typedef sw_error_t + (*hsl_port_txmac_status_set) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable); + + typedef sw_error_t + (*hsl_port_txmac_status_get) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable); + + typedef sw_error_t + (*hsl_port_rxmac_status_set) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable); + + typedef sw_error_t + (*hsl_port_rxmac_status_get) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable); + + typedef sw_error_t + (*hsl_port_txfc_status_set) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable); + + typedef sw_error_t + (*hsl_port_txfc_status_get) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable); + + typedef sw_error_t + (*hsl_port_rxfc_status_set) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable); + + typedef sw_error_t + (*hsl_port_rxfc_status_get) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable); + + typedef sw_error_t + (*hsl_port_bp_status_set) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable); + + typedef sw_error_t + (*hsl_port_bp_status_get) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable); + + typedef sw_error_t + (*hsl_port_link_forcemode_set) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable); + + typedef sw_error_t + (*hsl_port_link_forcemode_get) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable); + + typedef sw_error_t + (*hsl_port_link_status_get) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * status); + + typedef sw_error_t + (*hsl_ports_link_status_get) (a_uint32_t dev_id, a_uint32_t * status); + + typedef sw_error_t + (*hsl_port_mac_loopback_set) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable); + + typedef sw_error_t + (*hsl_port_mac_loopback_get) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable); + + typedef sw_error_t + (*hsl_port_congestion_drop_set) (a_uint32_t dev_id, fal_port_t port_id, + a_uint32_t queue_id, a_bool_t enable); + + typedef sw_error_t + (*hsl_port_congestion_drop_get) (a_uint32_t dev_id, fal_port_t port_id, + a_uint32_t queue_id, a_bool_t * enable); + + typedef sw_error_t + (*hsl_ring_flow_ctrl_thres_set) (a_uint32_t dev_id, a_uint32_t ring_id, + a_uint8_t on_thres, a_uint8_t off_thres); + + typedef sw_error_t + (*hsl_ring_flow_ctrl_thres_get) (a_uint32_t dev_id, a_uint32_t ring_id, + a_uint8_t * on_thres, + a_uint8_t * off_thres); + + typedef sw_error_t + (*hsl_port_8023az_set) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable); + + + typedef sw_error_t + (*hsl_port_8023az_get) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable); + + typedef sw_error_t + (*hsl_port_mdix_set) (a_uint32_t dev_id, fal_port_t port_id, + fal_port_mdix_mode_t mode); + + typedef sw_error_t + (*hsl_port_mdix_get) (a_uint32_t dev_id, fal_port_t port_id, + fal_port_mdix_mode_t * mode); + + typedef sw_error_t + (*hsl_port_mdix_status_get) (a_uint32_t dev_id, fal_port_t port_id, + fal_port_mdix_status_t * mode); + + typedef sw_error_t + (*hsl_port_combo_prefer_medium_set) (a_uint32_t dev_id, + fal_port_t port_id, + fal_port_medium_t medium); + + typedef sw_error_t + (*hsl_port_combo_prefer_medium_get) (a_uint32_t dev_id, + fal_port_t port_id, + fal_port_medium_t * medium); + + typedef sw_error_t + (*hsl_port_combo_medium_status_get) (a_uint32_t dev_id, + fal_port_t port_id, + fal_port_medium_t * medium); + + typedef sw_error_t + (*hsl_port_combo_fiber_mode_set) (a_uint32_t dev_id, fal_port_t port_id, + fal_port_fiber_mode_t mode); + + typedef sw_error_t + (*hsl_port_combo_fiber_mode_get) (a_uint32_t dev_id, fal_port_t port_id, + fal_port_fiber_mode_t * mode); + + typedef sw_error_t + (*hsl_port_local_loopback_set) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable); + + typedef sw_error_t + (*hsl_port_local_loopback_get) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable); + + typedef sw_error_t + (*hsl_port_remote_loopback_set) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable); + + typedef sw_error_t + (*hsl_port_remote_loopback_get) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable); + + typedef sw_error_t + (*hsl_port_reset) (a_uint32_t dev_id, fal_port_t port_id); + + typedef sw_error_t + (*hsl_port_power_off) (a_uint32_t dev_id, fal_port_t port_id); + + typedef sw_error_t + (*hsl_port_power_on) (a_uint32_t dev_id, fal_port_t port_id); + + typedef sw_error_t + (*hsl_port_phy_id_get) (a_uint32_t dev_id, fal_port_t port_id,a_uint16_t * org_id, a_uint16_t * rev_id); + + typedef sw_error_t + (*hsl_port_wol_status_set) (a_uint32_t dev_id, fal_port_t port_id,a_bool_t enable); + + typedef sw_error_t + (*hsl_port_wol_status_get) (a_uint32_t dev_id, fal_port_t port_id,a_bool_t *enable); + + typedef sw_error_t + (*hsl_port_magic_frame_mac_set) (a_uint32_t dev_id, fal_port_t port_id,fal_mac_addr_t * mac); + + typedef sw_error_t + (*hsl_port_magic_frame_mac_get) (a_uint32_t dev_id, fal_port_t port_id,fal_mac_addr_t * mac); + + typedef sw_error_t + (*hsl_port_interface_mode_set) (a_uint32_t dev_id, fal_port_t port_id, + fal_port_interface_mode_t mode); + + typedef sw_error_t + (*hsl_port_interface_mode_get) (a_uint32_t dev_id, fal_port_t port_id, + fal_port_interface_mode_t * mode); + typedef sw_error_t + (*hsl_port_interface_mode_apply) (a_uint32_t dev_id); + + typedef sw_error_t + (*hsl_port_interface_mode_status_get) (a_uint32_t dev_id, fal_port_t port_id, + fal_port_interface_mode_t * mode); + typedef sw_error_t + (*hsl_port_counter_set) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable); + typedef sw_error_t + (*hsl_port_counter_get) (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable); + typedef sw_error_t + (*hsl_port_counter_show) (a_uint32_t dev_id, fal_port_t port_id, + fal_port_counter_info_t * counter_info); + + typedef sw_error_t (*hsl_dev_reset) (a_uint32_t dev_id); + + typedef sw_error_t (*hsl_dev_clean) (a_uint32_t dev_id); + + typedef sw_error_t + (*hsl_dev_access_set) (a_uint32_t dev_id, hsl_access_mode mode); +#define REG_FUNC_PROTOTYPE_DEF + typedef sw_error_t + (*hsl_phy_get) (a_uint32_t dev_id, a_uint32_t phy_addr, a_uint32_t reg, + a_uint16_t * value); + + typedef sw_error_t + (*hsl_phy_set) (a_uint32_t dev_id, a_uint32_t phy_addr, a_uint32_t reg, + a_uint16_t value); + + typedef struct + { + /* Port control */ + hsl_port_duplex_set port_duplex_set; + hsl_port_duplex_get port_duplex_get; + hsl_port_speed_set port_speed_set; + hsl_port_speed_get port_speed_get; + hsl_port_autoneg_status_get port_autoneg_status_get; + hsl_port_autoneg_enable port_autoneg_enable; + hsl_port_autoneg_restart port_autoneg_restart; + hsl_port_autoneg_adv_get port_autoneg_adv_get; + hsl_port_autoneg_adv_set port_autoneg_adv_set; + hsl_port_flowctrl_set port_flowctrl_set; + hsl_port_flowctrl_get port_flowctrl_get; + hsl_port_powersave_set port_powersave_set; + hsl_port_powersave_get port_powersave_get; + hsl_port_hibernate_set port_hibernate_set; + hsl_port_hibernate_get port_hibernate_get; + hsl_port_cdt port_cdt; + hsl_port_link_status_get port_link_status_get; + hsl_ports_link_status_get ports_link_status_get; + hsl_port_8023az_set port_8023az_set; + hsl_port_8023az_get port_8023az_get; + hsl_port_mdix_set port_mdix_set; + hsl_port_mdix_get port_mdix_get; + hsl_port_mdix_status_get port_mdix_status_get; + hsl_port_local_loopback_set port_local_loopback_set; + hsl_port_local_loopback_get port_local_loopback_get; + hsl_port_remote_loopback_set port_remote_loopback_set; + hsl_port_remote_loopback_get port_remote_loopback_get; + hsl_port_reset port_reset; + hsl_port_power_off port_power_off; + hsl_port_power_on port_power_on; + hsl_port_phy_id_get port_phy_id_get; + hsl_port_wol_status_set port_wol_status_set; + hsl_port_wol_status_get port_wol_status_get; + hsl_port_magic_frame_mac_set port_magic_frame_mac_set; + hsl_port_magic_frame_mac_get port_magic_frame_mac_get; + hsl_port_interface_mode_status_get port_interface_mode_status_get; + hsl_port_counter_set port_counter_set; + hsl_port_counter_get port_counter_get; + hsl_port_counter_show port_counter_show; + /* REG Access */ + hsl_phy_get phy_get; + hsl_phy_set phy_set; + /*INIT*/ hsl_dev_reset dev_reset; + hsl_dev_clean dev_clean; + hsl_phy_get phy_i2c_get; + hsl_phy_set phy_i2c_set; + } hsl_api_t; + + hsl_api_t *hsl_api_ptr_get (a_uint32_t dev_id); + + sw_error_t hsl_api_init (a_uint32_t dev_id); + +#if defined(SW_API_LOCK) && (!defined(HSL_STANDALONG)) + extern aos_lock_t sw_hsl_api_lock; +#define FAL_API_LOCK aos_lock(&sw_hsl_api_lock) +#define FAL_API_UNLOCK aos_unlock(&sw_hsl_api_lock) +#else +#define FAL_API_LOCK +#define FAL_API_UNLOCK +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _SW_API_H */ diff --git a/qca/src/qca-psdk/drv/include/hsl/hsl_dev.h b/qca/src/qca-psdk/drv/include/hsl/hsl_dev.h new file mode 100644 index 00000000000..41c1846de59 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/hsl/hsl_dev.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2012, 2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef _HSL_DEV_H +#define _HSL_DEV_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "hsl_api.h" +#include "ssdk_init.h" + +#define HSL_DEV_ID_CHECK(dev_id) \ +do { \ + if (dev_id >= SW_MAX_NR_DEV) \ + return SW_OUT_OF_RANGE; \ +} while (0) + +#define HSL_PORT_ID_CHECK(port_id) \ +do { \ + if (port_id >= SW_MAX_NR_PORT) \ + return SW_OUT_OF_RANGE; \ +} while (0) + + typedef struct + { + a_uint32_t dev_id; + a_uint8_t cpu_port_nr; + a_uint8_t nr_ports; + a_uint8_t nr_phy; + a_uint8_t nr_queue; + a_uint16_t nr_vlans; + a_bool_t hw_vlan_query; + hsl_acl_func_t acl_func; + hsl_init_mode cpu_mode; + a_uint32_t wan_bmp; + } hsl_dev_t; + + hsl_dev_t *hsl_dev_ptr_get(a_uint32_t dev_id); + sw_error_t + hsl_dev_init(a_uint32_t dev_id, ssdk_init_cfg * cfg); + + sw_error_t + hsl_dev_cleanup(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _HSL_DEV_H */ diff --git a/qca/src/qca-psdk/drv/include/hsl/hsl_lock.h b/qca/src/qca-psdk/drv/include/hsl/hsl_lock.h new file mode 100755 index 00000000000..db79fd5e05b --- /dev/null +++ b/qca/src/qca-psdk/drv/include/hsl/hsl_lock.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2012, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + + +#ifndef _HSL_LOCK_H_ +#define _HSL_LOCK_H_ + +#ifdef __cplusplus +extern "c" { +#endif + sw_error_t hsl_api_lock_init(void); + + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /*_HSL_LOCK_H_ */ diff --git a/qca/src/qca-psdk/drv/include/hsl/hsl_phy.h b/qca/src/qca-psdk/drv/include/hsl/hsl_phy.h new file mode 100644 index 00000000000..cb43bb291a3 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/hsl/hsl_phy.h @@ -0,0 +1,359 @@ +/* + * Copyright (c) 2015, 2017-2020, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef _HSL_PHY_H_ +#define _HSL_PHY_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "fal.h" +#include + + /** Phy function reset type */ + typedef enum { + PHY_FIFO_RESET = 0, /**< Phy fifo reset */ + } hsl_phy_function_reset_t; + + typedef sw_error_t(*hsl_phy_init) (a_uint32_t dev_id, + a_uint32_t phy_id); + typedef sw_error_t(*hsl_phy_hibernation_set) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_bool_t enable); + typedef sw_error_t(*hsl_phy_hibernation_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_bool_t * enable); + typedef sw_error_t(*hsl_phy_speed_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + fal_port_speed_t * speed); + typedef sw_error_t(*hsl_phy_speed_set) (a_uint32_t dev_id, + a_uint32_t phy_id, + fal_port_speed_t speed); + typedef sw_error_t(*hsl_phy_duplex_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + fal_port_duplex_t * duplex); + typedef sw_error_t(*hsl_phy_duplex_set) (a_uint32_t dev_id, + a_uint32_t phy_id, + fal_port_duplex_t duplex); + typedef sw_error_t(*hsl_phy_autoneg_enable_set) (a_uint32_t dev_id, + a_uint32_t phy_id); + typedef sw_error_t(*hsl_phy_autoneg_enable_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_bool_t * enable); + typedef sw_error_t(*hsl_phy_restart_autoneg) (a_uint32_t dev_id, + a_uint32_t phy_id); + typedef a_bool_t(*hsl_phy_autoneg_status_get) (a_uint32_t dev_id, + a_uint32_t phy_id); + typedef sw_error_t(*hsl_phy_powersave_set) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_bool_t enable); + typedef sw_error_t(*hsl_phy_powersave_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_bool_t * enable); + typedef sw_error_t(*hsl_phy_cdt) (a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t mdi_pair, + fal_cable_status_t * cable_status, + a_uint32_t * cable_len); + typedef a_bool_t(*hsl_phy_link_status_get) (a_uint32_t dev_id, + a_uint32_t phy_id); + typedef sw_error_t(*hsl_phy_get_ability) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_uint32_t * ability); + typedef sw_error_t(*hsl_phy_mdix_set) (a_uint32_t dev_id, + a_uint32_t phy_id, + fal_port_mdix_mode_t mode); + typedef sw_error_t(*hsl_phy_mdix_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + fal_port_mdix_mode_t * mode); + typedef sw_error_t(*hsl_phy_mdix_status_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + fal_port_mdix_status_t * + mode); + typedef sw_error_t(*hsl_phy_8023az_set) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_bool_t enable); + typedef sw_error_t(*hsl_phy_8023az_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_bool_t * enable); + typedef sw_error_t(*hsl_phy_local_loopback_set) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_bool_t enable); + typedef sw_error_t(*hsl_phy_local_loopback_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_bool_t * enable); + typedef sw_error_t(*hsl_phy_remote_loopback_set) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_bool_t enable); + typedef sw_error_t(*hsl_phy_remote_loopback_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_bool_t * enable); + typedef sw_error_t(*hsl_phy_master_set) (a_uint32_t dev_id, + a_uint32_t phy_id, + fal_port_master_t master); + typedef sw_error_t(*hsl_phy_master_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + fal_port_master_t * master); + typedef sw_error_t(*hsl_phy_reset) (a_uint32_t dev_id, + a_uint32_t phy_id); + typedef sw_error_t(*hsl_phy_reset_status_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + fal_port_reset_status_t * + status); + typedef sw_error_t(*hsl_phy_power_off) (a_uint32_t dev_id, + a_uint32_t phy_id); + typedef sw_error_t(*hsl_phy_power_on) (a_uint32_t dev_id, + a_uint32_t phy_id); + typedef sw_error_t(*hsl_phy_id_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_uint32_t *phy_chip_id); + typedef sw_error_t(*hsl_phy_autoneg_adv_set) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_uint32_t autoneg); + typedef sw_error_t(*hsl_phy_autoneg_adv_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_uint32_t * autoneg); + typedef sw_error_t(*hsl_phy_reg_write) (a_uint32_t dev_id, + a_uint32_t phy_addr, + a_uint32_t reg, + a_uint16_t reg_val); + typedef a_uint16_t(*hsl_phy_reg_read) (a_uint32_t dev_id, + a_uint32_t phy_addr, + a_uint32_t reg); + typedef sw_error_t(*hsl_phy_debug_write) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_uint16_t reg_id, + a_uint16_t reg_val); + typedef a_uint16_t(*hsl_phy_debug_read) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_uint16_t reg_id); + typedef sw_error_t(*hsl_phy_mmd_write) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_uint16_t mmd_num, + a_uint16_t reg_id, + a_uint16_t reg_val); + typedef a_uint16_t(*hsl_phy_mmd_read) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_uint16_t mmd_num, + a_uint16_t reg_id); + + typedef sw_error_t(*hsl_phy_magic_frame_mac_set) (a_uint32_t dev_id, + a_uint32_t phy_id, + fal_mac_addr_t * mac); + + typedef sw_error_t(*hsl_phy_magic_frame_mac_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + fal_mac_addr_t * mac); + typedef sw_error_t(*hsl_phy_wol_status_set) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_bool_t enable); + typedef sw_error_t(*hsl_phy_wol_status_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_bool_t * enable); + typedef sw_error_t(*hsl_phy_interface_mode_set) (a_uint32_t dev_id, + a_uint32_t phy_id, + fal_port_interface_mode_t + interface_mode); + typedef sw_error_t(*hsl_phy_interface_mode_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + fal_port_interface_mode_t + * interface_mode); + typedef sw_error_t(*hsl_phy_interface_mode_status_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + fal_port_interface_mode_t + * interface_mode); + typedef sw_error_t(*hsl_phy_intr_mask_set) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_uint32_t mask); + typedef sw_error_t(*hsl_phy_intr_mask_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_uint32_t * mask); + typedef sw_error_t(*hsl_phy_intr_status_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_uint32_t * status); + typedef sw_error_t(*hsl_phy_counter_set) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_bool_t enable); + typedef sw_error_t(*hsl_phy_counter_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_bool_t * enable); + typedef sw_error_t(*hsl_phy_counter_show) (a_uint32_t dev_id, + a_uint32_t phy_id, + fal_port_counter_info_t * counter_info); + typedef sw_error_t(*hsl_phy_serdes_reset) (a_uint32_t dev_id); + + typedef sw_error_t(*hsl_phy_get_status) (a_uint32_t dev_id, + a_uint32_t phy_id, struct port_phy_status *phy_status); + + typedef sw_error_t(*hsl_phy_eee_adv_set) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_uint32_t adv); + typedef sw_error_t(*hsl_phy_eee_adv_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_uint32_t * adv); + typedef sw_error_t(*hsl_phy_eee_partner_adv_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_uint32_t * adv); + typedef sw_error_t(*hsl_phy_eee_cap_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_uint32_t * cap); + typedef sw_error_t(*hsl_phy_eee_status_get) (a_uint32_t dev_id, + a_uint32_t phy_id, + a_uint32_t * status); + typedef struct hsl_phy_ops_s { + + hsl_phy_init phy_init; + hsl_phy_hibernation_set phy_hibernation_set; + hsl_phy_hibernation_get phy_hibernation_get; + hsl_phy_speed_get phy_speed_get; + hsl_phy_speed_set phy_speed_set; + hsl_phy_duplex_get phy_duplex_get; + hsl_phy_duplex_set phy_duplex_set; + hsl_phy_autoneg_enable_set phy_autoneg_enable_set; + hsl_phy_autoneg_enable_get phy_autoneg_enable_get; + hsl_phy_restart_autoneg phy_restart_autoneg; + hsl_phy_autoneg_status_get phy_autoneg_status_get; + hsl_phy_autoneg_adv_set phy_autoneg_adv_set; + hsl_phy_autoneg_adv_get phy_autoneg_adv_get; + hsl_phy_powersave_set phy_powersave_set; + hsl_phy_powersave_get phy_powersave_get; + hsl_phy_cdt phy_cdt; + hsl_phy_link_status_get phy_link_status_get; + hsl_phy_get_ability phy_get_ability; + hsl_phy_mdix_set phy_mdix_set; + hsl_phy_mdix_get phy_mdix_get; + hsl_phy_mdix_status_get phy_mdix_status_get; + hsl_phy_8023az_set phy_8023az_set; + hsl_phy_8023az_get phy_8023az_get; + hsl_phy_local_loopback_set phy_local_loopback_set; + hsl_phy_local_loopback_get phy_local_loopback_get; + hsl_phy_remote_loopback_set phy_remote_loopback_set; + hsl_phy_remote_loopback_get phy_remote_loopback_get; + hsl_phy_master_set phy_master_set; + hsl_phy_master_get phy_master_get; + hsl_phy_reset phy_reset; + hsl_phy_power_off phy_power_off; + hsl_phy_power_on phy_power_on; + hsl_phy_reset_status_get phy_reset_status_get; + hsl_phy_id_get phy_id_get; + hsl_phy_reg_write phy_reg_write; + hsl_phy_reg_read phy_reg_read; + hsl_phy_debug_write phy_debug_write; + hsl_phy_debug_read phy_debug_read; + hsl_phy_mmd_write phy_mmd_write; + hsl_phy_mmd_read phy_mmd_read; + hsl_phy_magic_frame_mac_set phy_magic_frame_mac_set; + hsl_phy_magic_frame_mac_get phy_magic_frame_mac_get; + hsl_phy_wol_status_set phy_wol_status_set; + hsl_phy_wol_status_get phy_wol_status_get; + hsl_phy_interface_mode_set phy_interface_mode_set; + hsl_phy_interface_mode_get phy_interface_mode_get; + hsl_phy_interface_mode_status_get phy_interface_mode_status_get; + hsl_phy_intr_mask_set phy_intr_mask_set; + hsl_phy_intr_mask_get phy_intr_mask_get; + hsl_phy_intr_status_get phy_intr_status_get; + hsl_phy_counter_set phy_counter_set; + hsl_phy_counter_get phy_counter_get; + hsl_phy_counter_show phy_counter_show; + hsl_phy_serdes_reset phy_serdes_reset; + hsl_phy_get_status phy_get_status; + hsl_phy_eee_adv_set phy_eee_adv_set; + hsl_phy_eee_adv_get phy_eee_adv_get; + hsl_phy_eee_partner_adv_get phy_eee_partner_adv_get; + hsl_phy_eee_cap_get phy_eee_cap_get; + hsl_phy_eee_status_get phy_eee_status_get; + } hsl_phy_ops_t; + +typedef struct phy_driver_instance { + a_uint32_t phy_type; + a_uint32_t port_bmp[SW_MAX_NR_DEV]; + hsl_phy_ops_t *phy_ops; + int (*init)(a_uint32_t dev_id, a_uint32_t portbmp); + void (*exit)(a_uint32_t dev_id, a_uint32_t portbmp); +} phy_driver_instance_t; + +typedef enum +{ + QCA808X_PHY_CHIP, + MAX_PHY_CHIP, +} phy_type_t; + +typedef struct { + a_uint32_t phy_address[SW_MAX_NR_PORT]; + a_uint32_t phy_type[SW_MAX_NR_PORT]; + /* fake mdio address is used to register the phy device, + * when the phy is not accessed by the MDIO bus. + * */ + a_uint32_t phy_mdio_fake_address[SW_MAX_NR_PORT]; + a_uint8_t phy_access_type[SW_MAX_NR_PORT]; + a_bool_t phy_c45[SW_MAX_NR_PORT]; + a_bool_t phy_combo[SW_MAX_NR_PORT]; + a_uint32_t phy_reset_gpio[SW_MAX_NR_PORT]; +} phy_info_t; +#define QCA8081_PHY_V1_1 0x004DD101 +#define INVALID_PHY_ID 0 + +#define SFP_PHY 0xaaaabbbb +#define PHY_MDIO_ACCESS 0 +#define PHY_I2C_ACCESS 1 + +#define INVALID_PHY_ADDR 0xff +#define MAX_PHY_ADDR 0x1f +#define QCA8072_PHY_NUM 0x2 + +#define PHY_INVALID_DATA 0xffff + +#define PHY_RTN_ON_READ_ERROR(phy_data) \ + do { if (phy_data == PHY_INVALID_DATA) return(SW_READ_ERROR); } while(0); + +#define PHY_RTN_ON_ERROR(rv) \ + do { if (rv != SW_OK) return(rv); } while(0); + +sw_error_t +hsl_phy_api_ops_register(phy_type_t phy_type, hsl_phy_ops_t * phy_api_ops); + +sw_error_t +hsl_phy_api_ops_unregister(phy_type_t phy_type, hsl_phy_ops_t * phy_api_ops); + +hsl_phy_ops_t *hsl_phy_api_ops_get(a_uint32_t dev_id, a_uint32_t port_id); + +sw_error_t phy_api_ops_init(phy_type_t phy_type); + +int ssdk_phy_driver_init(a_uint32_t dev_id, ssdk_init_cfg *cfg); + +int qca_ssdk_phy_info_init(a_uint32_t dev_id); + +void qca_ssdk_port_bmp_init(a_uint32_t dev_id); +a_uint32_t +hsl_phyid_get(a_uint32_t dev_id, a_uint32_t port_id, ssdk_init_cfg *cfg); + +a_uint32_t +qca_ssdk_port_to_phy_addr(a_uint32_t dev_id, a_uint32_t port_id); +void qca_ssdk_port_bmp_set(a_uint32_t dev_id, a_uint32_t value); + +a_uint32_t qca_ssdk_port_bmp_get(a_uint32_t dev_id); +a_uint32_t +qca_ssdk_phy_addr_to_port(a_uint32_t dev_id, a_uint32_t phy_addr); +a_uint8_t +hsl_port_phy_access_type_get(a_uint32_t dev_id, a_uint32_t port_id); + +void +hsl_port_phy_access_type_set(a_uint32_t dev_id, a_uint32_t port_id, + a_uint8_t access_type); +sw_error_t ssdk_phy_driver_cleanup(void); +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _HSL_PHY_H_ */ diff --git a/qca/src/qca-psdk/drv/include/hsl/hsl_port_prop.h b/qca/src/qca-psdk/drv/include/hsl/hsl_port_prop.h new file mode 100755 index 00000000000..9b2c419d866 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/hsl/hsl_port_prop.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2012, 2017, 2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + + +#ifndef _HSL_PORT_PROPERTY_H_ +#define _HSL_PORT_PROPERTY_H_ + +#ifdef __cplusplus +extern "c" { +#endif + + typedef enum { + HSL_PP_PHY = 0, /* setting concerning phy */ + HSL_PP_INCL_CPU, /* setting may include cpu port */ + HSL_PP_EXCL_CPU, /* setting exclude cpu port */ + HSL_PP_INNER, /* setting inner ports */ + HSL_PP_CPU, /* setting cpu ports */ + HSL_PP_BUTT + } + hsl_port_prop_t; + + a_bool_t + hsl_port_prop_check(a_uint32_t dev_id, fal_port_t port_id, + hsl_port_prop_t p_type); + + a_bool_t + hsl_mports_prop_check(a_uint32_t dev_id, fal_pbmp_t port_bitmap, + hsl_port_prop_t p_type); + a_bool_t + hsl_port_validity_check(a_uint32_t dev_id, fal_port_t port_id); + + a_bool_t + hsl_mports_validity_check(a_uint32_t dev_id, fal_pbmp_t port_bitmap); + + sw_error_t + hsl_port_prop_portmap_get(a_uint32_t dev_id, fal_pbmp_t port_bitmap); + + sw_error_t + hsl_port_prop_set(a_uint32_t dev_id, fal_port_t port_id, + hsl_port_prop_t p_type); + + sw_error_t + hsl_port_prop_portmap_set(a_uint32_t dev_id, fal_port_t port_id); + + sw_error_t + hsl_port_prop_clr(a_uint32_t dev_id, fal_port_t port_id, + hsl_port_prop_t p_type); + + sw_error_t + hsl_port_prop_get_phyid(a_uint32_t dev_id, fal_port_t port_id, + a_uint32_t *phy_id); + + sw_error_t + hsl_port_prop_set_phyid(a_uint32_t dev_id, fal_port_t port_id, + a_uint32_t phy_id); + + sw_error_t + hsl_port_prop_init_by_dev(a_uint32_t dev_id); + + sw_error_t + hsl_port_prop_cleanup_by_dev(a_uint32_t dev_id); + + sw_error_t + hsl_port_prop_init(a_uint32_t dev_id); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /*_HSL_PORT_PROPERTY_H_ */ diff --git a/qca/src/qca-psdk/drv/include/hsl/qca808x_phy.h b/qca/src/qca-psdk/drv/include/hsl/qca808x_phy.h new file mode 100644 index 00000000000..395daec24f3 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/hsl/qca808x_phy.h @@ -0,0 +1,623 @@ +/* + * Copyright (c) 2018, 2020, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _QCA808X_PHY_H_ +#define _QCA808X_PHY_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#define QCA808X_MII_ADDR_C45 (1<<30) +#define QCA808X_REG_C45_ADDRESS(dev_type, reg_num) (QCA808X_MII_ADDR_C45 | \ + ((dev_type & 0x1f) << 16) | (reg_num & 0xffff)) + +#define QCA808X_COMMON_CTRL 0x1040 + +#define QCA808X_PHY_MMD1_PMA_CONTROL 0x0 +#define QCA808X_PMA_CONTROL_SPEED_MASK 0x2040 +#define QCA808X_PMA_CONTROL_2500M 0x2040 +#define QCA808X_PMA_CONTROL_1000M 0x40 +#define QCA808X_PMA_CONTROL_100M 0x2000 +#define QCA808X_PMA_CONTROL_10M 0x0 + +#define QCA808X_PHY_MMD1_PMA_TYPE 0x7 +#define QCA808X_PMA_TYPE_MASK 0x3f +#define QCA808X_PMA_TYPE_2500M 0x30 +#define QCA808X_PMA_TYPE_1000M 0xc +#define QCA808X_PMA_TYPE_100M 0xe +#define QCA808X_PMA_TYPE_10M 0xf + + /* PHY Registers */ +#define QCA808X_PHY_CONTROL 0 +#define QCA808X_PHY_STATUS 1 +#define QCA808X_PHY_SPEC_STATUS 17 + +#define QCA808X_PHY_ID1 2 +#define QCA808X_PHY_ID2 3 +#define QCA808X_AUTONEG_ADVERT 4 +#define QCA808X_LINK_PARTNER_ABILITY 5 +#define QCA808X_1000BASET_CONTROL 9 +#define QCA808X_1000BASET_STATUS 10 +#define QCA808X_MMD_CTRL_REG 13 +#define QCA808X_MMD_DATA_REG 14 +#define QCA808X_EXTENDED_STATUS 15 +#define QCA808X_PHY_SPEC_CONTROL 16 +#define QCA808X_PHY_INTR_MASK 18 +#define QCA808X_PHY_INTR_STATUS 19 +#define QCA808X_PHY_CDT_CONTROL 22 +#define QCA808X_DEBUG_PORT_ADDRESS 29 +#define QCA808X_DEBUG_PORT_DATA 30 +#define QCA808X_DEBUG_LOCAL_SEED 9 + +/* Chip Configuration Register */ +#define QCA808X_PHY_CHIP_CONFIG 31 + +#define QCA808X_PHY_MODE_MASK 0x6000 +#define QCA808X_PHY_SGMII_MODE 0x0000 +#define QCA808X_PHY_SGMII_PLUS_MODE 0x2000 +#define QCA808X_PHY_SGMII_BASET 0x4 +#define QCA808X_PHY_CHIP_MODE_CFG 0xf + +#define QCA808X_DEBUG_PHY_HIBERNATION_CTRL 0xb +#define QCA808X_DEBUG_PHY_HIBERNATION_STAT 0xc +#define QCA808X_DEBUG_PHY_POWER_SAVING_CTRL 0x29 +#define QCA808X_PHY_MMD7_ADDR_8023AZ_EEE_CTRL 0x3c +#define QCA808X_PHY_MMD7_ADDR_8023AZ_EEE_PARTNER 0x3d +#define QCA808X_PHY_MMD7_ADDR_8023AZ_EEE_STATUS 0x8000 +#define QCA808X_PHY_MMD3_ADDR_8023AZ_EEE_CAPABILITY 0x14 +#define QCA808X_PHY_MMD7_ADDR_EEE_LP_ADVERTISEMENT 0x40 + +#define QCA808X_PHY_MMD3_ADDR_8023AZ_EEE_DB 0x800f +#define QCA808X_PHY_8023AZ_EEE_LP_STAT 0x2000 +#define QCA808X_PHY_MMD3_ADDR_REMOTE_LOOPBACK_CTRL 0x805a +#define QCA808X_PHY_MMD3_WOL_MAGIC_MAC_CTRL1 0x804a +#define QCA808X_PHY_MMD3_WOL_MAGIC_MAC_CTRL2 0x804b +#define QCA808X_PHY_MMD3_WOL_MAGIC_MAC_CTRL3 0x804c +#define QCA808X_PHY_MMD3_WOL_CTRL 0x8012 +#define QCA808X_PHY_MMD3_ADDR_8023AZ_TIMER_CTRL 0x804e +#define QCA808X_PHY_MMD3_ADDR_CLD_CTRL7 0x8007 +#define QCA808X_PHY_MMD3_ADDR_CLD_CTRL5 0x8005 +#define QCA808X_PHY_MMD3_ADDR_CLD_CTRL3 0x8003 +#define QCA808X_PHY_MMD3_AZ_TRAINING_CTRL 0x8008 + +#define QCA808X_PHY_HIBERNATION_CFG 0x8000 +#define QCA808X_PHY_HIBERNATION_STAT_EN 0x0800 + +#define QCA808X_PHY_WOL_EN 0x0020 + +#define QCA808X_PHY_REMOTE_LOOPBACK_EN 0x0001 + +#define QCA808X_PHY_8023AZ_EEE_1000BT 0x0004 +#define QCA808X_PHY_8023AZ_EEE_100BT 0x0002 +#define QCA808X_PHY_MMD3_AZ_TRAINING_VAL 0x1c32 + +#define QCA808X_PHY_MDIX 0x0020 +#define QCA808X_PHY_MDIX_AUTO 0x0060 +#define QCA808X_PHY_MDIX_STATUS 0x0040 + +#define QCA808X_PHY_MMD7_NUM 7 +#define QCA808X_PHY_MMD3_NUM 3 +#define QCA808X_PHY_MMD1_NUM 1 + +#define QCA808X_PHY_MMD1_FAST_RETRAIN_STATUS_CTL 0x93 +#define QCA808X_PHY_MMD1_MSE_THRESHOLD_20DB 0x8014 +#define QCA808X_PHY_MMD1_MSE_THRESHOLD_17DB 0x800E +#define QCA808X_PHY_MMD1_MSE_THRESHOLD_27DB 0x801E +#define QCA808X_PHY_MMD1_MSE_THRESHOLD_28DB 0x8020 +#define QCA808X_PHY_MMD7_TOP_OPTION1 0x901c +#define QCA808X_PHY_EEE_ADV_100M 0x0002 +#define QCA808X_PHY_EEE_ADV_1000M 0x0004 +#define QCA808X_PHY_EEE_PARTNER_ADV_100M 0x0002 +#define QCA808X_PHY_EEE_PARTNER_ADV_1000M 0x0004 +#define QCA808X_PHY_EEE_CAPABILITY_100M 0x0002 +#define QCA808X_PHY_EEE_CAPABILITY_1000M 0x0004 +#define QCA808X_PHY_EEE_STATUS_100M 0x0002 +#define QCA808X_PHY_EEE_STATUS_1000M 0x0004 + +#define QCA808X_PHY_FAST_RETRAIN_CTRL 0x1 +#define QCA808X_PHY_MSE_THRESHOLD_20DB_VALUE 0x529 +#define QCA808X_PHY_MSE_THRESHOLD_17DB_VALUE 0x341 +#define QCA808X_PHY_MSE_THRESHOLD_27DB_VALUE 0x419 +#define QCA808X_PHY_MSE_THRESHOLD_28DB_VALUE 0x341 +#define QCA808X_PHY_FAST_RETRAIN_2500BT 0x20 +#define QCA808X_PHY_ADV_LOOP_TIMING 0x1 +#define QCA808X_PHY_EEE_ADV_THP 0x8 +#define QCA808X_PHY_TOP_OPTION1_DATA 0x0 + + /* CDT */ +#define QCA808X_MDI_PAIR_NUM 4 +#define QCA808X_RUN_CDT 0x8000 +#define QCA808X_CABLE_LENGTH_UNIT 0x0400 +#define QCA808X_PHY_CDT_STATUS 0X8064 +#define QCA808X_PHY_CDT_DIAG_PAIR0 0X8065 +#define QCA808X_PHY_CDT_DIAG_PAIR1 0X8066 +#define QCA808X_PHY_CDT_DIAG_PAIR2 0X8067 +#define QCA808X_PHY_CDT_DIAG_PAIR3 0X8068 + + /* SYNCE CLOCK OUTPUT */ +#define QCA808X_DEBUG_ANA_CLOCK_CTRL_REG 0x3e80 +#define QCA808X_ANALOG_PHY_SYNCE_CLOCK_EN 0x20 + +#define QCA808X_MMD7_CLOCK_CTRL_REG 0x8072 +#define QCA808X_DIGITAL_PHY_SYNCE_CLOCK_EN 0x1 + + /* PHY Registers Field */ +#define QCA808X_STATUS_LINK_PASS 0x0400 + + /* Control Register fields offset:0 */ + /* bits 6,13: 10=1000, 01=100, 00=10 */ +#define QCA808X_CTRL_SPEED_MSB 0x0040 + + /* Collision test enable */ +#define QCA808X_CTRL_COLL_TEST_ENABLE 0x0080 +/* FDX =1, half duplex =0 */ +#define QCA808X_CTRL_FULL_DUPLEX 0x0100 + + /* Restart auto negotiation */ +#define QCA808X_CTRL_RESTART_AUTONEGOTIATION 0x0200 + + /* Power down */ +#define QCA808X_CTRL_POWER_DOWN 0x0800 + + /* Auto Neg Enable */ +#define QCA808X_CTRL_AUTONEGOTIATION_ENABLE 0x1000 + + /* Local Loopback Enable */ +#define QCA808X_LOCAL_LOOPBACK_ENABLE 0x4000 + + /* bits 6,13: 10=1000, 01=100, 00=10 */ +#define QCA808X_CTRL_SPEED_LSB 0x2000 + + /* 0 = normal, 1 = loopback */ +#define QCA808X_CTRL_LOOPBACK 0x4000 +#define QCA808X_CTRL_SOFTWARE_RESET 0x8000 + +#define QCA808X_PHY_MMD7_AUTONEGOTIATION_CONTROL 0x20 + +#define QCA808X_CTRL_SPEED_MASK 0x2040 +#define QCA808X_CTRL_SPEED_1000 0x0040 +#define QCA808X_CTRL_SPEED_100 0x2000 +#define QCA808X_CTRL_SPEED_10 0x0000 + +#define QCA808X_MASTER_SLAVE_SEED_ENABLE 0x2 +#define QCA808X_MASTER_SLAVE_SEED_CFG 0x1FFC +#define QCA808X_MASTER_SLAVE_SEED_RANGE 0x32 +#define QCA808X_MASTER_SLAVE_CONFIG_FAULT 0x8000 + +#define QCA808X_RESET_DONE(phy_control) \ + (((phy_control) & (QCA808X_CTRL_SOFTWARE_RESET)) == 0) + + /* Status Register fields offset:1 */ +#define QCA808X_STATUS_EXTENDED_CAPS 0x0001 + + /* Jabber Detected */ +#define QCA808X_STATUS_JABBER_DETECT 0x0002 + + /* Link Status 1 = link */ +#define QCA808X_STATUS_LINK_STATUS_UP 0x0004 + + /* Auto Neg Capable */ +#define QCA808X_STATUS_AUTONEG_CAPS 0x0008 + + /* Remote Fault Detect */ +#define QCA808X_STATUS_REMOTE_FAULT 0x0010 + + /* Auto Neg Complete */ +#define QCA808X_STATUS_AUTO_NEG_DONE 0x0020 + + /* Preamble may be suppressed */ +#define QCA808X_STATUS_PREAMBLE_SUPPRESS 0x0040 + + /* Ext. status info in Reg 0x0F */ +#define QCA808X_STATUS_EXTENDED_STATUS 0x0100 + + /* 100T2 Half Duplex Capable */ +#define QCA808X_STATUS_100T2_HD_CAPS 0x0200 + + /* 100T2 Full Duplex Capable */ +#define QCA808X_STATUS_100T2_FD_CAPS 0x0400 + + /* 10T Half Duplex Capable */ +#define QCA808X_STATUS_10T_HD_CAPS 0x0800 + + /* 10T Full Duplex Capable */ +#define QCA808X_STATUS_10T_FD_CAPS 0x1000 + + /* 100TX Half Duplex Capable */ +#define QCA808X_STATUS_100TX_HD_CAPS 0x2000 + + /* 100TX Full Duplex Capable */ +#define QCA808X_STATUS_100TX_FD_CAPS 0x4000 + + /* 100T4 Capable */ +#define QCA808X_STATUS_100T4_CAPS 0x8000 + + /* extended status register capabilities */ + +#define QCA808X_STATUS_1000T_HD_CAPS 0x1000 + +#define QCA808X_STATUS_1000T_FD_CAPS 0x2000 + +#define QCA808X_STATUS_1000X_HD_CAPS 0x4000 + +#define QCA808X_STATUS_1000X_FD_CAPS 0x8000 + +#define QCA808X_MMD1_PMA_CAP_REG 0x4 + /* MMD1 2500T capabilities */ +#define QCA808X_STATUS_2500T_FD_CAPS 0x2000 + + /* Link Partner ability offset:5 */ +#define QCA808X_LINK_SLCT 0x001f + + /* Can do 10mbps half-duplex */ +#define QCA808X_LINK_10BASETX_HALF_DUPLEX 0x0020 + + /* Can do 10mbps full-duplex */ +#define QCA808X_LINK_10BASETX_FULL_DUPLEX 0x0040 + + /* Can do 100mbps half-duplex */ +#define QCA808X_LINK_100BASETX_HALF_DUPLEX 0x0080 + + /* Can do 100mbps full-duplex */ +#define QCA808X_LINK_100BASETX_FULL_DUPLEX 0x0100 + + /* Can do 1000mbps full-duplex */ +#define QCA808X_LINK_1000BASETX_FULL_DUPLEX 0x0800 + + /* Can do 1000mbps half-duplex */ +#define QCA808X_LINK_1000BASETX_HALF_DUPLEX 0x0400 + + /* Can do 2500mbps full-duplex */ +#define QCA808X_LINK_2500BASETX_FULL_DUPLEX 0x0020 + + /* 100BASE-T4 */ +#define QCA808X_LINK_100BASE4 0x0200 + + /* PAUSE */ +#define QCA808X_LINK_PAUSE 0x0400 + + /* Asymmetrical PAUSE */ +#define QCA808X_LINK_ASYPAUSE 0x0800 + + /* Link partner faulted */ +#define QCA808X_LINK_RFAULT 0x2000 + + /* Link partner acked us */ +#define QCA808X_LINK_LPACK 0x4000 + + /* Next page bit */ +#define QCA808X_LINK_NPAGE 0x8000 + + /* Auto Neg Complete */ +#define QCA808X_STATUS_AUTO_NEG_DONE 0x0020 +#define QCA808X_AUTONEG_DONE(ip_phy_status) \ + (((ip_phy_status) & (QCA808X_STATUS_AUTO_NEG_DONE)) == \ + (QCA808X_STATUS_AUTO_NEG_DONE)) + +#define QCA808X_STATUS_RESOVLED 0x0800 +#define QCA808X_SPEED_DUPLEX_RESOVLED(phy_status) \ + (((phy_status) & \ + (QCA808X_STATUS_RESOVLED)) == \ + (QCA808X_STATUS_RESOVLED)) + + /* Auto-Negotiation Advertisement register. offset:4 */ +#define QCA808X_ADVERTISE_SELECTOR_FIELD 0x0001 + + /* 10T Half Duplex Capable */ +#define QCA808X_ADVERTISE_10HALF 0x0020 + + /* 10T Full Duplex Capable */ +#define QCA808X_ADVERTISE_10FULL 0x0040 + + /* 100TX Half Duplex Capable */ +#define QCA808X_ADVERTISE_100HALF 0x0080 + + /* 100TX Full Duplex Capable */ +#define QCA808X_ADVERTISE_100FULL 0x0100 + + /* 100T4 Capable */ +#define QCA808X_ADVERTISE_100T4 0x0200 + + /* Pause operation desired */ +#define QCA808X_ADVERTISE_PAUSE 0x0400 + + /* Asymmetric Pause Direction bit */ +#define QCA808X_ADVERTISE_ASYM_PAUSE 0x0800 + + /* Remote Fault detected */ +#define QCA808X_ADVERTISE_REMOTE_FAULT 0x2000 + + /* 1000TX Half Duplex Capable */ +#define QCA808X_ADVERTISE_1000HALF 0x0100 + + /* 1000TX Full Duplex Capable */ +#define QCA808X_ADVERTISE_1000FULL 0x0200 + + /* 2500TX Full Duplex Capable */ +#define QCA808X_ADVERTISE_2500FULL 0x80 + +#define QCA808X_ADVERTISE_ALL \ + (QCA808X_ADVERTISE_10HALF | QCA808X_ADVERTISE_10FULL | \ + QCA808X_ADVERTISE_100HALF | QCA808X_ADVERTISE_100FULL | \ + QCA808X_ADVERTISE_1000FULL) + +#define QCA808X_ADVERTISE_MEGA_ALL \ + (QCA808X_ADVERTISE_10HALF | QCA808X_ADVERTISE_10FULL | \ + QCA808X_ADVERTISE_100HALF | QCA808X_ADVERTISE_100FULL | \ + QCA808X_ADVERTISE_PAUSE | QCA808X_ADVERTISE_ASYM_PAUSE) + +#define QCA808X_BX_ADVERTISE_1000FULL 0x0020 +#define QCA808X_BX_ADVERTISE_1000HALF 0x0040 +#define QCA808X_BX_ADVERTISE_PAUSE 0x0080 +#define QCA808X_BX_ADVERTISE_ASYM_PAUSE 0x0100 + +#define QCA808X_BX_ADVERTISE_ALL \ + (QCA808X_BX_ADVERTISE_ASYM_PAUSE | QCA808X_BX_ADVERTISE_PAUSE | \ + QCA808X_BX_ADVERTISE_1000HALF | QCA808X_BX_ADVERTISE_1000FULL) + + /* 1=Duplex 0=Half Duplex */ +#define QCA808X_STATUS_FULL_DUPLEX 0x2000 +#define QCA808X_PHY_RX_FLOWCTRL_STATUS 0x4 +#define QCA808X_PHY_TX_FLOWCTRL_STATUS 0x8 + + /* Speed, bits 9:7 */ +#define QCA808X_STATUS_SPEED_MASK 0x380 + + /* 000=10Mbs */ +#define QCA808X_STATUS_SPEED_10MBS 0x0000 + + /* 001=100Mbs */ +#define QCA808X_STATUS_SPEED_100MBS 0x80 + + /* 010=1000Mbs */ +#define QCA808X_STATUS_SPEED_1000MBS 0x100 + + /* 100=2500Mbs */ +#define QCA808X_STATUS_SPEED_2500MBS 0x200 + + /*QCA808X interrupt flag */ +#define QCA808X_INTR_FAST_LINK_DOWN 0x8000 +#define QCA808X_INTR_SPEED_CHANGE 0x4000 +#define QCA808X_INTR_SEC_ENA_CHANGE 0x2000 +#define QCA808X_INTR_STATUS_DOWN_CHANGE 0x0800 +#define QCA808X_INTR_STATUS_UP_CHANGE 0x0400 +#define QCA808X_INTR_FAST_LINK_DOWN_MASK 0x240 +#define QCA808X_INTR_FAST_LINK_DOWN_STAT_10M 0x40 +#define QCA808X_INTR_FAST_LINK_DOWN_STAT_100M 0x200 +#define QCA808X_INTR_FAST_LINK_DOWN_STAT_1000M 0x240 +#define QCA808X_INTR_LINK_FAIL_SG 0x0100 +#define QCA808X_INTR_LINK_SUCCESS_SG 0x0080 +#define QCA808X_INTR_DOWNSHIF 0x0020 +#define QCA808X_INTR_10MS_PTP 0x0010 +#define QCA808X_INTR_RX_PTP 0x0008 +#define QCA808X_INTR_TX_PTP 0x0004 +#define QCA808X_INTR_POE 0x0002 +#define QCA808X_INTR_WOL 0x0001 + + /* QCA808X counter */ +#define QCA808X_PHY_MMD7_COUNTER_CTRL 0x8029 +#define QCA808X_PHY_MMD7_INGRESS_COUNTER_HIGH 0x802a +#define QCA808X_PHY_MMD7_INGRESS_COUNTER_LOW 0x802b +#define QCA808X_PHY_MMD7_INGRESS_ERROR_COUNTER 0x802c +#define QCA808X_PHY_MMD7_EGRESS_COUNTER_HIGH 0x802d +#define QCA808X_PHY_MMD7_EGRESS_COUNTER_LOW 0x802e +#define QCA808X_PHY_MMD7_EGRESS_ERROR_COUNTER 0x802f +#define QCA808X_PHY_MMD7_LED_POLARITY_CTRL 0x901a +#define QCA808X_PHY_MMD7_LED0_CTRL 0x8078 +#define QCA808X_PHY_MMD7_LED1_CTRL 0x8074 +#define QCA808X_PHY_MMD7_LED2_CTRL 0x8076 +#define QCA808X_PHY_MMD7_LED_POLARITY_ACTIVE_HIGH 0x46 +#define QCA808X_PHY_MMD7_LED0_CTRL_ENABLE 0x8670 +#define QCA808X_PHY_MMD7_LED1_CTRL_DISABLE 0x0 +#define QCA808X_PHY_MMD7_LED2_CTRL_DISABLE 0x0 + +#define QCA808X_PHY_FRAME_CHECK_EN 0x0001 +#define QCA808X_PHY_XMIT_MAC_CNT_SELFCLR 0x0002 +a_uint16_t +qca808x_phy_reg_read(a_uint32_t dev_id, a_uint32_t phy_id, a_uint32_t reg_id); + +sw_error_t +qca808x_phy_reg_write(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t reg_id, a_uint16_t reg_val); + +sw_error_t +qca808x_phy_mmd_write(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint16_t mmd_num, a_uint16_t reg_id, + a_uint16_t reg_val); + +a_uint16_t +qca808x_phy_mmd_read(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint16_t mmd_num, a_uint16_t reg_id); + +a_uint16_t +qca808x_phy_reg_read(a_uint32_t dev_id, a_uint32_t phy_id, a_uint32_t reg_id); + +sw_error_t +qca808x_phy_reg_write(a_uint32_t dev_id, a_uint32_t phy_id, a_uint32_t +reg_id, a_uint16_t reg_val); + +sw_error_t +qca808x_phy_debug_write(a_uint32_t dev_id, a_uint32_t phy_id, a_uint16_t reg_id, + a_uint16_t reg_val); +a_uint16_t +qca808x_phy_debug_read(a_uint32_t dev_id, a_uint32_t phy_id, a_uint16_t reg_id); + +sw_error_t +qca808x_phy_mmd_write(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint16_t mmd_num, a_uint16_t reg_id, a_uint16_t +reg_val); + +a_uint16_t +qca808x_phy_mmd_read(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint16_t mmd_num, a_uint16_t reg_id); + +#define QCA808X_PHY_8023AZ_AFE_CTRL_MASK 0x01f0 +#define QCA808X_PHY_8023AZ_AFE_EN 0x0090 + +sw_error_t +qca808x_phy_set_duplex (a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_duplex_t duplex); + +sw_error_t +qca808x_phy_get_duplex (a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_duplex_t * duplex); + +sw_error_t +qca808x_phy_set_speed (a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_speed_t speed); + +sw_error_t +qca808x_phy_get_speed (a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_speed_t * speed); + +sw_error_t +qca808x_phy_restart_autoneg (a_uint32_t dev_id, a_uint32_t phy_id); + +sw_error_t +qca808x_phy_enable_autoneg (a_uint32_t dev_id, a_uint32_t phy_id); + +a_bool_t +qca808x_phy_get_link_status (a_uint32_t dev_id, a_uint32_t phy_id); + +sw_error_t +qca808x_phy_set_autoneg_adv (a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t autoneg); + +sw_error_t +qca808x_phy_get_autoneg_adv (a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t * autoneg); + +a_bool_t qca808x_phy_autoneg_status (a_uint32_t dev_id, a_uint32_t phy_id); +#ifndef IN_PORTCONTROL_MINI +sw_error_t +qca808x_phy_intr_mask_set (a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t intr_mask_flag); + +sw_error_t +qca808x_phy_intr_mask_get (a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t * intr_mask_flag); + +sw_error_t +qca808x_phy_intr_status_get (a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t * intr_status_flag); +#endif +sw_error_t +qca808x_phy_get_phy_id(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t *phy_data); + +sw_error_t +qca808x_phy_get_status(a_uint32_t dev_id, a_uint32_t phy_id, + struct port_phy_status *phy_status); + +sw_error_t +qca808x_phy_interface_get_mode_status(a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_interface_mode_t *interface_mode_status); + +sw_error_t qca808x_phy_reset(a_uint32_t dev_id, a_uint32_t phy_id); + +sw_error_t +qca808x_phy_set_force_speed(a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_speed_t speed); +sw_error_t qca808x_phy_poweroff(a_uint32_t dev_id, a_uint32_t phy_id); +sw_error_t qca808x_phy_poweron(a_uint32_t dev_id, a_uint32_t phy_id); +#ifndef IN_PORTCONTROL_MINI +sw_error_t +qca808x_phy_set_hibernate(a_uint32_t dev_id, a_uint32_t phy_id, a_bool_t enable); +sw_error_t +qca808x_phy_get_hibernate(a_uint32_t dev_id, a_uint32_t phy_id, + a_bool_t * enable); +sw_error_t +qca808x_phy_cdt(a_uint32_t dev_id, a_uint32_t phy_id, a_uint32_t mdi_pair, + fal_cable_status_t * cable_status, a_uint32_t * cable_len); +sw_error_t +qca808x_phy_set_mdix(a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_mdix_mode_t mode); +sw_error_t +qca808x_phy_get_mdix(a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_mdix_mode_t * mode); +sw_error_t +qca808x_phy_get_mdix_status(a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_mdix_status_t * mode); +sw_error_t +qca808x_phy_set_local_loopback(a_uint32_t dev_id, a_uint32_t phy_id, + a_bool_t enable); +sw_error_t +qca808x_phy_get_local_loopback(a_uint32_t dev_id, a_uint32_t phy_id, + a_bool_t * enable); +sw_error_t +qca808x_phy_set_remote_loopback(a_uint32_t dev_id, a_uint32_t phy_id, + a_bool_t enable); +sw_error_t +qca808x_phy_get_remote_loopback(a_uint32_t dev_id, a_uint32_t phy_id, + a_bool_t * enable); +sw_error_t +qca808x_phy_set_wol_status(a_uint32_t dev_id, a_uint32_t phy_id, a_bool_t enable); +sw_error_t +qca808x_phy_get_wol_status(a_uint32_t dev_id, a_uint32_t phy_id, a_bool_t * enable); +sw_error_t +qca808x_phy_set_magic_frame_mac(a_uint32_t dev_id, a_uint32_t phy_id, + fal_mac_addr_t * mac); +sw_error_t +qca808x_phy_get_magic_frame_mac(a_uint32_t dev_id, a_uint32_t phy_id, + fal_mac_addr_t * mac); +sw_error_t +qca808x_phy_set_counter(a_uint32_t dev_id, a_uint32_t phy_id, a_bool_t enable); +sw_error_t +qca808x_phy_get_counter(a_uint32_t dev_id, a_uint32_t phy_id, + a_bool_t * enable); +sw_error_t +qca808x_phy_show_counter(a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_counter_info_t * counter_infor); +sw_error_t +qca808x_phy_set_intr_mask(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t intr_mask_flag); +sw_error_t +qca808x_phy_get_intr_mask(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t * intr_mask_flag); +sw_error_t +qca808x_phy_get_intr_status(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t * intr_status_flag); +sw_error_t +qca808x_phy_set_8023az(a_uint32_t dev_id, a_uint32_t phy_id, a_bool_t enable); +sw_error_t +qca808x_phy_get_8023az(a_uint32_t dev_id, a_uint32_t phy_id, a_bool_t * enable); +#endif +sw_error_t +qca808x_phy_set_eee_adv(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t adv); +sw_error_t +qca808x_phy_get_eee_adv(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t *adv); +sw_error_t +qca808x_phy_get_eee_partner_adv(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t *adv); +sw_error_t +qca808x_phy_get_eee_cap(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t *cap); +sw_error_t +qca808x_phy_get_eee_status(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t *status); +void qca808x_phy_lock_init(void); +int qca808x_phy_init(a_uint32_t dev_id, a_uint32_t port_bmp); + +void qca808x_phy_exit(a_uint32_t dev_id, a_uint32_t port_id); +a_bool_t +qca808x_phy_2500caps(a_uint32_t dev_id, a_uint32_t phy_id); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _qca808x_PHY_H_ */ diff --git a/qca/src/qca-psdk/drv/include/hsl/scomphy_init.h b/qca/src/qca-psdk/drv/include/hsl/scomphy_init.h new file mode 100755 index 00000000000..decb90945b2 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/hsl/scomphy_init.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +/** + * @defgroup scomphy_init SCOMPHY_INIT + * @{ + */ +#ifndef _SCOMPHY_INIT_H_ +#define _SCOMPHY_INIT_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "ssdk_init.h" + +sw_error_t +scomphy_init(a_uint32_t dev_id, ssdk_init_cfg *cfg); + +sw_error_t +scomphy_cleanup(a_uint32_t dev_id); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _SCOMPHY_INIT_H_ */ +/** + * @} + */ diff --git a/qca/src/qca-psdk/drv/include/hsl/scomphy_port_ctrl.h b/qca/src/qca-psdk/drv/include/hsl/scomphy_port_ctrl.h new file mode 100644 index 00000000000..a463978bbfd --- /dev/null +++ b/qca/src/qca-psdk/drv/include/hsl/scomphy_port_ctrl.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef _SCOMPHY_PORT_CTRL_H_ +#define _SCOMPHY_PORT_CTRL_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#include "fal/fal_port_ctrl.h" + +sw_error_t scomphy_port_ctrl_init (a_uint32_t dev_id); + +sw_error_t +scomphy_port_reset (a_uint32_t dev_id, fal_port_t port_id); + +#define SCOMPHY_PORT_CTRL_INIT(rv, dev_id) \ + { \ + rv = scomphy_port_ctrl_init(dev_id); \ + SW_RTN_ON_ERROR(rv); \ + } +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _SCOMPHY_PORT_CTRL_H_ */ diff --git a/qca/src/qca-psdk/drv/include/hsl/scomphy_reg_access.h b/qca/src/qca-psdk/drv/include/hsl/scomphy_reg_access.h new file mode 100644 index 00000000000..c9e3a166a27 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/hsl/scomphy_reg_access.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + + +#ifndef _SCOMPHY_REG_ACCESS_H_ +#define _SCOMPHY_REG_ACCESS_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "sw.h" + +sw_error_t +scomphy_phy_get(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg, a_uint16_t * value); + +sw_error_t +scomphy_phy_set(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg, a_uint16_t value); +sw_error_t +scomphy_reg_access_init(a_uint32_t dev_id, ssdk_init_cfg *cfg); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _SCOMPHY_REG_ACCESS_H_ */ diff --git a/qca/src/qca-psdk/drv/include/osal/aos_head.h b/qca/src/qca-psdk/drv/include/osal/aos_head.h new file mode 100755 index 00000000000..b4962118b88 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/osal/aos_head.h @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2012,2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "aos_mem.h" +#include "aos_timer.h" +#include "aos_lock.h" +#include "aos_types.h" + diff --git a/qca/src/qca-psdk/drv/include/osal/aos_lock.h b/qca/src/qca-psdk/drv/include/osal/aos_lock.h new file mode 100755 index 00000000000..830151e95f5 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/osal/aos_lock.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2012,2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _AOS_LOCK_H +#define _AOS_LOCK_H + + +#include "aos_lock_pvt.h" + + +typedef aos_lock_pvt_t aos_lock_t; + + +#define aos_lock_init(lock) __aos_lock_init(lock) + + +#define aos_lock(lock) __aos_lock(lock) + + +#define aos_unlock(lock) __aos_unlock(lock) + +#define aos_lock_bh(lock) __aos_lock_bh(lock) + +#define aos_unlock_bh(lock) __aos_unlock_bh(lock) + + +#define aos_irq_save(flags) __aos_irq_save(flags) + + +#define aos_irq_restore(flags) __aos_irq_restore(flags) + + +#define aos_default_unlock __aos_default_unlock + + +#endif diff --git a/qca/src/qca-psdk/drv/include/osal/aos_lock_pvt.h b/qca/src/qca-psdk/drv/include/osal/aos_lock_pvt.h new file mode 100755 index 00000000000..fe220abd337 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/osal/aos_lock_pvt.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2012, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _AOS_LOCK_PVT_H +#define _AOS_LOCK_PVT_H + + +#include +#include + + +typedef spinlock_t aos_lock_pvt_t; + + +#define __aos_lock_init(lock) spin_lock_init(lock) + + +#define __aos_lock(lock) spin_lock(lock) + + +#define __aos_unlock(lock) spin_unlock(lock) + +#define __aos_lock_bh(lock) spin_lock_bh(lock) + +#define __aos_unlock_bh(lock) spin_unlock_bh(lock) + +#define __aos_irq_save(flags) local_irq_save(flags) + +#define __aos_irq_restore(flags) local_irq_restore(flags) + +#ifndef KVER32 +#define __aos_default_unlock SPIN_LOCK_UNLOCKED +#endif + +#endif /*_AOS_LOCK_PVT_H*/ + diff --git a/qca/src/qca-psdk/drv/include/osal/aos_mem.h b/qca/src/qca-psdk/drv/include/osal/aos_mem.h new file mode 100755 index 00000000000..b9365b955a5 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/osal/aos_mem.h @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2012,2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _AOS_MEM_H +#define _AOS_MEM_H + +#include "aos_types.h" +#include "aos_mem_pvt.h" + +/** + * @g aos_mem mem + * @{ + * + * @ig shim_ext + */ + +/** + * @brief Allocate a memory buffer. Note it's a non-blocking call. + * This call can block. + * + * @param[in] size buffer size + * + * @return Buffer pointer or NULL if there's not enough memory. + */ +static inline void * +aos_mem_alloc(aos_size_t size) +{ + return __aos_mem_alloc(size); +} + +/** + * @brief Free malloc'ed buffer + * + * @param[in] buf buffer pointer allocated by aos_alloc() + * @param[in] size buffer size + */ +static inline void +aos_mem_free(void *buf) +{ + __aos_mem_free(buf); +} + +/** + * @brief Move a memory buffer + * + * @param[in] dst destination address + * @param[in] src source address + * @param[in] size buffer size + */ +static inline void +aos_mem_copy(void *dst, void *src, aos_size_t size) +{ + __aos_mem_copy(dst, src, size); +} + +/** + * @brief Fill a memory buffer + * + * @param[in] buf buffer to be filled + * @param[in] b byte to fill + * @param[in] size buffer size + */ +static inline void +aos_mem_set(void *buf, a_uint8_t b, aos_size_t size) +{ + __aos_mem_set(buf, b, size); +} + +/** + * @brief Zero a memory buffer + * + * @param[in] buf buffer to be zeroed + * @param[in] size buffer size + */ +static inline void +aos_mem_zero(void *buf, aos_size_t size) +{ + __aos_mem_zero(buf, size); +} + +/** + * @brief Compare two memory buffers + * + * @param[in] buf1 first buffer + * @param[in] buf2 second buffer + * @param[in] size buffer size + * + * @retval 0 equal + * @retval 1 not equal + */ +static inline int +aos_mem_cmp(void *buf1, void *buf2, aos_size_t size) +{ + return __aos_mem_cmp(buf1, buf2, size); +} + +/** + * @} + */ + +#endif diff --git a/qca/src/qca-psdk/drv/include/osal/aos_mem_pvt.h b/qca/src/qca-psdk/drv/include/osal/aos_mem_pvt.h new file mode 100755 index 00000000000..f81e23c504c --- /dev/null +++ b/qca/src/qca-psdk/drv/include/osal/aos_mem_pvt.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2012, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _AOS_MEM_PVT_H +#define _AOS_MEM_PVT_H + +#include + +static inline void *__aos_mem_alloc(aos_size_t size) +{ + return (kmalloc(size, GFP_KERNEL | __GFP_ZERO)); +} + +static inline void __aos_mem_free(void *buf) +{ + kfree(buf); +} + +/* move a memory buffer */ +static inline void +__aos_mem_copy(void *dst, void *src, aos_size_t size) +{ + memcpy(dst, src, size); +} + +/* set a memory buffer */ +static inline void +__aos_mem_set(void *buf, a_uint8_t b, aos_size_t size) +{ + memset(buf, b, size); +} + +/* zero a memory buffer */ +static inline void +__aos_mem_zero(void *buf, aos_size_t size) +{ + memset(buf, 0, size); +} + +/* compare two memory buffers */ +static inline int +__aos_mem_cmp(void *buf1, void *buf2, aos_size_t size) +{ + return (memcmp(buf1, buf2, size) == 0) ? 0 : 1; +} + + + +#endif /*_AOS_MEM_PVT_H*/ diff --git a/qca/src/qca-psdk/drv/include/osal/aos_timer.h b/qca/src/qca-psdk/drv/include/osal/aos_timer.h new file mode 100755 index 00000000000..3b4161b9bf8 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/osal/aos_timer.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2012,2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef _AOS_TIMER_H +#define _AOS_TIMER_H + +#include "aos_types.h" +#include "aos_timer_pvt.h" + + +typedef __aos_timer_t aos_timer_t; + + +/* + * Delay in microseconds + */ +static inline void +aos_udelay(int usecs) +{ + return __aos_udelay(usecs); +} + +/* + * Delay in milliseconds. + */ +static inline void +aos_mdelay(int msecs) +{ + return __aos_mdelay(msecs); +} + + +#endif + diff --git a/qca/src/qca-psdk/drv/include/osal/aos_timer_pvt.h b/qca/src/qca-psdk/drv/include/osal/aos_timer_pvt.h new file mode 100755 index 00000000000..8bb49bc06a4 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/osal/aos_timer_pvt.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2012, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _AOS_TIMER_PVT_H +#define _AOS_TIMER_PVT_H + +#ifdef KVER26 +#include +#endif +#include +#include + + +/* + * timer data type + */ +typedef struct timer_list __aos_timer_t; + + +static inline void +__aos_udelay(int usecs) +{ + udelay(usecs); +} + +static inline void +__aos_mdelay(int msecs) +{ + mdelay(msecs); +} + +#endif /*_AOS_TIMER_PVT_H*/ diff --git a/qca/src/qca-psdk/drv/include/osal/aos_types.h b/qca/src/qca-psdk/drv/include/osal/aos_types.h new file mode 100755 index 00000000000..c26fb18058d --- /dev/null +++ b/qca/src/qca-psdk/drv/include/osal/aos_types.h @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2012,2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _AOS_TYPES_H +#define _AOS_TYPES_H + +#include "aos_types_pvt.h" + +#ifndef NULL +#define NULL 0 +#endif + +/** + * @g aos_types types + * @{ + * + * @ig shim_ext + */ +/* + *@ basic data types. + */ +typedef enum +{ + A_FALSE, + A_TRUE +} a_bool_t; + +typedef __a_uint8_t a_uint8_t; +typedef __a_int8_t a_int8_t; +typedef __a_uint16_t a_uint16_t; +typedef __a_int16_t a_int16_t; +typedef __a_uint32_t a_uint32_t; +typedef __a_int32_t a_int32_t; +typedef __a_uint64_t a_uint64_t; +typedef __a_int64_t a_int64_t; +typedef unsigned long a_ulong_t; + + +typedef void * acore_t; + +/** + * @brief Platform/bus generic handle. Used for bus specific functions. + */ +typedef __aos_device_t aos_device_t; + +/** + * @brief size of an object + */ +typedef __aos_size_t aos_size_t; + +/** + * @brief Generic status to be used by acore. + */ +typedef enum +{ + A_STATUS_OK, + A_STATUS_FAILED, + A_STATUS_ENOENT, + A_STATUS_ENOMEM, + A_STATUS_EINVAL, + A_STATUS_EINPROGRESS, + A_STATUS_ENOTSUPP, + A_STATUS_EBUSY, +} a_status_t; + +/* + * An ecore needs to provide a table of all pci device/vendor id's it + * supports + * + * This table should be terminated by a NULL entry , i.e. {0} + */ +typedef struct +{ + a_uint32_t vendor; + a_uint32_t device; + a_uint32_t subvendor; + a_uint32_t subdevice; +} aos_pci_dev_id_t; + +#define AOS_PCI_ANY_ID (~0) + +/* + * Typically core's can use this macro to create a table of various device + * ID's + */ +#define AOS_PCI_DEVICE(_vendor, _device) \ + (_vendor), (_device), AOS_PCI_ANY_ID, AOS_PCI_ANY_ID + + +typedef __aos_iomem_t aos_iomem_t; +/* + * These define the hw resources the OS has allocated for the device + * Note that start defines a mapped area. + */ +typedef enum +{ + AOS_RESOURCE_TYPE_MEM, + AOS_RESOURCE_TYPE_IO, +} aos_resource_type_t; + +typedef struct +{ + a_uint32_t start; + a_uint32_t end; + aos_resource_type_t type; +} aos_resource_t; + +#define AOS_DEV_ID_TABLE_MAX 256 + +typedef union +{ + aos_pci_dev_id_t *pci; + void *raw; +} aos_bus_reg_data_t; + +typedef void *aos_attach_data_t; + +#define AOS_REGIONS_MAX 5 + +typedef enum +{ + AOS_BUS_TYPE_PCI = 1, + AOS_BUS_TYPE_GENERIC, +} aos_bus_type_t; + +typedef enum +{ + AOS_IRQ_NONE, + AOS_IRQ_HANDLED, +} aos_irq_resp_t; + +typedef enum +{ + AOS_DMA_MASK_32BIT, + AOS_DMA_MASK_64BIT, +} aos_dma_mask_t; + + +/** + * @brief DMA directions + */ +typedef enum +{ + AOS_DMA_TO_DEVICE = 0, /**< Data is transfered from device to memory */ + AOS_DMA_FROM_DEVICE, /**< Data is transfered from memory to device */ +} aos_dma_dir_t; + +/* + * Protoypes shared between public and private headers + */ + + +/* + * work queue(kernel thread) function callback + */ +typedef void (*aos_work_func_t)(void *); + +/** + * @brief Prototype of the critical region function that is to be + * executed with spinlock held and interrupt disalbed + */ +typedef a_bool_t (*aos_irqlocked_func_t)(void *); + +/** + * @brief Prototype of timer function + */ +typedef void (*aos_timer_func_t)(void *); + +#endif diff --git a/qca/src/qca-psdk/drv/include/osal/aos_types_pvt.h b/qca/src/qca-psdk/drv/include/osal/aos_types_pvt.h new file mode 100755 index 00000000000..6d85ecb8947 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/osal/aos_types_pvt.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2012, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _AOS_PVTTYPES_H +#define _AOS_PVTTYPES_H + +#include +#include +#include +/* + * Private definitions of general data types + */ + +/* generic data types */ +typedef struct device * __aos_device_t; +typedef int __aos_size_t; + +#ifdef KVER26 +#ifdef LNX26_22 +typedef __u8 * __aos_iomem_t; +#else +typedef u8 __iomem * __aos_iomem_t; +#endif +#else /*Linux Kernel 2.4 */ +typedef u8 * __aos_iomem_t; +#endif + +#ifdef KVER32 +typedef u8 __iomem * __aos_iomem_t; +#endif + +#ifdef LNX26_22 /* > Linux 2.6.22 */ +typedef __u8 __a_uint8_t; +typedef __s8 __a_int8_t; +typedef __u16 __a_uint16_t; +typedef __s16 __a_int16_t; +typedef __u32 __a_uint32_t; +typedef __s32 __a_int32_t; +typedef __u64 __a_uint64_t; +typedef __s64 __a_int64_t; +#else +typedef u8 __a_uint8_t; +typedef s8 __a_int8_t; +typedef u16 __a_uint16_t; +typedef s16 __a_int16_t; +typedef u32 __a_uint32_t; +typedef s32 __a_int32_t; +typedef u64 __a_uint64_t; +typedef s64 __a_int64_t; +#endif + +#define aos_printk printk + +#define AUTO_UPDATE_PPPOE_INFO 1 +#if 0 +#undef AUTO_UPDATE_PPPOE_INFO +#endif + +#endif diff --git a/qca/src/qca-psdk/drv/include/sd.h b/qca/src/qca-psdk/drv/include/sd.h new file mode 100644 index 00000000000..a647ce6f78d --- /dev/null +++ b/qca/src/qca-psdk/drv/include/sd.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2012, 2017-2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef _SD_H_ +#define _SD_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + sw_error_t + sd_reg_mdio_set(a_uint32_t dev_id, a_uint32_t phy, a_uint32_t reg, + a_uint16_t data); + + sw_error_t + sd_reg_mdio_get(a_uint32_t dev_id, a_uint32_t phy, a_uint32_t reg, + a_uint16_t * data); + + sw_error_t + sd_reg_i2c_set(a_uint32_t dev_id, a_uint32_t phy, a_uint32_t reg, + a_uint16_t data); + + sw_error_t + sd_reg_i2c_get(a_uint32_t dev_id, a_uint32_t phy, a_uint32_t reg, + a_uint16_t * data); + sw_error_t sd_init(a_uint32_t dev_id, ssdk_init_cfg * cfg); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _SD_H_ */ diff --git a/qca/src/qca-psdk/drv/include/shared_func.h b/qca/src/qca-psdk/drv/include/shared_func.h new file mode 100755 index 00000000000..729938c3292 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/shared_func.h @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2012, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + + +#ifndef _SHARED_FUNC_H +#define _SHARED_FUNC_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define SW_RTN_ON_ERROR(rtn) \ + do { if (rtn != SW_OK) return(rtn); } while(0); + +#define SW_OUT_ON_ERROR(rtn) \ + do { \ + if (rtn != SW_OK) { \ + rv = rtn; \ + goto out;\ + } \ + } while(0); + +#define SW_CNTU_ON_ERROR_AND_COND1_OR_GOTO_OUT(rtn, cond1) \ + { \ + if ((rtn != SW_OK)) { \ + if (rtn == cond1) \ + continue; \ + else \ + goto out; \ + } \ + } + +#define SW_RTN_ON_ERROR_EXCEPT_COND1(rtn, cond1) \ + do { \ + if ((rtn != SW_OK) && (rtn != cond1)) \ + return rtn; \ + }while(0); + +#define SW_RTN_ON_NULL(op) \ + do { \ + if ((op) == NULL) \ + return SW_NOT_INITIALIZED;\ + }while(0); + + /* register functions */ +#define SW_BIT_MASK_U32(nr) (~(0xFFFFFFFF << (nr))) + +#define SW_FIELD_MASK_U32(offset, len) \ + ((SW_BIT_MASK_U32(len) << (offset))) + +#define SW_FIELD_MASK_NOT_U32(offset,len) \ + (~(SW_BIT_MASK_U32(len) << (offset))) + +#define SW_FIELD_2_REG(field_val, bit_offset) \ + (field_val << (bit_offset) ) + +#define SW_REG_2_FIELD(reg_val, bit_offset, field_len) \ + (((reg_val) >> (bit_offset)) & ((1 << (field_len)) - 1)) + +#define SW_REG_SET_BY_FIELD_U32(reg_value, field_value, bit_offset, field_len)\ + do { \ + (reg_value) = \ + (((reg_value) & SW_FIELD_MASK_NOT_U32((bit_offset),(field_len))) \ + | (((field_value) & SW_BIT_MASK_U32(field_len)) << (bit_offset)));\ + } while (0) + +#define SW_FIELD_GET_BY_REG_U32(reg_value, field_value, bit_offset, field_len)\ + do { \ + (field_value) = \ + (((reg_value) >> (bit_offset)) & SW_BIT_MASK_U32(field_len)); \ + } while (0) + +#define SW_SWAP_BITS_U8(x) \ + ((((x)&0x80)>>7) | (((x)&0x40)>>5) | (((x)&0x20)>>3) | (((x)&0x10)>>1) \ + |(((x)&0x1)<<7) | (((x)&0x2)<<5) | (((x)&0x4)<<3) |(((x)&0x8)<<1) ) + + +#define SW_OFFSET_U8_2_U16(byte_offset) ((byte_offset) >> 1) + +#define SW_OFFSET_U16_2_U8(word16_offset) ((word16_offset) << 1) + +#define SW_OFFSET_BIT_2_U8_ALIGN16(bit_offset) (((bit_offset) / 16) * 2) + +#define SW_SET_REG_BY_FIELD(reg, field, field_value, reg_value) \ + SW_REG_SET_BY_FIELD_U32(reg_value, field_value, reg##_##field##_BOFFSET, \ + reg##_##field##_BLEN) + +#define SW_GET_FIELD_BY_REG(reg, field, field_value, reg_value) \ + SW_FIELD_GET_BY_REG_U32(reg_value, field_value, reg##_##field##_BOFFSET, \ + reg##_##field##_BLEN) + + /* port bitmap functions */ +#define SW_IS_PBMP_MEMBER(pbm, port) ((pbm & (1 << port)) ? A_TRUE: A_FALSE) +#define SW_IS_PBMP_EQ(pbm0, pbm1) ((pbm0 == pbm1) ? A_TRUE: A_FALSE) + +#define SW_PBMP_AND(pbm0, pbm1) ((pbm0) &= (pbm1)) +#define SW_PBMP_OR(pbm0, pbm1) ((pbm0) |= (pbm1)) +#define SW_IS_PBMP_INCLUDE(pbm0, pbm1) \ + ((pbm1 == SW_PBMP_AND(pbm0, pbm1)) ? A_TRUE: A_FALSE) + +#define SW_PBMP_CLEAR(pbm) ((pbm) = 0) +#define SW_PBMP_ADD_PORT(pbm, port) ((pbm) |= (1U << (port))) +#define SW_PBMP_DEL_PORT(pbm,port) ((pbm) &= ~(1U << (port))) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _SHARED_FUNC_H */ diff --git a/qca/src/qca-psdk/drv/include/ssdk_init.h b/qca/src/qca-psdk/drv/include/ssdk_init.h new file mode 100644 index 00000000000..d98695add85 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/ssdk_init.h @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2012, 2015-2020, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef _SSDK_INIT_H_ +#define _SSDK_INIT_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "sw.h" +#include "fal_type.h" +#define SSDK_MAX_PORT_NUM 8 + typedef enum { + HSL_MDIO = 1, + HSL_HEADER, + } + hsl_access_mode; + + typedef enum + { + HSL_NO_CPU = 0, + HSL_CPU_1, + HSL_CPU_2, + HSL_CPU_1_PLUS, + } hsl_init_mode; + + typedef enum + { + HSL_REG_MDIO = 0, + HSL_REG_LOCAL_BUS, + } hsl_reg_mode; + + typedef sw_error_t + (*mdio_reg_set) (a_uint32_t dev_id, a_uint32_t phy_addr, a_uint32_t reg, + a_uint16_t data); + + typedef sw_error_t + (*mdio_reg_get) (a_uint32_t dev_id, a_uint32_t phy_addr, a_uint32_t reg, + a_uint16_t * data); + + typedef sw_error_t + (*i2c_reg_set) (a_uint32_t dev_id, a_uint32_t phy_addr, a_uint32_t reg, + a_uint16_t data); + + typedef sw_error_t + (*i2c_reg_get) (a_uint32_t dev_id, a_uint32_t phy_addr, a_uint32_t reg, + a_uint16_t * data); +enum ssdk_port_wrapper_cfg { + PORT_WRAPPER_PSGMII = 0, + PORT_WRAPPER_PSGMII_RGMII5, + PORT_WRAPPER_SGMII0_RGMII5, + PORT_WRAPPER_SGMII1_RGMII5, + PORT_WRAPPER_PSGMII_RMII0, + PORT_WRAPPER_PSGMII_RMII1, + PORT_WRAPPER_PSGMII_RMII0_RMII1, + PORT_WRAPPER_PSGMII_RGMII4, + PORT_WRAPPER_SGMII0_RGMII4, + PORT_WRAPPER_SGMII1_RGMII4, + PORT_WRAPPER_SGMII4_RGMII4, + PORT_WRAPPER_QSGMII, + PORT_WRAPPER_SGMII_PLUS, + PORT_WRAPPER_USXGMII, + PORT_WRAPPER_10GBASE_R, + PORT_WRAPPER_SGMII_CHANNEL0, + PORT_WRAPPER_SGMII_CHANNEL1, + PORT_WRAPPER_SGMII_CHANNEL4, + PORT_WRAPPER_RGMII, + PORT_WRAPPER_PSGMII_FIBER, + PORT_WRAPPER_SGMII_FIBER, + PORT_WRAPPER_MAX = 0xFF +}; + + typedef struct + { + mdio_reg_set mdio_set; + mdio_reg_get mdio_get; + i2c_reg_set i2c_set; + i2c_reg_get i2c_get; + } hsl_reg_func; + typedef enum + { + CHIP_UNSPECIFIED = 0, + CHIP_ATHENA, + CHIP_GARUDA, + CHIP_SHIVA, + CHIP_HORUS, + CHIP_ISIS, + CHIP_ISISC, + CHIP_DESS, + CHIP_HPPE, + CHIP_SCOMPHY, + } ssdk_chip_type; +#define phy_features_t a_uint16_t +#define __PHY_F_BIT(bit) ((phy_features_t)1 << (bit)) +#define _PHY_F(name) __PHY_F_BIT(QCA_PHY_F_##name##_BIT) + +#define PHY_F_CLAUSE45 _PHY_F(CLAUSE45) +#define PHY_F_COMBO _PHY_F(COMBO) +#define PHY_F_QGMAC _PHY_F(QGMAC) +#define PHY_F_XGMAC _PHY_F(XGMAC) +#define PHY_F_I2C _PHY_F(I2C) +#define PHY_F_INIT _PHY_F(INIT) +#define PHY_F_FORCE _PHY_F(FORCE) + +typedef struct +{ + hsl_init_mode cpu_mode; + hsl_access_mode reg_mode; + hsl_reg_func reg_func; + + ssdk_chip_type chip_type; + a_uint32_t chip_revision; + + /* os specific parameter */ + /* when uk_if based on netlink, it's netlink protocol type*/ + /* when uk_if based on ioctl, it's minor device number, major number + is always 10(misc device) */ + a_uint32_t nl_prot; + + /* chip specific parameter */ + void * chip_spec_cfg; + a_uint32_t phy_id; + a_uint32_t mac_mode1; + a_uint32_t mac_mode2; +} ssdk_init_cfg; +#define CFG_STR_SIZE 20 + typedef struct + { + a_uint8_t build_ver[CFG_STR_SIZE]; + a_uint8_t build_date[CFG_STR_SIZE]; + + a_uint8_t chip_type[CFG_STR_SIZE]; //GARUDA + a_uint8_t cpu_type[CFG_STR_SIZE]; //mips + a_uint8_t os_info[CFG_STR_SIZE]; //OS=linux OS_VER=2_6 + + a_bool_t fal_mod; + a_bool_t kernel_mode; + a_bool_t uk_if; + ssdk_init_cfg init_cfg; + } ssdk_cfg_t; + +#define SSDK_RFS_INTF_MAX 8 +typedef struct +{ + a_uint32_t if_idx; /*netdevic idx*/ + fal_mac_addr_t macaddr; + a_uint16_t vid; + a_uint8_t hw_idx; /* HW table entry idx*/ +} ssdk_rfs_intf_t; + +sw_error_t +ssdk_init(a_uint32_t dev_id, ssdk_init_cfg *cfg); +struct qca_phy_priv* ssdk_phy_priv_data_get(a_uint32_t dev_id); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _SSDK_INIT_H */ diff --git a/qca/src/qca-psdk/drv/include/ssdk_phy_i2c.h b/qca/src/qca-psdk/drv/include/ssdk_phy_i2c.h new file mode 100755 index 00000000000..e682c8a9f30 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/ssdk_phy_i2c.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _SSDK_PHY_I2C_H_ +#define _SSDK_PHY_I2C_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#define QCA_PHY_I2C_MMD_OR_MII_SHIFT 6 +#define QCA_PHY_I2C_IS_MMD 1 +#define QCA_PHY_I2C_IS_MII 0 +#define QCA_PHY_I2C_MMD_ADDR_OR_DATA_SHIFT 5 +#define QCA_PHY_I2C_MMD_IS_ADDR 1 +#define QCA_PHY_I2C_MMD_IS_DATA 0 + +#define QCA_PHY_MII_ADDR_C45 (1<<30) +#define QCA_PHY_MII_ADDR_C45_IS_MMD(reg_addr_c45) ((reg_addr_c45) & QCA_PHY_MII_ADDR_C45) +#define QCA_PHY_MII_ADDR_C45_MMD_NUM(reg_addr_c45) (((reg_addr_c45) >> 16) & 0x1f) +#define QCA_PHY_MII_ADDR_C45_REG_ADDR(reg_addr_c45) ((reg_addr_c45) & 0xffff) + +#define QCA_PHY_I2C_PHYCORE_DEVADDR 0x44 +#define QCA_PHY_I2C_SERDES_DEVADDR 0x45 +#define QCA_PHY_I2C_DEVADDR_MASK 0x47 + +#define QCA_PHY_MMD1_NUM 1 +#define QCA_PHY_MMD3_NUM 3 +#define QCA_PHY_MMD7_NUM 7 + +sw_error_t +qca_phy_i2c_mii_read(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg_addr, a_uint16_t *reg_data); +sw_error_t +qca_phy_i2c_mii_write(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg_addr, a_uint16_t reg_data); +sw_error_t +qca_i2c_data_get(a_uint32_t dev_id, a_uint32_t i2c_slave, + a_uint32_t data_addr, a_uint8_t *buf, a_uint32_t count); + +sw_error_t +qca_i2c_data_set(a_uint32_t dev_id, a_uint32_t i2c_slave, + a_uint32_t data_addr, a_uint8_t *buf, a_uint32_t count); + +#ifdef IN_PHY_I2C_MODE +sw_error_t +qca_phy_i2c_mmd_read(a_uint32_t dev_id, a_uint32_t phy_addr, a_uint16_t mmd_num, + a_uint32_t reg_addr, a_uint16_t *reg_data); +sw_error_t +qca_phy_i2c_mmd_write(a_uint32_t dev_id, a_uint32_t phy_addr, a_uint16_t mmd_num, + a_uint32_t reg_addr, a_uint16_t reg_data); +a_bool_t +qca_phy_is_i2c_addr(a_uint32_t phy_addr); +sw_error_t +qca_phy_i2c_read(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg_addr_c45, a_uint16_t *reg_data); +sw_error_t +qca_phy_i2c_write(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg_addr_c45, a_uint16_t reg_data); +#endif +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _SSDK_PHY_I2C_H_ */ diff --git a/qca/src/qca-psdk/drv/include/ssdk_plat.h b/qca/src/qca-psdk/drv/include/ssdk_plat.h new file mode 100644 index 00000000000..38f0ce52ced --- /dev/null +++ b/qca/src/qca-psdk/drv/include/ssdk_plat.h @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2012, 2014-2015, 2017-2020, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef __SSDK_PLAT_H +#define __SSDK_PLAT_H + +#include "sw.h" +#include + +#ifndef BIT +#define BIT(_n) (1UL << (_n)) +#endif + + +#ifndef BITS +#define BITS(_s, _n) (((1UL << (_n)) - 1) << _s) +#endif + +/* Atheros specific MII registers */ +#define QCA_MII_MMD_ADDR 0x0d +#define QCA_MII_MMD_DATA 0x0e +#define QCA_MII_DBG_ADDR 0x1d +#define QCA_MII_DBG_DATA 0x1e +#define SSDK_PHY_BCAST_ID 0x1f +#define SSDK_PHY_MIN_ID 0x0 +#define SSDK_PORT_CPU 0 +enum { + QCA_VER_AR8216 = 0x01, + QCA_VER_AR8227 = 0x02, + QCA_VER_AR8236 = 0x03, + QCA_VER_AR8316 = 0x10, + QCA_VER_AR8327 = 0x12, + QCA_VER_AR8337 = 0x13, + QCA_VER_DESS = 0x14, + QCA_VER_HPPE = 0x15, + QCA_VER_SCOMPHY = 0xEE +}; +#define SSDK_PHYSICAL_PORT0 0 +#define SSDK_PHYSICAL_PORT1 1 +#define SSDK_PHYSICAL_PORT2 2 +#define SSDK_PHYSICAL_PORT3 3 +#define SSDK_PHYSICAL_PORT4 4 +#define SSDK_PHYSICAL_PORT5 5 +#define SSDK_PHYSICAL_PORT6 6 +#define SSDK_PHYSICAL_PORT7 7 +#define SSDK_LOG_LEVEL_ERROR 0 +#define SSDK_LOG_LEVEL_WARN 1 +#define SSDK_LOG_LEVEL_INFO 2 +#define SSDK_LOG_LEVEL_DEBUG 3 +#define SSDK_LOG_LEVEL_DEFAULT SSDK_LOG_LEVEL_INFO + +extern a_uint32_t ssdk_log_level; + +#define __SSDK_LOG_FUN(lev, fmt, ...) \ + do { \ + if (SSDK_LOG_LEVEL_##lev <= ssdk_log_level) { \ + printk("%s[%u]:"#lev":"fmt, \ + __FUNCTION__, __LINE__, ##__VA_ARGS__); \ + } \ + } while(0) +#define SSDK_DUMP_BUF(lev, buf, len) \ + do {\ + if (SSDK_LOG_LEVEL_##lev <= ssdk_log_level) {\ + a_uint32_t i_buf = 0;\ + for(i_buf=0; i_buf<(len); i_buf++) {\ + printk("%08lx ", *((buf)+i_buf));\ + }\ + printk("\n");\ + }\ + } while(0) + +#define SSDK_ERROR(fmt, ...) __SSDK_LOG_FUN(ERROR, fmt, ##__VA_ARGS__) +#define SSDK_WARN(fmt, ...) __SSDK_LOG_FUN(WARN, fmt, ##__VA_ARGS__) +#define SSDK_INFO(fmt, ...) __SSDK_LOG_FUN(INFO, fmt, ##__VA_ARGS__) +#define SSDK_DEBUG(fmt, ...) __SSDK_LOG_FUN(DEBUG, fmt, ##__VA_ARGS__) + +struct qca_phy_priv { + struct phy_device *phy; +#if defined(IN_SWCONFIG) + struct switch_dev sw_dev; +#endif + a_uint8_t version; + a_uint8_t revision; + a_uint32_t (*mii_read)(a_uint32_t dev_id, a_uint32_t reg); + void (*mii_write)(a_uint32_t dev_id, a_uint32_t reg, a_uint32_t val); + void (*phy_dbg_write)(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint16_t dbg_addr, a_uint16_t dbg_data); + void (*phy_dbg_read)(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint16_t dbg_addr, a_uint16_t *dbg_data); + void (*phy_mmd_write)(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint16_t addr, a_uint16_t data); + sw_error_t (*phy_write)(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg, a_uint16_t data); + sw_error_t (*phy_read)(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg, a_uint16_t* data); + + bool init; + a_uint8_t device_id; + struct device_node *of_node; + struct mii_bus *miibus; +}; + +struct ipq40xx_mdio_data { + struct mii_bus *mii_bus; + void __iomem *membase; + int phy_irq[PHY_MAX_ADDR]; +}; + +#if defined(IN_SWCONFIG) +#define qca_phy_priv_get(_dev) \ + container_of(_dev, struct qca_phy_priv, sw_dev) +#endif + +sw_error_t +qca_ar8327_phy_read(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg, a_uint16_t* data); +sw_error_t +qca_ar8327_phy_write(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg, a_uint16_t data); +void +qca_ar8327_mmd_write(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint16_t addr, a_uint16_t data); +void +qca_ar8327_phy_dbg_write(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint16_t dbg_addr, a_uint16_t dbg_data); +void +qca_ar8327_phy_dbg_read(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint16_t dbg_addr, a_uint16_t *dbg_data); + +void +qca_phy_mmd_write(u32 dev_id, u32 phy_id, + u16 mmd_num, u16 reg_id, u16 reg_val); + +u16 +qca_phy_mmd_read(u32 dev_id, u32 phy_id, + u16 mmd_num, u16 reg_id); +int ssdk_plat_init(ssdk_init_cfg *cfg, a_uint32_t dev_id); +void ssdk_plat_exit(a_uint32_t dev_id); + +#endif diff --git a/qca/src/qca-psdk/drv/include/sw.h b/qca/src/qca-psdk/drv/include/sw.h new file mode 100755 index 00000000000..fa82d561a1b --- /dev/null +++ b/qca/src/qca-psdk/drv/include/sw.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2012,2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + + +#ifndef _SW_H_ +#define _SW_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "sw_config.h" +#include "aos_head.h" +#include "sw_error.h" +#include "shared_func.h" + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _SW_H_ */ + diff --git a/qca/src/qca-psdk/drv/include/sw_api.h b/qca/src/qca-psdk/drv/include/sw_api.h new file mode 100755 index 00000000000..127fb59efb8 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/sw_api.h @@ -0,0 +1,276 @@ +/* + * Copyright (c) 2012, 2015-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + + +#ifndef _SW_API_H +#define _SW_API_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "sw.h" +#include "sw_ioctl.h" + +#define SW_MAX_API_BUF 2048 +#define SW_MAX_API_PARAM 12 /* cmd type + return value + ten parameters */ +#define SW_MAX_PAYLOAD (SW_MAX_API_PARAM << 2) /* maximum payload size for netlink msg*/ +#define SW_PARAM_IN 0x1 +#define SW_PARAM_OUT 0x2 +#define SW_PARAM_PTR 0x4 + +#define SW_API_DEF(ioctl, name) {ioctl, name} + +#define SW_PARAM_DEF(ioctl, data, size, type, name) {ioctl, size, data, type} + +typedef enum +{ + SW_UINT8 = 1, + SW_INT8, + SW_UINT16, + SW_INT16, + SW_UINT32, + SW_INT32, + SW_UINT64, + SW_INT64, + SW_ENABLE, + SW_SPEED, + SW_DUPLEX, + SW_1QMODE, + SW_EGMODE, + SW_CAP, + SW_VLAN, + SW_LAN_WAN_CFG, + SW_PBMP, + SW_MIB, + SW_MIB_CNTR, + SW_XGMIB, + SW_MACADDR, + SW_FDBENTRY, + SW_MACLIMIT_CTRL, + SW_SCH, + SW_QOS, + SW_STORM, + SW_STP, + SW_LEAKY, + SW_MACCMD, + SW_FLOWTYPE, + SW_FLOWCMD, + SW_UINT_A, + SW_ACLRULE, + SW_LEDPATTERN, + SW_INVLAN, + SW_VLANPROPAGATION, + SW_VLANTRANSLATION, + SW_QINQMODE, + SW_QINQROLE, + SW_CABLESTATUS, + SW_CABLELEN, + SW_SSDK_CFG, + SW_HDRMODE, + SW_FDBOPRATION, + SW_PPPOE, + SW_PPPOE_LESS, + SW_ACL_UDF_TYPE, + SW_IP_HOSTENTRY, + SW_ARP_LEARNMODE, + SW_IP_GUARDMODE, + SW_NATENTRY, + SW_NAPTENTRY, + SW_FLOWENTRY, + SW_NAPTMODE, + SW_IP4ADDR, + SW_IP6ADDR, + SW_INTFMACENTRY, + SW_PUBADDRENTRY, + SW_INGPOLICER, + SW_EGSHAPER, + SW_ACLPOLICER, + SW_MACCONFIG, + SW_PHYCONFIG, + SW_DATA_MAX, + SW_FDBSMODE, + SW_FX100CONFIG, + SW_SGENTRY, + SW_SEC_MAC, + SW_SEC_IP, + SW_SEC_IP4, + SW_SEC_IP6, + SW_SEC_TCP, + SW_SEC_UDP, + SW_SEC_ICMP4, + SW_SEC_ICMP6, + SW_REMARKENTRY, + SW_SGINFOENTRY, + SW_DEFAULT_ROUTE_ENTRY, + SW_HOST_ROUTE_ENTRY, + SW_IP_WCMP_ENTRY, + SW_IP_RFS_IP4, + SW_IP_RFS_IP6, + SW_FLOWCOOKIE, + SW_FDB_RFS, + SW_FLOWRFS, + SW_CROSSOVER_MODE, + SW_CROSSOVER_STATUS, + SW_PREFER_MEDIUM, + SW_FIBER_MODE, + SW_INTERFACE_MODE, + SW_COUNTER_INFO, + SW_REG_DUMP, + SW_DBG_REG_DUMP, + SW_VSI_NEWADDR_LRN, + SW_VSI_STAMOVE, + SW_VSI_MEMBER, + SW_VSI_COUNTER, + SW_MTU_INFO, + SW_MRU_INFO, + SW_MTU_ENTRY, + SW_MRU_ENTRY, + SW_FRAME_MAX_SIZE, + SW_SOURCE_FILTER, + SW_ARP_SG_CFG, + SW_IP_NETWORK_ROUTE, + SW_IP_INTF, + SW_IP_VSI_INTF, + SW_IP_NEXTHOP, + SW_UCAST_QUEUE_MAP, + SW_UCAST_PRI_CLASS, + SW_MCAST_PRI_CLASS, + SW_IP_SG, + SW_IP_PUB, + SW_IP_PORTMAC, + SW_IP_MCMODE, + SW_FLOW_AGE, + SW_FLOW_CTRL, + SW_AC_CTRL, + SW_AC_OBJ, + SW_STATIC_THRESH, + SW_DYNAMIC_THRESH, + SW_GROUP_BUFFER, + SW_FLOW_ENTRY, + SW_FLOW_HOST, + SW_IP_GLOBAL, + SW_FLOW_GLOBAL, + SW_GLOBAL_QINQMODE, + SW_PT_QINQMODE, + SW_TPID, + SW_INGRESS_FILTER, + SW_PT_DEF_VID_EN, + SW_PT_VLAN_TAG, + SW_PT_VLAN_DIRECTION, + SW_PT_VLAN_TRANS_ADV_RULE, + SW_PT_VLAN_TRANS_ADV_ACTION, + SW_PT_VLAN_COUNTER, + SW_DEBUG_COUNTER_EN, + SW_TAG_PROPAGATION, + SW_EGRESS_DEFAULT_VID, + SW_EGRESS_MODE, + SW_CTRLPKT_PROFILE, + SW_SERVCODE_CONFIG, + SW_RSS_HASH_MODE, + SW_RSS_HASH_CONFIG, + SW_MIRR_ANALYSIS_CONFIG, + SW_MIRR_DIRECTION, + SW_L3_PARSER, + SW_L4_PARSER, + SW_EXP_CTRL, + SW_ACL_UDF_PKT_TYPE, + SW_PORTGROUP, + SW_PORTPRI, + SW_PORTREMARK, + SW_COSMAP, + SW_SCHEDULER, + SW_QUEUEBMP, + SW_BMSTHRESH, + SW_BMDTHRESH, + SW_BMPORTCNT, + SW_PORT_SHAPER_TOKEN_CONFIG, + SW_SHAPER_TOKEN_CONFIG, + SW_PORT_SHAPER_CONFIG, + SW_SHAPER_CONFIG, + SW_MODULE, + SW_FUNC_CTRL, + SW_QM_CNT, + SW_POLICER_COUNTER, + SW_POLICER_PORT_CONFIG, + SW_POLICER_ACL_CONFIG, + SW_POLICER_CMD_CONFIG, + SW_POLICER_GLOBAL_COUNTER, + SW_PHY_DUMP, + SW_RESOURCE_SCHE, + SW_PTP_CONFIG, + SW_PTP_REFERENCE_CLOCK, + SW_PTP_RX_TIMESTAMP_MODE, + SW_PTP_DIRECTION, + SW_PTP_PKT_INFO, + SW_PTP_TIME, + SW_PTP_GRANDMASTER_MODE, + SW_PTP_SECURITY, + SW_PTP_PPS_SIGNAL_CONTROL, + SW_PTP_ASYM_CORRECTION, + SW_PTP_OUTPUT_WAVEFORM, + SW_PTP_TOD_UART, + SW_PTP_ENHANCED_TS_ENGINE, + SW_PTP_TRIGGER, + SW_PTP_CAPTURE, + SW_PTP_INTERRUPT, + SW_PORT_EEE_CONFIG, + SW_SRC_FILTER_CONFIG, + SW_PORT_LOOPBACK_CONFIG, + SW_SFP_DATA, + SW_SFP_DEV_TYPE, + SW_SFP_TRANSC_CODE, + SW_SFP_RATE_ENCODE, + SW_SFP_LINK_LENGTH, + SW_SFP_VENDOR_INFO, + SW_SFP_LASER_WAVELENGTH, + SW_SFP_OPTION, + SW_SFP_CTRL_RATE, + SW_SFP_ENHANCED_CFG, + SW_SFP_DIAG_THRESHOLD, + SW_SFP_DIAG_CAL_CONST, + SW_SFP_DIAG_REALTIME, + SW_SFP_CTRL_STATUS, + SW_SFP_ALARM_WARN_FLAG, + SW_SFP_CCODE_TYPE, +} sw_data_type_e; + + typedef struct + { + a_uint32_t api_id; + void *func; + } sw_api_func_t; + + typedef struct + { + a_uint32_t api_id; + a_uint16_t data_size; + a_uint8_t data_type; + a_uint8_t param_type; + } sw_api_param_t; + + typedef struct + { + a_uint32_t api_id; + sw_api_func_t *api_fp; + sw_api_param_t *api_pp; + a_uint32_t api_nr; + } sw_api_t; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _SW_API_H */ diff --git a/qca/src/qca-psdk/drv/include/sw_api_ks.h b/qca/src/qca-psdk/drv/include/sw_api_ks.h new file mode 100755 index 00000000000..fcc05521ee9 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/sw_api_ks.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2012,2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + + +#ifndef _SW_API_KS_H +#define _SW_API_KS_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "sw.h" + + sw_error_t sw_uk_init(a_uint32_t nl_prot); + + sw_error_t sw_uk_cleanup(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _SW_API_KS_H */ diff --git a/qca/src/qca-psdk/drv/include/sw_config.h b/qca/src/qca-psdk/drv/include/sw_config.h new file mode 100755 index 00000000000..d1c4f6956b9 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/sw_config.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2012, 2017, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + + +#ifndef _SW_CONFIG_H +#define _SW_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define SW_MAX_NR_DEV 3 +#define SW_MAX_NR_PORT 16 + +#ifdef HSL_STANDALONG +#define HSL_LOCAL +#else +#define HSL_LOCAL static +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/qca/src/qca-psdk/drv/include/sw_error.h b/qca/src/qca-psdk/drv/include/sw_error.h new file mode 100755 index 00000000000..7a175173fae --- /dev/null +++ b/qca/src/qca-psdk/drv/include/sw_error.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2012, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + + +#ifndef _SW_ERROR_H +#define _SW_ERROR_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + typedef enum { + SW_OK = 0, /* Operation succeeded */ + SW_FAIL = -1, /* Operation failed */ + SW_BAD_VALUE = -2, /* Illegal value */ + SW_OUT_OF_RANGE = -3, /* Value is out of range */ + SW_BAD_PARAM = -4, /* Illegal parameter(s) */ + SW_BAD_PTR = -5, /* Illegal pointer value */ + SW_BAD_LEN = -6, /* Wrong length */ + SW_BAD_STATE = -7, /* Wrong state of state machine */ + SW_READ_ERROR = -8, /* Read operation failed */ + SW_WRITE_ERROR = -9, /* Write operation failed */ + SW_CREATE_ERROR = -10, /* Fail in creating an entry */ + SW_DELETE_ERROR = -11, /* Fail in deleteing an entry */ + SW_NOT_FOUND = -12, /* Entry not found */ + SW_NO_CHANGE = -13, /* The parameter(s) is the same */ + SW_NO_MORE = -14, /* No more entry found */ + SW_NO_SUCH = -15, /* No such entry */ + SW_ALREADY_EXIST = -16, /* Tried to create existing entry */ + SW_FULL = -17, /* Table is full */ + SW_EMPTY = -18, /* Table is empty */ + SW_NOT_SUPPORTED = -19, /* This request is not support */ + SW_NOT_IMPLEMENTED = -20, /* This request is not implemented */ + SW_NOT_INITIALIZED = -21, /* The item is not initialized */ + SW_BUSY = -22, /* Operation is still running */ + SW_TIMEOUT = -23, /* Operation Time Out */ + SW_DISABLE = -24, /* Operation is disabled */ + SW_NO_RESOURCE = -25, /* Resource not available (memory ...) */ + SW_INIT_ERROR = -26, /* Error occured while INIT process */ + SW_NOT_READY = -27, /* The other side is not ready yet */ + SW_OUT_OF_MEM = -28, /* Cpu memory allocation failed. */ + SW_ABORTED = -29 /* Operation has been aborted. */ + } sw_error_t; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _SW_ERROR_H */ + diff --git a/qca/src/qca-psdk/drv/include/sw_ioctl.h b/qca/src/qca-psdk/drv/include/sw_ioctl.h new file mode 100644 index 00000000000..ae6a261de31 --- /dev/null +++ b/qca/src/qca-psdk/drv/include/sw_ioctl.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2012, 2015-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef _SW_IOCTL_H_ +#define _SW_IOCTL_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + /*init*/ +#define SW_API_INIT_OFFSET 10 +#define SW_API_SWITCH_INIT (0 + SW_API_INIT_OFFSET) +#define SW_API_SWITCH_RESET (1 + SW_API_INIT_OFFSET) +#define SW_API_SSDK_CFG (2 + SW_API_INIT_OFFSET) +#define SW_API_MODULE_FUNC_CTRL_SET (3 + SW_API_INIT_OFFSET) +#define SW_API_MODULE_FUNC_CTRL_GET (4 + SW_API_INIT_OFFSET) + + /*port ctrl*/ +#define SW_API_PORT_OFFSET 30 +#define SW_API_PT_DUPLEX_GET (0 + SW_API_PORT_OFFSET) +#define SW_API_PT_DUPLEX_SET (1 + SW_API_PORT_OFFSET) +#define SW_API_PT_SPEED_GET (2 + SW_API_PORT_OFFSET) +#define SW_API_PT_SPEED_SET (3 + SW_API_PORT_OFFSET) +#define SW_API_PT_AN_ADV_GET (4 + SW_API_PORT_OFFSET) +#define SW_API_PT_AN_ADV_SET (5 + SW_API_PORT_OFFSET) +#define SW_API_PT_AN_GET (6 + SW_API_PORT_OFFSET) +#define SW_API_PT_AN_ENABLE (7 + SW_API_PORT_OFFSET) +#define SW_API_PT_AN_RESTART (8 + SW_API_PORT_OFFSET) +#define SW_API_PT_HIBERNATE_SET (17 + SW_API_PORT_OFFSET) +#define SW_API_PT_HIBERNATE_GET (18 + SW_API_PORT_OFFSET) +#define SW_API_PT_CDT (19 + SW_API_PORT_OFFSET) +#define SW_API_PT_LINK_STATUS_GET (38 + SW_API_PORT_OFFSET) +#define SW_API_PT_8023AZ_SET (46 + SW_API_PORT_OFFSET) +#define SW_API_PT_8023AZ_GET (47 + SW_API_PORT_OFFSET) +#define SW_API_PT_MDIX_SET (48 + SW_API_PORT_OFFSET) +#define SW_API_PT_MDIX_GET (49 + SW_API_PORT_OFFSET) +#define SW_API_PT_MDIX_STATUS_GET (50 + SW_API_PORT_OFFSET) +#define SW_API_PT_LOCAL_LOOPBACK_SET (56 + SW_API_PORT_OFFSET) +#define SW_API_PT_LOCAL_LOOPBACK_GET (57 + SW_API_PORT_OFFSET) +#define SW_API_PT_REMOTE_LOOPBACK_SET (58 + SW_API_PORT_OFFSET) +#define SW_API_PT_REMOTE_LOOPBACK_GET (59 + SW_API_PORT_OFFSET) +#define SW_API_PT_RESET (60 + SW_API_PORT_OFFSET) +#define SW_API_PT_POWER_OFF (61 + SW_API_PORT_OFFSET) +#define SW_API_PT_POWER_ON (62 + SW_API_PORT_OFFSET) +#define SW_API_PT_MAGIC_FRAME_MAC_SET (63 + SW_API_PORT_OFFSET) +#define SW_API_PT_MAGIC_FRAME_MAC_GET (64 + SW_API_PORT_OFFSET) +#define SW_API_PT_PHY_ID_GET (65 + SW_API_PORT_OFFSET) +#define SW_API_PT_WOL_STATUS_SET (66 + SW_API_PORT_OFFSET) +#define SW_API_PT_WOL_STATUS_GET (67 + SW_API_PORT_OFFSET) +#define SW_API_PT_INTERFACE_MODE_STATUS_GET (70 + SW_API_PORT_OFFSET) +#define SW_API_DEBUG_PHYCOUNTER_SET (71 + SW_API_PORT_OFFSET) +#define SW_API_DEBUG_PHYCOUNTER_GET (72 + SW_API_PORT_OFFSET) +#define SW_API_DEBUG_PHYCOUNTER_SHOW (73 + SW_API_PORT_OFFSET) + /*debug*/ +#define SW_API_DEBUG_OFFSET 10000 +#define SW_API_PHY_GET (0 + SW_API_DEBUG_OFFSET) +#define SW_API_PHY_SET (1 + SW_API_DEBUG_OFFSET) +#define SW_API_PHY_I2C_GET (22 + SW_API_DEBUG_OFFSET) +#define SW_API_PHY_I2C_SET (23 + SW_API_DEBUG_OFFSET) + +#define SW_API_MAX 0xffff + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _SW_IOCTL_H_ */ diff --git a/qca/src/qca-psdk/drv/src/api_access.c b/qca/src/qca-psdk/drv/src/api_access.c new file mode 100644 index 00000000000..e629e8d006b --- /dev/null +++ b/qca/src/qca-psdk/drv/src/api_access.c @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2012, 2017-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include "sw.h" +#include "fal.h" +#include "hsl.h" +#include "hsl_dev.h" + +#include "sw_api.h" +#include "api_desc.h" +#include "fal_api.h" +static sw_api_func_t sw_api_func[] = { + SSDK_API }; +static sw_api_param_t sw_api_param[] = { + SSDK_PARAM }; + +sw_api_func_t * +sw_api_func_find(a_uint32_t api_id) +{ + a_uint32_t i = 0; + static a_uint32_t save = 0; + + if(api_id == sw_api_func[save].api_id) + return &sw_api_func[save]; + + do + { + if (api_id == sw_api_func[i].api_id) + { + save = i; + return &sw_api_func[i]; + } + + } + while (++i < (sizeof(sw_api_func)/sizeof(sw_api_func[0]))); + + return NULL; +} + +sw_api_param_t * +sw_api_param_find(a_uint32_t api_id) +{ + a_uint32_t i = 0; + static a_uint32_t save = 0; + + if(api_id == sw_api_param[save].api_id) + return &sw_api_param[save]; + + do + { + if (api_id == sw_api_param[i].api_id) + { + save = i; + return &sw_api_param[i]; + } + } + while (++i < (sizeof(sw_api_param)/sizeof(sw_api_param[0]))); + + return NULL; +} + +a_uint32_t +sw_api_param_nums(a_uint32_t api_id) +{ + a_uint32_t i = 0; + sw_api_param_t *p = NULL; + static sw_api_param_t *savep = NULL; + static a_uint32_t save = 0; + + p = sw_api_param_find(api_id); + if (!p) + { + return 0; + } + + if (p == savep) + { + return save; + } + + savep = p; + while (api_id == p->api_id) + { + p++; + i++; + } + + /*error*/ + if(i >= sizeof(sw_api_param)/sizeof(sw_api_param[0])) + { + savep = NULL; + save = 0; + return 0; + } + save = i; + + return i; +} + +sw_error_t +sw_api_get(sw_api_t *sw_api) +{ + if(!sw_api) + return SW_FAIL; + + if ((sw_api->api_fp = sw_api_func_find(sw_api->api_id)) == NULL) + return SW_NOT_SUPPORTED; + + if ((sw_api->api_pp = sw_api_param_find(sw_api->api_id)) == NULL) + return SW_NOT_SUPPORTED; + + if((sw_api->api_nr = sw_api_param_nums(sw_api->api_id)) == 0) + return SW_NOT_SUPPORTED; + + return SW_OK; +} diff --git a/qca/src/qca-psdk/drv/src/fal/fal_init.c b/qca/src/qca-psdk/drv/src/fal/fal_init.c new file mode 100644 index 00000000000..cd7252c74b2 --- /dev/null +++ b/qca/src/qca-psdk/drv/src/fal/fal_init.c @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2012, 2016-2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +/** + * @defgroup fal_init FAL_INIT + * @{ + */ +#include "sw.h" +#include "hsl.h" +#include "hsl_dev.h" +#include "hsl_api.h" +/** + * @brief Init fal layer. + * @details Comments: + * This operation will init fal layer and hsl layer + * @param[in] dev_id device id + * @param[in] cfg configuration for initialization + * @return SW_OK or error code + */ +sw_error_t +fal_init(a_uint32_t dev_id, ssdk_init_cfg *cfg) +{ + sw_error_t rv; + HSL_DEV_ID_CHECK(dev_id); + + rv = hsl_api_init(dev_id); + SW_RTN_ON_ERROR(rv); + + rv = hsl_dev_init(dev_id, cfg); + SW_RTN_ON_ERROR(rv); + + return rv; +} +sw_error_t +fal_cleanup(void) +{ + sw_error_t rv; + + rv = hsl_dev_cleanup(); + SW_RTN_ON_ERROR(rv); + return SW_OK; +} diff --git a/qca/src/qca-psdk/drv/src/fal/fal_port_ctrl.c b/qca/src/qca-psdk/drv/src/fal/fal_port_ctrl.c new file mode 100644 index 00000000000..a143b514bfd --- /dev/null +++ b/qca/src/qca-psdk/drv/src/fal/fal_port_ctrl.c @@ -0,0 +1,1147 @@ +/* + * Copyright (c) 2012, 2015-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +/** + * @defgroup fal_port_ctrl FAL_PORT_CONTROL + * @{ + */ +#include "sw.h" +#include "fal_port_ctrl.h" +#include "hsl_api.h" +static sw_error_t +_fal_port_duplex_set (a_uint32_t dev_id, fal_port_t port_id, + fal_port_duplex_t duplex) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_duplex_set) + return SW_NOT_SUPPORTED; + + rv = p_api->port_duplex_set (dev_id, port_id, duplex); + return rv; +} + +static sw_error_t +_fal_port_speed_set (a_uint32_t dev_id, fal_port_t port_id, + fal_port_speed_t speed) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_speed_set) + return SW_NOT_SUPPORTED; + + rv = p_api->port_speed_set (dev_id, port_id, speed); + return rv; +} +static sw_error_t +_fal_port_speed_get (a_uint32_t dev_id, fal_port_t port_id, + fal_port_speed_t * pspeed) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_speed_get) + return SW_NOT_SUPPORTED; + + rv = p_api->port_speed_get (dev_id, port_id, pspeed); + return rv; +} + +static sw_error_t +_fal_port_duplex_get (a_uint32_t dev_id, fal_port_t port_id, + fal_port_duplex_t * pduplex) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_duplex_get) + return SW_NOT_SUPPORTED; + + rv = p_api->port_duplex_get (dev_id, port_id, pduplex); + return rv; +} + +static sw_error_t +_fal_port_autoneg_enable (a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_autoneg_enable) + return SW_NOT_SUPPORTED; + + rv = p_api->port_autoneg_enable (dev_id, port_id); + return rv; +} + +static sw_error_t +_fal_port_autoneg_restart (a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_autoneg_restart) + return SW_NOT_SUPPORTED; + + rv = p_api->port_autoneg_restart (dev_id, port_id); + return rv; +} + + +static sw_error_t +_fal_port_autoneg_adv_set (a_uint32_t dev_id, fal_port_t port_id, + a_uint32_t autoadv) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_autoneg_adv_set) + return SW_NOT_SUPPORTED; + + rv = p_api->port_autoneg_adv_set (dev_id, port_id, autoadv); + return rv; +} + +static sw_error_t +_fal_port_autoneg_status_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * status) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_autoneg_status_get) + return SW_NOT_SUPPORTED; + + rv = p_api->port_autoneg_status_get (dev_id, port_id, status); + return rv; +} + +static sw_error_t +_fal_port_autoneg_adv_get (a_uint32_t dev_id, fal_port_t port_id, + a_uint32_t * autoadv) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_autoneg_adv_get) + return SW_NOT_SUPPORTED; + + rv = p_api->port_autoneg_adv_get (dev_id, port_id, autoadv); + return rv; +} +static sw_error_t +_fal_port_hibernate_set (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_hibernate_set) + return SW_NOT_SUPPORTED; + + rv = p_api->port_hibernate_set (dev_id, port_id, enable); + return rv; +} + + +static sw_error_t +_fal_port_hibernate_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_hibernate_get) + return SW_NOT_SUPPORTED; + + rv = p_api->port_hibernate_get (dev_id, port_id, enable); + return rv; +} + +static sw_error_t +_fal_port_cdt (a_uint32_t dev_id, fal_port_t port_id, a_uint32_t mdi_pair, + a_uint32_t * cable_status, a_uint32_t * cable_len) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_cdt) + return SW_NOT_SUPPORTED; + + rv = p_api->port_cdt (dev_id, port_id, mdi_pair, cable_status, cable_len); + return rv; +} +static sw_error_t +_fal_port_link_status_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * status) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_link_status_get) + return SW_NOT_SUPPORTED; + + rv = p_api->port_link_status_get (dev_id, port_id, status); + return rv; +} + +static sw_error_t +_fal_port_power_off (a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_power_off) + return SW_NOT_SUPPORTED; + + rv = p_api->port_power_off (dev_id, port_id); + return rv; +} + +static sw_error_t +_fal_port_power_on (a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_power_on) + return SW_NOT_SUPPORTED; + + rv = p_api->port_power_on (dev_id, port_id); + return rv; +} +static sw_error_t +_fal_port_8023az_set (a_uint32_t dev_id, fal_port_t port_id, a_bool_t enable) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_8023az_set) + return SW_NOT_SUPPORTED; + + rv = p_api->port_8023az_set (dev_id, port_id, enable); + return rv; +} + + +static sw_error_t +_fal_port_8023az_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_8023az_get) + return SW_NOT_SUPPORTED; + + rv = p_api->port_8023az_get (dev_id, port_id, enable); + return rv; +} + +static sw_error_t +_fal_port_mdix_set (a_uint32_t dev_id, fal_port_t port_id, + fal_port_mdix_mode_t mode) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_mdix_set) + return SW_NOT_SUPPORTED; + + rv = p_api->port_mdix_set (dev_id, port_id, mode); + return rv; +} + +static sw_error_t +_fal_port_mdix_get (a_uint32_t dev_id, fal_port_t port_id, + fal_port_mdix_mode_t * mode) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_mdix_get) + return SW_NOT_SUPPORTED; + + rv = p_api->port_mdix_get (dev_id, port_id, mode); + return rv; +} + +static sw_error_t +_fal_port_mdix_status_get (a_uint32_t dev_id, fal_port_t port_id, + fal_port_mdix_status_t * mode) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_mdix_status_get) + return SW_NOT_SUPPORTED; + + rv = p_api->port_mdix_status_get (dev_id, port_id, mode); + return rv; +} +static sw_error_t +_fal_port_local_loopback_set (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_local_loopback_set) + return SW_NOT_SUPPORTED; + + rv = p_api->port_local_loopback_set (dev_id, port_id, enable); + return rv; +} + + +static sw_error_t +_fal_port_local_loopback_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_local_loopback_get) + return SW_NOT_SUPPORTED; + + rv = p_api->port_local_loopback_get (dev_id, port_id, enable); + return rv; +} + +static sw_error_t +_fal_port_remote_loopback_set (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_remote_loopback_set) + return SW_NOT_SUPPORTED; + + rv = p_api->port_remote_loopback_set (dev_id, port_id, enable); + return rv; +} + + +static sw_error_t +_fal_port_remote_loopback_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_remote_loopback_get) + return SW_NOT_SUPPORTED; + + rv = p_api->port_remote_loopback_get (dev_id, port_id, enable); + return rv; +} + +static sw_error_t +_fal_port_reset (a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_reset) + return SW_NOT_SUPPORTED; + + rv = p_api->port_reset (dev_id, port_id); + return rv; +} + + +static sw_error_t +_fal_port_phy_id_get (a_uint32_t dev_id, fal_port_t port_id,a_uint16_t * org_id, a_uint16_t * rev_id) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_phy_id_get) + return SW_NOT_SUPPORTED; + + rv = p_api->port_phy_id_get (dev_id, port_id,org_id,rev_id); + return rv; +} + +static sw_error_t +_fal_port_wol_status_set (a_uint32_t dev_id, fal_port_t port_id, a_bool_t enable) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_wol_status_set) + return SW_NOT_SUPPORTED; + + rv = p_api->port_wol_status_set (dev_id, port_id,enable); + return rv; +} + +static sw_error_t +_fal_port_wol_status_get (a_uint32_t dev_id, fal_port_t port_id, a_bool_t *enable) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_wol_status_get) + return SW_NOT_SUPPORTED; + + rv = p_api->port_wol_status_get (dev_id, port_id,enable); + return rv; +} + +static sw_error_t +_fal_port_magic_frame_mac_set (a_uint32_t dev_id, fal_port_t port_id, fal_mac_addr_t * mac) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_magic_frame_mac_set) + return SW_NOT_SUPPORTED; + + rv = p_api->port_magic_frame_mac_set (dev_id, port_id, mac); + return rv; +} + +static sw_error_t +_fal_port_magic_frame_mac_get (a_uint32_t dev_id, fal_port_t port_id, fal_mac_addr_t * mac) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_magic_frame_mac_get) + return SW_NOT_SUPPORTED; + + rv = p_api->port_magic_frame_mac_get (dev_id, port_id, mac); + return rv; +} +static sw_error_t +_fal_port_interface_mode_status_get (a_uint32_t dev_id, fal_port_t port_id, fal_port_interface_mode_t * mode) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_interface_mode_status_get) + return SW_NOT_SUPPORTED; + + rv = p_api->port_interface_mode_status_get (dev_id, port_id, mode); + return rv; +} + +static sw_error_t +_fal_port_counter_set (a_uint32_t dev_id, fal_port_t port_id, a_bool_t enable) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_counter_set) + return SW_NOT_SUPPORTED; + + rv = p_api->port_counter_set (dev_id, port_id, enable); + return rv; +} + + +static sw_error_t +_fal_port_counter_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_counter_get) + return SW_NOT_SUPPORTED; + + rv = p_api->port_counter_get (dev_id, port_id, enable); + return rv; +} + +static sw_error_t +_fal_port_counter_show (a_uint32_t dev_id, fal_port_t port_id, fal_port_counter_info_t * counter_info) +{ + sw_error_t rv; + hsl_api_t *p_api; + SW_RTN_ON_NULL (p_api = hsl_api_ptr_get (dev_id)); + + if (NULL == p_api->port_counter_show) + return SW_NOT_SUPPORTED; + + rv = p_api->port_counter_show (dev_id, port_id, counter_info); + return rv; +} +/*insert flag for inner fal, don't remove it*/ +/** + * @brief Set duplex mode on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[in] duplex duplex mode + * @return SW_OK or error code + */ +sw_error_t +fal_port_duplex_set (a_uint32_t dev_id, fal_port_t port_id, + fal_port_duplex_t duplex) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_duplex_set (dev_id, port_id, duplex); + FAL_API_UNLOCK; + return rv; +} + + + +/** + * @brief Set speed on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[in] speed port speed + * @return SW_OK or error code + */ +sw_error_t +fal_port_speed_set (a_uint32_t dev_id, fal_port_t port_id, + fal_port_speed_t speed) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_speed_set (dev_id, port_id, speed); + FAL_API_UNLOCK; + return rv; +} +/** + * @brief Get duplex mode on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] duplex duplex mode + * @return SW_OK or error code + */ +sw_error_t +fal_port_duplex_get (a_uint32_t dev_id, fal_port_t port_id, + fal_port_duplex_t * pduplex) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_duplex_get (dev_id, port_id, pduplex); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief Get speed on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] speed port speed + * @return SW_OK or error code + */ +sw_error_t +fal_port_speed_get (a_uint32_t dev_id, fal_port_t port_id, + fal_port_speed_t * pspeed) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_speed_get (dev_id, port_id, pspeed); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief Enable auto negotiation status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @return SW_OK or error code + */ +sw_error_t +fal_port_autoneg_enable (a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_autoneg_enable (dev_id, port_id); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief Restart auto negotiation procedule on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @return SW_OK or error code + */ +sw_error_t +fal_port_autoneg_restart (a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_autoneg_restart (dev_id, port_id); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief Set auto negotiation advtisement ability on a particular port. + * @details Comments: + * auto negotiation advtisement ability is defined by macro such as + * FAL_PHY_ADV_10T_HD, FAL_PHY_ADV_PAUSE... + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[in] autoadv auto negotiation advtisement ability bit map + * @return SW_OK or error code + */ +sw_error_t +fal_port_autoneg_adv_set (a_uint32_t dev_id, fal_port_t port_id, + a_uint32_t autoadv) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_autoneg_adv_set (dev_id, port_id, autoadv); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief Get auto negotiation status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] status A_TRUE or A_FALSE + * @return SW_OK or error code + */ +sw_error_t +fal_port_autoneg_status_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * status) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_autoneg_status_get (dev_id, port_id, status); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief Get auto negotiation advtisement ability on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] autoadv auto negotiation advtisement ability bit map + * @return SW_OK or error code + */ +sw_error_t +fal_port_autoneg_adv_get (a_uint32_t dev_id, fal_port_t port_id, + a_uint32_t * autoadv) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_autoneg_adv_get (dev_id, port_id, autoadv); + FAL_API_UNLOCK; + return rv; +} +/** + * @brief Set hibernate status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[in] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +sw_error_t +fal_port_hibernate_set (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_hibernate_set (dev_id, port_id, enable); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief Get hibernate status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +sw_error_t +fal_port_hibernate_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_hibernate_get (dev_id, port_id, enable); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief cable diagnostic test. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[in] mdi_pair mdi pair id + * @param[out] cable_status cable status + * @param[out] cable_len cable len + * @return SW_OK or error code + */ +sw_error_t +fal_port_cdt (a_uint32_t dev_id, fal_port_t port_id, a_uint32_t mdi_pair, + a_uint32_t * cable_status, a_uint32_t * cable_len) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_cdt (dev_id, port_id, mdi_pair, cable_status, cable_len); + FAL_API_UNLOCK; + return rv; +} +/** + * @brief Get link status on particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] status link status up (A_TRUE) or down (A_FALSE) + * @return SW_OK or error code + */ +sw_error_t +fal_port_link_status_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * status) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_link_status_get (dev_id, port_id, status); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief power off on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] + * @return SW_OK or error code + */ +sw_error_t +fal_port_power_off (a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_power_off (dev_id, port_id); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief power on on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] + * @return SW_OK or error code + */ +sw_error_t +fal_port_power_on (a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_power_on (dev_id, port_id); + FAL_API_UNLOCK; + return rv; +} +/** + * @brief Set 8023az status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[in] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +sw_error_t +fal_port_8023az_set (a_uint32_t dev_id, fal_port_t port_id, a_bool_t enable) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_8023az_set (dev_id, port_id, enable); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief Get 8023az status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +sw_error_t +fal_port_8023az_get (a_uint32_t dev_id, fal_port_t port_id, a_bool_t * enable) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_8023az_get (dev_id, port_id, enable); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief Set mdix mode on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[in] set mdix mode [mdx , mdix or auto] + * @return SW_OK or error code + */ +sw_error_t +fal_port_mdix_set (a_uint32_t dev_id, fal_port_t port_id, + fal_port_mdix_mode_t mode) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_mdix_set (dev_id, port_id, mode); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief Get mdix on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] set mdx ,mdix or auto + * @return SW_OK or error code + */ +sw_error_t +fal_port_mdix_get (a_uint32_t dev_id, fal_port_t port_id, + fal_port_mdix_mode_t * mode) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_mdix_get (dev_id, port_id, mode); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief Get mdix status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] set mdx ,mdix + * @return SW_OK or error code + */ +sw_error_t +fal_port_mdix_status_get (a_uint32_t dev_id, fal_port_t port_id, + fal_port_mdix_status_t * mode) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_mdix_status_get (dev_id, port_id, mode); + FAL_API_UNLOCK; + return rv; +} +/** + * @brief Set local loopback on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[in] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +sw_error_t +fal_port_local_loopback_set (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_local_loopback_set (dev_id, port_id, enable); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief Get local loopback status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +sw_error_t +fal_port_local_loopback_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_local_loopback_get (dev_id, port_id, enable); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief Set remote loopback on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[in] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +sw_error_t +fal_port_remote_loopback_set (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_remote_loopback_set (dev_id, port_id, enable); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief Get remote loopback status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +sw_error_t +fal_port_remote_loopback_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_remote_loopback_get (dev_id, port_id, enable); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief software reset on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] + * @return SW_OK or error code + */ +sw_error_t +fal_port_reset (a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_reset (dev_id, port_id); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief phy id on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] + * @return SW_OK or error code + */ +sw_error_t +fal_port_phy_id_get (a_uint32_t dev_id, fal_port_t port_id, a_uint16_t * org_id, a_uint16_t * rev_id) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_phy_id_get (dev_id, port_id,org_id,rev_id); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief wol status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] + * @return SW_OK or error code + */ +sw_error_t +fal_port_wol_status_set (a_uint32_t dev_id, fal_port_t port_id, a_bool_t enable) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_wol_status_set (dev_id, port_id,enable); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief wol status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] + * @return SW_OK or error code + */ +sw_error_t +fal_port_wol_status_get (a_uint32_t dev_id, fal_port_t port_id, a_bool_t *enable) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_wol_status_get (dev_id, port_id,enable); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief magic frame mac on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] + * @return SW_OK or error code + */ +sw_error_t +fal_port_magic_frame_mac_set (a_uint32_t dev_id, fal_port_t port_id, fal_mac_addr_t * mac) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_magic_frame_mac_set (dev_id, port_id,mac); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief magic frame mac on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] + * @return SW_OK or error code + */ +sw_error_t +fal_port_magic_frame_mac_get (a_uint32_t dev_id, fal_port_t port_id, fal_mac_addr_t * mac) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_magic_frame_mac_get (dev_id, port_id,mac); + FAL_API_UNLOCK; + return rv; +} +/** + * @brief interface mode status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] + * @return SW_OK or error code + */ +sw_error_t +fal_port_interface_mode_status_get (a_uint32_t dev_id, fal_port_t port_id, fal_port_interface_mode_t * mode) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_interface_mode_status_get (dev_id, port_id,mode); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief Set counter status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[in] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +sw_error_t +fal_debug_phycounter_set (a_uint32_t dev_id, fal_port_t port_id, a_bool_t enable) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_counter_set (dev_id, port_id, enable); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief Get counter status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +sw_error_t +fal_debug_phycounter_get (a_uint32_t dev_id, fal_port_t port_id, a_bool_t * enable) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_counter_get (dev_id, port_id, enable); + FAL_API_UNLOCK; + return rv; +} + +/** + * @brief Get counter statistics on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] counter frame number + * @return SW_OK or error code + */ +sw_error_t +fal_debug_phycounter_show (a_uint32_t dev_id, fal_port_t port_id, fal_port_counter_info_t* port_counter_info) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_port_counter_show (dev_id, port_id, port_counter_info); + FAL_API_UNLOCK; + return rv; +} diff --git a/qca/src/qca-psdk/drv/src/fal/fal_reg_access.c b/qca/src/qca-psdk/drv/src/fal/fal_reg_access.c new file mode 100644 index 00000000000..1fc4ef10e19 --- /dev/null +++ b/qca/src/qca-psdk/drv/src/fal/fal_reg_access.c @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2012, 2017-2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +/** + * @defgroup fal_reg_access FAL_REG_ACCESS + * @{ + */ +#include "sw.h" +#include "fal_reg_access.h" +#include "hsl_api.h" +#include "hsl_phy.h" + +static sw_error_t +_fal_phy_get(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg, a_uint16_t * value) +{ + sw_error_t rv; + hsl_api_t *p_api; + a_uint8_t phy_addr_type; + hsl_phy_get phy_get_func; + + SW_RTN_ON_NULL(p_api = hsl_api_ptr_get(dev_id)); + + /* the MSB first byte of phy_addr marks the type of + * phy address, such as the i2c address, the value of + * MSB first byte should be 1 */ + phy_addr_type = (phy_addr & 0xff000000) >> 24; + phy_addr = phy_addr & 0xff; + switch (phy_addr_type) { + case PHY_I2C_ACCESS: + phy_get_func = p_api->phy_i2c_get; + break; + default: + phy_get_func = p_api->phy_get; + break; + } + + if (NULL == phy_get_func) { + return SW_NOT_SUPPORTED; + } + + rv = phy_get_func(dev_id, phy_addr, reg, value); + return rv; +} + +static sw_error_t +_fal_phy_set(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg, a_uint16_t value) +{ + sw_error_t rv; + hsl_api_t *p_api; + a_uint8_t phy_addr_type; + hsl_phy_set phy_set_func; + + SW_RTN_ON_NULL(p_api = hsl_api_ptr_get(dev_id)); + + /* the MSB first byte of phy_addr marks the type of + * phy address, such as the i2c address, the value of + * MSB first byte should be 1 */ + phy_addr_type = (phy_addr & 0xff000000) >> 24; + phy_addr = phy_addr & 0xff; + switch (phy_addr_type) { + case PHY_I2C_ACCESS: + phy_set_func = p_api->phy_i2c_set; + break; + default: + phy_set_func = p_api->phy_set; + break; + } + + if (NULL == phy_set_func) { + return SW_NOT_SUPPORTED; + } + + rv = phy_set_func(dev_id, phy_addr, reg, value); + return rv; +} +/** + * fal_phy_get - get value of specific phy device + * @phy_addr: id of the phy device + * @reg: register id of phy device + * @value: pointer to the memory storing the value. + * @return SW_OK or error code + */ +sw_error_t +fal_phy_get(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg, a_uint16_t * value) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_phy_get(dev_id, phy_addr, reg, value); + FAL_API_UNLOCK; + return rv; +} + +/** + * fal_phy_set - set value of specific phy device + * @phy_addr: id of the phy device + * @reg: register id of phy device + * @value: register value. + * @return SW_OK or error code + */ +sw_error_t +fal_phy_set(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg, a_uint16_t value) +{ + sw_error_t rv; + + FAL_API_LOCK; + rv = _fal_phy_set(dev_id, phy_addr, reg, value); + FAL_API_UNLOCK; + return rv; +} diff --git a/qca/src/qca-psdk/drv/src/hsl/hsl_api.c b/qca/src/qca-psdk/drv/src/hsl/hsl_api.c new file mode 100755 index 00000000000..aeb3d36e84a --- /dev/null +++ b/qca/src/qca-psdk/drv/src/hsl/hsl_api.c @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2012, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + + +#include "sw.h" +#include "hsl_api.h" + +static hsl_api_t hsl_api_table[SW_MAX_NR_DEV]; + +hsl_api_t * +hsl_api_ptr_get(a_uint32_t dev_id) +{ + if (dev_id >= SW_MAX_NR_DEV) + return NULL; + + return &(hsl_api_table[dev_id]); +} + +sw_error_t +hsl_api_init(a_uint32_t dev_id) +{ + if (SW_MAX_NR_DEV <= dev_id) + { + return SW_BAD_PARAM; + } + + aos_mem_set(&hsl_api_table[dev_id], 0, sizeof (hsl_api_t)); + return SW_OK; +} + diff --git a/qca/src/qca-psdk/drv/src/hsl/hsl_dev.c b/qca/src/qca-psdk/drv/src/hsl/hsl_dev.c new file mode 100644 index 00000000000..b151663cc74 --- /dev/null +++ b/qca/src/qca-psdk/drv/src/hsl/hsl_dev.c @@ -0,0 +1,210 @@ +/* + * Copyright (c) 2012, 2017-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include "sw.h" +#include "hsl.h" +#include "hsl_dev.h" +#include "hsl_lock.h" +#include "sd.h" +#include "scomphy_init.h" +#include "sw_api.h" +#include "sw_api_ks.h" +static hsl_dev_t dev_table[SW_MAX_NR_DEV]; +static ssdk_init_cfg *dev_ssdk_cfg[SW_MAX_NR_DEV] = { 0 }; +ssdk_chip_type SSDK_CURRENT_CHIP_TYPE = CHIP_UNSPECIFIED; + +static sw_error_t hsl_set_current_chip_type(ssdk_chip_type chip_type) +{ + sw_error_t rv = SW_OK; + + SSDK_CURRENT_CHIP_TYPE = chip_type; + + if (SSDK_CURRENT_CHIP_TYPE == CHIP_UNSPECIFIED) + { + SSDK_CURRENT_CHIP_TYPE = CHIP_SCOMPHY; + } + return rv; +} + +hsl_dev_t * +hsl_dev_ptr_get(a_uint32_t dev_id) +{ + if (dev_id >= SW_MAX_NR_DEV) + return NULL; + + return &dev_table[dev_id]; +} +sw_error_t +hsl_dev_init(a_uint32_t dev_id, ssdk_init_cfg *cfg) +{ + sw_error_t rv = SW_OK; + static int dev_init = 0; + + if (SW_MAX_NR_DEV <= dev_id) + { + return SW_BAD_PARAM; + } + + aos_mem_set(&dev_table[dev_id], 0, sizeof (hsl_dev_t)); + + if (!dev_init) { + SW_RTN_ON_ERROR(sd_init(dev_id,cfg)); + +#ifdef UK_IF + SW_RTN_ON_ERROR(sw_uk_init(cfg->nl_prot)); +#endif + +#if defined API_LOCK + SW_RTN_ON_ERROR(hsl_api_lock_init()); +#endif + dev_init = 1; + } + rv = hsl_set_current_chip_type(cfg->chip_type); + SW_RTN_ON_ERROR(rv); + + if (NULL == dev_ssdk_cfg[dev_id]) + { + dev_ssdk_cfg[dev_id] = aos_mem_alloc(sizeof (ssdk_init_cfg)); + } + + if (NULL == dev_ssdk_cfg[dev_id]) + { + return SW_OUT_OF_MEM; + } + + aos_mem_copy(dev_ssdk_cfg[dev_id], cfg, sizeof (ssdk_init_cfg)); +#if defined UK_MINOR_DEV + dev_ssdk_cfg[dev_id]->nl_prot = UK_MINOR_DEV; +#endif + + rv = SW_INIT_ERROR; + switch (cfg->chip_type) + { + case CHIP_SCOMPHY: + rv = scomphy_init(dev_id, cfg); + break; + default: + return SW_BAD_PARAM; + } + + return rv; +} +sw_error_t +hsl_dev_cleanup(void) +{ + sw_error_t rv = SW_OK; + a_uint32_t dev_id; + + for (dev_id = 0; dev_id < SW_MAX_NR_DEV; dev_id++) + { + if (dev_ssdk_cfg[dev_id]) + { + hsl_api_t *p_api; + + SW_RTN_ON_NULL(p_api = hsl_api_ptr_get(dev_id)); + if (p_api->dev_clean) + { + rv = p_api->dev_clean(dev_id); + SW_RTN_ON_ERROR(rv); + } + + aos_mem_free(dev_ssdk_cfg[dev_id]); + dev_ssdk_cfg[dev_id] = NULL; + } + } + +#ifdef UK_IF + SW_RTN_ON_ERROR(sw_uk_cleanup()); +#endif + + return SW_OK; +} +sw_error_t reduce_hsl_phy_set(a_uint32_t dev,a_uint32_t phy_addr,a_uint32_t reg,a_uint16_t value) +{ + sw_error_t rv; + + hsl_api_t *p_api = hsl_api_ptr_get(dev); + if (p_api) { + rv = p_api->phy_set(dev, phy_addr, reg, value); + } else { + rv = SW_NOT_INITIALIZED; + } + + return rv; +} + +sw_error_t reduce_hsl_phy_get(a_uint32_t dev,a_uint32_t phy_addr,a_uint32_t reg,a_uint16_t* value) +{ + sw_error_t rv; + + hsl_api_t *p_api = hsl_api_ptr_get(dev); + if (p_api) { + rv = p_api->phy_get(dev, phy_addr, reg, value); + } else { + rv = SW_NOT_INITIALIZED; + } + + return rv; +} + +sw_error_t hsl_phy_i2c_set(a_uint32_t dev,a_uint32_t phy_addr,a_uint32_t reg,a_uint16_t value) +{ + sw_error_t rv; + + hsl_api_t *p_api = hsl_api_ptr_get(dev); + if (p_api) { + rv = p_api->phy_i2c_set(dev, phy_addr, reg, value); + } else { + rv = SW_NOT_INITIALIZED; + } + + return rv; +} + +sw_error_t hsl_phy_i2c_get(a_uint32_t dev,a_uint32_t phy_addr,a_uint32_t reg,a_uint16_t* value) +{ + sw_error_t rv; + + hsl_api_t *p_api = hsl_api_ptr_get(dev); + if (p_api) { + rv = p_api->phy_i2c_get(dev, phy_addr, reg, value); + } else { + rv = SW_NOT_INITIALIZED; + } + + return rv; +} + +#if 0 +void reduce_sw_set_reg_by_field_u32(unsigned int reg_value,unsigned int field_value, + unsigned int reg_offset,unsigned int reg_len) +{ + do { + (reg_value) = (((reg_value) & SW_FIELD_MASK_NOT_U32((reg_offset),(reg_offset))) + | (((field_value) & SW_BIT_MASK_U32(reg_len)) << (reg_offset))); + } while (0); + +} + + +void reduce_sw_field_get_by_reg_u32(unsigned int reg_value,unsigned int field_value, + unsigned int reg_offset,unsigned int reg_len) +{ + do { + (field_value) = (((reg_value) >> (reg_offset)) & SW_BIT_MASK_U32(reg_len)); + } while (0); + +} +#endif diff --git a/qca/src/qca-psdk/drv/src/hsl/hsl_lock.c b/qca/src/qca-psdk/drv/src/hsl/hsl_lock.c new file mode 100755 index 00000000000..e9d45405282 --- /dev/null +++ b/qca/src/qca-psdk/drv/src/hsl/hsl_lock.c @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2012, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + + +#include "sw.h" + +#ifdef KVER32 +aos_lock_t sw_hsl_api_lock; +#else +aos_lock_t sw_hsl_api_lock = aos_default_unlock; +#endif + +sw_error_t +hsl_api_lock_init(void) +{ + aos_lock_init(&sw_hsl_api_lock); + return SW_OK; +} diff --git a/qca/src/qca-psdk/drv/src/hsl/hsl_phy.c b/qca/src/qca-psdk/drv/src/hsl/hsl_phy.c new file mode 100644 index 00000000000..ab84702b5df --- /dev/null +++ b/qca/src/qca-psdk/drv/src/hsl/hsl_phy.c @@ -0,0 +1,352 @@ +/* + * Copyright (c) 2015, 2017-2020, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include "sw.h" +#include "hsl_phy.h" +#include "hsl.h" +#include +#include "sw.h" +#include "ssdk_plat.h" +#include "hsl_port_prop.h" + +phy_info_t *phy_info[SW_MAX_NR_DEV] = {0}; +a_uint32_t port_bmp[SW_MAX_NR_DEV] = {0}; + + +phy_driver_instance_t ssdk_phy_driver[] = +{ + {QCA808X_PHY_CHIP, {0}, NULL, qca808x_phy_init, qca808x_phy_exit}, + {MAX_PHY_CHIP, {0}, NULL, NULL, NULL} +}; +sw_error_t hsl_phy_api_ops_register(phy_type_t phy_type, hsl_phy_ops_t * phy_api_ops) +{ + + ssdk_phy_driver[phy_type].phy_ops = phy_api_ops; + + return SW_OK; + +} + +sw_error_t hsl_phy_api_ops_unregister(phy_type_t phy_type, hsl_phy_ops_t * phy_api_ops) +{ + + ssdk_phy_driver[phy_type].phy_ops = NULL; + + return SW_OK; + +} + +hsl_phy_ops_t *hsl_phy_api_ops_get(a_uint32_t dev_id, a_uint32_t port_id) +{ + phy_type_t phytype = 0; + + if (dev_id >= SW_MAX_NR_DEV) + return NULL; + + phytype = phy_info[dev_id]->phy_type[port_id]; + if(phytype == MAX_PHY_CHIP) + { + return NULL; + } + + return ssdk_phy_driver[phytype].phy_ops; + +} + +sw_error_t phy_api_ops_init(phy_type_t phy_type) +{ + + if (MAX_PHY_CHIP <= phy_type) + return SW_BAD_PARAM; + + if(ssdk_phy_driver[phy_type].phy_ops != NULL) + { + kfree(ssdk_phy_driver[phy_type].phy_ops); + ssdk_phy_driver[phy_type].phy_ops = NULL; + } + return SW_OK; +} + +a_bool_t hsl_port_is_sfp(a_uint32_t dev_id, a_uint32_t port_id, ssdk_init_cfg *cfg) +{ + if ((cfg->chip_type == CHIP_HPPE) && + (((SSDK_PHYSICAL_PORT5 == port_id) && + ((cfg->mac_mode1 == PORT_WRAPPER_10GBASE_R) || + (cfg->mac_mode1 == PORT_WRAPPER_SGMII_FIBER))) || + ((SSDK_PHYSICAL_PORT6 == port_id) && + ((cfg->mac_mode2 == PORT_WRAPPER_10GBASE_R) || + (cfg->mac_mode2 == PORT_WRAPPER_SGMII_FIBER))))) + return A_TRUE; + else + return A_FALSE; +} + +a_uint32_t hsl_phyid_get(a_uint32_t dev_id, + a_uint32_t port_id, ssdk_init_cfg *cfg) +{ + a_uint16_t org_id = 0, rev_id = 0; + a_uint32_t reg_pad = 0, phy_id = 0; + + if (hsl_port_is_sfp(dev_id, port_id, cfg)){ + return SFP_PHY; + } + + if (phy_info[dev_id]->phy_c45[port_id] == A_TRUE){ + reg_pad = BIT(30) | BIT(16); + } + +#if defined(IN_PHY_I2C_MODE) + if (hsl_port_phy_access_type_get(dev_id, port_id) == PHY_I2C_ACCESS) { + cfg->reg_func.i2c_get(dev_id, + phy_info[dev_id]->phy_address[port_id], reg_pad | 2, &org_id); + cfg->reg_func.i2c_get(dev_id, + phy_info[dev_id]->phy_address[port_id], reg_pad | 3, &rev_id); + if(((org_id << 16) | rev_id) == INVALID_PHY_ID) { + return QCA8081_PHY_V1_1; + } + } + else +#endif + { + cfg->reg_func.mdio_get(dev_id, + phy_info[dev_id]->phy_address[port_id], reg_pad | 2, &org_id); + cfg->reg_func.mdio_get(dev_id, + phy_info[dev_id]->phy_address[port_id], reg_pad | 3, &rev_id); + } + + phy_id = (org_id<<16) | rev_id; + + return phy_id; +} + +phy_type_t hsl_phytype_get_by_phyid(a_uint32_t dev_id, a_uint32_t phy_id) +{ + phy_type_t phytype = MAX_PHY_CHIP; + + switch (phy_id) + { + case QCA8081_PHY_V1_1: + phytype = QCA808X_PHY_CHIP; + break; + default: + phytype = MAX_PHY_CHIP; + } + + return phytype; +} +int ssdk_phy_driver_init(a_uint32_t dev_id, ssdk_init_cfg *cfg) +{ + + int i = 0; + a_uint32_t phy_id = 0; + phy_type_t phytype = MAX_PHY_CHIP; + + for (i = 0; i < SW_MAX_NR_PORT; i++) + { + if (port_bmp[dev_id] & (0x1 << i)) + { + phy_id = hsl_phyid_get(dev_id, i, cfg); + phytype = hsl_phytype_get_by_phyid(dev_id, phy_id); + if (MAX_PHY_CHIP != phytype) { + phy_info[dev_id]->phy_type[i] = phytype; + ssdk_phy_driver[phytype].port_bmp[dev_id] |= (0x1 << i); + } else { + SSDK_INFO("dev_id = %d, phy_adress = %d, phy_id = 0x%x phy" + "type doesn't match\n", dev_id, + phy_info[dev_id]->phy_address[i], phy_id); + } + } + } + + for(i = 0; i < MAX_PHY_CHIP;i++) { + if(ssdk_phy_driver[i].port_bmp[dev_id] != 0 && + ssdk_phy_driver[i].init != NULL) { + ssdk_phy_driver[i].init(dev_id, ssdk_phy_driver[i].port_bmp[dev_id]); + } + } + return 0; +} + +#ifdef QCA808X_PORTS_INFO +typedef struct { + a_uint32_t port_id; + a_uint32_t phy_address; + a_uint8_t phy_access_type; +} qca808x_phy_info_t; +/*5 is port_id, 0x1c is qca808x phy address, PHY_MDIO_ACCESS is mdio +mode to access qca808x phy, PHY_I2C_ACCESS is I2C mode to access +qca808x phy*/ +static qca808x_phy_info_t qca808x_phy_info[] = { + {5,0x7c,PHY_I2C_ACCESS} +}; +static int qca_ssdk_qca808x_phy_info_init(a_uint32_t dev_id) +{ + a_uint32_t port_bmp = 0, port_id = 0, port_index = 0, port_index_max = 0; + + port_index_max = sizeof(qca808x_phy_info)/(sizeof(qca808x_phy_info_t)); + for(port_index = 0; port_index < port_index_max; port_index++) { + port_id = qca808x_phy_info[port_index].port_id; + port_bmp |= (1 << port_id); + /*qca808x phy address*/ + phy_info[dev_id]->phy_address[port_id] = + qca808x_phy_info[port_index].phy_address; + /*qca808x access mode, 1:i2c, 0:mdio*/ + phy_info[dev_id]->phy_access_type[port_id] = + qca808x_phy_info[port_index].phy_access_type; + } + qca_ssdk_port_bmp_set(dev_id, port_bmp); + + return 0; +} +#endif + +int qca_ssdk_phy_info_init(a_uint32_t dev_id) +{ + a_uint32_t j = 0; + phy_info_t *phy_information; + + phy_information = kzalloc(sizeof(phy_info_t), GFP_KERNEL); + if (phy_information == NULL) { + SSDK_ERROR("phy_information kzalloc failed!\n"); + return -ENOMEM; + } + memset(phy_information, 0, sizeof(*phy_information)); + phy_info[dev_id] = phy_information; + + for (j = SSDK_PHYSICAL_PORT0; j < SW_MAX_NR_PORT; j ++) + { + phy_info[dev_id]->phy_type[j] = MAX_PHY_CHIP; + if(j == SSDK_PHYSICAL_PORT0) + { + phy_info[dev_id]->phy_address[j] = INVALID_PHY_ADDR; + } + else + { + phy_info[dev_id]->phy_address[j] = j - 1; + } + } +#ifdef QCA808X_PORTS_INFO + qca_ssdk_qca808x_phy_info_init(dev_id); +#endif + + return 0; +} +void qca_ssdk_port_bmp_init(a_uint32_t dev_id) +{ + port_bmp[dev_id] = 0x3e; + + return; +} +void qca_ssdk_port_bmp_set(a_uint32_t dev_id, a_uint32_t value) +{ + port_bmp[dev_id] = value; + + return; +} + +a_uint32_t qca_ssdk_port_bmp_get(a_uint32_t dev_id) +{ + + return port_bmp[dev_id]; +} +a_uint32_t +qca_ssdk_port_to_phy_addr(a_uint32_t dev_id, a_uint32_t port_id) +{ + return phy_info[dev_id]->phy_address[port_id]; +} + +a_uint32_t +qca_ssdk_phy_addr_to_port(a_uint32_t dev_id, a_uint32_t phy_addr) +{ + a_uint32_t i = 0; + + for (i = 0; i < SW_MAX_NR_PORT; i ++) + { + if (phy_info[dev_id]->phy_address[i] == phy_addr) + return i; + } + SSDK_ERROR("doesn't match port_id to specified phy_addr !\n"); + return 0; +} + +a_bool_t +hsl_port_phy_combo_capability_get(a_uint32_t dev_id, a_uint32_t port_id) +{ + if (dev_id >= SW_MAX_NR_DEV) + return A_FALSE; + + return phy_info[dev_id]->phy_combo[port_id]; +} + +void +hsl_port_phy_combo_capability_set(a_uint32_t dev_id, a_uint32_t port_id, + a_bool_t enable) +{ + if (dev_id >= SW_MAX_NR_DEV) + return; + + phy_info[dev_id]->phy_combo[port_id] = enable; + + return; +} + +a_uint8_t +hsl_port_phy_access_type_get(a_uint32_t dev_id, a_uint32_t port_id) +{ + if (dev_id >= SW_MAX_NR_DEV) + return 0; + + return phy_info[dev_id]->phy_access_type[port_id]; +} + +void +hsl_port_phy_access_type_set(a_uint32_t dev_id, a_uint32_t port_id, + a_uint8_t access_type) +{ + if (dev_id >= SW_MAX_NR_DEV) + return; + + phy_info[dev_id]->phy_access_type[port_id] = access_type; + + return; +} +sw_error_t ssdk_phy_driver_cleanup(void) +{ + a_uint32_t i = 0, j = 0; + + for (i = 0; i < MAX_PHY_CHIP;i++) { + for (j = 0; j < SW_MAX_NR_DEV; j++) { + if (ssdk_phy_driver[i].port_bmp[j] != 0 && + ssdk_phy_driver[i].exit != NULL) { + ssdk_phy_driver[i].exit(j, ssdk_phy_driver[i].port_bmp[j]); + } + } + if(ssdk_phy_driver[i].phy_ops != NULL) + { + kfree(ssdk_phy_driver[i].phy_ops); + ssdk_phy_driver[i].phy_ops = NULL; + } + } + + for(i = 0; i < SW_MAX_NR_DEV;i++) { + + if(phy_info[i] != NULL) + { + kfree(phy_info[i]); + phy_info[i] = NULL; + } + } + return SW_OK; +} diff --git a/qca/src/qca-psdk/drv/src/hsl/hsl_port_prop.c b/qca/src/qca-psdk/drv/src/hsl/hsl_port_prop.c new file mode 100755 index 00000000000..b450fe40a77 --- /dev/null +++ b/qca/src/qca-psdk/drv/src/hsl/hsl_port_prop.c @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2012, 2017, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + + +#include "sw_config.h" +#include "aos_head.h" +#include "sw_error.h" +#include "shared_func.h" +#include "fal_type.h" +#include "hsl.h" +#include "hsl_dev.h" +#include "hsl_port_prop.h" +#include "hsl_phy.h" + + +typedef struct +{ + a_uint32_t phy_id[SW_MAX_NR_PORT]; + fal_pbmp_t dev_portmap; + fal_pbmp_t property[HSL_PP_BUTT]; +} port_info_t; + +static port_info_t *p_port_info[SW_MAX_NR_DEV] = { 0 }; + +a_bool_t +hsl_port_prop_check(a_uint32_t dev_id, fal_port_t port_id, + hsl_port_prop_t p_type) +{ + fal_pbmp_t pbitmap; + + if (dev_id >= SW_MAX_NR_DEV) + return A_FALSE; + + if (HSL_PP_BUTT <= p_type) + { + return A_FALSE; + } + + pbitmap = p_port_info[dev_id]->property[p_type]; + + return SW_IS_PBMP_MEMBER(pbitmap, port_id); +} + +a_bool_t +hsl_mports_prop_check(a_uint32_t dev_id, fal_pbmp_t port_bitmap, + hsl_port_prop_t p_type) +{ + fal_pbmp_t pbitmap; + + if (dev_id >= SW_MAX_NR_DEV) + return A_FALSE; + + if (HSL_PP_BUTT <= p_type) + { + return A_FALSE; + } + + pbitmap = p_port_info[dev_id]->property[p_type]; + + return (SW_IS_PBMP_INCLUDE(pbitmap, port_bitmap)); +} + +a_bool_t +hsl_port_validity_check(a_uint32_t dev_id, fal_port_t port_id) +{ + fal_pbmp_t pbitmap; + + if (dev_id >= SW_MAX_NR_DEV) + return A_FALSE; + + pbitmap = p_port_info[dev_id]->dev_portmap; + + return SW_IS_PBMP_MEMBER(pbitmap, port_id); +} + +a_bool_t +hsl_mports_validity_check(a_uint32_t dev_id, fal_pbmp_t port_bitmap) +{ + fal_pbmp_t pbitmap; + + if (dev_id >= SW_MAX_NR_DEV) + return A_FALSE; + + pbitmap = p_port_info[dev_id]->dev_portmap; + + return (SW_IS_PBMP_INCLUDE(pbitmap, port_bitmap)); +} + +sw_error_t +hsl_port_prop_set(a_uint32_t dev_id, fal_port_t port_id, hsl_port_prop_t p_type) +{ + HSL_DEV_ID_CHECK(dev_id); + + if (A_FALSE == hsl_port_validity_check(dev_id, port_id)) + { + return SW_OUT_OF_RANGE; + } + + if (HSL_PP_BUTT <= p_type) + { + return SW_BAD_PARAM; + } + + SW_PBMP_ADD_PORT(p_port_info[dev_id]->property[p_type], port_id); + + return SW_OK; +} + +sw_error_t +hsl_port_prop_clr(a_uint32_t dev_id, fal_port_t port_id, hsl_port_prop_t p_type) +{ + HSL_DEV_ID_CHECK(dev_id);; + + if (A_FALSE == hsl_port_validity_check(dev_id, port_id)) + { + return SW_OUT_OF_RANGE; + } + + if (HSL_PP_BUTT <= p_type) + { + return SW_BAD_PARAM; + } + + SW_PBMP_DEL_PORT(p_port_info[dev_id]->property[p_type], port_id); + + return SW_OK; +} + +sw_error_t +hsl_port_prop_get_phyid(a_uint32_t dev_id, fal_port_t port_id, + a_uint32_t * phy_id) +{ + HSL_DEV_ID_CHECK(dev_id); + HSL_PORT_ID_CHECK(port_id); + + if (A_FALSE == hsl_port_validity_check(dev_id, port_id)) + { + return SW_BAD_PARAM; + } + + *phy_id = qca_ssdk_port_to_phy_addr(dev_id, port_id); + + return SW_OK; +} + +sw_error_t +hsl_port_prop_set_phyid(a_uint32_t dev_id, fal_port_t port_id, a_uint32_t phy_id) +{ + HSL_DEV_ID_CHECK(dev_id); + HSL_PORT_ID_CHECK(port_id); + + if (A_FALSE == hsl_port_validity_check(dev_id, port_id)) + { + return SW_BAD_PARAM; + } + + p_port_info[dev_id]->phy_id[port_id] = phy_id; + return SW_OK; +} + +sw_error_t +hsl_port_prop_portmap_set(a_uint32_t dev_id, fal_port_t port_id) +{ + HSL_DEV_ID_CHECK(dev_id); + + if (port_id > SW_MAX_NR_PORT) + return SW_OUT_OF_RANGE; + + SW_PBMP_ADD_PORT(p_port_info[dev_id]->dev_portmap, port_id); + + return SW_OK; +} + +sw_error_t +hsl_port_prop_init_by_dev(a_uint32_t dev_id) +{ + port_info_t *p_mem; + + HSL_DEV_ID_CHECK(dev_id); + + p_mem = aos_mem_alloc(sizeof (port_info_t)); + if (p_mem == NULL) + return SW_OUT_OF_MEM; + + aos_mem_zero(p_mem, sizeof (port_info_t)); + p_port_info[dev_id] = p_mem; + + return SW_OK; +} + +sw_error_t +hsl_port_prop_cleanup_by_dev(a_uint32_t dev_id) +{ + HSL_DEV_ID_CHECK(dev_id); + + if (p_port_info[dev_id] != NULL) + aos_mem_free((void *)p_port_info[dev_id]); + + p_port_info[dev_id] = NULL; + + return SW_OK; +} + + +sw_error_t +hsl_port_prop_init(a_uint32_t dev_id) +{ + if (dev_id >= SW_MAX_NR_DEV) + return SW_BAD_VALUE; + + p_port_info[dev_id] = NULL; + + return SW_OK; +} diff --git a/qca/src/qca-psdk/drv/src/hsl/qca808x_phy.c b/qca/src/qca-psdk/drv/src/hsl/qca808x_phy.c new file mode 100644 index 00000000000..7073b27e076 --- /dev/null +++ b/qca/src/qca-psdk/drv/src/hsl/qca808x_phy.c @@ -0,0 +1,2201 @@ +/* + * Copyright (c) 2018, 2020, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include "sw.h" +#include "fal_port_ctrl.h" +#include "hsl_api.h" +#include "hsl.h" +#include "hsl_phy.h" +#include "ssdk_plat.h" +#include "qca808x_phy.h" +static a_bool_t phy_ops_flag = A_FALSE; + +static struct mutex qca808x_reg_lock; + +#define QCA808X_LOCKER_INIT mutex_init(&qca808x_reg_lock) +#define QCA808X_REG_LOCK mutex_lock(&qca808x_reg_lock) +#define QCA808X_REG_UNLOCK mutex_unlock(&qca808x_reg_lock) + +/****************************************************************************** +* +* qca808x_phy_mii_read - mii register read +* +* mii register read +*/ +a_uint16_t +qca808x_phy_reg_read(a_uint32_t dev_id, a_uint32_t phy_id, a_uint32_t reg_id) +{ + sw_error_t rv = SW_OK; + a_uint16_t phy_data = 0; +#if defined(IN_PHY_I2C_MODE) + a_uint32_t port_id = qca_ssdk_phy_addr_to_port(dev_id, phy_id); + a_uint8_t phy_access_type = hsl_port_phy_access_type_get(dev_id, port_id); + + if (phy_access_type == PHY_I2C_ACCESS) { + HSL_PHY_I2C_GET(rv, dev_id, phy_id, reg_id, &phy_data); + } + else +#endif + { + HSL_PHY_GET(rv, dev_id, phy_id, reg_id, &phy_data); + } + + if (rv != SW_OK) { + return PHY_INVALID_DATA; + } + + return phy_data; +} + +/****************************************************************************** +* +* qca808x_phy_mii_write - mii register write +* +* mii register write +*/ +sw_error_t +qca808x_phy_reg_write(a_uint32_t dev_id, a_uint32_t phy_id, a_uint32_t reg_id, + a_uint16_t reg_val) +{ + sw_error_t rv; +#if defined(IN_PHY_I2C_MODE) + a_uint32_t port_id = qca_ssdk_phy_addr_to_port(dev_id, phy_id); + a_uint8_t phy_access_type = hsl_port_phy_access_type_get(dev_id, port_id); + + if (phy_access_type == PHY_I2C_ACCESS) { + HSL_PHY_I2C_SET(rv, dev_id, phy_id, reg_id, reg_val); + } + else +#endif + { + HSL_PHY_SET(rv, dev_id, phy_id, reg_id, reg_val); + } + + return rv; + +} + +/****************************************************************************** +* +* qca808x_phy_debug_write - debug port write +* +* debug port write +*/ +sw_error_t +qca808x_phy_debug_write(a_uint32_t dev_id, a_uint32_t phy_id, a_uint16_t reg_id, + a_uint16_t reg_val) +{ + sw_error_t rv = SW_OK; + + QCA808X_REG_LOCK; + rv = qca808x_phy_reg_write(dev_id, phy_id, QCA808X_DEBUG_PORT_ADDRESS, reg_id); + if (rv != SW_OK) + { + QCA808X_REG_UNLOCK; + SSDK_ERROR("qca808x_phy_reg_write failed\n"); + return SW_FAIL; + } + + rv = qca808x_phy_reg_write(dev_id, phy_id, QCA808X_DEBUG_PORT_DATA, reg_val); + if (rv != SW_OK) + { + QCA808X_REG_UNLOCK; + SSDK_ERROR("qca808x_phy_reg_write failed\n"); + return SW_FAIL; + } + QCA808X_REG_UNLOCK; + + return rv; +} + +/****************************************************************************** +* +* qca808x_phy_debug_read - debug port read +* +* debug port read +*/ +a_uint16_t +qca808x_phy_debug_read(a_uint32_t dev_id, a_uint32_t phy_id, a_uint16_t reg_id) +{ + sw_error_t rv = SW_OK; + a_uint16_t phy_data = 0; + + QCA808X_REG_LOCK; + rv = qca808x_phy_reg_write(dev_id, phy_id, QCA808X_DEBUG_PORT_ADDRESS, reg_id); + if (rv != SW_OK) { + QCA808X_REG_UNLOCK; + SSDK_ERROR("qca808x_phy_reg_write failed\n"); + return PHY_INVALID_DATA; + } + phy_data = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_DEBUG_PORT_DATA); + if (phy_data == PHY_INVALID_DATA) { + QCA808X_REG_UNLOCK; + SSDK_ERROR("qca808x_phy_reg_read failed\n"); + return PHY_INVALID_DATA; + } + QCA808X_REG_UNLOCK; + + return phy_data; +} + +/****************************************************************************** +* +* qca808x_phy_mmd_write - PHY MMD register write +* +* PHY MMD register write +*/ +sw_error_t +qca808x_phy_mmd_write(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint16_t mmd_num, a_uint16_t reg_id, a_uint16_t reg_val) +{ + sw_error_t rv; + a_uint32_t reg_id_c45 = QCA808X_REG_C45_ADDRESS(mmd_num, reg_id); +#if defined(IN_PHY_I2C_MODE) + a_uint32_t port_id = qca_ssdk_phy_addr_to_port(dev_id, phy_id); + a_uint8_t phy_access_type = hsl_port_phy_access_type_get(dev_id, port_id); + + if (phy_access_type == PHY_I2C_ACCESS) { + HSL_PHY_I2C_SET(rv, dev_id, phy_id, reg_id_c45, reg_val); + } + else +#endif + { + HSL_PHY_SET(rv, dev_id, phy_id, reg_id_c45, reg_val); + } + + return rv; +} + +/****************************************************************************** +* +* qca808x_phy_mmd_read - PHY MMD register read +* +* PHY MMD register read +*/ +a_uint16_t +qca808x_phy_mmd_read(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint16_t mmd_num, a_uint16_t reg_id) +{ + sw_error_t rv = SW_OK; + a_uint16_t phy_data = 0; + a_uint32_t reg_id_c45 = QCA808X_REG_C45_ADDRESS(mmd_num, reg_id); +#if defined(IN_PHY_I2C_MODE) + a_uint32_t port_id = qca_ssdk_phy_addr_to_port(dev_id, phy_id); + a_uint8_t phy_access_type = hsl_port_phy_access_type_get(dev_id, port_id); + + if (phy_access_type == PHY_I2C_ACCESS) { + HSL_PHY_I2C_GET(rv, dev_id, phy_id, reg_id_c45, &phy_data); + } + else +#endif + { + HSL_PHY_GET(rv, dev_id, phy_id, reg_id_c45, &phy_data); + } + + if (rv != SW_OK) { + return PHY_INVALID_DATA; + } + + return phy_data; +} + +static sw_error_t +qca808x_phy_ms_random_seed_set(a_uint32_t dev_id, a_uint32_t phy_id) +{ + a_uint16_t phy_data; + sw_error_t rv = SW_OK; + + phy_data = qca808x_phy_debug_read(dev_id, phy_id, + QCA808X_DEBUG_LOCAL_SEED); + phy_data &= ~(QCA808X_MASTER_SLAVE_SEED_CFG); + phy_data |= (prandom_u32()%QCA808X_MASTER_SLAVE_SEED_RANGE) << 2; + SSDK_DEBUG("QCA808X_DEBUG_LOCAL_SEED:%x\n", phy_data); + rv = qca808x_phy_debug_write(dev_id, phy_id, + QCA808X_DEBUG_LOCAL_SEED, phy_data); + + return rv; +} + +static sw_error_t +qca808x_phy_ms_seed_enable(a_uint32_t dev_id, a_uint32_t phy_id, + a_bool_t enable) +{ + a_uint16_t phy_data; + sw_error_t rv = SW_OK; + + phy_data = qca808x_phy_debug_read(dev_id, phy_id, + QCA808X_DEBUG_LOCAL_SEED); + if(enable) + { + phy_data |= QCA808X_MASTER_SLAVE_SEED_ENABLE; + } + else + { + phy_data &= ~(QCA808X_MASTER_SLAVE_SEED_ENABLE); + } + rv = qca808x_phy_debug_write(dev_id, phy_id, + QCA808X_DEBUG_LOCAL_SEED, phy_data); + + return rv; +} + +a_bool_t +qca808x_phy_2500caps(a_uint32_t dev_id, a_uint32_t phy_id) +{ + a_uint16_t phy_data; + + phy_data = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD1_NUM, + QCA808X_MMD1_PMA_CAP_REG); + + if (phy_data & QCA808X_STATUS_2500T_FD_CAPS) { + return A_TRUE; + } + + return A_FALSE; + +} + +/****************************************************************************** +* +* qca808x_phy_get status +* +* get phy status +*/ +sw_error_t +qca808x_phy_get_status(a_uint32_t dev_id, a_uint32_t phy_id, + struct port_phy_status *phy_status) +{ + a_uint16_t phy_data; + + phy_data = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_SPEC_STATUS); + PHY_RTN_ON_READ_ERROR(phy_data); + + /*get phy link status*/ + if (phy_data & QCA808X_STATUS_LINK_PASS) { + phy_status->link_status = A_TRUE; + } + else { + phy_status->link_status = A_FALSE; + if (qca808x_phy_2500caps(dev_id, phy_id) == A_TRUE) { + SW_RTN_ON_ERROR( + qca808x_phy_ms_random_seed_set (dev_id, phy_id)); + /*protect logic, if MASTER_SLAVE_CONFIG_FAULT is 1, + then disable this logic*/ + phy_data = qca808x_phy_reg_read(dev_id, phy_id, + QCA808X_1000BASET_STATUS); + if ((phy_data & QCA808X_MASTER_SLAVE_CONFIG_FAULT) >> 15) + { + SW_RTN_ON_ERROR( + qca808x_phy_ms_seed_enable (dev_id, phy_id, A_FALSE)); + SSDK_INFO("master_slave_config_fault was set\n"); + } + } + + return SW_OK; + } + + /*get phy speed*/ + switch (phy_data & QCA808X_STATUS_SPEED_MASK) { + case QCA808X_STATUS_SPEED_2500MBS: + phy_status->speed = FAL_SPEED_2500; + break; + case QCA808X_STATUS_SPEED_1000MBS: + phy_status->speed = FAL_SPEED_1000; + break; + case QCA808X_STATUS_SPEED_100MBS: + phy_status->speed = FAL_SPEED_100; + break; + case QCA808X_STATUS_SPEED_10MBS: + phy_status->speed = FAL_SPEED_10; + break; + default: + return SW_READ_ERROR; + } + + /*get phy duplex*/ + if (phy_data & QCA808X_STATUS_FULL_DUPLEX) { + phy_status->duplex = FAL_FULL_DUPLEX; + } else { + phy_status->duplex = FAL_HALF_DUPLEX; + } + + /* get phy flowctrl resolution status */ + if (phy_data & QCA808X_PHY_RX_FLOWCTRL_STATUS) { + phy_status->rx_flowctrl = A_TRUE; + } else { + phy_status->rx_flowctrl = A_FALSE; + } + + if (phy_data & QCA808X_PHY_TX_FLOWCTRL_STATUS) { + phy_status->tx_flowctrl = A_TRUE; + } else { + phy_status->tx_flowctrl = A_FALSE; + } + + return SW_OK; +} + +/****************************************************************************** +* +* qca808x_phy_get_speed - Determines the speed of phy ports associated with the +* specified device. +*/ + +sw_error_t +qca808x_phy_get_speed(a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_speed_t * speed) +{ + sw_error_t rv = SW_OK; + struct port_phy_status phy_status = {0}; + + rv = qca808x_phy_get_status(dev_id, phy_id, &phy_status); + PHY_RTN_ON_ERROR(rv); + + if (phy_status.link_status == A_TRUE) { + *speed = phy_status.speed; + } else { + *speed = FAL_SPEED_10; + } + + return rv; +} + +/****************************************************************************** +* +* qca808x_phy_set_force_speed - Force the speed of qca808x phy ports associated with the +* specified device. +*/ +sw_error_t +qca808x_phy_set_force_speed(a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_speed_t speed) +{ + a_uint16_t phy_data1 = 0; + a_uint16_t phy_data2 = 0; + sw_error_t rv = SW_OK; + + /* the speed of qca808x controled by MMD1 PMA/PMD control register */ + phy_data1 = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD1_NUM, + QCA808X_PHY_MMD1_PMA_CONTROL); + PHY_RTN_ON_READ_ERROR(phy_data1); + phy_data1 &= ~QCA808X_PMA_CONTROL_SPEED_MASK; + + phy_data2 = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD1_NUM, + QCA808X_PHY_MMD1_PMA_TYPE); + PHY_RTN_ON_READ_ERROR(phy_data2); + phy_data2 &= ~QCA808X_PMA_TYPE_MASK; + + switch(speed) + { + case FAL_SPEED_2500: + phy_data1 |= QCA808X_PMA_CONTROL_2500M; + phy_data2 |= QCA808X_PMA_TYPE_2500M; + break; + case FAL_SPEED_1000: + phy_data1 |= QCA808X_PMA_CONTROL_1000M; + phy_data2 |= QCA808X_PMA_TYPE_1000M; + break; + case FAL_SPEED_100: + phy_data1 |= QCA808X_PMA_CONTROL_100M; + phy_data2 |= QCA808X_PMA_TYPE_100M; + break; + case FAL_SPEED_10: + phy_data1 |= QCA808X_PMA_CONTROL_10M; + phy_data2 |= QCA808X_PMA_TYPE_10M; + break; + default: + return SW_BAD_PARAM; + } + + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD1_NUM, + QCA808X_PHY_MMD1_PMA_CONTROL, phy_data1); + PHY_RTN_ON_ERROR(rv); + + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD1_NUM, + QCA808X_PHY_MMD1_PMA_TYPE, phy_data2); + + return rv; +} + +sw_error_t +_qca808x_phy_set_autoneg_adv_ext(a_uint32_t dev_id, a_uint32_t phy_id, a_uint32_t autoneg) +{ + a_uint16_t phy_data = 0; + sw_error_t rv = SW_OK; + + phy_data = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_AUTONEGOTIATION_CONTROL); + PHY_RTN_ON_READ_ERROR(phy_data); + + if (autoneg & FAL_PHY_ADV_2500T_FD) { + phy_data |= QCA808X_ADVERTISE_2500FULL; + } else { + phy_data &= ~QCA808X_ADVERTISE_2500FULL; + } + + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_AUTONEGOTIATION_CONTROL, phy_data); + + return rv; + +} + +/****************************************************************************** +* +* qca808x_phy_set_speed - Determines the speed of phy ports associated with the +* specified device. +*/ +sw_error_t +qca808x_phy_set_speed(a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_speed_t speed) +{ + a_uint16_t phy_data = 0; + fal_port_duplex_t old_duplex = QCA808X_CTRL_FULL_DUPLEX; + sw_error_t rv = SW_OK; + + phy_data = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_CONTROL); + PHY_RTN_ON_READ_ERROR(phy_data); + + switch(speed) + { + case FAL_SPEED_2500: + case FAL_SPEED_1000: + if (speed == FAL_SPEED_2500) { + rv = _qca808x_phy_set_autoneg_adv_ext(dev_id, phy_id, + FAL_PHY_ADV_2500T_FD); + PHY_RTN_ON_ERROR(rv); + } else { + rv = _qca808x_phy_set_autoneg_adv_ext(dev_id, phy_id, + ~FAL_PHY_ADV_2500T_FD); + PHY_RTN_ON_ERROR(rv); + } + phy_data |= QCA808X_CTRL_FULL_DUPLEX; + phy_data |= QCA808X_CTRL_AUTONEGOTIATION_ENABLE; + phy_data |= QCA808X_CTRL_RESTART_AUTONEGOTIATION; + break; + case FAL_SPEED_100: + case FAL_SPEED_10: + /* set qca808x phy speed by pma control registers */ + rv = qca808x_phy_set_force_speed(dev_id, phy_id, speed); + PHY_RTN_ON_ERROR(rv); + rv = qca808x_phy_get_duplex(dev_id, phy_id, &old_duplex); + PHY_RTN_ON_ERROR(rv); + + if (old_duplex == FAL_FULL_DUPLEX) { + phy_data |= QCA808X_CTRL_FULL_DUPLEX; + } + else if (old_duplex == FAL_HALF_DUPLEX) { + phy_data &= ~QCA808X_CTRL_FULL_DUPLEX; + } + phy_data &= ~QCA808X_CTRL_AUTONEGOTIATION_ENABLE; + break; + default: + return SW_BAD_PARAM; + } + + rv = qca808x_phy_reg_write(dev_id, phy_id, QCA808X_PHY_CONTROL, phy_data); + + return rv; +} + +/****************************************************************************** +* +* qca808x_phy_set_duplex - Determines the duplex of phy ports associated with the +* specified device. +*/ +sw_error_t +qca808x_phy_set_duplex(a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_duplex_t duplex) +{ + a_uint16_t phy_data = 0; + fal_port_speed_t old_speed; + sw_error_t rv = SW_OK; + + phy_data = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_CONTROL); + PHY_RTN_ON_READ_ERROR(phy_data); + + rv = qca808x_phy_get_speed(dev_id, phy_id, &old_speed); + PHY_RTN_ON_ERROR(rv); + + switch(old_speed) + { + case FAL_SPEED_2500: + case FAL_SPEED_1000: + if (duplex == FAL_FULL_DUPLEX) { + phy_data |= QCA808X_CTRL_FULL_DUPLEX; + } else { + return SW_NOT_SUPPORTED; + } + phy_data |= QCA808X_CTRL_AUTONEGOTIATION_ENABLE; + + if (old_speed == FAL_SPEED_2500) { + rv = _qca808x_phy_set_autoneg_adv_ext(dev_id, phy_id, + FAL_PHY_ADV_2500T_FD); + PHY_RTN_ON_ERROR(rv); + } else { + rv = _qca808x_phy_set_autoneg_adv_ext(dev_id, phy_id, + ~FAL_PHY_ADV_2500T_FD); + PHY_RTN_ON_ERROR(rv); + } + break; + case FAL_SPEED_100: + case FAL_SPEED_10: + /* force the speed */ + rv = qca808x_phy_set_force_speed(dev_id, phy_id, old_speed); + PHY_RTN_ON_ERROR(rv); + phy_data &= ~QCA808X_CTRL_AUTONEGOTIATION_ENABLE; + if (duplex == FAL_FULL_DUPLEX) { + phy_data |= QCA808X_CTRL_FULL_DUPLEX; + } else { + phy_data &= ~QCA808X_CTRL_FULL_DUPLEX; + } + break; + default: + return SW_FAIL; + } + rv = qca808x_phy_reg_write(dev_id, phy_id, QCA808X_PHY_CONTROL, phy_data); + + return rv; +} + +/****************************************************************************** +* +* qca808x_phy_get_duplex - Determines the duplex of phy ports associated with the +* specified device. +*/ +sw_error_t +qca808x_phy_get_duplex(a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_duplex_t * duplex) +{ + sw_error_t rv = SW_OK; + struct port_phy_status phy_status = {0}; + + rv = qca808x_phy_get_status(dev_id, phy_id, &phy_status); + PHY_RTN_ON_ERROR(rv); + + if (phy_status.link_status == A_TRUE) { + *duplex = phy_status.duplex; + } else { + *duplex = FAL_HALF_DUPLEX; + } + + return rv; +} + +/****************************************************************************** +* +* qca808x_phy_reset - reset the phy +* +* reset the phy +*/ +sw_error_t qca808x_phy_reset(a_uint32_t dev_id, a_uint32_t phy_id) +{ + a_uint16_t phy_data; + sw_error_t rv = SW_OK; + + phy_data = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_CONTROL); + PHY_RTN_ON_READ_ERROR(phy_data); + + rv = qca808x_phy_reg_write(dev_id, phy_id, QCA808X_PHY_CONTROL, + phy_data | QCA808X_CTRL_SOFTWARE_RESET); + SW_RTN_ON_ERROR(rv); + /*the configure will lost when reset.*/ + rv = qca808x_phy_ms_seed_enable(dev_id, phy_id, A_TRUE); + + return rv; +} +/****************************************************************************** +* +* qca808x_phy_status - test to see if the specified phy link is alive +* +* RETURNS: +* A_TRUE --> link is alive +* A_FALSE --> link is down +*/ +a_bool_t qca808x_phy_get_link_status(a_uint32_t dev_id, a_uint32_t phy_id) +{ + struct port_phy_status phy_status = {0}; + sw_error_t rv = SW_OK; + + rv = qca808x_phy_get_status(dev_id, phy_id, &phy_status); + if (rv == SW_OK) { + return phy_status.link_status; + } else { + return A_FALSE; + } +} +#ifndef IN_PORTCONTROL_MINI +/****************************************************************************** +* +* qca808x_phy_cdt - cable diagnostic test +* +* cable diagnostic test +*/ + +static inline fal_cable_status_t _phy_cdt_status_mapping(a_uint16_t status) +{ + fal_cable_status_t status_mapping = FAL_CABLE_STATUS_INVALID; + + switch (status) { + case 0: + status_mapping = FAL_CABLE_STATUS_INVALID; + break; + case 1: + status_mapping = FAL_CABLE_STATUS_NORMAL; + break; + case 2: + status_mapping = FAL_CABLE_STATUS_OPENED; + break; + case 3: + status_mapping = FAL_CABLE_STATUS_SHORT; + break; + } + + return status_mapping; +} + +static sw_error_t qca808x_phy_cdt_start(a_uint32_t dev_id, a_uint32_t phy_id) +{ + a_uint16_t status = 0; + a_uint16_t ii = 100; + sw_error_t rv = SW_OK; + + /* RUN CDT */ + rv = qca808x_phy_reg_write(dev_id, phy_id, QCA808X_PHY_CDT_CONTROL, + QCA808X_RUN_CDT | QCA808X_CABLE_LENGTH_UNIT); + PHY_RTN_ON_ERROR(rv); + + do { + aos_mdelay(30); + status = + qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_CDT_CONTROL); + PHY_RTN_ON_READ_ERROR(status); + } + while ((status & QCA808X_RUN_CDT) && (--ii)); + + if (ii == 0) { + return SW_TIMEOUT; + } else { + return SW_OK; + } +} + +sw_error_t +qca808x_phy_cdt(a_uint32_t dev_id, a_uint32_t phy_id, a_uint32_t mdi_pair, + fal_cable_status_t * cable_status, a_uint32_t * cable_len) +{ + a_uint16_t cable_delta_time = 0; + a_uint16_t status; + sw_error_t rv; + + if ((mdi_pair >= QCA808X_MDI_PAIR_NUM)) { + return SW_BAD_PARAM; + } + + rv = qca808x_phy_cdt_start(dev_id, phy_id); + + if (rv != SW_OK) { + *cable_status = FAL_CABLE_STATUS_INVALID; + *cable_len = 0; + return rv; + } + + /* Get cable status */ + status = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_CDT_STATUS); + PHY_RTN_ON_READ_ERROR(status); + + switch (mdi_pair) { + case 0: + *cable_status = + _phy_cdt_status_mapping((status >> 12) & 0x3); + cable_delta_time = + qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_CDT_DIAG_PAIR0); + PHY_RTN_ON_READ_ERROR(cable_delta_time); + + break; + case 1: + *cable_status = + _phy_cdt_status_mapping((status >> 8) & 0x3); + cable_delta_time = + qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_CDT_DIAG_PAIR1); + PHY_RTN_ON_READ_ERROR(cable_delta_time); + + break; + case 2: + *cable_status = + _phy_cdt_status_mapping((status >> 4) & 0x3); + cable_delta_time = + qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_CDT_DIAG_PAIR2); + PHY_RTN_ON_READ_ERROR(cable_delta_time); + + break; + case 3: + *cable_status = + _phy_cdt_status_mapping(status & 0x3); + cable_delta_time = + qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_CDT_DIAG_PAIR3); + PHY_RTN_ON_READ_ERROR(cable_delta_time); + + break; + } + + /* the actual cable length equals to CableDeltaTime * 0.824 */ + *cable_len = ((cable_delta_time & 0xff) * 824) / 1000; + + return rv; +} + +/****************************************************************************** +* +* qca808x_phy_set_mdix - +* +* set phy mdix configuraiton +*/ +sw_error_t +qca808x_phy_set_mdix(a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_mdix_mode_t mode) +{ + a_uint16_t phy_data; + sw_error_t rv; + + phy_data = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_SPEC_CONTROL); + PHY_RTN_ON_READ_ERROR(phy_data); + + if (mode == PHY_MDIX_AUTO) { + phy_data |= QCA808X_PHY_MDIX_AUTO; + } else if (mode == PHY_MDIX_MDIX) { + phy_data &= ~QCA808X_PHY_MDIX_AUTO; + phy_data |= QCA808X_PHY_MDIX; + } else if (mode == PHY_MDIX_MDI) { + phy_data &= ~QCA808X_PHY_MDIX_AUTO; + } else { + return SW_BAD_PARAM; + } + + rv = qca808x_phy_reg_write(dev_id, phy_id, QCA808X_PHY_SPEC_CONTROL, phy_data); + PHY_RTN_ON_ERROR(rv); + + rv = qca808x_phy_reset(dev_id, phy_id); + return rv; +} + +/****************************************************************************** +* +* qca808x_phy_get_mdix +* +* get phy mdix configuration +*/ +sw_error_t +qca808x_phy_get_mdix(a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_mdix_mode_t * mode) +{ + a_uint16_t phy_data; + + phy_data = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_SPEC_CONTROL); + PHY_RTN_ON_READ_ERROR(phy_data); + + if ((phy_data & QCA808X_PHY_MDIX_AUTO) == QCA808X_PHY_MDIX_AUTO) { + *mode = PHY_MDIX_AUTO; + } else if ((phy_data & QCA808X_PHY_MDIX) == QCA808X_PHY_MDIX) { + *mode = PHY_MDIX_MDIX; + } else { + *mode = PHY_MDIX_MDI; + } + + return SW_OK; + +} + +/****************************************************************************** +* +* qca808x_phy_get_mdix status +* +* get phy mdix status +*/ +sw_error_t +qca808x_phy_get_mdix_status(a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_mdix_status_t * mode) +{ + a_uint16_t phy_data; + + phy_data = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_SPEC_STATUS); + PHY_RTN_ON_READ_ERROR(phy_data); + + *mode = + (phy_data & QCA808X_PHY_MDIX_STATUS) ? PHY_MDIX_STATUS_MDIX : + PHY_MDIX_STATUS_MDI; + + return SW_OK; + +} + +/****************************************************************************** +* +* qca808x_phy_set_local_loopback +* +* set phy local loopback +*/ +sw_error_t +qca808x_phy_set_local_loopback(a_uint32_t dev_id, a_uint32_t phy_id, + a_bool_t enable) +{ + a_uint16_t phy_data; + fal_port_speed_t old_speed; + sw_error_t rv = SW_OK; + + phy_data = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_CONTROL); + PHY_RTN_ON_READ_ERROR(phy_data); + + if (enable == A_TRUE) { + /* get the link speed first, then force the corresponding + * speed to enable local loopback */ + rv = qca808x_phy_get_speed(dev_id, phy_id, &old_speed); + PHY_RTN_ON_ERROR(rv); + rv = qca808x_phy_set_force_speed(dev_id, phy_id, old_speed); + PHY_RTN_ON_ERROR(rv); + + phy_data &= ~QCA808X_CTRL_AUTONEGOTIATION_ENABLE; + phy_data |= QCA808X_LOCAL_LOOPBACK_ENABLE; + phy_data |= QCA808X_CTRL_FULL_DUPLEX; + } else { + phy_data = QCA808X_COMMON_CTRL; + } + + rv = qca808x_phy_reg_write(dev_id, phy_id, QCA808X_PHY_CONTROL, phy_data); + return rv; +} + +/****************************************************************************** +* +* qca808x_phy_get_local_loopback +* +* get phy local loopback +*/ +sw_error_t +qca808x_phy_get_local_loopback(a_uint32_t dev_id, a_uint32_t phy_id, + a_bool_t * enable) +{ + a_uint16_t phy_data; + + phy_data = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_CONTROL); + PHY_RTN_ON_READ_ERROR(phy_data); + + if (phy_data & QCA808X_LOCAL_LOOPBACK_ENABLE) { + *enable = A_TRUE; + } else { + *enable = A_FALSE; + } + + return SW_OK; + +} + +/****************************************************************************** +* +* qca808x_phy_set_remote_loopback +* +* set phy remote loopback +*/ +sw_error_t +qca808x_phy_set_remote_loopback(a_uint32_t dev_id, a_uint32_t phy_id, + a_bool_t enable) +{ + a_uint16_t phy_data; + sw_error_t rv = SW_OK; + + phy_data = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_MMD3_ADDR_REMOTE_LOOPBACK_CTRL); + PHY_RTN_ON_READ_ERROR(phy_data); + + if (enable == A_TRUE) { + phy_data |= QCA808X_PHY_REMOTE_LOOPBACK_EN; + } else { + phy_data &= ~QCA808X_PHY_REMOTE_LOOPBACK_EN; + } + + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_MMD3_ADDR_REMOTE_LOOPBACK_CTRL, + phy_data); + return rv; + +} + +/****************************************************************************** +* +* qca808x_phy_get_remote_loopback +* +* get phy remote loopback +*/ +sw_error_t +qca808x_phy_get_remote_loopback(a_uint32_t dev_id, a_uint32_t phy_id, + a_bool_t * enable) +{ + a_uint16_t phy_data; + + phy_data = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_MMD3_ADDR_REMOTE_LOOPBACK_CTRL); + PHY_RTN_ON_READ_ERROR(phy_data); + + if (phy_data & QCA808X_PHY_REMOTE_LOOPBACK_EN) { + *enable = A_TRUE; + } else { + *enable = A_FALSE; + } + + return SW_OK; + +} +#endif +/****************************************************************************** +* +* qca808x_set_autoneg_adv - set the phy autoneg Advertisement +* +*/ +sw_error_t +qca808x_phy_set_autoneg_adv(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t autoneg) +{ + a_uint16_t phy_data = 0; + sw_error_t rv = SW_OK; + + phy_data = qca808x_phy_reg_read(dev_id, phy_id, + QCA808X_AUTONEG_ADVERT); + PHY_RTN_ON_READ_ERROR(phy_data); + + phy_data &= ~QCA808X_ADVERTISE_MEGA_ALL; + + if (autoneg & FAL_PHY_ADV_100TX_FD) { + phy_data |= QCA808X_ADVERTISE_100FULL; + } + + if (autoneg & FAL_PHY_ADV_100TX_HD) { + phy_data |= QCA808X_ADVERTISE_100HALF; + } + + if (autoneg & FAL_PHY_ADV_10T_FD) { + phy_data |= QCA808X_ADVERTISE_10FULL; + } + + if (autoneg & FAL_PHY_ADV_10T_HD) { + phy_data |= QCA808X_ADVERTISE_10HALF; + } + + if (autoneg & FAL_PHY_ADV_PAUSE) { + phy_data |= QCA808X_ADVERTISE_PAUSE; + } + + if (autoneg & FAL_PHY_ADV_ASY_PAUSE) { + phy_data |= QCA808X_ADVERTISE_ASYM_PAUSE; + } + rv = qca808x_phy_reg_write(dev_id, phy_id, QCA808X_AUTONEG_ADVERT, + phy_data); + PHY_RTN_ON_ERROR(rv); + + phy_data = qca808x_phy_reg_read(dev_id, phy_id, + QCA808X_1000BASET_CONTROL); + PHY_RTN_ON_READ_ERROR(phy_data); + + phy_data &= ~QCA808X_ADVERTISE_1000FULL; + phy_data &= ~QCA808X_ADVERTISE_1000HALF; + + if (autoneg & FAL_PHY_ADV_1000T_FD) { + phy_data |= QCA808X_ADVERTISE_1000FULL; + } + + rv = qca808x_phy_reg_write(dev_id, phy_id, QCA808X_1000BASET_CONTROL, + phy_data); + PHY_RTN_ON_ERROR(rv); + + if (qca808x_phy_2500caps(dev_id, phy_id) == A_TRUE) { + rv = _qca808x_phy_set_autoneg_adv_ext(dev_id, phy_id, autoneg); + } + + return rv; +} + +sw_error_t +_qca808x_phy_get_autoneg_adv_ext(a_uint32_t dev_id, a_uint32_t phy_id, a_uint16_t *phy_data) +{ + *phy_data = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_AUTONEGOTIATION_CONTROL); + PHY_RTN_ON_READ_ERROR(*phy_data); + + return SW_OK; +} + +/****************************************************************************** +* +* qca808x_get_autoneg_adv - get the phy autoneg Advertisement +* +*/ +sw_error_t +qca808x_phy_get_autoneg_adv(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t * autoneg) +{ + a_uint16_t phy_data = 0; + sw_error_t rv = SW_OK; + + *autoneg = 0; + phy_data = + qca808x_phy_reg_read(dev_id, phy_id, QCA808X_AUTONEG_ADVERT); + PHY_RTN_ON_READ_ERROR(phy_data); + + if (phy_data & QCA808X_ADVERTISE_100FULL) { + *autoneg |= FAL_PHY_ADV_100TX_FD; + } + + if (phy_data & QCA808X_ADVERTISE_100HALF) { + *autoneg |= FAL_PHY_ADV_100TX_HD; + } + + if (phy_data & QCA808X_ADVERTISE_10FULL) { + *autoneg |= FAL_PHY_ADV_10T_FD; + } + + if (phy_data & QCA808X_ADVERTISE_10HALF) { + *autoneg |= FAL_PHY_ADV_10T_HD; + } + + if (phy_data & QCA808X_ADVERTISE_PAUSE) { + *autoneg |= FAL_PHY_ADV_PAUSE; + } + + if (phy_data & QCA808X_ADVERTISE_ASYM_PAUSE) { + *autoneg |= FAL_PHY_ADV_ASY_PAUSE; + } + + phy_data = qca808x_phy_reg_read(dev_id, phy_id, + QCA808X_1000BASET_CONTROL); + PHY_RTN_ON_READ_ERROR(phy_data); + + if (phy_data & QCA808X_ADVERTISE_1000FULL) { + *autoneg |= FAL_PHY_ADV_1000T_FD; + } + + if (qca808x_phy_2500caps(dev_id, phy_id) == A_TRUE) { + rv = _qca808x_phy_get_autoneg_adv_ext(dev_id, phy_id, &phy_data); + if ((rv == SW_OK) && + (phy_data & QCA808X_ADVERTISE_2500FULL)) { + *autoneg |= FAL_PHY_ADV_2500T_FD; + } + } + + return rv; +} + +/****************************************************************************** +* +* qca808x_phy_autoneg_status - get the phy autoneg status +* +*/ +a_bool_t qca808x_phy_autoneg_status(a_uint32_t dev_id, a_uint32_t phy_id) +{ + a_uint16_t phy_data; + + phy_data = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_CONTROL); + + if (phy_data & QCA808X_CTRL_AUTONEGOTIATION_ENABLE) { + return A_TRUE; + } + + return A_FALSE; +} + +/****************************************************************************** +* +* qca808x_restart_autoneg - restart the phy autoneg +* +*/ +sw_error_t qca808x_phy_restart_autoneg(a_uint32_t dev_id, a_uint32_t phy_id) +{ + a_uint16_t phy_data = 0; + sw_error_t rv = SW_OK; + + phy_data = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_CONTROL); + PHY_RTN_ON_READ_ERROR(phy_data); + + phy_data |= QCA808X_CTRL_AUTONEGOTIATION_ENABLE; + rv = qca808x_phy_reg_write(dev_id, phy_id, QCA808X_PHY_CONTROL, + phy_data | QCA808X_CTRL_RESTART_AUTONEGOTIATION); + + return rv; +} + +/****************************************************************************** +* +* qca808x_phy_enable_autonego +* +*/ +sw_error_t qca808x_phy_enable_autoneg(a_uint32_t dev_id, a_uint32_t phy_id) +{ + a_uint16_t phy_data = 0; + sw_error_t rv = SW_OK; + + phy_data = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_CONTROL); + PHY_RTN_ON_READ_ERROR(phy_data); + + rv = qca808x_phy_reg_write(dev_id, phy_id, QCA808X_PHY_CONTROL, + phy_data | QCA808X_CTRL_AUTONEGOTIATION_ENABLE); + + return rv; +} + +/****************************************************************************** +* +* qca808x_phy_get_phy_id - get the phy id +* +*/ +sw_error_t +qca808x_phy_get_phy_id(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t *phy_data) +{ + a_uint16_t org_id, rev_id; + org_id = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_ID1); + PHY_RTN_ON_READ_ERROR(org_id); + + rev_id = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_ID2); + PHY_RTN_ON_READ_ERROR(rev_id); + + *phy_data = ((org_id & 0xffff) << 16) | (rev_id & 0xffff); + + return SW_OK; +} + +/****************************************************************************** +* +* qca808x_phy_off - power off the phy +* +* Power off the phy +*/ +sw_error_t qca808x_phy_poweroff(a_uint32_t dev_id, a_uint32_t phy_id) +{ + a_uint16_t phy_data; + sw_error_t rv = SW_OK; + + phy_data = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_CONTROL); + PHY_RTN_ON_READ_ERROR(phy_data); + + rv = qca808x_phy_reg_write(dev_id, phy_id, QCA808X_PHY_CONTROL, + phy_data | QCA808X_CTRL_POWER_DOWN); + return rv; +} + +/****************************************************************************** +* +* qca808x_phy_on - power on the phy +* +* Power on the phy +*/ +sw_error_t qca808x_phy_poweron(a_uint32_t dev_id, a_uint32_t phy_id) +{ + a_uint16_t phy_data; + sw_error_t rv = SW_OK; + + phy_data = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_CONTROL); + PHY_RTN_ON_READ_ERROR(phy_data); + + rv = qca808x_phy_reg_write(dev_id, phy_id, QCA808X_PHY_CONTROL, + phy_data & ~QCA808X_CTRL_POWER_DOWN); + + aos_mdelay(200); + + return rv; +} +#ifndef IN_PORTCONTROL_MINI +/****************************************************************************** +* +* qca808x_phy_set_802.3az +* +* set 802.3az status +*/ +sw_error_t +qca808x_phy_set_8023az(a_uint32_t dev_id, a_uint32_t phy_id, a_bool_t enable) +{ + a_uint16_t phy_data; + sw_error_t rv = SW_OK; + + phy_data = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_ADDR_8023AZ_EEE_CTRL); + PHY_RTN_ON_READ_ERROR(phy_data); + + if (enable == A_TRUE) { + phy_data |= QCA808X_PHY_8023AZ_EEE_1000BT; + phy_data |= QCA808X_PHY_8023AZ_EEE_100BT; + } else { + phy_data &= ~QCA808X_PHY_8023AZ_EEE_1000BT; + phy_data &= ~QCA808X_PHY_8023AZ_EEE_100BT; + } + + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_ADDR_8023AZ_EEE_CTRL, phy_data); + PHY_RTN_ON_ERROR(rv); + + rv = qca808x_phy_restart_autoneg(dev_id, phy_id); + + return rv; +} + +/****************************************************************************** +* +* qca808x_phy_get_8023az status +* +* get 8023az status +*/ +sw_error_t +qca808x_phy_get_8023az(a_uint32_t dev_id, a_uint32_t phy_id, a_bool_t * enable) +{ + a_uint16_t phy_data; + *enable = A_FALSE; + + phy_data = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_ADDR_8023AZ_EEE_CTRL); + PHY_RTN_ON_READ_ERROR(phy_data); + + if ((phy_data & QCA808X_PHY_8023AZ_EEE_1000BT) && + (phy_data & QCA808X_PHY_8023AZ_EEE_100BT)) { + *enable = A_TRUE; + } + + return SW_OK; +} + +/****************************************************************************** +* +* _qca808x_phy_get_8023az_status status +* +* get 8023az status +*/ +sw_error_t +_qca808x_phy_get_8023az_status(a_uint32_t dev_id, a_uint32_t phy_id, a_bool_t * enable) +{ + a_uint16_t phy_data; + *enable = A_FALSE; + + phy_data = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_MMD3_ADDR_8023AZ_EEE_DB); + PHY_RTN_ON_READ_ERROR(phy_data); + + if (phy_data & QCA808X_PHY_8023AZ_EEE_LP_STAT) { + *enable = A_TRUE; + } + + return SW_OK; +} + +/****************************************************************************** +* +* qca808x_phy_set wol frame mac address +* +* set phy wol frame mac address +*/ +sw_error_t +qca808x_phy_set_magic_frame_mac(a_uint32_t dev_id, a_uint32_t phy_id, + fal_mac_addr_t * mac) +{ + a_uint16_t phy_data1; + a_uint16_t phy_data2; + a_uint16_t phy_data3; + sw_error_t rv = SW_OK; + + phy_data1 = (mac->uc[0] << 8) | mac->uc[1]; + phy_data2 = (mac->uc[2] << 8) | mac->uc[3]; + phy_data3 = (mac->uc[4] << 8) | mac->uc[5]; + + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_MMD3_WOL_MAGIC_MAC_CTRL1, phy_data1); + PHY_RTN_ON_ERROR(rv); + + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_MMD3_WOL_MAGIC_MAC_CTRL2, phy_data2); + PHY_RTN_ON_ERROR(rv); + + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_MMD3_WOL_MAGIC_MAC_CTRL3, phy_data3); + + return rv; +} + +/****************************************************************************** +* +* qca808x_phy_get wol frame mac address +* +* get phy wol frame mac address +*/ +sw_error_t +qca808x_phy_get_magic_frame_mac(a_uint32_t dev_id, a_uint32_t phy_id, + fal_mac_addr_t * mac) +{ + a_uint16_t phy_data1; + a_uint16_t phy_data2; + a_uint16_t phy_data3; + + phy_data1 = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_MMD3_WOL_MAGIC_MAC_CTRL1); + PHY_RTN_ON_READ_ERROR(phy_data1); + + phy_data2 = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_MMD3_WOL_MAGIC_MAC_CTRL2); + PHY_RTN_ON_READ_ERROR(phy_data2); + + phy_data3 = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_MMD3_WOL_MAGIC_MAC_CTRL3); + PHY_RTN_ON_READ_ERROR(phy_data3); + + mac->uc[0] = (phy_data1 >> 8); + mac->uc[1] = (phy_data1 & 0x00ff); + mac->uc[2] = (phy_data2 >> 8); + mac->uc[3] = (phy_data2 & 0x00ff); + mac->uc[4] = (phy_data3 >> 8); + mac->uc[5] = (phy_data3 & 0x00ff); + + return SW_OK; +} + +/****************************************************************************** +* +* qca808x_phy_set wol enable or disable +* +* set phy wol enable or disable +*/ +sw_error_t +qca808x_phy_set_wol_status(a_uint32_t dev_id, a_uint32_t phy_id, a_bool_t enable) +{ + a_uint16_t phy_data; + sw_error_t rv = SW_OK; + + phy_data = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_MMD3_WOL_CTRL); + PHY_RTN_ON_READ_ERROR(phy_data); + + if (enable == A_TRUE) { + phy_data |= QCA808X_PHY_WOL_EN; + } else { + phy_data &= ~QCA808X_PHY_WOL_EN; + } + + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_MMD3_WOL_CTRL, phy_data); + + return rv; +} + +/****************************************************************************** +* +* qca808x_phy_get_wol status +* +* get wol status +*/ +sw_error_t +qca808x_phy_get_wol_status(a_uint32_t dev_id, a_uint32_t phy_id, a_bool_t * enable) +{ + a_uint16_t phy_data; + + *enable = A_FALSE; + + phy_data = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_MMD3_WOL_CTRL); + PHY_RTN_ON_READ_ERROR(phy_data); + + if (phy_data & QCA808X_PHY_WOL_EN) { + *enable = A_TRUE; + } + + return SW_OK; +} + +/****************************************************************************** +* +* qca808x_phy_set_hibernate - set hibernate status +* +* set hibernate status +*/ +sw_error_t +qca808x_phy_set_hibernate(a_uint32_t dev_id, a_uint32_t phy_id, a_bool_t enable) +{ + a_uint16_t phy_data; + sw_error_t rv = SW_OK; + + phy_data = qca808x_phy_debug_read(dev_id, phy_id, + QCA808X_DEBUG_PHY_HIBERNATION_CTRL); + PHY_RTN_ON_READ_ERROR(phy_data); + + if (enable == A_TRUE) { + phy_data |= QCA808X_PHY_HIBERNATION_CFG; + } else { + phy_data &= ~QCA808X_PHY_HIBERNATION_CFG; + } + + rv = qca808x_phy_debug_write(dev_id, phy_id, + QCA808X_DEBUG_PHY_HIBERNATION_CTRL, phy_data); + + return rv; +} + +/****************************************************************************** +* +* qca808x_phy_get_hibernate - get hibernate status +* +* get hibernate status +*/ +sw_error_t +qca808x_phy_get_hibernate(a_uint32_t dev_id, a_uint32_t phy_id, + a_bool_t * enable) +{ + a_uint16_t phy_data; + + *enable = A_FALSE; + + phy_data = qca808x_phy_debug_read(dev_id, phy_id, + QCA808X_DEBUG_PHY_HIBERNATION_CTRL); + PHY_RTN_ON_READ_ERROR(phy_data); + + if (phy_data & QCA808X_PHY_HIBERNATION_CFG) { + *enable = A_TRUE; + } + + return SW_OK; +} + +/****************************************************************************** +* +* _qca808x_phy_get_hibernate_status - get hibernate status +* +* get hibernate status +*/ +sw_error_t +_qca808x_phy_get_hibernate_status(a_uint32_t dev_id, a_uint32_t phy_id, + a_bool_t * enable) +{ + a_uint16_t phy_data; + + *enable = A_TRUE; + + phy_data = qca808x_phy_debug_read(dev_id, phy_id, + QCA808X_DEBUG_PHY_HIBERNATION_STAT); + PHY_RTN_ON_READ_ERROR(phy_data); + + if (phy_data & QCA808X_PHY_HIBERNATION_STAT_EN) { + *enable = A_FALSE; + } + + return SW_OK; +} +#endif +/****************************************************************************** +* +* qca808x_phy_interface mode set +* +* set qca808x phy interface mode +*/ +sw_error_t +qca808x_phy_interface_set_mode(a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_interface_mode_t interface_mode) +{ + /* qca808x phy will automatically switch the interface mode according + * to the speed, 2.5G works on SGMII+, other works on SGMII. + */ + + return SW_OK; +} + +/****************************************************************************** +* +* qca808x_phy_interface mode get +* +* get qca808x phy interface mode +*/ +sw_error_t +qca808x_phy_interface_get_mode(a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_interface_mode_t *interface_mode) +{ + a_uint16_t phy_data; + phy_data = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_CHIP_CONFIG); + PHY_RTN_ON_READ_ERROR(phy_data); + + phy_data &= QCA808X_PHY_CHIP_MODE_CFG; + if (phy_data == QCA808X_PHY_SGMII_BASET) { + *interface_mode = PHY_SGMII_BASET; + } + + return SW_OK; +} + +/****************************************************************************** +* +* qca808x_phy_interface mode status get +* +* get qca808x phy interface mode status +*/ +sw_error_t +qca808x_phy_interface_get_mode_status(a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_interface_mode_t *interface_mode_status) +{ + a_uint16_t phy_data; + phy_data = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_CHIP_CONFIG); + PHY_RTN_ON_READ_ERROR(phy_data); + + phy_data &= QCA808X_PHY_MODE_MASK; + switch (phy_data) { + case QCA808X_PHY_SGMII_PLUS_MODE: + *interface_mode_status = PORT_SGMII_PLUS; + break; + case QCA808X_PHY_SGMII_MODE: + *interface_mode_status = PHY_SGMII_BASET; + break; + default: + *interface_mode_status = PORT_INTERFACE_MODE_MAX; + break; + } + + return SW_OK; +} +#ifndef IN_PORTCONTROL_MINI +/****************************************************************************** +* +* qca808x_phy_set_intr_mask - Set interrupt mask with the +* specified device. +*/ +sw_error_t +qca808x_phy_set_intr_mask(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t intr_mask_flag) +{ + a_uint16_t phy_data = 0; + sw_error_t rv = SW_OK; + + phy_data = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_INTR_MASK); + PHY_RTN_ON_READ_ERROR(phy_data); + + if (intr_mask_flag & FAL_PHY_INTR_STATUS_UP_CHANGE) { + phy_data |= QCA808X_INTR_STATUS_UP_CHANGE; + } else { + phy_data &= (~QCA808X_INTR_STATUS_UP_CHANGE); + } + + if (intr_mask_flag & FAL_PHY_INTR_STATUS_DOWN_CHANGE) { + phy_data |= QCA808X_INTR_STATUS_DOWN_CHANGE; + } else { + phy_data &= (~QCA808X_INTR_STATUS_DOWN_CHANGE); + } + + if (intr_mask_flag & FAL_PHY_INTR_SPEED_CHANGE) { + phy_data |= QCA808X_INTR_SPEED_CHANGE; + } else { + phy_data &= (~QCA808X_INTR_SPEED_CHANGE); + } + + if (intr_mask_flag & FAL_PHY_INTR_BX_FX_STATUS_UP_CHANGE) { + phy_data |= QCA808X_INTR_LINK_SUCCESS_SG; + } else { + phy_data &= (~QCA808X_INTR_LINK_SUCCESS_SG); + } + + if (intr_mask_flag & FAL_PHY_INTR_BX_FX_STATUS_DOWN_CHANGE) { + phy_data |= QCA808X_INTR_LINK_FAIL_SG; + } else { + phy_data &= (~QCA808X_INTR_LINK_FAIL_SG); + } + + if (intr_mask_flag & FAL_PHY_INTR_WOL_STATUS) { + phy_data |= QCA808X_INTR_WOL; + } else { + phy_data &= (~QCA808X_INTR_WOL); + } + + if (intr_mask_flag & FAL_PHY_INTR_POE_STATUS) { + phy_data |= QCA808X_INTR_POE; + } else { + phy_data &= (~QCA808X_INTR_POE); + } + + rv = qca808x_phy_reg_write(dev_id, phy_id, QCA808X_PHY_INTR_MASK, phy_data); + return rv; +} + +/****************************************************************************** +* +* qca808x_phy_get_intr_mask - Get interrupt mask with the +* specified device. +*/ +sw_error_t +qca808x_phy_get_intr_mask(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t * intr_mask_flag) +{ + a_uint16_t phy_data = 0; + + phy_data = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_INTR_MASK); + PHY_RTN_ON_READ_ERROR(phy_data); + + *intr_mask_flag = 0; + if (phy_data & QCA808X_INTR_STATUS_UP_CHANGE) { + *intr_mask_flag |= FAL_PHY_INTR_STATUS_UP_CHANGE; + } + + if (phy_data & QCA808X_INTR_STATUS_DOWN_CHANGE) { + *intr_mask_flag |= FAL_PHY_INTR_STATUS_DOWN_CHANGE; + } + + if (phy_data & QCA808X_INTR_SPEED_CHANGE) { + *intr_mask_flag |= FAL_PHY_INTR_SPEED_CHANGE; + } + + if (phy_data & QCA808X_INTR_LINK_SUCCESS_SG) { + *intr_mask_flag |= FAL_PHY_INTR_BX_FX_STATUS_UP_CHANGE; + } + + if (phy_data & QCA808X_INTR_LINK_FAIL_SG) { + *intr_mask_flag |= FAL_PHY_INTR_BX_FX_STATUS_DOWN_CHANGE; + } + + if (phy_data & QCA808X_INTR_WOL) { + *intr_mask_flag |= FAL_PHY_INTR_WOL_STATUS; + } + + if (phy_data & QCA808X_INTR_POE) { + *intr_mask_flag |= FAL_PHY_INTR_POE_STATUS; + } + + return SW_OK; +} + +/****************************************************************************** +* +* qca808x_phy_get_intr_status - Get interrupt status with the +* specified device. +*/ +sw_error_t +qca808x_phy_get_intr_status(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t * intr_status_flag) +{ + a_uint16_t phy_data = 0; + + phy_data = qca808x_phy_reg_read(dev_id, phy_id, QCA808X_PHY_INTR_STATUS); + PHY_RTN_ON_READ_ERROR(phy_data); + + *intr_status_flag = 0; + if (phy_data & QCA808X_INTR_STATUS_UP_CHANGE) { + *intr_status_flag |= FAL_PHY_INTR_STATUS_UP_CHANGE; + } + + if (phy_data & QCA808X_INTR_STATUS_DOWN_CHANGE) { + *intr_status_flag |= FAL_PHY_INTR_STATUS_DOWN_CHANGE; + } + + if (phy_data & QCA808X_INTR_SPEED_CHANGE) { + *intr_status_flag |= FAL_PHY_INTR_SPEED_CHANGE; + } + + if (phy_data & QCA808X_INTR_LINK_SUCCESS_SG) { + *intr_status_flag |= FAL_PHY_INTR_BX_FX_STATUS_UP_CHANGE; + } + + if (phy_data & QCA808X_INTR_LINK_FAIL_SG) { + *intr_status_flag |= FAL_PHY_INTR_BX_FX_STATUS_DOWN_CHANGE; + } + + if (phy_data & QCA808X_INTR_WOL) { + *intr_status_flag |= FAL_PHY_INTR_WOL_STATUS; + } + + if (phy_data & QCA808X_INTR_POE) { + *intr_status_flag |= FAL_PHY_INTR_POE_STATUS; + } + + return SW_OK; +} + +/****************************************************************************** +* +* qca808x_phy_set_counter - set counter status +* +* set counter status +*/ +sw_error_t +qca808x_phy_set_counter(a_uint32_t dev_id, a_uint32_t phy_id, a_bool_t enable) +{ + a_uint16_t phy_data; + sw_error_t rv = SW_OK; + + phy_data = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_COUNTER_CTRL); + PHY_RTN_ON_READ_ERROR(phy_data); + + if (enable == A_TRUE) { + phy_data |= QCA808X_PHY_FRAME_CHECK_EN; + phy_data |= QCA808X_PHY_XMIT_MAC_CNT_SELFCLR; + } else { + phy_data &= ~QCA808X_PHY_FRAME_CHECK_EN; + phy_data &= ~QCA808X_PHY_XMIT_MAC_CNT_SELFCLR; + } + + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_COUNTER_CTRL, phy_data); + + return rv; +} + +/****************************************************************************** +* +* qca808x_phy_get_counter_status - get counter status +* +* set counter status +*/ +sw_error_t +qca808x_phy_get_counter(a_uint32_t dev_id, a_uint32_t phy_id, + a_bool_t * enable) +{ + a_uint16_t phy_data; + + phy_data = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_COUNTER_CTRL); + PHY_RTN_ON_READ_ERROR(phy_data); + + if (phy_data & QCA808X_PHY_FRAME_CHECK_EN) { + *enable = A_TRUE; + } else { + *enable = A_FALSE; + } + + return SW_OK; +} + +/****************************************************************************** +* +* qca808x_phy_show show counter statistics +* +* show counter statistics +*/ +sw_error_t +qca808x_phy_show_counter(a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_counter_info_t * counter_infor) +{ + a_uint16_t ingress_high_counter = 0; + a_uint16_t ingress_low_counter = 0; + a_uint16_t egress_high_counter = 0; + a_uint16_t egress_low_counter = 0; + + ingress_high_counter = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_INGRESS_COUNTER_HIGH); + ingress_low_counter = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_INGRESS_COUNTER_LOW); + counter_infor->RxGoodFrame = (ingress_high_counter << 16 ) | ingress_low_counter; + counter_infor->RxBadCRC = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_INGRESS_ERROR_COUNTER); + + egress_high_counter = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_EGRESS_COUNTER_HIGH); + egress_low_counter = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_EGRESS_COUNTER_LOW); + counter_infor->TxGoodFrame = (egress_high_counter << 16 ) | egress_low_counter; + counter_infor->TxBadCRC = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_EGRESS_ERROR_COUNTER); + + return SW_OK; +} +#endif +/****************************************************************************** +* +* qca808x_phy_set_eee_advertisement +* +* set eee advertisement +*/ +sw_error_t +qca808x_phy_set_eee_adv(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t adv) +{ + a_uint16_t phy_data = 0; + sw_error_t rv = SW_OK; + + phy_data = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_ADDR_8023AZ_EEE_CTRL); + phy_data &= ~(QCA808X_PHY_EEE_ADV_100M | QCA808X_PHY_EEE_ADV_1000M); + + if (adv & FAL_PHY_EEE_100BASE_T) { + phy_data |= QCA808X_PHY_EEE_ADV_100M; + } + if (adv & FAL_PHY_EEE_1000BASE_T) { + phy_data |= QCA808X_PHY_EEE_ADV_1000M; + } + + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_ADDR_8023AZ_EEE_CTRL, phy_data); + + rv = qca808x_phy_restart_autoneg(dev_id, phy_id); + + return rv; +} + +/****************************************************************************** +* +* qca808x_phy_get_eee_advertisement +* +* get eee advertisement +*/ +sw_error_t +qca808x_phy_get_eee_adv(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t *adv) +{ + a_uint16_t phy_data = 0; + sw_error_t rv = SW_OK; + + *adv = 0; + phy_data = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_ADDR_8023AZ_EEE_CTRL); + + if (phy_data & QCA808X_PHY_EEE_ADV_100M) { + *adv |= FAL_PHY_EEE_100BASE_T; + } + if (phy_data & QCA808X_PHY_EEE_ADV_1000M) { + *adv |= FAL_PHY_EEE_1000BASE_T; + } + + return rv; +} +/****************************************************************************** +* +* qca808x_phy_get_eee_partner_advertisement +* +* get eee partner advertisement +*/ +sw_error_t +qca808x_phy_get_eee_partner_adv(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t *adv) +{ + a_uint16_t phy_data = 0; + sw_error_t rv = SW_OK; + + *adv = 0; + phy_data = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_ADDR_8023AZ_EEE_PARTNER); + + if (phy_data & QCA808X_PHY_EEE_PARTNER_ADV_100M) { + *adv |= FAL_PHY_EEE_100BASE_T; + } + if (phy_data & QCA808X_PHY_EEE_PARTNER_ADV_1000M) { + *adv |= FAL_PHY_EEE_1000BASE_T; + } + + return rv; +} +/****************************************************************************** +* +* qca808x_phy_get_eee_capability +* +* get eee capability +*/ +sw_error_t +qca808x_phy_get_eee_cap(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t *cap) +{ + a_uint16_t phy_data = 0; + sw_error_t rv = SW_OK; + + *cap = 0; + phy_data = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_MMD3_ADDR_8023AZ_EEE_CAPABILITY); + + if (phy_data & QCA808X_PHY_EEE_CAPABILITY_100M) { + *cap |= FAL_PHY_EEE_100BASE_T; + } + if (phy_data & QCA808X_PHY_EEE_CAPABILITY_1000M) { + *cap |= FAL_PHY_EEE_1000BASE_T; + } + + return rv; +} +/****************************************************************************** +* +* qca808x_phy_get_eee_status +* +* get eee status +*/ +sw_error_t +qca808x_phy_get_eee_status(a_uint32_t dev_id, a_uint32_t phy_id, + a_uint32_t *status) +{ + a_uint16_t phy_data = 0; + sw_error_t rv = SW_OK; + + *status = 0; + phy_data = qca808x_phy_mmd_read(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_ADDR_8023AZ_EEE_STATUS); + + if (phy_data & QCA808X_PHY_EEE_STATUS_100M) { + *status |= FAL_PHY_EEE_100BASE_T; + } + if (phy_data & QCA808X_PHY_EEE_STATUS_1000M) { + *status |= FAL_PHY_EEE_1000BASE_T; + } + + return rv; +} + +/****************************************************************************** +* +* qca808x_phy_led_init - set led behavior +* +* set led behavior +*/ +static sw_error_t +qca808x_phy_led_init(a_uint32_t dev_id, a_uint32_t phy_id) +{ + sw_error_t rv = SW_OK; + + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_LED_POLARITY_CTRL, + QCA808X_PHY_MMD7_LED_POLARITY_ACTIVE_HIGH); + SW_RTN_ON_ERROR(rv); + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_LED0_CTRL, + QCA808X_PHY_MMD7_LED0_CTRL_ENABLE); + SW_RTN_ON_ERROR(rv); + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_LED1_CTRL, + QCA808X_PHY_MMD7_LED1_CTRL_DISABLE); + SW_RTN_ON_ERROR(rv); + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_LED2_CTRL, + QCA808X_PHY_MMD7_LED2_CTRL_DISABLE); + SW_RTN_ON_ERROR(rv); + + return rv; +} + +static sw_error_t +qca808x_phy_fast_retrain_cfg(a_uint32_t dev_id, a_uint32_t phy_id) +{ + sw_error_t rv = SW_OK; + + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_AUTONEGOTIATION_CONTROL, + QCA808X_ADVERTISE_2500FULL | + QCA808X_PHY_FAST_RETRAIN_2500BT | + QCA808X_PHY_ADV_LOOP_TIMING); + SW_RTN_ON_ERROR(rv); + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD1_NUM, + QCA808X_PHY_MMD1_FAST_RETRAIN_STATUS_CTL, + QCA808X_PHY_FAST_RETRAIN_CTRL); + SW_RTN_ON_ERROR(rv); + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD1_NUM, + QCA808X_PHY_MMD1_MSE_THRESHOLD_20DB, + QCA808X_PHY_MSE_THRESHOLD_20DB_VALUE); + SW_RTN_ON_ERROR(rv); + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD1_NUM, + QCA808X_PHY_MMD1_MSE_THRESHOLD_17DB, + QCA808X_PHY_MSE_THRESHOLD_17DB_VALUE); + SW_RTN_ON_ERROR(rv); + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD1_NUM, + QCA808X_PHY_MMD1_MSE_THRESHOLD_27DB, + QCA808X_PHY_MSE_THRESHOLD_27DB_VALUE); + SW_RTN_ON_ERROR(rv); + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD1_NUM, + QCA808X_PHY_MMD1_MSE_THRESHOLD_28DB, + QCA808X_PHY_MSE_THRESHOLD_28DB_VALUE); + SW_RTN_ON_ERROR(rv); + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_ADDR_EEE_LP_ADVERTISEMENT, + QCA808X_PHY_EEE_ADV_THP); + SW_RTN_ON_ERROR(rv); + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD7_NUM, + QCA808X_PHY_MMD7_TOP_OPTION1, + QCA808X_PHY_TOP_OPTION1_DATA); + SW_RTN_ON_ERROR(rv); + /*adjust the threshold for link down*/ + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + 0xa100, 0x9203); + SW_RTN_ON_ERROR(rv); + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + 0xa105, 0x8001); + SW_RTN_ON_ERROR(rv); + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + 0xa106, 0x1111); + SW_RTN_ON_ERROR(rv); + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + 0xa103, 0x1698); + SW_RTN_ON_ERROR(rv); + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + 0xa011, 0x5f85); + SW_RTN_ON_ERROR(rv); + rv = qca808x_phy_mmd_write(dev_id, phy_id, QCA808X_PHY_MMD3_NUM, + 0xa101, 0x48ad); + + return rv; +} + +void qca808x_phy_lock_init(void) +{ + static a_bool_t is_init = A_FALSE; + + if(!is_init) + { + QCA808X_LOCKER_INIT; + is_init = A_TRUE; + } + + return; +} + +static sw_error_t +qca808x_phy_hw_init(a_uint32_t dev_id, a_uint32_t port_bmp) +{ + a_uint16_t phy_data = 0; + a_uint32_t port_id = 0, phy_addr = 0; + sw_error_t rv = SW_OK; + + for (port_id = SSDK_PHYSICAL_PORT0; port_id < SW_MAX_NR_PORT; port_id ++) + { + if (port_bmp & (0x1 << port_id)) + { + phy_addr = qca_ssdk_port_to_phy_addr(dev_id, port_id); + /*enable vga when init napa to fix 8023az issue*/ + phy_data = qca808x_phy_mmd_read(dev_id, phy_addr, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_MMD3_ADDR_CLD_CTRL7); + phy_data &= (~QCA808X_PHY_8023AZ_AFE_CTRL_MASK); + phy_data |= QCA808X_PHY_8023AZ_AFE_EN; + rv = qca808x_phy_mmd_write(dev_id, phy_addr, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_MMD3_ADDR_CLD_CTRL7, phy_data); + SW_RTN_ON_ERROR(rv); + /*set napa led pin behavior on HK board*/ + rv = qca808x_phy_led_init(dev_id, phy_addr); + SW_RTN_ON_ERROR(rv); + /*special configuration for AZ under 1G speed mode*/ + phy_data = QCA808X_PHY_MMD3_AZ_TRAINING_VAL; + rv = qca808x_phy_mmd_write(dev_id, phy_addr, QCA808X_PHY_MMD3_NUM, + QCA808X_PHY_MMD3_AZ_TRAINING_CTRL, phy_data); + SW_RTN_ON_ERROR(rv); + /*config the fast retrain*/ + rv = qca808x_phy_fast_retrain_cfg(dev_id, phy_addr); + SW_RTN_ON_ERROR(rv); + /*enable seed and configure ramdom seed in order that napa can be + as slave easier*/ + rv = qca808x_phy_ms_seed_enable(dev_id, phy_addr, A_TRUE); + SW_RTN_ON_ERROR(rv); + rv = qca808x_phy_ms_random_seed_set(dev_id, phy_addr); + SW_RTN_ON_ERROR(rv); + } + } + + return rv; +} + +static sw_error_t qca808x_phy_api_ops_init(void) +{ + sw_error_t ret = SW_OK; + hsl_phy_ops_t *qca808x_phy_api_ops = NULL; + + qca808x_phy_api_ops = kzalloc(sizeof(hsl_phy_ops_t), GFP_KERNEL); + if (qca808x_phy_api_ops == NULL) { + SSDK_ERROR("qca808x phy ops kzalloc failed!\n"); + return -ENOMEM; + } + + phy_api_ops_init(QCA808X_PHY_CHIP); + + qca808x_phy_api_ops->phy_reg_write = qca808x_phy_reg_write; + qca808x_phy_api_ops->phy_reg_read = qca808x_phy_reg_read; + qca808x_phy_api_ops->phy_debug_write = qca808x_phy_debug_write; + qca808x_phy_api_ops->phy_debug_read = qca808x_phy_debug_read; + qca808x_phy_api_ops->phy_mmd_write = qca808x_phy_mmd_write; + qca808x_phy_api_ops->phy_mmd_read = qca808x_phy_mmd_read; + qca808x_phy_api_ops->phy_get_status = qca808x_phy_get_status; + qca808x_phy_api_ops->phy_speed_get = qca808x_phy_get_speed; + qca808x_phy_api_ops->phy_speed_set = qca808x_phy_set_speed; + qca808x_phy_api_ops->phy_duplex_get = qca808x_phy_get_duplex; + qca808x_phy_api_ops->phy_duplex_set = qca808x_phy_set_duplex; + qca808x_phy_api_ops->phy_autoneg_enable_set = qca808x_phy_enable_autoneg; + qca808x_phy_api_ops->phy_restart_autoneg = qca808x_phy_restart_autoneg; + qca808x_phy_api_ops->phy_autoneg_status_get = qca808x_phy_autoneg_status; + qca808x_phy_api_ops->phy_autoneg_adv_set = qca808x_phy_set_autoneg_adv; + qca808x_phy_api_ops->phy_autoneg_adv_get = qca808x_phy_get_autoneg_adv; + qca808x_phy_api_ops->phy_link_status_get = qca808x_phy_get_link_status; + qca808x_phy_api_ops->phy_reset = qca808x_phy_reset; +#ifndef IN_PORTCONTROL_MINI + qca808x_phy_api_ops->phy_cdt = qca808x_phy_cdt; + qca808x_phy_api_ops->phy_mdix_set = qca808x_phy_set_mdix; + qca808x_phy_api_ops->phy_mdix_get = qca808x_phy_get_mdix; + qca808x_phy_api_ops->phy_mdix_status_get = qca808x_phy_get_mdix_status; + qca808x_phy_api_ops->phy_local_loopback_set = qca808x_phy_set_local_loopback; + qca808x_phy_api_ops->phy_local_loopback_get = qca808x_phy_get_local_loopback; + qca808x_phy_api_ops->phy_remote_loopback_set = qca808x_phy_set_remote_loopback; + qca808x_phy_api_ops->phy_remote_loopback_get = qca808x_phy_get_remote_loopback; +#endif + qca808x_phy_api_ops->phy_id_get = qca808x_phy_get_phy_id; + qca808x_phy_api_ops->phy_power_off = qca808x_phy_poweroff; + qca808x_phy_api_ops->phy_power_on = qca808x_phy_poweron; +#ifndef IN_PORTCONTROL_MINI + qca808x_phy_api_ops->phy_8023az_set = qca808x_phy_set_8023az; + qca808x_phy_api_ops->phy_8023az_get = qca808x_phy_get_8023az; + qca808x_phy_api_ops->phy_hibernation_set = qca808x_phy_set_hibernate; + qca808x_phy_api_ops->phy_hibernation_get = qca808x_phy_get_hibernate; + qca808x_phy_api_ops->phy_magic_frame_mac_set = qca808x_phy_set_magic_frame_mac; + qca808x_phy_api_ops->phy_magic_frame_mac_get = qca808x_phy_get_magic_frame_mac; + qca808x_phy_api_ops->phy_wol_status_set = qca808x_phy_set_wol_status; + qca808x_phy_api_ops->phy_wol_status_get = qca808x_phy_get_wol_status; +#endif + qca808x_phy_api_ops->phy_interface_mode_set = qca808x_phy_interface_set_mode; + qca808x_phy_api_ops->phy_interface_mode_get = qca808x_phy_interface_get_mode; + qca808x_phy_api_ops->phy_interface_mode_status_get = qca808x_phy_interface_get_mode_status; +#ifndef IN_PORTCONTROL_MINI + qca808x_phy_api_ops->phy_intr_mask_set = qca808x_phy_set_intr_mask; + qca808x_phy_api_ops->phy_intr_mask_get = qca808x_phy_get_intr_mask; + qca808x_phy_api_ops->phy_intr_status_get = qca808x_phy_get_intr_status; + qca808x_phy_api_ops->phy_counter_set = qca808x_phy_set_counter; + qca808x_phy_api_ops->phy_counter_get = qca808x_phy_get_counter; + qca808x_phy_api_ops->phy_counter_show = qca808x_phy_show_counter; +#endif + qca808x_phy_api_ops->phy_eee_adv_set = qca808x_phy_set_eee_adv; + qca808x_phy_api_ops->phy_eee_adv_get = qca808x_phy_get_eee_adv; + qca808x_phy_api_ops->phy_eee_partner_adv_get = qca808x_phy_get_eee_partner_adv; + qca808x_phy_api_ops->phy_eee_cap_get = qca808x_phy_get_eee_cap; + qca808x_phy_api_ops->phy_eee_status_get = qca808x_phy_get_eee_status; +#ifdef IN_LED + qca808x_phy_led_api_ops_init(qca808x_phy_api_ops); +#endif + ret = hsl_phy_api_ops_register(QCA808X_PHY_CHIP, qca808x_phy_api_ops); + + if (ret == SW_OK) { + SSDK_INFO("qca probe qca808x phy driver succeeded!\n"); + } else { + SSDK_ERROR("qca probe qca808x phy driver failed! (code: %d)\n", ret); + } + + return ret; +} + +/****************************************************************************** +* +* qca808x_phy_init - +* +*/ +int qca808x_phy_init(a_uint32_t dev_id, a_uint32_t port_bmp) +{ + a_int32_t ret = 0; + + if(phy_ops_flag == A_FALSE && + qca808x_phy_api_ops_init() == SW_OK) { + qca808x_phy_lock_init(); + phy_ops_flag = A_TRUE; + } + qca808x_phy_hw_init(dev_id, port_bmp); + + return ret; +} + +void qca808x_phy_exit(a_uint32_t dev_id, a_uint32_t port_bmp) +{ +} diff --git a/qca/src/qca-psdk/drv/src/hsl/scomphy_init.c b/qca/src/qca-psdk/drv/src/hsl/scomphy_init.c new file mode 100755 index 00000000000..7f82807d82a --- /dev/null +++ b/qca/src/qca-psdk/drv/src/hsl/scomphy_init.c @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +/** + * @defgroup scomphy_init SCOMPHY_INIT + * @{ + */ +#include "sw.h" +#include "hsl.h" +#include "hsl_dev.h" +#include "hsl_phy.h" +#include "hsl_port_prop.h" +#include "scomphy_port_ctrl.h" +#include "scomphy_reg_access.h" +#include "scomphy_init.h" + +static ssdk_init_cfg * scomphy_cfg[SW_MAX_NR_DEV] = { 0 }; + +static sw_error_t +scomphy_portproperty_init(a_uint32_t dev_id, hsl_init_mode mode) +{ + hsl_port_prop_t p_type; + hsl_dev_t *pdev = NULL; + fal_port_t port_id; + a_uint32_t port_bmp = qca_ssdk_port_bmp_get(dev_id); + + pdev = hsl_dev_ptr_get(dev_id); + if (pdev == NULL) + return SW_NOT_INITIALIZED; + + /* for port property set, SSDK should not generate some limitations */ + for (port_id = 1; port_id < SW_MAX_NR_PORT; port_id++) + { + if((1 << port_id) & port_bmp) + { + hsl_port_prop_portmap_set(dev_id, port_id); + + for (p_type = HSL_PP_PHY; p_type < HSL_PP_BUTT; p_type++) + { + SW_RTN_ON_ERROR(hsl_port_prop_set(dev_id, port_id, p_type)); + } + } + } + + return SW_OK; +} + +static sw_error_t +scomphy_dev_init(a_uint32_t dev_id, hsl_init_mode cpu_mode) +{ + sw_error_t rv = SW_OK; + hsl_dev_t *pdev = NULL; + a_uint8_t nr_ports = 0; + a_uint32_t port_bmp = qca_ssdk_port_bmp_get(dev_id); + + pdev = hsl_dev_ptr_get(dev_id); + if (pdev == NULL) + return SW_NOT_INITIALIZED; + + while (port_bmp) { + if (port_bmp & 1) + nr_ports++; + port_bmp >>= 1; + } + + pdev->nr_ports = nr_ports; + pdev->nr_phy = nr_ports; + pdev->cpu_port_nr = 0; + pdev->hw_vlan_query = A_TRUE; + pdev->cpu_mode = cpu_mode; + + return rv; +} + + +static sw_error_t +_scomphy_reset(a_uint32_t dev_id) +{ + sw_error_t rv = SW_OK; + a_uint32_t port_bmp = 0; + a_uint8_t port_id = 0; + + HSL_DEV_ID_CHECK(dev_id); + + port_bmp = qca_ssdk_port_bmp_get(dev_id); + while (port_bmp) { + if (port_bmp & 1) + SW_RTN_ON_ERROR(scomphy_port_reset(dev_id, port_id)); + + port_bmp >>= 1; + port_id++; + } + + return rv; +} + +sw_error_t +scomphy_cleanup(a_uint32_t dev_id) +{ + sw_error_t rv = SW_OK; + + if (scomphy_cfg[dev_id]) + { + SW_RTN_ON_ERROR(hsl_port_prop_cleanup_by_dev(dev_id)); + + aos_mem_free(scomphy_cfg[dev_id]); + scomphy_cfg[dev_id] = NULL; + } + + return rv; +} + +/** + * @brief reset hsl layer. + * @details Comments: + * This operation will reset hsl layer + * @param[in] dev_id device id + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_reset(a_uint32_t dev_id) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_reset(dev_id); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Init hsl layer. + * @details Comments: + * This operation will init hsl layer and hsl layer + * @param[in] dev_id device id + * @param[in] cfg configuration for initialization + * @return SW_OK or error code + */ +sw_error_t +scomphy_init(a_uint32_t dev_id, ssdk_init_cfg *cfg) +{ + HSL_DEV_ID_CHECK(dev_id); + + if (NULL == scomphy_cfg[dev_id]) + { + scomphy_cfg[dev_id] = aos_mem_alloc(sizeof (ssdk_init_cfg)); + } + + if (NULL == scomphy_cfg[dev_id]) + { + return SW_OUT_OF_MEM; + } + + aos_mem_copy(scomphy_cfg[dev_id], cfg, sizeof (ssdk_init_cfg)); + + SW_RTN_ON_ERROR(scomphy_reg_access_init(dev_id, cfg)); + + SW_RTN_ON_ERROR(scomphy_dev_init(dev_id, cfg->cpu_mode)); + + { + sw_error_t rv; + + SW_RTN_ON_ERROR(hsl_port_prop_init(dev_id)); + SW_RTN_ON_ERROR(hsl_port_prop_init_by_dev(dev_id)); + SW_RTN_ON_ERROR(scomphy_portproperty_init(dev_id, cfg->cpu_mode)); + + SCOMPHY_PORT_CTRL_INIT(rv, dev_id); + + { + hsl_api_t *p_api; + + SW_RTN_ON_NULL(p_api = hsl_api_ptr_get(dev_id)); + p_api->dev_reset = scomphy_reset; + p_api->dev_clean = scomphy_cleanup; + } + } + + return SW_OK; +} + +/** + * @} + */ + diff --git a/qca/src/qca-psdk/drv/src/hsl/scomphy_port_ctrl.c b/qca/src/qca-psdk/drv/src/hsl/scomphy_port_ctrl.c new file mode 100644 index 00000000000..714f13ce024 --- /dev/null +++ b/qca/src/qca-psdk/drv/src/hsl/scomphy_port_ctrl.c @@ -0,0 +1,1747 @@ +/* + * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +/** + * @defgroup scomphy_port_ctrl SCOMPHY_PORT_CONTROL + * @{ + */ +#include "sw.h" +#include "hsl.h" +#include "hsl_dev.h" +#include "hsl_port_prop.h" +#include "scomphy_port_ctrl.h" +#include "hsl_phy.h" + +static sw_error_t +_scomphy_port_duplex_set (a_uint32_t dev_id, fal_port_t port_id, + fal_port_duplex_t duplex) +{ + sw_error_t rv; + a_uint32_t phy_id; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_duplex_set) + return SW_NOT_SUPPORTED; + + if (FAL_DUPLEX_BUTT <= duplex) + { + return SW_BAD_PARAM; + } + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_duplex_set (dev_id, phy_id, duplex); + SW_RTN_ON_ERROR (rv); + return rv; +} + +static sw_error_t +_scomphy_port_duplex_get (a_uint32_t dev_id, fal_port_t port_id, + fal_port_duplex_t * pduplex) +{ + sw_error_t rv = SW_OK; + a_uint32_t phy_id; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_duplex_get) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_duplex_get (dev_id, phy_id, pduplex); + SW_RTN_ON_ERROR (rv); + + return rv; +} + +static sw_error_t +_scomphy_port_speed_set (a_uint32_t dev_id, fal_port_t port_id, + fal_port_speed_t speed) +{ + sw_error_t rv; + a_uint32_t phy_id; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_speed_set) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_speed_set (dev_id, phy_id, speed); + SW_RTN_ON_ERROR (rv); + return rv; +} + +static sw_error_t +_scomphy_port_speed_get (a_uint32_t dev_id, fal_port_t port_id, + fal_port_speed_t * pspeed) +{ + sw_error_t rv = SW_OK; + a_uint32_t phy_id; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_speed_get) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + rv = phy_drv->phy_speed_get (dev_id, phy_id, pspeed); + SW_RTN_ON_ERROR (rv); + + return rv; +} + +static sw_error_t +_scomphy_port_autoneg_status_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * status) +{ + a_uint32_t phy_id; + sw_error_t rv; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_autoneg_status_get) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + *status = phy_drv->phy_autoneg_status_get (dev_id, phy_id); + + return SW_OK; +} + +static sw_error_t +_scomphy_port_autoneg_enable (a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + a_uint32_t phy_id; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_autoneg_enable_set) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_autoneg_enable_set (dev_id, phy_id); + return rv; +} + +static sw_error_t +_scomphy_port_autoneg_restart (a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + a_uint32_t phy_id; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_restart_autoneg) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_restart_autoneg (dev_id, phy_id); + return rv; +} + +static sw_error_t +_scomphy_port_autoneg_adv_set (a_uint32_t dev_id, fal_port_t port_id, + a_uint32_t autoadv) +{ + sw_error_t rv; + a_uint32_t phy_id; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_autoneg_adv_set) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_autoneg_adv_set (dev_id, phy_id, autoadv); + SW_RTN_ON_ERROR (rv); + + return SW_OK; +} + +static sw_error_t +_scomphy_port_autoneg_adv_get (a_uint32_t dev_id, fal_port_t port_id, + a_uint32_t * autoadv) +{ + sw_error_t rv; + a_uint32_t phy_id; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_autoneg_adv_get) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + *autoadv = 0; + rv = phy_drv->phy_autoneg_adv_get (dev_id, phy_id, autoadv); + SW_RTN_ON_ERROR (rv); + + return SW_OK; +} + +#ifndef IN_PORTCONTROL_MINI +static sw_error_t +_scomphy_port_powersave_set (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_powersave_set) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_powersave_set (dev_id, phy_id, enable); + + return rv; +} + +static sw_error_t +_scomphy_port_powersave_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_powersave_get) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_powersave_get (dev_id, phy_id, enable); + + return rv; +} + +static sw_error_t +_scomphy_port_hibernate_set (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_hibernation_set) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_hibernation_set (dev_id, phy_id, enable); + + return rv; +} + +static sw_error_t +_scomphy_port_hibernate_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_hibernation_get) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_hibernation_get (dev_id, phy_id, enable); + + return rv; +} + +static sw_error_t +_scomphy_port_cdt (a_uint32_t dev_id, fal_port_t port_id, a_uint32_t mdi_pair, + fal_cable_status_t * cable_status, a_uint32_t * cable_len) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_cdt) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_cdt (dev_id, phy_id, mdi_pair, cable_status, cable_len); + + return rv; +} + +static sw_error_t +_scomphy_port_8023az_set (a_uint32_t dev_id, fal_port_t port_id, a_bool_t enable) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_8023az_set) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_8023az_set (dev_id, phy_id, enable); + + return rv; +} + +static sw_error_t +_scomphy_port_8023az_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_8023az_get) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_8023az_get (dev_id, phy_id, enable); + + return rv; +} + +static sw_error_t +_scomphy_port_mdix_set (a_uint32_t dev_id, fal_port_t port_id, + fal_port_mdix_mode_t mode) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_mdix_set) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_mdix_set (dev_id, phy_id, mode); + + return rv; +} + +static sw_error_t +_scomphy_port_mdix_get (a_uint32_t dev_id, fal_port_t port_id, + fal_port_mdix_mode_t * mode) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_mdix_get) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_mdix_get (dev_id, phy_id, mode); + + return rv; +} + +static sw_error_t +_scomphy_port_mdix_status_get (a_uint32_t dev_id, fal_port_t port_id, + fal_port_mdix_status_t * mode) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_mdix_status_get) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_mdix_status_get (dev_id, phy_id, mode); + + return rv; +} +static sw_error_t +_scomphy_port_local_loopback_set (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_local_loopback_set) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_local_loopback_set (dev_id, phy_id, enable); + + return rv; +} + +static sw_error_t +_scomphy_port_local_loopback_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_local_loopback_get) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_local_loopback_get (dev_id, phy_id, enable); + + return rv; +} + +static sw_error_t +_scomphy_port_remote_loopback_set (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_remote_loopback_set) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_remote_loopback_set (dev_id, phy_id, enable); + + return rv; +} + +static sw_error_t +_scomphy_port_remote_loopback_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_remote_loopback_get) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_remote_loopback_get (dev_id, phy_id, enable); + + return rv; +} +#endif + +static sw_error_t +_scomphy_port_power_off (a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_power_off) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_power_off(dev_id, phy_id); + + return rv; +} + +static sw_error_t +_scomphy_port_power_on (a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_power_on) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_power_on(dev_id, phy_id); + + return rv; +} + +#ifndef IN_PORTCONTROL_MINI +static sw_error_t +_scomphy_port_wol_status_set (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_wol_status_set) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_wol_status_set (dev_id, phy_id, enable); + + return rv; +} + +static sw_error_t +_scomphy_port_wol_status_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_wol_status_get) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_wol_status_get (dev_id, phy_id, enable); + + return rv; +} +static sw_error_t +_scomphy_port_interface_mode_status_get (a_uint32_t dev_id, fal_port_t port_id, + fal_port_interface_mode_t * mode) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_interface_mode_status_get) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_interface_mode_status_get (dev_id, phy_id,mode); + + return rv; +} + +static sw_error_t +_scomphy_port_magic_frame_mac_set (a_uint32_t dev_id, fal_port_t port_id, + fal_mac_addr_t * mac) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_magic_frame_mac_set) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_magic_frame_mac_set (dev_id, phy_id,mac); + + return rv; +} + +static sw_error_t +_scomphy_port_magic_frame_mac_get (a_uint32_t dev_id, fal_port_t port_id, + fal_mac_addr_t * mac) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_magic_frame_mac_get) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_magic_frame_mac_get (dev_id, phy_id,mac); + + return rv; +} + +static sw_error_t +_scomphy_port_counter_set (a_uint32_t dev_id, fal_port_t port_id, a_bool_t enable) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_counter_set) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_counter_set (dev_id, phy_id, enable); + + return rv; +} + +static sw_error_t +_scomphy_port_counter_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_counter_get) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_counter_get (dev_id, phy_id, enable); + + return rv; +} + +static sw_error_t +_scomphy_port_counter_show (a_uint32_t dev_id, fal_port_t port_id, + fal_port_counter_info_t * counter_info) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_counter_show) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_counter_show (dev_id, phy_id,counter_info); + + return rv; +} +#endif + +static sw_error_t +_scomphy_port_link_status_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * status) +{ + sw_error_t rv; + a_uint32_t phy_id; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_link_status_get) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + if (A_TRUE == phy_drv->phy_link_status_get (dev_id, phy_id)) + { + *status = A_TRUE; + } + else + { + *status = A_FALSE; + } + + return SW_OK; +} + +static sw_error_t +_scomphy_port_reset (a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_reset) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_reset(dev_id, phy_id); + + return rv; +} + +#ifndef IN_PORTCONTROL_MINI +static sw_error_t +_scomphy_port_phy_id_get (a_uint32_t dev_id, fal_port_t port_id, + a_uint16_t * org_id, a_uint16_t * rev_id) +{ + sw_error_t rv; + a_uint32_t phy_id = 0; + hsl_phy_ops_t *phy_drv; + a_uint32_t phy_data; + + HSL_DEV_ID_CHECK (dev_id); + + if (A_TRUE != hsl_port_prop_check (dev_id, port_id, HSL_PP_PHY)) + { + return SW_BAD_PARAM; + } + + SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id, port_id)); + if (NULL == phy_drv->phy_id_get) + return SW_NOT_SUPPORTED; + + rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id); + SW_RTN_ON_ERROR (rv); + + rv = phy_drv->phy_id_get (dev_id, phy_id, &phy_data); + SW_RTN_ON_ERROR (rv); + + *org_id = (phy_data >> 16) & 0xffff; + *rev_id = phy_data & 0xffff; + + return rv; +} +#endif + +/** + * @brief Set duplex mode on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[in] duplex duplex mode + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_duplex_set (a_uint32_t dev_id, fal_port_t port_id, + fal_port_duplex_t duplex) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_duplex_set (dev_id, port_id, duplex); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Get duplex mode on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] duplex duplex mode + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_duplex_get (a_uint32_t dev_id, fal_port_t port_id, + fal_port_duplex_t * pduplex) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_duplex_get (dev_id, port_id, pduplex); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Set speed on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[in] speed port speed + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_speed_set (a_uint32_t dev_id, fal_port_t port_id, + fal_port_speed_t speed) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_speed_set (dev_id, port_id, speed); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Get speed on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] speed port speed + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_speed_get (a_uint32_t dev_id, fal_port_t port_id, + fal_port_speed_t * pspeed) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_speed_get (dev_id, port_id, pspeed); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Get auto negotiation status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] status A_TRUE or A_FALSE + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_autoneg_status_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * status) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_autoneg_status_get (dev_id, port_id, status); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Enable auto negotiation status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_autoneg_enable (a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_autoneg_enable (dev_id, port_id); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Restart auto negotiation procedule on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_autoneg_restart (a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_autoneg_restart (dev_id, port_id); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Set auto negotiation advtisement ability on a particular port. + * @details Comments: + * auto negotiation advtisement ability is defined by macro such as + * FAL_PHY_ADV_10T_HD, FAL_PHY_ADV_PAUSE... + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[in] autoadv auto negotiation advtisement ability bit map + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_autoneg_adv_set (a_uint32_t dev_id, fal_port_t port_id, + a_uint32_t autoadv) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_autoneg_adv_set (dev_id, port_id, autoadv); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Get auto negotiation advtisement ability on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] autoadv auto negotiation advtisement ability bit map + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_autoneg_adv_get (a_uint32_t dev_id, fal_port_t port_id, + a_uint32_t * autoadv) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_autoneg_adv_get (dev_id, port_id, autoadv); + HSL_API_UNLOCK; + return rv; +} + +#ifndef IN_PORTCONTROL_MINI +/** + * @brief Set powersaving status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_powersave_set (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_powersave_set (dev_id, port_id, enable); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Get powersaving status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_powersave_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_powersave_get (dev_id, port_id, enable); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Set hibernate status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_hibernate_set (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_hibernate_set (dev_id, port_id, enable); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Get hibernate status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_hibernate_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_hibernate_get (dev_id, port_id, enable); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Run cable diagnostic test on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[in] mdi_pair mdi pair id + * @param[out] cable_status cable status + * @param[out] cable_len cable len + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_cdt (a_uint32_t dev_id, fal_port_t port_id, a_uint32_t mdi_pair, + fal_cable_status_t * cable_status, a_uint32_t * cable_len) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_cdt (dev_id, port_id, mdi_pair, cable_status, cable_len); + HSL_API_UNLOCK; + return rv; +} +/** + * @brief Set 802.3az status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_8023az_set (a_uint32_t dev_id, fal_port_t port_id, a_bool_t enable) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_8023az_set (dev_id, port_id, enable); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Get 8023az status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_8023az_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_8023az_get (dev_id, port_id, enable); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Set mdix on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] mode + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_mdix_set (a_uint32_t dev_id, a_uint32_t phy_id, + fal_port_mdix_mode_t mode) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_mdix_set (dev_id, phy_id, mode); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Get mdix configuration on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] mode + * @return SW_OK or error code + */ + +HSL_LOCAL sw_error_t +scomphy_port_mdix_get (a_uint32_t dev_id, fal_port_t port_id, + fal_port_mdix_mode_t * mode) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_mdix_get (dev_id, port_id, mode); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Get mdix status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] mode + * @return SW_OK or error code + */ + +HSL_LOCAL sw_error_t +scomphy_port_mdix_status_get (a_uint32_t dev_id, fal_port_t port_id, + fal_port_mdix_status_t * mode) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_mdix_status_get (dev_id, port_id, mode); + HSL_API_UNLOCK; + return rv; +} +/** + * @brief Set phy local loop back on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[in] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_local_loopback_set (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + HSL_API_LOCK; + rv = _scomphy_port_local_loopback_set (dev_id, port_id, enable); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Get phy local loop back on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_local_loopback_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_local_loopback_get (dev_id, port_id, enable); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Set phy remote loop back on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[in] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_remote_loopback_set (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + HSL_API_LOCK; + rv = _scomphy_port_remote_loopback_set (dev_id, port_id, enable); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Get phy remote loop back on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_remote_loopback_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_remote_loopback_get (dev_id, port_id, enable); + HSL_API_UNLOCK; + return rv; +} +#endif + +/** + * @brief phy power off on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[in] + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_power_off (a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + HSL_API_LOCK; + rv = _scomphy_port_power_off (dev_id, port_id); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief phy power on on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[in] + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_power_on (a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + HSL_API_LOCK; + rv = _scomphy_port_power_on (dev_id, port_id); + HSL_API_UNLOCK; + return rv; +} + +#ifndef IN_PORTCONTROL_MINI +/** + * @brief Set phy wol enable on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[in] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_wol_status_set (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t enable) +{ + sw_error_t rv; + HSL_API_LOCK; + rv = _scomphy_port_wol_status_set (dev_id, port_id, enable); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Get phy wol status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_wol_status_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_wol_status_get (dev_id, port_id, enable); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Set phy magic frame mac on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[in] mac address + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_magic_frame_mac_set (a_uint32_t dev_id, fal_port_t port_id, + fal_mac_addr_t * mac) +{ + sw_error_t rv; + HSL_API_LOCK; + rv = _scomphy_port_magic_frame_mac_set (dev_id, port_id, mac); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Get phy magic frame mac on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] mac address + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_magic_frame_mac_get (a_uint32_t dev_id, fal_port_t port_id, + fal_mac_addr_t * mac) +{ + sw_error_t rv; + HSL_API_LOCK; + rv = _scomphy_port_magic_frame_mac_get (dev_id, port_id, mac); + HSL_API_UNLOCK; + return rv; +} +/** + * @brief Set phy interface mode status. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] interface mode.. + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_interface_mode_status_get (a_uint32_t dev_id, fal_port_t port_id, + fal_port_interface_mode_t * mode) +{ + sw_error_t rv; + HSL_API_LOCK; + rv = _scomphy_port_interface_mode_status_get (dev_id, port_id, mode); + HSL_API_UNLOCK; + return rv; +} +#endif + +/** + * @brief Get link status on particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] status link status up (A_TRUE) or down (A_FALSE) + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_link_status_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * status) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_link_status_get (dev_id, port_id, status); + HSL_API_UNLOCK; + return rv; +} + +#ifndef IN_PORTCONTROL_MINI +/** + * @brief Set counter status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_counter_set (a_uint32_t dev_id, fal_port_t port_id, a_bool_t enable) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_counter_set (dev_id, port_id, enable); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Get counter status on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] enable A_TRUE or A_FALSE + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_counter_get (a_uint32_t dev_id, fal_port_t port_id, + a_bool_t * enable) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_counter_get (dev_id, port_id, enable); + HSL_API_UNLOCK; + return rv; +} + +/** + * @brief Get counter statistics on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] frame counter statistics + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_counter_show(a_uint32_t dev_id, fal_port_t port_id, + fal_port_counter_info_t * counter_info) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_counter_show (dev_id, port_id, counter_info); + HSL_API_UNLOCK; + return rv; +} +#endif + +/** + * @brief software reset on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[in] + * @return SW_OK or error code + */ +sw_error_t +scomphy_port_reset (a_uint32_t dev_id, fal_port_t port_id) +{ + sw_error_t rv; + HSL_API_LOCK; + rv = _scomphy_port_reset (dev_id, port_id); + HSL_API_UNLOCK; + return rv; +} + +#ifndef IN_PORTCONTROL_MINI +/** + * @brief Get phy id on a particular port. + * @param[in] dev_id device id + * @param[in] port_id port id + * @param[out] org_id and rev_id + * @return SW_OK or error code + */ +HSL_LOCAL sw_error_t +scomphy_port_phy_id_get (a_uint32_t dev_id, fal_port_t port_id, + a_uint16_t * org_id, a_uint16_t * rev_id) +{ + sw_error_t rv; + + HSL_API_LOCK; + rv = _scomphy_port_phy_id_get (dev_id, port_id, org_id,rev_id); + HSL_API_UNLOCK; + return rv; +} +#endif + +sw_error_t +scomphy_port_ctrl_init(a_uint32_t dev_id) +{ + HSL_DEV_ID_CHECK(dev_id); + +#ifndef HSL_STANDALONG + { + hsl_api_t *p_api; + + SW_RTN_ON_NULL(p_api = hsl_api_ptr_get(dev_id)); + + p_api->port_duplex_get = scomphy_port_duplex_get; + p_api->port_duplex_set = scomphy_port_duplex_set; + p_api->port_speed_get = scomphy_port_speed_get; + p_api->port_speed_set = scomphy_port_speed_set; + p_api->port_autoneg_status_get = scomphy_port_autoneg_status_get; + p_api->port_autoneg_enable = scomphy_port_autoneg_enable; + p_api->port_autoneg_restart = scomphy_port_autoneg_restart; + p_api->port_autoneg_adv_get = scomphy_port_autoneg_adv_get; + p_api->port_autoneg_adv_set = scomphy_port_autoneg_adv_set; +#ifndef IN_PORTCONTROL_MINI + p_api->port_powersave_set = scomphy_port_powersave_set; + p_api->port_powersave_get = scomphy_port_powersave_get; + p_api->port_hibernate_set = scomphy_port_hibernate_set; + p_api->port_hibernate_get = scomphy_port_hibernate_get; + p_api->port_cdt = scomphy_port_cdt; + p_api->port_8023az_set = scomphy_port_8023az_set; + p_api->port_8023az_get = scomphy_port_8023az_get; + p_api->port_mdix_set = scomphy_port_mdix_set; + p_api->port_mdix_get = scomphy_port_mdix_get; + p_api->port_mdix_status_get = scomphy_port_mdix_status_get; + p_api->port_local_loopback_set = scomphy_port_local_loopback_set; + p_api->port_local_loopback_get = scomphy_port_local_loopback_get; + p_api->port_remote_loopback_set = scomphy_port_remote_loopback_set; + p_api->port_remote_loopback_get = scomphy_port_remote_loopback_get; +#endif + p_api->port_power_off = scomphy_port_power_off; + p_api->port_power_on = scomphy_port_power_on; +#ifndef IN_PORTCONTROL_MINI + p_api->port_wol_status_set = scomphy_port_wol_status_set; + p_api->port_wol_status_get = scomphy_port_wol_status_get; + p_api->port_magic_frame_mac_set = scomphy_port_magic_frame_mac_set; + p_api->port_magic_frame_mac_get = scomphy_port_magic_frame_mac_get; + p_api->port_interface_mode_status_get = scomphy_port_interface_mode_status_get; + p_api->port_counter_set = scomphy_port_counter_set; + p_api->port_counter_get = scomphy_port_counter_get; + p_api->port_counter_show = scomphy_port_counter_show; +#endif + p_api->port_link_status_get = scomphy_port_link_status_get; + p_api->port_reset = scomphy_port_reset; +#ifndef IN_PORTCONTROL_MINI + p_api->port_phy_id_get = scomphy_port_phy_id_get; +#endif + } +#endif + + return SW_OK; +} + +/** + * @} + */ diff --git a/qca/src/qca-psdk/drv/src/hsl/scomphy_reg_access.c b/qca/src/qca-psdk/drv/src/hsl/scomphy_reg_access.c new file mode 100644 index 00000000000..6c9b9ebaa5f --- /dev/null +++ b/qca/src/qca-psdk/drv/src/hsl/scomphy_reg_access.c @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include "sw.h" +#include "hsl.h" +#include "hsl_dev.h" +#include "sd.h" +#include "scomphy_reg_access.h" +#include "hsl_phy.h" + +#if defined(API_LOCK) +static aos_lock_t mdio_lock; +#define MDIO_LOCKER_INIT aos_lock_init(&mdio_lock) +#define MDIO_LOCKER_LOCK aos_lock(&mdio_lock) +#define MDIO_LOCKER_UNLOCK aos_unlock(&mdio_lock) +#else +#define MDIO_LOCKER_INIT +#define MDIO_LOCKER_LOCK +#define MDIO_LOCKER_UNLOCK +#endif + +sw_error_t +scomphy_phy_get(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg, a_uint16_t * value) +{ + sw_error_t rv; + + MDIO_LOCKER_LOCK; + rv = sd_reg_mdio_get(dev_id, phy_addr, reg, value); + MDIO_LOCKER_UNLOCK; + return rv; +} + +sw_error_t +scomphy_phy_set(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg, a_uint16_t value) +{ + sw_error_t rv; + + MDIO_LOCKER_LOCK; + rv = sd_reg_mdio_set(dev_id, phy_addr, reg, value); + MDIO_LOCKER_UNLOCK; + return rv; +} + +sw_error_t +scomphy_phy_i2c_get(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg, a_uint16_t * value) +{ + sw_error_t rv; + + rv = sd_reg_i2c_get(dev_id, phy_addr, reg, value); + + return rv; +} + +sw_error_t +scomphy_phyi2c_set(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg, a_uint16_t value) +{ + sw_error_t rv; + + rv = sd_reg_i2c_set(dev_id, phy_addr, reg, value); + + return rv; +} +sw_error_t +scomphy_reg_access_init(a_uint32_t dev_id, ssdk_init_cfg *cfg) +{ + hsl_api_t *p_api; + + MDIO_LOCKER_INIT; + + SW_RTN_ON_NULL(p_api = hsl_api_ptr_get(dev_id)); + p_api->phy_get = scomphy_phy_get; + p_api->phy_set = scomphy_phy_set; + p_api->phy_i2c_get = scomphy_phy_i2c_get; + p_api->phy_i2c_set = scomphy_phyi2c_set; + return SW_OK; +} diff --git a/qca/src/qca-psdk/drv/src/sd.c b/qca/src/qca-psdk/drv/src/sd.c new file mode 100644 index 00000000000..69d297ae6f7 --- /dev/null +++ b/qca/src/qca-psdk/drv/src/sd.c @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2012, 2017-2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include "sw.h" +#include "ssdk_init.h" +#include "sd.h" +#include "sw_api.h" +#if ((!defined(KERNEL_MODULE)) && defined(UK_IF)) +#include "sw_api_us.h" +#endif + +mdio_reg_set ssdk_mdio_set = NULL; +mdio_reg_get ssdk_mdio_get = NULL; +i2c_reg_set ssdk_i2c_set = NULL; +i2c_reg_get ssdk_i2c_get = NULL; +sw_error_t +sd_reg_mdio_set(a_uint32_t dev_id, a_uint32_t phy, a_uint32_t reg, + a_uint16_t data) +{ + sw_error_t rv = SW_OK; + + if (NULL != ssdk_mdio_set) + { + rv = ssdk_mdio_set(dev_id, phy, reg, data); + } + else + { +#if ((!defined(KERNEL_MODULE)) && defined(UK_IF)) + { + a_uint32_t args[SW_MAX_API_PARAM]; + + args[0] = SW_API_PHY_SET; + args[1] = (a_uint32_t) & rv; + args[2] = dev_id; + args[3] = phy; + args[4] = reg; + args[5] = data; + if (SW_OK != sw_uk_if(args)) + { + return SW_FAIL; + } + } +#else + return SW_NOT_SUPPORTED; +#endif + } + + return rv; +} + +sw_error_t +sd_reg_mdio_get(a_uint32_t dev_id, a_uint32_t phy, a_uint32_t reg, a_uint16_t * data) +{ + sw_error_t rv = SW_OK; + + if (NULL != ssdk_mdio_get) + { + rv = ssdk_mdio_get(dev_id, phy, reg, data); + } + else + { +#if ((!defined(KERNEL_MODULE)) && defined(UK_IF)) + { + a_uint32_t args[SW_MAX_API_PARAM]; + a_uint32_t tmp; + + args[0] = SW_API_PHY_GET; + args[1] = (a_uint32_t) & rv; + args[2] = dev_id; + args[3] = phy; + args[4] = reg; + args[5] = (a_uint32_t) & tmp; + if (SW_OK != sw_uk_if(args)) + { + return SW_FAIL; + } + *data = *((a_uint16_t *)&tmp); + } +#else + return SW_NOT_SUPPORTED; +#endif + } + + return rv; +} + +sw_error_t +sd_reg_i2c_set(a_uint32_t dev_id, a_uint32_t phy, a_uint32_t reg, + a_uint16_t data) +{ + sw_error_t rv = SW_OK; + + if (NULL != ssdk_i2c_set) + { + rv = ssdk_i2c_set(dev_id, phy, reg, data); + } + else + { +#if ((!defined(KERNEL_MODULE)) && defined(UK_IF)) + { + a_uint32_t args[SW_MAX_API_PARAM]; + + args[0] = SW_API_PHY_I2C_SET; + args[1] = (a_uint32_t) & rv; + args[2] = dev_id; + args[3] = phy; + args[4] = reg; + args[5] = data; + if (SW_OK != sw_uk_if(args)) + { + return SW_FAIL; + } + } +#else + return SW_NOT_SUPPORTED; +#endif + } + + return rv; +} + +sw_error_t +sd_reg_i2c_get(a_uint32_t dev_id, a_uint32_t phy, a_uint32_t reg, a_uint16_t * data) +{ + sw_error_t rv = SW_OK; + + if (NULL != ssdk_i2c_get) + { + rv = ssdk_i2c_get(dev_id, phy, reg, data); + } + else + { +#if ((!defined(KERNEL_MODULE)) && defined(UK_IF)) + { + a_uint32_t args[SW_MAX_API_PARAM]; + a_uint32_t tmp; + + args[0] = SW_API_PHY_I2C_GET; + args[1] = (a_uint32_t) & rv; + args[2] = dev_id; + args[3] = phy; + args[4] = reg; + args[5] = (a_uint32_t) & tmp; + if (SW_OK != sw_uk_if(args)) + { + return SW_FAIL; + } + *data = *((a_uint16_t *)&tmp); + } +#else + return SW_NOT_SUPPORTED; +#endif + } + + return rv; +} +sw_error_t +sd_init(a_uint32_t dev_id, ssdk_init_cfg * cfg) +{ + if (NULL != cfg->reg_func.mdio_set) + { + ssdk_mdio_set = cfg->reg_func.mdio_set; + } + + if (NULL != cfg->reg_func.mdio_get) + { + ssdk_mdio_get = cfg->reg_func.mdio_get; + } + + if (NULL != cfg->reg_func.i2c_set) + { + ssdk_i2c_set = cfg->reg_func.i2c_set; + } + + if (NULL != cfg->reg_func.i2c_get) + { + ssdk_i2c_get = cfg->reg_func.i2c_get; + } + return SW_OK; +} diff --git a/qca/src/qca-psdk/drv/src/ssdk_init.c b/qca/src/qca-psdk/drv/src/ssdk_init.c new file mode 100644 index 00000000000..a9e24e0c278 --- /dev/null +++ b/qca/src/qca-psdk/drv/src/ssdk_init.c @@ -0,0 +1,284 @@ +/* + * Copyright (c) 2012, 2014-2020, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include "sw.h" +#include "ssdk_init.h" +#include "fal_init.h" +#include "fal.h" +#include "hsl.h" +#include "hsl_dev.h" +#include "hsl_phy.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ssdk_plat.h" +#if defined(IN_PHY_I2C_MODE) +#include "ssdk_phy_i2c.h" +#endif +struct qca_phy_priv **qca_phy_priv_global; + +struct qca_phy_priv* ssdk_phy_priv_data_get(a_uint32_t dev_id) +{ + if (dev_id >= SW_MAX_NR_DEV || !qca_phy_priv_global) + return NULL; + + return qca_phy_priv_global[dev_id]; +} +sw_error_t +ssdk_init(a_uint32_t dev_id, ssdk_init_cfg * cfg) +{ + sw_error_t rv; + + rv = fal_init(dev_id, cfg); + if (rv != SW_OK) + SSDK_ERROR("ssdk fal init failed: %d. \r\n", rv); + + rv = ssdk_phy_driver_init(dev_id, cfg); + if (rv != SW_OK) + SSDK_ERROR("ssdk phy init failed: %d. \r\n", rv); + + return rv; +} + +sw_error_t +ssdk_cleanup(void) +{ + sw_error_t rv; + + rv = fal_cleanup(); + rv = ssdk_phy_driver_cleanup(); + + return rv; +} +static int chip_is_scomphy(a_uint32_t dev_id, ssdk_init_cfg* cfg) +{ + int rv = -ENODEV; + a_uint32_t phy_id = 0, port_id = 0; + a_uint32_t port_bmp = qca_ssdk_port_bmp_get(dev_id); + while (port_bmp) { + if (port_bmp & 0x1) { + phy_id = hsl_phyid_get(dev_id, port_id, cfg); + switch (phy_id) { + case QCA8081_PHY_V1_1: + cfg->chip_type = CHIP_SCOMPHY; + /*MP GEPHY is always the first port*/ + if(cfg->phy_id == 0) + { + cfg->phy_id = phy_id; + } + rv = SW_OK; + break; + default: + break; + } + } + port_bmp >>= 1; + port_id++; + } + + return rv; +} + +static int chip_ver_get(a_uint32_t dev_id, ssdk_init_cfg* cfg) +{ + int rv = SW_OK; + a_uint8_t chip_ver = 0; + a_uint8_t chip_revision = 0; + if(chip_ver == QCA_VER_AR8227) + cfg->chip_type = CHIP_SHIVA; + else if(chip_ver == QCA_VER_AR8337) + cfg->chip_type = CHIP_ISISC; + else if(chip_ver == QCA_VER_AR8327) + cfg->chip_type = CHIP_ISIS; + else if(chip_ver == QCA_VER_DESS) + cfg->chip_type = CHIP_DESS; + else if(chip_ver == QCA_VER_HPPE) { + cfg->chip_type = CHIP_HPPE; + cfg->chip_revision = chip_revision; + } + else { + /* try single phy without switch connected */ + rv = chip_is_scomphy(dev_id, cfg); + } + + return rv; +} +static void ssdk_cfg_default_init(ssdk_init_cfg *cfg) +{ + memset(cfg, 0, sizeof(ssdk_init_cfg)); + cfg->cpu_mode = HSL_CPU_1; + cfg->nl_prot = 30; + cfg->reg_func.mdio_set = qca_ar8327_phy_write; + cfg->reg_func.mdio_get = qca_ar8327_phy_read; +#if defined(IN_PHY_I2C_MODE) + cfg->reg_func.i2c_set = qca_phy_i2c_write; + cfg->reg_func.i2c_get = qca_phy_i2c_read; +#endif +} +static void ssdk_free_priv(void) +{ + a_uint32_t dev_id, dev_num = 1; + + if(!qca_phy_priv_global) { + return; + } + for (dev_id = 0; dev_id < dev_num; dev_id++) { + if (qca_phy_priv_global[dev_id]) { + kfree(qca_phy_priv_global[dev_id]); + } + + qca_phy_priv_global[dev_id] = NULL; + } + + kfree(qca_phy_priv_global); + + qca_phy_priv_global = NULL; +} + +static int ssdk_alloc_priv(a_uint32_t dev_num) +{ + int rev = SW_OK; + a_uint32_t dev_id = 0; + + qca_phy_priv_global = kzalloc(dev_num * sizeof(struct qca_phy_priv *), GFP_KERNEL); + if (qca_phy_priv_global == NULL) { + return -ENOMEM; + } + + for (dev_id = 0; dev_id < dev_num; dev_id++) { + qca_phy_priv_global[dev_id] = kzalloc(sizeof(struct qca_phy_priv), GFP_KERNEL); + if (qca_phy_priv_global[dev_id] == NULL) { + return -ENOMEM; + } + qca_ssdk_port_bmp_init(dev_id); + qca_ssdk_phy_info_init(dev_id); + } + + return rev; +} + +#ifndef SSDK_STR +#define SSDK_STR "ssdk" +#endif +#if defined (ISISC) || defined (ISIS) +static void qca_ar8327_gpio_reset(struct qca_phy_priv *priv) +{ + struct device_node *np = NULL; + const __be32 *reset_gpio; + a_int32_t len; + int gpio_num = 0, ret = 0; + + if (priv->ess_switch_flag == A_TRUE) + np = priv->of_node; + else +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)) + np = priv->phy->mdio.dev.of_node; +#else + np = priv->phy->dev.of_node; +#endif + if(!np) + return; + + reset_gpio = of_get_property(np, "reset_gpio", &len); + if (!reset_gpio ) + { + SSDK_INFO("reset_gpio node does not exist\n"); + return; + } + + gpio_num = be32_to_cpup(reset_gpio); + if(gpio_num <= 0) + { + SSDK_INFO("reset gpio doesn't exist\n "); + return; + } + ret = gpio_request(gpio_num, "reset_gpio"); + if(ret) + { + SSDK_ERROR("gpio%d request failed, ret:%d\n", gpio_num, ret); + return; + } + gpio_direction_output(gpio_num, SSDK_GPIO_RESET); + msleep(200); + gpio_set_value(gpio_num, SSDK_GPIO_RELEASE); + SSDK_INFO("GPIO%d reset switch done\n", gpio_num); + + gpio_free(gpio_num); + + return; +} +#endif +static int __init regi_init(void) +{ + a_uint32_t num = 0, dev_id = 0, dev_num = 1; + ssdk_init_cfg cfg; + int rv = 0; + rv = ssdk_alloc_priv(dev_num); + if (rv) + goto out; + + for (num = 0; num < dev_num; num++) { + ssdk_cfg_default_init(&cfg); + rv = ssdk_plat_init(&cfg, dev_id); + SW_CNTU_ON_ERROR_AND_COND1_OR_GOTO_OUT(rv, -ENODEV); + rv = chip_ver_get(dev_id, &cfg); + SW_CNTU_ON_ERROR_AND_COND1_OR_GOTO_OUT(rv, -ENODEV); + rv = ssdk_init(dev_id, &cfg); + SW_CNTU_ON_ERROR_AND_COND1_OR_GOTO_OUT(rv, -ENODEV); + + } + +out: + if (rv == 0) + SSDK_INFO("qca-%s module init succeeded!\n", SSDK_STR); + else { + if (rv == -ENODEV) { + rv = 0; + SSDK_INFO("qca-%s module init, no device found!\n", SSDK_STR); + } else { + SSDK_INFO("qca-%s module init failed! (code: %d)\n", SSDK_STR, rv); + ssdk_free_priv(); + } + } + + return rv; +} + +static void __exit +regi_exit(void) +{ + sw_error_t rv; + rv = ssdk_cleanup(); + + if (rv == 0) + SSDK_INFO("qca-%s module exit done!\n", SSDK_STR); + else + SSDK_ERROR("qca-%s module exit failed! (code: %d)\n", SSDK_STR, rv); + ssdk_free_priv(); +} + +module_init(regi_init); +module_exit(regi_exit); + +MODULE_DESCRIPTION("QCA SSDK Driver"); +MODULE_LICENSE("Dual BSD/GPL"); diff --git a/qca/src/qca-psdk/drv/src/ssdk_phy_i2c.c b/qca/src/qca-psdk/drv/src/ssdk_phy_i2c.c new file mode 100644 index 00000000000..acf7f200a5b --- /dev/null +++ b/qca/src/qca-psdk/drv/src/ssdk_phy_i2c.c @@ -0,0 +1,458 @@ +/* + * Copyright (c) 2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include "sw.h" +#include "ssdk_phy_i2c.h" +#include +#include "ssdk_init.h" +#include "ssdk_plat.h" + +#define I2C_RW_LIMIT 8 +#define I2C_ADAPTER_DEFAULT_ID 0 + +/****************************************************************************** +* +* _qca_i2c_read - read data per i2c bus +* +* read data per i2c bus +*/ +static inline a_int16_t +_qca_i2c_read(a_uint32_t i2c_bus_id, a_uint32_t i2c_slave, + a_uint32_t data_addr, a_uint8_t *buf, a_uint32_t count) +{ + a_int16_t ret, i; + struct i2c_adapter *adapt; + a_uint8_t addrbuf[2]; + struct i2c_msg msg[2]; + + ret =0; + i = 0; + + if (data_addr & 0xff00) { + addrbuf[i++] = (data_addr >> 8) & 0xff; + } + + addrbuf[i++] = data_addr & 0xff; + + if (count > I2C_RW_LIMIT) { + count = I2C_RW_LIMIT; + } + + /* + * msg for configuring the address + */ + aos_mem_set(msg, 0, sizeof(msg)); + msg[0].addr = i2c_slave; + msg[0].len = i; + msg[0].buf = addrbuf; + + /* + * msg for acquiring data + */ + msg[1].addr = i2c_slave; + msg[1].flags = I2C_M_RD; + msg[1].len = count; + msg[1].buf = buf; + + adapt = i2c_get_adapter(i2c_bus_id); + if (adapt) { + ret = i2c_transfer(adapt, msg, ARRAY_SIZE(msg)); + i2c_put_adapter(adapt); + } + + if (ret == ARRAY_SIZE(msg)) { + return count; + } + + return ret; +} + +/****************************************************************************** +* +* qca_i2c_data_get - wrapper of reading data per i2c bus +* +* wrapper of reading data per i2c bus +*/ +sw_error_t +qca_i2c_data_get(a_uint32_t dev_id, a_uint32_t i2c_slave, + a_uint32_t data_addr, a_uint8_t *buf, a_uint32_t count) +{ + a_int16_t ret = 0, cur = 0; + a_uint16_t cnt = count; + + while (cnt) { + cur = _qca_i2c_read(I2C_ADAPTER_DEFAULT_ID, + i2c_slave, data_addr, buf, cnt); + + /* No such i2c_slave device */ + if (cur == -ENXIO) { + return SW_NO_RESOURCE; + } + + if (cur <= 0) { + break; + } + /* + * loop to acquire the data from the new + * address based on the returned count. + */ + cnt -= cur; + buf += cur; + data_addr += cur; + ret += cur; + } + + if (ret != count) { + return SW_FAIL; + } + + return SW_OK; +} + +/****************************************************************************** +* +* _qca_i2c_write - write data per i2c bus +* +* write data per i2c bus +*/ +static inline a_int16_t +_qca_i2c_write(a_uint32_t i2c_bus_id, a_uint32_t i2c_slave, + a_uint32_t data_addr, a_uint8_t *buf, a_uint32_t count) +{ + a_int16_t ret, i; + struct i2c_adapter *adapt; + struct i2c_msg msg; + a_uint8_t i2c_wbuf[I2C_RW_LIMIT+2]; + + ret = 0; + i = 0; + + if (data_addr & 0xff00) { + i2c_wbuf[i++] = (data_addr >> 8) & 0xff; + } + + /* + * the write buffer is for saving address + * and the data to sent. + */ + i2c_wbuf[i++] = data_addr & 0xff; + + if (count > I2C_RW_LIMIT) { + count = I2C_RW_LIMIT; + } + memcpy(&i2c_wbuf[i], buf, count); + + aos_mem_set(&msg, 0, sizeof(msg)); + msg.addr = i2c_slave; + msg.len = i + count; + msg.buf = i2c_wbuf; + + adapt = i2c_get_adapter(i2c_bus_id); + if (adapt) { + ret = i2c_transfer(adapt, &msg, 1); + i2c_put_adapter(adapt); + } + + if (ret == 1) { + return count; + } + + return ret; +} + +/****************************************************************************** +* +* qca_i2c_data_set - wrapper of writting data per i2c bus +* +* wrapper of writting data per i2c bus +*/ +sw_error_t +qca_i2c_data_set(a_uint32_t dev_id, a_uint32_t i2c_slave, + a_uint32_t data_addr, a_uint8_t *buf, a_uint32_t count) +{ + a_int16_t ret = 0, cur = 0; + a_uint16_t cnt = count; + + while (cnt) { + cur = _qca_i2c_write(I2C_ADAPTER_DEFAULT_ID, + i2c_slave, data_addr, buf, cnt); + + /* No such i2c_slave device */ + if (cur == -ENXIO) { + return SW_NO_RESOURCE; + } + + if (cur <= 0) { + break; + } + /* + * loop to write the data to the new + * address based on the returned count. + */ + cnt -= cur; + buf += cur; + data_addr += cur; + ret += cur; + } + + if (ret != count) { + return SW_FAIL; + } + + return SW_OK; +} + +/****************************************************************************** +* +* _qca_phy_i2c_mii_read - mii register i2c read +* +* mii register i2c read +*/ +sw_error_t +qca_phy_i2c_mii_read(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg_addr, a_uint16_t *reg_data) +{ + sw_error_t ret; + a_uint8_t rx[2] = { 0 }; + + reg_addr &= 0xff; + + ret = qca_i2c_data_get(dev_id, phy_addr, + reg_addr, rx, sizeof(rx)); + + if (ret == SW_OK) { + *reg_data = (rx[0] << 8) | rx[1]; + } else { + *reg_data = 0xffff; + } + + return ret; +} + +/****************************************************************************** +* +* _qca_phy_i2c_mii_write - mii register i2c write +* +* mii register i2c write +*/ +sw_error_t +qca_phy_i2c_mii_write(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg_addr, a_uint16_t reg_data) +{ + sw_error_t ret; + a_uint8_t tx[2] = {(reg_data >> 8) & 0xff, reg_data & 0xff}; + + reg_addr &= 0xff; + + ret = qca_i2c_data_set(dev_id, phy_addr, + reg_addr, tx, sizeof(tx)); + + return ret; +} + +#ifdef IN_PHY_I2C_MODE +/****************************************************************************** +* +* _qca_phy_i2c_mmd_read - mmd register i2c read +* +* mmd register i2c read +*/ +sw_error_t +qca_phy_i2c_mmd_read(a_uint32_t dev_id, a_uint32_t phy_addr, a_uint16_t mmd_num, + a_uint32_t reg_addr, a_uint16_t *reg_data) +{ + a_uint8_t ret; + struct i2c_adapter *adapt; + /* + TX buffer to send: + 1st byte: Bit[6](1:MMD 0:MII) Bit[5](1:MMD address 0:MMD data) Bit[4:0](MMD num) + 2nd byte is high 8bits of reg addr + 3rd byte is low 8bits of reg addr + 4th byte: add one extra byte at the end of address writing msg to avoid qca808x + treat it as data writing operation + */ + a_uint8_t tx[4] = { ((QCA_PHY_I2C_IS_MMD << QCA_PHY_I2C_MMD_OR_MII_SHIFT) | + (QCA_PHY_I2C_MMD_IS_ADDR << QCA_PHY_I2C_MMD_ADDR_OR_DATA_SHIFT) | mmd_num), + (reg_addr >> 8) & 0xff, reg_addr & 0xff, 0 }; + /* + RX buffer to receive: + 1st byte is high 8bits of reg data + 2nd byte is low 8bits of reg data + */ + a_uint8_t rx[2] = { 0 }; + struct i2c_msg msg[] = { + { .addr = phy_addr, .flags = 0, + .buf = tx, .len = sizeof(tx) }, + { .addr = phy_addr, .flags = I2C_M_RD, + .buf = rx, .len = sizeof(rx) } }; + + if((mmd_num != QCA_PHY_MMD1_NUM) && (mmd_num != QCA_PHY_MMD3_NUM) && + (mmd_num != QCA_PHY_MMD7_NUM)) { + SSDK_ERROR("wrong MMD number:[%d]\n", mmd_num); + return SW_FAIL; + } + + adapt = i2c_get_adapter(I2C_ADAPTER_DEFAULT_ID); + if (!adapt) { + return SW_FAIL; + } + + ret = i2c_transfer(adapt, msg, ARRAY_SIZE(msg)); + *reg_data = (rx[0] << 8) | rx[1]; + + i2c_put_adapter(adapt); + + if (ret != ARRAY_SIZE(msg)) { + return SW_FAIL; + } + + return SW_OK; +} + +/****************************************************************************** +* +* _qca_phy_i2c_mmd_write - mmd register i2c write +* +* mmd register i2c write +*/ +sw_error_t +qca_phy_i2c_mmd_write(a_uint32_t dev_id, a_uint32_t phy_addr, a_uint16_t mmd_num, + a_uint32_t reg_addr, a_uint16_t reg_data) +{ + a_uint8_t ret; + struct i2c_adapter *adapt; + /* + First TX buffer to send: + 1st byte: Bit[6](1:MMD 0:MII) Bit[5](1:MMD address 0:MMD data) Bit[4:0](MMD num) + 2nd byte is high 8bits of reg addr + 3rd byte is low 8bits of reg addr + 4th byte: add one extra byte at the end of address writing msg to avoid qca808x + treat it as data writing operation + */ + a_uint8_t tx[4] = { ((QCA_PHY_I2C_IS_MMD << QCA_PHY_I2C_MMD_OR_MII_SHIFT) | + (QCA_PHY_I2C_MMD_IS_ADDR << QCA_PHY_I2C_MMD_ADDR_OR_DATA_SHIFT) | mmd_num), + (reg_addr >> 8) & 0xff, reg_addr & 0xff, 0 }; + + /* + Second TX buffer to send: + 1st byte: Bit[6](1:MMD 0:MII) Bit[5](1:MMD address 0:MMD data) Bit[4:0](MMD num) + 2nd byte is high 8bits of reg data + 3rd byte is low 8bits of reg data + */ + a_uint8_t tx2[3] = { ((QCA_PHY_I2C_IS_MMD << QCA_PHY_I2C_MMD_OR_MII_SHIFT) | + (QCA_PHY_I2C_MMD_IS_DATA << QCA_PHY_I2C_MMD_ADDR_OR_DATA_SHIFT) | mmd_num), + (reg_data >> 8) & 0xff, reg_data & 0xff }; + + struct i2c_msg msg[] = { + { .addr = phy_addr, .flags = 0, + .buf = tx, .len = sizeof(tx) }, + { .addr = phy_addr, .flags = 0, + .buf = tx2, .len = sizeof(tx2) } }; + + if((mmd_num != QCA_PHY_MMD1_NUM) && (mmd_num != QCA_PHY_MMD3_NUM) && + (mmd_num != QCA_PHY_MMD7_NUM)) { + SSDK_ERROR("wrong MMD number:[%d]\n", mmd_num); + return SW_FAIL; + } + + adapt = i2c_get_adapter(I2C_ADAPTER_DEFAULT_ID); + if (!adapt) { + return SW_FAIL; + } + + ret = i2c_transfer(adapt, msg, ARRAY_SIZE(msg)); + + i2c_put_adapter(adapt); + + if (ret != ARRAY_SIZE(msg)) { + return SW_FAIL; + } + + return SW_OK; +} + +/****************************************************************************** +* +* qca_phy_is_i2c_addr - check if phy addr is i2c addr +* +* check if phy addr is i2c addr +*/ +a_bool_t +qca_phy_is_i2c_addr(a_uint32_t phy_addr) +{ + if(((phy_addr & QCA_PHY_I2C_DEVADDR_MASK) == + QCA_PHY_I2C_PHYCORE_DEVADDR) || + ((phy_addr & QCA_PHY_I2C_DEVADDR_MASK) == + QCA_PHY_I2C_SERDES_DEVADDR)) { + return A_TRUE; + } else { + return A_FALSE; + } +} + +/****************************************************************************** +* +* qca_phy_i2c_read - PHY register i2c read +* +* PHY register i2c read +*/ +sw_error_t +qca_phy_i2c_read(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg_addr_c45, a_uint16_t *reg_data) +{ + a_uint32_t mmd_num = QCA_PHY_MII_ADDR_C45_MMD_NUM(reg_addr_c45); + a_uint32_t reg_addr = QCA_PHY_MII_ADDR_C45_REG_ADDR(reg_addr_c45); + + if(qca_phy_is_i2c_addr(phy_addr) == A_FALSE) { + return SW_BAD_PARAM; + } + + if(QCA_PHY_MII_ADDR_C45_IS_MMD(reg_addr_c45)) { + qca_phy_i2c_mmd_read(dev_id, phy_addr, mmd_num, reg_addr, reg_data); + + } else { + qca_phy_i2c_mii_read(dev_id, phy_addr, reg_addr, reg_data); + } + + return SW_OK; +} + +/****************************************************************************** +* +* qca_phy_i2c_write - PHY register i2c write +* +* PHY register i2c write +*/ +sw_error_t +qca_phy_i2c_write(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg_addr_c45, a_uint16_t reg_data) +{ + a_uint32_t mmd_num = QCA_PHY_MII_ADDR_C45_MMD_NUM(reg_addr_c45); + a_uint32_t reg_addr = QCA_PHY_MII_ADDR_C45_REG_ADDR(reg_addr_c45); + + if(qca_phy_is_i2c_addr(phy_addr) == A_FALSE) { + return SW_BAD_PARAM; + } + + if(QCA_PHY_MII_ADDR_C45_IS_MMD(reg_addr_c45)) { + qca_phy_i2c_mmd_write(dev_id, phy_addr, mmd_num, reg_addr, reg_data); + + } else { + qca_phy_i2c_mii_write(dev_id, phy_addr, reg_addr, reg_data); + } + + return SW_OK; +} +#endif diff --git a/qca/src/qca-psdk/drv/src/ssdk_plat.c b/qca/src/qca-psdk/drv/src/ssdk_plat.c new file mode 100644 index 00000000000..909298ff534 --- /dev/null +++ b/qca/src/qca-psdk/drv/src/ssdk_plat.c @@ -0,0 +1,256 @@ +/* + * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include "sw.h" +#include "ssdk_init.h" +#include "fal_init.h" +#include "fal.h" +#include "hsl.h" +#include "hsl_dev.h" +#include "ssdk_init.h" +#include +#if defined(CONFIG_OF) && (LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)) +#include +#include +#include +#elif defined(CONFIG_OF) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) +#include +#include +#include +#include +#include +#else +#include +#include +#include +#endif +#include "ssdk_plat.h" + +extern struct qca_phy_priv **qca_phy_priv_global; +extern ssdk_chip_type SSDK_CURRENT_CHIP_TYPE; +#define MDIO_BUS_0 0 +#define MDIO_BUS_1 1 +a_uint32_t ssdk_log_level = SSDK_LOG_LEVEL_DEFAULT; +a_bool_t +phy_addr_validation_check(a_uint32_t phy_addr) +{ + + if ((phy_addr > SSDK_PHY_BCAST_ID) || (phy_addr < SSDK_PHY_MIN_ID)) + return A_FALSE; + else + return A_TRUE; +} + +static struct mii_bus * +ssdk_phy_miibus_get(a_uint32_t dev_id, a_uint32_t phy_addr) +{ + struct mii_bus *bus = NULL; + if (!bus) + bus = qca_phy_priv_global[dev_id]->miibus; + + return bus; +} + +sw_error_t +qca_ar8327_phy_read(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg, a_uint16_t* data) +{ + struct mii_bus *bus = NULL; + + if (A_TRUE != phy_addr_validation_check (phy_addr)) + { + return SW_BAD_PARAM; + } + + bus = ssdk_phy_miibus_get(dev_id, phy_addr); + if (!bus) + return SW_NOT_SUPPORTED; + + *data = mdiobus_read(bus, phy_addr, reg); + return 0; +} + +sw_error_t +qca_ar8327_phy_write(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint32_t reg, a_uint16_t data) +{ + struct mii_bus *bus = NULL; + + if (A_TRUE != phy_addr_validation_check (phy_addr)) + { + return SW_BAD_PARAM; + } + + bus = ssdk_phy_miibus_get(dev_id, phy_addr); + if (!bus) + return SW_NOT_SUPPORTED; + + mdiobus_write(bus, phy_addr, reg, data); + return 0; +} + +void +qca_ar8327_phy_dbg_write(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint16_t dbg_addr, a_uint16_t dbg_data) +{ + struct mii_bus *bus = NULL; + + if (A_TRUE != phy_addr_validation_check (phy_addr)) + { + return; + } + + bus = ssdk_phy_miibus_get(dev_id, phy_addr); + if (!bus) + return; + + mdiobus_write(bus, phy_addr, QCA_MII_DBG_ADDR, dbg_addr); + mdiobus_write(bus, phy_addr, QCA_MII_DBG_DATA, dbg_data); +} + +void +qca_ar8327_phy_dbg_read(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint16_t dbg_addr, a_uint16_t *dbg_data) +{ + struct mii_bus *bus = NULL; + + if (A_TRUE != phy_addr_validation_check (phy_addr)) + { + return; + } + + bus = ssdk_phy_miibus_get(dev_id, phy_addr); + if (!bus) + return; + + mdiobus_write(bus, phy_addr, QCA_MII_DBG_ADDR, dbg_addr); + *dbg_data = mdiobus_read(bus, phy_addr, QCA_MII_DBG_DATA); +} + + +void +qca_ar8327_mmd_write(a_uint32_t dev_id, a_uint32_t phy_addr, + a_uint16_t addr, a_uint16_t data) +{ + struct mii_bus *bus = NULL; + + if (A_TRUE != phy_addr_validation_check (phy_addr)) + { + return; + } + + bus = ssdk_phy_miibus_get(dev_id, phy_addr); + if (!bus) + return; + + mdiobus_write(bus, phy_addr, QCA_MII_MMD_ADDR, addr); + mdiobus_write(bus, phy_addr, QCA_MII_MMD_DATA, data); +} + +void qca_phy_mmd_write(u32 dev_id, u32 phy_id, + u16 mmd_num, u16 reg_id, u16 reg_val) +{ + qca_ar8327_phy_write(dev_id, phy_id, + QCA_MII_MMD_ADDR, mmd_num); + qca_ar8327_phy_write(dev_id, phy_id, + QCA_MII_MMD_DATA, reg_id); + qca_ar8327_phy_write(dev_id, phy_id, + QCA_MII_MMD_ADDR, + 0x4000 | mmd_num); + qca_ar8327_phy_write(dev_id, phy_id, + QCA_MII_MMD_DATA, reg_val); +} + +u16 qca_phy_mmd_read(u32 dev_id, u32 phy_id, + u16 mmd_num, u16 reg_id) +{ + u16 value = 0; + qca_ar8327_phy_write(dev_id, phy_id, + QCA_MII_MMD_ADDR, mmd_num); + qca_ar8327_phy_write(dev_id, phy_id, + QCA_MII_MMD_DATA, reg_id); + qca_ar8327_phy_write(dev_id, phy_id, + QCA_MII_MMD_ADDR, + 0x4000 | mmd_num); + qca_ar8327_phy_read(dev_id, phy_id, + QCA_MII_MMD_DATA, &value); + return value; +} +static int miibus_get(a_uint32_t dev_id) +{ + struct device_node *mdio_node = NULL; + struct device_node *switch_node = NULL; + struct platform_device *mdio_plat = NULL; + struct ipq40xx_mdio_data *mdio_data = NULL; + struct qca_phy_priv *priv; + hsl_reg_mode reg_mode = HSL_REG_LOCAL_BUS; + priv = qca_phy_priv_global[dev_id]; + switch_node = qca_phy_priv_global[dev_id]->of_node; + if (switch_node) { + mdio_node = of_parse_phandle(switch_node, "mdio-bus", 0); + if (mdio_node) { + priv->miibus = of_mdio_find_bus(mdio_node); + return 0; + } + } + if(reg_mode == HSL_REG_LOCAL_BUS) + mdio_node = of_find_compatible_node(NULL, NULL, "qcom,ipq40xx-mdio"); + else + mdio_node = of_find_compatible_node(NULL, NULL, "virtual,mdio-gpio"); + + if (!mdio_node) { + SSDK_ERROR("No MDIO node found in DTS!\n"); + return 1; + } + + mdio_plat = of_find_device_by_node(mdio_node); + if (!mdio_plat) { + SSDK_ERROR("cannot find platform device from mdio node\n"); + return 1; + } + + if(reg_mode == HSL_REG_LOCAL_BUS) + { + mdio_data = dev_get_drvdata(&mdio_plat->dev); + if (!mdio_data) { + SSDK_ERROR("cannot get mdio_data reference from device data\n"); + return 1; + } + priv->miibus = mdio_data->mii_bus; + } + else + priv->miibus = dev_get_drvdata(&mdio_plat->dev); + + if (!priv->miibus) { + SSDK_ERROR("cannot get mii bus reference from device data\n"); + return 1; + } + return 0; +} +int +ssdk_plat_init(ssdk_init_cfg *cfg, a_uint32_t dev_id) +{ + printk("ssdk_plat_init start\n"); + if(miibus_get(dev_id)) + return -ENODEV; + + return 0; +} + +void +ssdk_plat_exit(a_uint32_t dev_id) +{ + printk("ssdk_plat_exit\n"); +} diff --git a/qca/src/qca-psdk/drv/src/sw_api_ks_ioctl.c b/qca/src/qca-psdk/drv/src/sw_api_ks_ioctl.c new file mode 100755 index 00000000000..2988a6e33f6 --- /dev/null +++ b/qca/src/qca-psdk/drv/src/sw_api_ks_ioctl.c @@ -0,0 +1,316 @@ +/* + * Copyright (c) 2012, 2017-2018, The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include "sw.h" +#include "sw_api.h" + +#ifdef KVER26 /*Linux Kernel 2.6 */ +#define __USER __user +#else /*Linux Kernel 2.4 */ +#include +#define __USER +#endif /*KVER26 */ + +#ifdef KVER34 +#include +#include +#include +#else +#include +#include +//#include +#endif + +#include +#include +#include +#include "api_access.h" +#include "sw_api_ks.h" +#ifdef KVER32 +#include +#include +#endif +#include +#include "ssdk_init.h" +#include "ssdk_plat.h" + +static int +switch_open(struct inode * inode,struct file * file); + +static int +switch_close(struct inode * inode, struct file * file); + + +#ifdef KVER32 //for linux3.2 +static long +switch_ioctl(struct file * file, unsigned int cmd, unsigned long arg); +#else +static long +switch_ioctl(struct inode *inode, struct file * file, unsigned int cmd, unsigned long arg); +#endif + +static unsigned long *cmd_buf = NULL; + +static struct mutex api_ioctl_lock; + +static struct file_operations switch_device_fops = +{ + .owner = THIS_MODULE, + .read = NULL, + .write = NULL, + .poll = NULL, + .unlocked_ioctl= switch_ioctl, + .open = switch_open, + .release = switch_close +}; + +#ifndef SHELL_DEV +#define SHELL_DEV "switch_ssdk" +#endif +static struct miscdevice switch_device = +{ + MISC_DYNAMIC_MINOR, + SHELL_DEV, + &switch_device_fops +}; + +static sw_error_t +input_parser(sw_api_param_t *p, a_uint32_t nr_param, unsigned long *args) +{ + a_uint32_t i = 0, buf_head = nr_param; + a_uint32_t offset = sizeof(unsigned long); + a_uint32_t credit = sizeof(unsigned long) - 1; + + for (i = 0; i < nr_param; i++) + { + if (p->param_type & SW_PARAM_PTR) + { + cmd_buf[i] = (unsigned long) & cmd_buf[buf_head]; + buf_head += (p->data_size + credit) / offset; + + if (buf_head > (SW_MAX_API_BUF / offset)) + { + SSDK_ERROR("Lengh of command is more than cmd buffer\n"); + return SW_NO_RESOURCE; + } + + if (p->param_type & SW_PARAM_IN) + { + if (copy_from_user((a_uint8_t*)(cmd_buf[i]), (void __USER *)args[i + 2], + ((p->data_size + credit) / offset) * offset)) + { + SSDK_ERROR("copy_from_user fail\n"); + return SW_NO_RESOURCE; + } + SSDK_DEBUG("Input parameter %d: ", i); + SSDK_DUMP_BUF(DEBUG, (unsigned long *)cmd_buf[i], + ((p->data_size + credit) / offset)); + } + } + else + { + cmd_buf[i] = args[i + 2]; + SSDK_DEBUG("Input parameter %d: %ld\n", i, cmd_buf[i]); + } + p++; + } + return SW_OK; +} + +static sw_error_t +output_parser(sw_api_param_t *p, a_uint32_t nr_param, unsigned long *args) +{ + a_uint32_t i =0; + a_uint32_t offset = sizeof(unsigned long); + a_uint32_t credit = sizeof(unsigned long) - 1; + + for (i = 0; i < nr_param; i++) + { + if (p->param_type & SW_PARAM_OUT) + { + SSDK_DEBUG("Output parameter %d: ", i); + SSDK_DUMP_BUF(DEBUG, (unsigned long *)cmd_buf[i], + ((p->data_size + credit) / offset)); + if (copy_to_user((void __USER *) args[i + 2], (unsigned long *) cmd_buf[i], + ((p->data_size + credit) / offset) * offset)) + { + SSDK_ERROR("copy_to_user fail\n"); + return SW_NO_RESOURCE; + } + } + p++; + } + + return SW_OK; +} + +static sw_error_t +sw_api_cmd(unsigned long * args) +{ + unsigned long *p = cmd_buf, api_id = args[0], nr_param = 0; + sw_error_t(*func) (unsigned long, ...); + sw_api_param_t *pp; + sw_api_func_t *fp; + sw_error_t rv; + sw_api_t sw_api; + + SSDK_DEBUG("api_id is %ld\n", api_id); + sw_api.api_id = api_id; + rv = sw_api_get(&sw_api); + SW_OUT_ON_ERROR(rv); + + fp = sw_api.api_fp; + pp = sw_api.api_pp; + nr_param = sw_api.api_nr; + + /* Clean up cmd_buf */ + aos_mem_set(cmd_buf, 0, SW_MAX_API_BUF); + rv = input_parser(pp, nr_param, args); + SW_OUT_ON_ERROR(rv); + func = fp->func; + + switch (nr_param) + { + case 1: + rv = (func) (p[0]); + break; + case 2: + rv = (func) (p[0], p[1]); + break; + case 3: + rv = (func) (p[0], p[1], p[2]); + break; + case 4: + rv = (func) (p[0], p[1], p[2], p[3]); + break; + case 5: + rv = (func) (p[0], p[1], p[2], p[3], p[4]); + break; + case 6: + rv = (func) (p[0], p[1], p[2], p[3], p[4], p[5]); + break; + case 7: + rv = (func) (p[0], p[1], p[2], p[3], p[4], p[5], p[6]); + break; + case 8: + rv = (func) (p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]); + break; + case 9: + rv = (func) (p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8]); + break; + case 10: + rv = (func) (p[0], p[1], p[2], p[3], p[4], p[5], + p[6], p[7], p[8], p[9]); + break; + default: + rv = SW_OUT_OF_RANGE; + } + + SW_OUT_ON_ERROR(rv); + rv = output_parser(pp, nr_param, args); + +out: + return rv; +} + +static int +switch_open(struct inode * inode,struct file * file) +{ + return SW_OK; +} + +static int +switch_close(struct inode * inode, struct file * file) +{ + return SW_OK; +} + +#ifdef KVER32 +static long +switch_ioctl(struct file * file, unsigned int cmd, unsigned long arg) +#else +static long +switch_ioctl(struct inode *inode, struct file * file, unsigned int cmd, unsigned long arg) +#endif +{ + unsigned long args[SW_MAX_API_PARAM], rtn; + sw_error_t rv = SW_NO_RESOURCE; + void __user *argp = (void __user *)arg; + + SSDK_DEBUG("Recieved IOCTL call\n"); + if (copy_from_user(args, argp, sizeof (args))) + { + SSDK_ERROR("copy_from_user fail\n"); + return SW_NO_RESOURCE; + } + + mutex_lock(&api_ioctl_lock); + rv = sw_api_cmd(args); + mutex_unlock(&api_ioctl_lock); + + /* return API result to user */ + rtn = (unsigned long) rv; + if (copy_to_user + ((void __USER *) args[1], &rtn, sizeof (unsigned long))) + { + SSDK_ERROR("copy_to_user fail\n"); + rv = SW_NO_RESOURCE; + } + + return SW_OK; +} + +sw_error_t +sw_uk_init(a_uint32_t nl_prot) +{ + if (!cmd_buf) + { + if((cmd_buf = (unsigned long *) aos_mem_alloc(SW_MAX_API_BUF)) == NULL) + { + return SW_OUT_OF_MEM; + } + +#if defined UK_MINOR_DEV + switch_device.minor = UK_MINOR_DEV; +#else + switch_device.minor = nl_prot; +#endif + + if (misc_register(&switch_device)) + { + return SW_INIT_ERROR; + } + + mutex_init(&api_ioctl_lock); + } + + return SW_OK; +} + +sw_error_t +sw_uk_cleanup(void) +{ + if (cmd_buf) + { + aos_mem_free(cmd_buf); + cmd_buf = NULL; + + mutex_destroy(&api_ioctl_lock); + misc_deregister(&switch_device); + } + + return SW_OK; +} + diff --git a/quick_start.sh b/quick_start.sh index a3b5639c592..fff1a0ca5de 100755 --- a/quick_start.sh +++ b/quick_start.sh @@ -44,7 +44,7 @@ update_config(){ compile(){ $RUN "make defconfig" - $RUN "make -j4" + $RUN "make V=sc -j$(nproc)" } clean(){ diff --git a/target/linux/ipq/base-files/lib/read_caldata_to_fs.sh b/target/linux/ipq/base-files/lib/read_caldata_to_fs.sh index 349ada742ef..4fce1dff4ec 100755 --- a/target/linux/ipq/base-files/lib/read_caldata_to_fs.sh +++ b/target/linux/ipq/base-files/lib/read_caldata_to_fs.sh @@ -4,6 +4,7 @@ # Copyright (C) 2011 OpenWrt.org . /lib/ipq806x.sh +. /lib/functions.sh do_load_ipq4019_board_bin() { diff --git a/target/linux/ipq/image/Makefile b/target/linux/ipq/image/Makefile index d3260105e19..1bbacac5852 100644 --- a/target/linux/ipq/image/Makefile +++ b/target/linux/ipq/image/Makefile @@ -20,7 +20,7 @@ define Device/Default endef DEVICE_VARS += DEVICE_DTS DEVICE_DTS_DIR -ifeq ($(SUBTARGET),ipq60xx) +ifeq ($(SUBTARGET), $(filter $(SUBTARGET), ipq60xx ipq60xx_64)) include ipq60xx.mk endif diff --git a/target/linux/ipq/image/ipq60xx.mk b/target/linux/ipq/image/ipq60xx.mk index 57813f68d24..3ff4f14c527 100644 --- a/target/linux/ipq/image/ipq60xx.mk +++ b/target/linux/ipq/image/ipq60xx.mk @@ -8,6 +8,11 @@ KERNEL_ENTRY := $(KERNEL_LOADADDR) INFO_IMG_PATH = $(TMP_DIR)/info.tmp INFO_IMG_SIZE = 152 +define Build/gzip + gzip -f -9n -c $@ $(1) > $@.new + @mv $@.new $@ +endef + define Build/fit-dummy-info dd if=/dev/zero of=$(INFO_IMG_PATH) bs=1 count=$(INFO_IMG_SIZE) $(TOPDIR)/scripts/mkits.sh \ @@ -27,14 +32,27 @@ define Build/insert-info endef DEVICE_NAME := mango - define Device/8devices-mango-dvk DEVICE_TITLE := 8Devices Mango DVK DEVICE_DTS := qcom-ipq6018-8dev-mango BOARDNAME := mango IMAGE_SIZE := 27776k BLOCKSIZE = 64k - KERNEL = kernel-bin | lzma | fit-dummy-info lzma $$(DEVICE_DTS_DIR)/$$(DEVICE_DTS).dtb + KERNEL = kernel-bin | gzip | fit-dummy-info gzip $$(DEVICE_DTS_DIR)/$$(DEVICE_DTS).dtb IMAGE/sysupgrade.bin := insert-info | append-kernel $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE) endef TARGET_DEVICES += 8devices-mango-dvk + + +#DEVICE_NAME := ax840 +#define Device/yuncore-ax840 +# DEVICE_TITLE := Yuncore ax840 +# DEVICE_DTS := qcom-ipq6018-ax840 +# BOARDNAME := ax840 +# IMAGE_SIZE := 27776k +# BLOCKSIZE = 64k +# KERNEL = kernel-bin | gzip | fit-dummy-info gzip $$(DEVICE_DTS_DIR)/$$(DEVICE_DTS).dtb +# IMAGE/sysupgrade.bin := insert-info | append-kernel $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE) +#endef +#TARGET_DEVICES += yuncore-ax840 + diff --git a/toolchain/Config.in b/toolchain/Config.in index 7f6fd32f161..b53b8e63ec1 100644 --- a/toolchain/Config.in +++ b/toolchain/Config.in @@ -28,7 +28,6 @@ menuconfig TARGET_OPTIONS config USE_MIPS16 bool "Build packages with MIPS16 instructions" if TARGET_OPTIONS depends on HAS_MIPS16 - depends on !GCC_VERSION_4_6 default y help If your target CPU does support the MIPS16 instruction set @@ -43,7 +42,7 @@ menuconfig EXTERNAL_TOOLCHAIN bool prompt "Use external toolchain" if DEVEL help - If enabled, OpenWrt will compile using an existing toolchain instead of + If enabled, LEDE will compile using an existing toolchain instead of compiling one. config NATIVE_TOOLCHAIN @@ -52,7 +51,7 @@ menuconfig EXTERNAL_TOOLCHAIN depends on EXTERNAL_TOOLCHAIN select NO_STRIP help - If enabled, OpenWrt will compile using the native toolchain for your + If enabled, LEDE will compile using the native toolchain for your host instead of compiling one. config TARGET_NAME @@ -210,6 +209,7 @@ menuconfig EXTRA_TARGET_ARCH bool "n64" config MIPS64_ABI_N32 + depends on !LIBC_USE_MUSL bool "n32" config MIPS64_ABI_O32 @@ -227,42 +227,51 @@ comment "Compiler" source "toolchain/gcc/Config.in" +config YASM + bool + depends on ( i386 || x86_64 ) + prompt "Build yasm" if TOOLCHAINOPTS + default y + help + Enable if you want to build yasm + comment "C Library" depends on TOOLCHAINOPTS choice prompt "C Library implementation" if TOOLCHAINOPTS - default LIBC_USE_GLIBC if (aarch64 || aarch64_be) - default LIBC_USE_UCLIBC + default LIBC_USE_UCLIBC if arc + default LIBC_USE_MUSL help Select the C library implementation. config LIBC_USE_GLIBC - bool "Use (e)glibc" + bool "Use glibc" select USE_GLIBC + depends on !arc config LIBC_USE_UCLIBC select USE_UCLIBC bool "Use uClibc" depends on !(aarch64 || aarch64_be) + depends on BROKEN || !(arm || armeb || i386 || x86_64 || mips || mipsel || mips64 || mips64el || powerpc) config LIBC_USE_MUSL select USE_MUSL bool "Use musl" - depends on !(mips64 || mips64el) + depends on !(arc) endchoice source "toolchain/glibc/Config.in" source "toolchain/uClibc/Config.in" -source "toolchain/musl/Config.in" comment "Debuggers" depends on TOOLCHAINOPTS config GDB bool - depends on !(aarch64_be) + depends on !(aarch64 || aarch64_be) prompt "Build gdb" if TOOLCHAINOPTS default y if !EXTERNAL_TOOLCHAIN help @@ -278,19 +287,20 @@ config INSIGHT config USE_GLIBC bool - default y if !TOOLCHAINOPTS && !EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN && (aarch64 || aarch64_be || octeon) config USE_UCLIBC + default y if !TOOLCHAINOPTS && !EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN && (arc) bool - default y if !TOOLCHAINOPTS && !EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN && !(aarch64 || aarch64_be || octeon) config USE_MUSL + default y if !TOOLCHAINOPTS && !EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN && !(arc) bool config USE_EXTERNAL_LIBC bool default y if EXTERNAL_TOOLCHAIN || NATIVE_TOOLCHAIN +source "toolchain/binutils/Config.version" source "toolchain/gcc/Config.version" source "toolchain/glibc/Config.version" diff --git a/toolchain/Makefile b/toolchain/Makefile index c250cba4808..9f565d0e592 100644 --- a/toolchain/Makefile +++ b/toolchain/Makefile @@ -24,33 +24,42 @@ # 8) toolchain/libc/utils/install # build & install libc utilities # +# For musl, steps 2 and 4 are skipped, and step 3 is done after 5 curdir:=toolchain # subdirectories to descend into -$(curdir)/builddirs := $(if $(CONFIG_GDB),gdb) $(if $(CONFIG_INSIGHT),insight) $(if $(CONFIG_EXTERNAL_TOOLCHAIN),wrapper,kernel-headers binutils gcc/minimal gcc/initial gcc/final $(LIBC)/headers $(LIBC)) +$(curdir)/builddirs := $(if $(CONFIG_GDB),gdb) $(if $(CONFIG_INSIGHT),insight) $(if $(CONFIG_EXTERNAL_TOOLCHAIN),wrapper,kernel-headers binutils gcc/initial gcc/final $(LIBC) fortify-headers) $(if $(CONFIG_YASM),yasm) ifdef CONFIG_USE_UCLIBC $(curdir)/builddirs += $(LIBC)/utils endif -$(curdir)/builddirs-compile:=$($(curdir)/builddirs-prepare) -$(curdir)/builddirs-install:=$($(curdir)/builddirs-compile) # builddir dependencies ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),) - $(curdir)/gcc/minimal/compile:=$(curdir)/binutils/install - $(curdir)/kernel-headers/install:=$(curdir)/gcc/minimal/install - $(curdir)/gcc/initial/prepare:=$(curdir)/gcc/minimal/prepare - $(curdir)/gcc/final/prepare:=$(curdir)/gcc/initial/prepare + ifdef CONFIG_USE_MUSL + $(curdir)/kernel-headers/compile:=$(curdir)/gcc/initial/install + $(curdir)/$(LIBC)/compile:=$(curdir)/kernel-headers/install + else + $(curdir)/builddirs += $(LIBC)/headers gcc/minimal + $(curdir)/gcc/minimal/compile:=$(curdir)/binutils/install + $(curdir)/kernel-headers/compile:=$(curdir)/gcc/minimal/install + $(curdir)/gcc/initial/prepare:=$(curdir)/gcc/minimal/prepare + $(curdir)/$(LIBC)/prepare:=$(curdir)/$(LIBC)/headers/prepare + $(curdir)/$(LIBC)/headers/compile:=$(curdir)/kernel-headers/install + $(curdir)/gcc/initial/compile:=$(curdir)/$(LIBC)/headers/install + endif - $(curdir)/$(LIBC)/headers/compile:=$(curdir)/kernel-headers/install - $(curdir)/gcc/initial/compile:=$(curdir)/$(LIBC)/headers/install + $(curdir)/gcc/initial/compile+=$(curdir)/binutils/install + $(curdir)/gcc/final/prepare:=$(curdir)/gcc/initial/prepare $(curdir)/$(LIBC)/compile:=$(curdir)/gcc/initial/install $(curdir)/gcc/final/compile:=$(curdir)/$(LIBC)/install $(curdir)/$(LIBC)/utils/compile:=$(curdir)/gcc/final/install - $(curdir)/$(LIBC)/prepare:=$(curdir)/$(LIBC)/headers/prepare $(curdir)/$(LIBC)/utils/prepare:=$(curdir)/$(LIBC)/headers/prepare endif +$(curdir)/builddirs-compile:=$($(curdir)/builddirs-prepare) +$(curdir)/builddirs-install:=$($(curdir)/builddirs-compile) + ifndef DUMP_TARGET_DB ifneq ($(ARCH),) $(TOOLCHAIN_DIR)/info.mk: .config @@ -78,5 +87,6 @@ $(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed: endif $(eval $(call stampfile,$(curdir),toolchain,install,$(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed,,$(TOOLCHAIN_DIR))) +$(eval $(call stampfile,$(curdir),toolchain,check,$(TMP_DIR)/.build)) $(eval $(call subdir,$(curdir))) diff --git a/toolchain/binutils/Config.in b/toolchain/binutils/Config.in index 8d912231f80..9e535c4b992 100644 --- a/toolchain/binutils/Config.in +++ b/toolchain/binutils/Config.in @@ -2,12 +2,25 @@ choice prompt "Binutils Version" if TOOLCHAINOPTS - default BINUTILS_VERSION_LINARO + default BINUTILS_USE_VERSION_2_25_1 if !arc + default BINUTILS_USE_VERSION_2_26_ARC if arc help Select the version of binutils you wish to use. - config BINUTILS_VERSION_LINARO - bool "Linaro binutils 2.24" + config BINUTILS_USE_VERSION_2_25_1 + depends on !arc + bool "Binutils 2.25.1" + select BINUTILS_VERSION_2_25_1 + + config BINUTILS_USE_VERSION_2_27 + depends on !arc + bool "Binutils 2.27" + select BINUTILS_VERSION_2_27 + + config BINUTILS_USE_VERSION_2_26_ARC + depends on arc + bool "ARC binutils 2.26" + select BINUTILS_VERSION_2_26_ARC endchoice @@ -17,9 +30,3 @@ config EXTRA_BINUTILS_CONFIG_OPTIONS default "" help Any additional binutils options you may want to include.... - -config BINUTILS_VERSION - string - prompt "Binutils Version" if (TOOLCHAINOPTS && NULL) - default "linaro" if BINUTILS_VERSION_LINARO - default "linaro" diff --git a/toolchain/binutils/Config.version b/toolchain/binutils/Config.version new file mode 100644 index 00000000000..5ef8df6085f --- /dev/null +++ b/toolchain/binutils/Config.version @@ -0,0 +1,17 @@ +config BINUTILS_VERSION_2_25_1 + default y if (!TOOLCHAINOPTS && !arc) + bool + +config BINUTILS_VERSION_2_27 + bool + +config BINUTILS_VERSION_2_26_ARC + default y if (!TOOLCHAINOPTS && arc) + bool + +config BINUTILS_VERSION + string + default "2.25.1" if BINUTILS_VERSION_2_25_1 + default "2.27" if BINUTILS_VERSION_2_27 + default "arc-2016.03" if BINUTILS_VERSION_2_26_ARC + diff --git a/toolchain/binutils/Makefile b/toolchain/binutils/Makefile index 9043db713f4..c8069504001 100644 --- a/toolchain/binutils/Makefile +++ b/toolchain/binutils/Makefile @@ -10,12 +10,38 @@ PKG_NAME:=binutils PKG_VERSION:=$(call qstrip,$(CONFIG_BINUTILS_VERSION)) BIN_VERSION:=$(PKG_VERSION) -PKG_SOURCE_URL:=https://releases.linaro.org/14.09/components/toolchain/binutils-linaro/ -PKG_REV:=2.24.0-2014.09 -PKG_SOURCE:=$(PKG_NAME)-linaro-$(PKG_REV).tar.xz -PKG_MD5SUM:=8f9b2b2e049d59b1b86ce9657802a353 -BINUTILS_DIR:=$(PKG_NAME)-linaro-$(PKG_REV) -HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(BINUTILS_DIR) +PKG_SOURCE_URL:=@GNU/binutils/ +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 + +ifeq ($(PKG_VERSION),2.25.1) + PKG_HASH:=b5b14added7d78a8d1ca70b5cb75fef57ce2197264f4f5835326b0df22ac9f22 +endif + +ifeq ($(PKG_VERSION),2.26.1) + PKG_HASH:=39c346c87aa4fb14b2f786560aec1d29411b6ec34dce3fe7309fe3dd56949fd8 +endif + +ifeq ($(PKG_VERSION),2.27) + PKG_HASH:=369737ce51587f92466041a97ab7d2358c6d9e1b6490b3940eb09fb0a9a6ac88 +endif + +ifeq ($(findstring linaro, $(CONFIG_BINUTILS_VERSION)),linaro) + PKG_SOURCE_URL:=https://releases.linaro.org/14.09/components/toolchain/binutils-linaro/ + PKG_REV:=2.24.0-2014.09 + PKG_SOURCE:=$(PKG_NAME)-linaro-$(PKG_REV).tar.xz + PKG_HASH:=e8bdf80bd6a5f3fc7df53245dfc0a678803d4f19c1c7ba2af3f98c8249e612b0 + BINUTILS_DIR:=$(PKG_NAME)-linaro-$(PKG_REV) + HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(BINUTILS_DIR) +endif + +ifneq ($(CONFIG_BINUTILS_VERSION_2_26_ARC),) + PKG_SOURCE_URL:=https://github.com/foss-for-synopsys-dwc-arc-processors/binutils-gdb/archive/arc-2016.03/ + PKG_REV:=2016.03 + PKG_SOURCE:=$(PKG_NAME)-arc-$(PKG_REV).tar.gz + PKG_HASH:=6583a0cd5c7251dc895a47c797a9b011e466c23377d2ca7548a707fdb918fba1 + BINUTILS_DIR:=$(PKG_NAME)-gdb-arc-$(PKG_REV) + HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(BINUTILS_DIR) +endif HOST_BUILD_PARALLEL:=1 @@ -32,10 +58,13 @@ BINUTILS_CONFIGURE:= \ --host=$(GNU_HOST_NAME) \ --target=$(REAL_GNU_TARGET_NAME) \ --with-sysroot=$(TOOLCHAIN_DIR) \ + --enable-deterministic-archives \ --enable-plugins \ --disable-multilib \ --disable-werror \ --disable-nls \ + --disable-sim \ + --disable-gdb \ $(GRAPHITE_CONFIGURE) \ $(SOFT_FLOAT_CONFIG_OPTION) \ $(call qstrip,$(CONFIG_EXTRA_BINUTILS_CONFIG_OPTIONS)) @@ -81,6 +110,12 @@ define Host/Install $(call FixupLibdir,$(TOOLCHAIN_DIR)/initial) $(RM) $(TOOLCHAIN_DIR)/initial/lib/libiberty.a $(CP) $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-readelf $(REAL_STAGING_DIR_HOST)/bin/readelf + # ARC gcc requires extlib. + # If extlib is not available in "initial" folder + # initial gcc will fail to build libc. + if [ -d $(TOOLCHAIN_DIR)/extlib ]; then \ + $(CP) -r $(TOOLCHAIN_DIR)/extlib $(TOOLCHAIN_DIR)/initial/; \ + fi endef define Host/Clean diff --git a/toolchain/binutils/patches/linaro/300-001_ld_makefile_patch.patch b/toolchain/binutils/patches/2.25.1/300-001_ld_makefile_patch.patch similarity index 93% rename from toolchain/binutils/patches/linaro/300-001_ld_makefile_patch.patch rename to toolchain/binutils/patches/2.25.1/300-001_ld_makefile_patch.patch index 0efcd183839..c51fc003fd7 100644 --- a/toolchain/binutils/patches/linaro/300-001_ld_makefile_patch.patch +++ b/toolchain/binutils/patches/2.25.1/300-001_ld_makefile_patch.patch @@ -11,7 +11,7 @@ EMULATION_OFILES = @EMULATION_OFILES@ --- a/ld/Makefile.in +++ b/ld/Makefile.in -@@ -386,7 +386,7 @@ AM_CFLAGS = $(WARN_CFLAGS) +@@ -388,7 +388,7 @@ AM_CFLAGS = $(WARN_CFLAGS) # We put the scripts in the directory $(scriptdir)/ldscripts. # We can't put the scripts in $(datadir) because the SEARCH_DIR # directives need to be different for native and cross linkers. diff --git a/toolchain/binutils/patches/linaro/300-012_check_ldrunpath_length.patch b/toolchain/binutils/patches/2.25.1/300-012_check_ldrunpath_length.patch similarity index 77% rename from toolchain/binutils/patches/linaro/300-012_check_ldrunpath_length.patch rename to toolchain/binutils/patches/2.25.1/300-012_check_ldrunpath_length.patch index 37752b75ac2..2e24b38cad4 100644 --- a/toolchain/binutils/patches/linaro/300-012_check_ldrunpath_length.patch +++ b/toolchain/binutils/patches/2.25.1/300-012_check_ldrunpath_length.patch @@ -1,6 +1,6 @@ --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em -@@ -1267,6 +1267,8 @@ fragment <link_next) + for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next) if (bfd_get_flavour (abfd) == bfd_target_elf_flavour) diff --git a/toolchain/binutils/patches/linaro/400-mips_no_dynamic_linking_sym.patch b/toolchain/binutils/patches/2.25.1/400-mips_no_dynamic_linking_sym.patch similarity index 79% rename from toolchain/binutils/patches/linaro/400-mips_no_dynamic_linking_sym.patch rename to toolchain/binutils/patches/2.25.1/400-mips_no_dynamic_linking_sym.patch index 251134fb934..a63203d1ccc 100644 --- a/toolchain/binutils/patches/linaro/400-mips_no_dynamic_linking_sym.patch +++ b/toolchain/binutils/patches/2.25.1/400-mips_no_dynamic_linking_sym.patch @@ -1,6 +1,6 @@ --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c -@@ -7450,6 +7450,7 @@ _bfd_mips_elf_create_dynamic_sections (b +@@ -7689,6 +7689,7 @@ _bfd_mips_elf_create_dynamic_sections (b name = SGI_COMPAT (abfd) ? "_DYNAMIC_LINK" : "_DYNAMIC_LINKING"; bh = NULL; @@ -8,7 +8,7 @@ if (!(_bfd_generic_link_add_one_symbol (info, abfd, name, BSF_GLOBAL, bfd_abs_section_ptr, 0, NULL, FALSE, get_elf_backend_data (abfd)->collect, &bh))) -@@ -7462,6 +7463,7 @@ _bfd_mips_elf_create_dynamic_sections (b +@@ -7701,6 +7702,7 @@ _bfd_mips_elf_create_dynamic_sections (b if (! bfd_elf_link_record_dynamic_symbol (info, h)) return FALSE; diff --git a/toolchain/binutils/patches/2.25.1/500-Change-default-emulation-for-mips64-linux.patch b/toolchain/binutils/patches/2.25.1/500-Change-default-emulation-for-mips64-linux.patch new file mode 100644 index 00000000000..3343a856619 --- /dev/null +++ b/toolchain/binutils/patches/2.25.1/500-Change-default-emulation-for-mips64-linux.patch @@ -0,0 +1,37 @@ +--- a/bfd/config.bfd ++++ b/bfd/config.bfd +@@ -1062,12 +1062,12 @@ case "${targ}" in + targ_selvecs="mips_elf32_le_vec mips_elf64_be_vec mips_elf64_le_vec mips_ecoff_be_vec mips_ecoff_le_vec" + ;; + mips64*el-*-linux*) +- targ_defvec=mips_elf32_ntrad_le_vec +- targ_selvecs="mips_elf32_ntrad_be_vec mips_elf32_trad_le_vec mips_elf32_trad_be_vec mips_elf64_trad_le_vec mips_elf64_trad_be_vec" ++ targ_defvec=mips_elf64_trad_le_vec ++ targ_selvecs="mips_elf32_ntrad_le_vec mips_elf32_ntrad_be_vec mips_elf32_trad_le_vec mips_elf32_trad_be_vec mips_elf64_trad_be_vec" + ;; + mips64*-*-linux*) +- targ_defvec=mips_elf32_ntrad_be_vec +- targ_selvecs="mips_elf32_ntrad_le_vec mips_elf32_trad_be_vec mips_elf32_trad_le_vec mips_elf64_trad_be_vec mips_elf64_trad_le_vec" ++ targ_defvec=mips_elf64_trad_be_vec ++ targ_selvecs="mips_elf32_ntrad_be_vec mips_elf32_ntrad_le_vec mips_elf32_trad_be_vec mips_elf32_trad_le_vec mips_elf64_trad_le_vec" + ;; + mips*el-*-linux*) + targ_defvec=mips_elf32_trad_le_vec +--- a/ld/configure.tgt ++++ b/ld/configure.tgt +@@ -476,11 +476,11 @@ mips*el-*-vxworks*) targ_emul=elf32elmip + mips*-*-vxworks*) targ_emul=elf32ebmipvxworks + targ_extra_emuls="elf32elmipvxworks" ;; + mips*-*-windiss) targ_emul=elf32mipswindiss ;; +-mips64*el-*-linux-*) targ_emul=elf32ltsmipn32 +- targ_extra_emuls="elf32btsmipn32 elf32ltsmip elf32btsmip elf64ltsmip elf64btsmip" ++mips64*el-*-linux-*) targ_emul=elf64ltsmip ++ targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32ltsmip elf32btsmip elf64btsmip" + targ_extra_libpath=$targ_extra_emuls ;; +-mips64*-*-linux-*) targ_emul=elf32btsmipn32 +- targ_extra_emuls="elf32ltsmipn32 elf32btsmip elf32ltsmip elf64btsmip elf64ltsmip" ++mips64*-*-linux-*) targ_emul=elf64btsmip ++ targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32btsmip elf32ltsmip elf64ltsmip" + targ_extra_libpath=$targ_extra_emuls ;; + mips*el-*-linux-*) targ_emul=elf32ltsmip + targ_extra_emuls="elf32btsmip elf32ltsmipn32 elf64ltsmip elf32btsmipn32 elf64btsmip" diff --git a/toolchain/binutils/patches/2.27/300-001_ld_makefile_patch.patch b/toolchain/binutils/patches/2.27/300-001_ld_makefile_patch.patch new file mode 100644 index 00000000000..e4cec7f69e3 --- /dev/null +++ b/toolchain/binutils/patches/2.27/300-001_ld_makefile_patch.patch @@ -0,0 +1,22 @@ +--- a/ld/Makefile.am ++++ b/ld/Makefile.am +@@ -57,7 +57,7 @@ endif + # We put the scripts in the directory $(scriptdir)/ldscripts. + # We can't put the scripts in $(datadir) because the SEARCH_DIR + # directives need to be different for native and cross linkers. +-scriptdir = $(tooldir)/lib ++scriptdir = $(libdir) + + EMUL = @EMUL@ + EMULATION_OFILES = @EMULATION_OFILES@ +--- a/ld/Makefile.in ++++ b/ld/Makefile.in +@@ -451,7 +451,7 @@ AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS) + # We put the scripts in the directory $(scriptdir)/ldscripts. + # We can't put the scripts in $(datadir) because the SEARCH_DIR + # directives need to be different for native and cross linkers. +-scriptdir = $(tooldir)/lib ++scriptdir = $(libdir) + BASEDIR = $(srcdir)/.. + BFDDIR = $(BASEDIR)/bfd + INCDIR = $(BASEDIR)/include diff --git a/toolchain/binutils/patches/2.27/300-012_check_ldrunpath_length.patch b/toolchain/binutils/patches/2.27/300-012_check_ldrunpath_length.patch new file mode 100644 index 00000000000..95d3f75b85b --- /dev/null +++ b/toolchain/binutils/patches/2.27/300-012_check_ldrunpath_length.patch @@ -0,0 +1,20 @@ +--- a/ld/emultempl/elf32.em ++++ b/ld/emultempl/elf32.em +@@ -1244,6 +1244,8 @@ fragment <link.next) + if (bfd_get_flavour (abfd) == bfd_target_elf_flavour) diff --git a/toolchain/binutils/patches/2.27/400-mips_no_dynamic_linking_sym.patch b/toolchain/binutils/patches/2.27/400-mips_no_dynamic_linking_sym.patch new file mode 100644 index 00000000000..b7458e58aaf --- /dev/null +++ b/toolchain/binutils/patches/2.27/400-mips_no_dynamic_linking_sym.patch @@ -0,0 +1,18 @@ +--- a/bfd/elfxx-mips.c ++++ b/bfd/elfxx-mips.c +@@ -7713,6 +7713,7 @@ _bfd_mips_elf_create_dynamic_sections (b + + name = SGI_COMPAT (abfd) ? "_DYNAMIC_LINK" : "_DYNAMIC_LINKING"; + bh = NULL; ++ if (0) { + if (!(_bfd_generic_link_add_one_symbol + (info, abfd, name, BSF_GLOBAL, bfd_abs_section_ptr, 0, + NULL, FALSE, get_elf_backend_data (abfd)->collect, &bh))) +@@ -7725,6 +7726,7 @@ _bfd_mips_elf_create_dynamic_sections (b + + if (! bfd_elf_link_record_dynamic_symbol (info, h)) + return FALSE; ++ } + + if (! mips_elf_hash_table (info)->use_rld_obj_head) + { diff --git a/toolchain/binutils/patches/2.27/500-Change-default-emulation-for-mips64-linux.patch b/toolchain/binutils/patches/2.27/500-Change-default-emulation-for-mips64-linux.patch new file mode 100644 index 00000000000..7a8f0ae13a9 --- /dev/null +++ b/toolchain/binutils/patches/2.27/500-Change-default-emulation-for-mips64-linux.patch @@ -0,0 +1,37 @@ +--- a/bfd/config.bfd ++++ b/bfd/config.bfd +@@ -1101,12 +1101,12 @@ case "${targ}" in + targ_selvecs="mips_elf32_le_vec mips_elf64_be_vec mips_elf64_le_vec mips_ecoff_be_vec mips_ecoff_le_vec" + ;; + mips64*el-*-linux*) +- targ_defvec=mips_elf32_ntrad_le_vec +- targ_selvecs="mips_elf32_ntrad_be_vec mips_elf32_trad_le_vec mips_elf32_trad_be_vec mips_elf64_trad_le_vec mips_elf64_trad_be_vec" ++ targ_defvec=mips_elf64_trad_le_vec ++ targ_selvecs="mips_elf32_ntrad_le_vec mips_elf32_ntrad_be_vec mips_elf32_trad_le_vec mips_elf32_trad_be_vec mips_elf64_trad_be_vec" + ;; + mips64*-*-linux*) +- targ_defvec=mips_elf32_ntrad_be_vec +- targ_selvecs="mips_elf32_ntrad_le_vec mips_elf32_trad_be_vec mips_elf32_trad_le_vec mips_elf64_trad_be_vec mips_elf64_trad_le_vec" ++ targ_defvec=mips_elf64_trad_be_vec ++ targ_selvecs="mips_elf32_ntrad_be_vec mips_elf32_ntrad_le_vec mips_elf32_trad_be_vec mips_elf32_trad_le_vec mips_elf64_trad_le_vec" + ;; + mips*el-*-linux*) + targ_defvec=mips_elf32_trad_le_vec +--- a/ld/configure.tgt ++++ b/ld/configure.tgt +@@ -513,11 +513,11 @@ mips*el-*-vxworks*) targ_emul=elf32elmip + mips*-*-vxworks*) targ_emul=elf32ebmipvxworks + targ_extra_emuls="elf32elmipvxworks" ;; + mips*-*-windiss) targ_emul=elf32mipswindiss ;; +-mips64*el-*-linux-*) targ_emul=elf32ltsmipn32 +- targ_extra_emuls="elf32btsmipn32 elf32ltsmip elf32btsmip elf64ltsmip elf64btsmip" ++mips64*el-*-linux-*) targ_emul=elf64ltsmip ++ targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32ltsmip elf32btsmip elf64btsmip" + targ_extra_libpath=$targ_extra_emuls ;; +-mips64*-*-linux-*) targ_emul=elf32btsmipn32 +- targ_extra_emuls="elf32ltsmipn32 elf32btsmip elf32ltsmip elf64btsmip elf64ltsmip" ++mips64*-*-linux-*) targ_emul=elf64btsmip ++ targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32btsmip elf32ltsmip elf64ltsmip" + targ_extra_libpath=$targ_extra_emuls ;; + mips*el-*-linux-*) targ_emul=elf32ltsmip + targ_extra_emuls="elf32btsmip elf32ltsmipn32 elf64ltsmip elf32btsmipn32 elf64btsmip" diff --git a/toolchain/binutils/patches/arc-2016.03/200-arc-fix-target-mask.patch b/toolchain/binutils/patches/arc-2016.03/200-arc-fix-target-mask.patch new file mode 100644 index 00000000000..7e51d588ae2 --- /dev/null +++ b/toolchain/binutils/patches/arc-2016.03/200-arc-fix-target-mask.patch @@ -0,0 +1,13 @@ +diff --git a/bfd/config.bfd b/bfd/config.bfd +index 5145d4a..a9c9c99 100644 +--- a/bfd/config.bfd ++++ b/bfd/config.bfd +@@ -275,7 +275,7 @@ case "${targ}" in + targ_defvec=am33_elf32_linux_vec + ;; + +- arc*-*-elf* | arc*-*-linux-uclibc*) ++ arc*-*-elf* | arc*-*-linux-*) + targ_defvec=arc_elf32_le_vec + targ_selvecs=arc_elf32_be_vec + ;; diff --git a/toolchain/binutils/patches/linaro/500-Change-default-emulation-for-mips64-linux.patch b/toolchain/binutils/patches/linaro/500-Change-default-emulation-for-mips64-linux.patch deleted file mode 100644 index cd036beca93..00000000000 --- a/toolchain/binutils/patches/linaro/500-Change-default-emulation-for-mips64-linux.patch +++ /dev/null @@ -1,37 +0,0 @@ ---- a/bfd/config.bfd -+++ b/bfd/config.bfd -@@ -1053,12 +1053,12 @@ case "${targ}" in - targ_selvecs="bfd_elf32_littlemips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec ecoff_big_vec ecoff_little_vec" - ;; - mips64*el-*-linux*) -- targ_defvec=bfd_elf32_ntradlittlemips_vec -- targ_selvecs="bfd_elf32_ntradbigmips_vec bfd_elf32_tradlittlemips_vec bfd_elf32_tradbigmips_vec bfd_elf64_tradlittlemips_vec bfd_elf64_tradbigmips_vec" -+ targ_defvec=bfd_elf64_tradlittlemips_vec -+ targ_selvecs="bfd_elf32_ntradbigmips_vec bfd_elf32_ntradlittlemips_vec bfd_elf32_tradlittlemips_vec bfd_elf32_tradbigmips_vec bfd_elf64_tradbigmips_vec" - ;; - mips64*-*-linux*) -- targ_defvec=bfd_elf32_ntradbigmips_vec -- targ_selvecs="bfd_elf32_ntradlittlemips_vec bfd_elf32_tradbigmips_vec bfd_elf32_tradlittlemips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec" -+ targ_defvec=bfd_elf64_tradbigmips_vec -+ targ_selvecs="bfd_elf32_ntradbigmips_vec bfd_elf32_ntradlittlemips_vec bfd_elf32_tradbigmips_vec bfd_elf32_tradlittlemips_vec bfd_elf64_tradlittlemips_vec" - ;; - mips*el-*-linux*) - targ_defvec=bfd_elf32_tradlittlemips_vec ---- a/ld/configure.tgt -+++ b/ld/configure.tgt -@@ -472,11 +472,11 @@ mips*el-*-vxworks*) targ_emul=elf32elmip - mips*-*-vxworks*) targ_emul=elf32ebmipvxworks - targ_extra_emuls="elf32elmipvxworks" ;; - mips*-*-windiss) targ_emul=elf32mipswindiss ;; --mips64*el-*-linux-*) targ_emul=elf32ltsmipn32 -- targ_extra_emuls="elf32btsmipn32 elf32ltsmip elf32btsmip elf64ltsmip elf64btsmip" -+mips64*el-*-linux-*) targ_emul=elf64ltsmip -+ targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32ltsmip elf32btsmip elf64btsmip" - targ_extra_libpath=$targ_extra_emuls ;; --mips64*-*-linux-*) targ_emul=elf32btsmipn32 -- targ_extra_emuls="elf32ltsmipn32 elf32btsmip elf32ltsmip elf64btsmip elf64ltsmip" -+mips64*-*-linux-*) targ_emul=elf64btsmip -+ targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32btsmip elf32ltsmip elf64ltsmip" - targ_extra_libpath=$targ_extra_emuls ;; - mips*el-*-linux-*) targ_emul=elf32ltsmip - targ_extra_emuls="elf32btsmip elf32ltsmipn32 elf64ltsmip elf32btsmipn32 elf64btsmip" diff --git a/toolchain/fortify-headers/Makefile b/toolchain/fortify-headers/Makefile new file mode 100644 index 00000000000..8caf8c84ce1 --- /dev/null +++ b/toolchain/fortify-headers/Makefile @@ -0,0 +1,28 @@ +# +# Copyright (C) 2015 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/target.mk + +PKG_NAME:=fortify-headers +PKG_VERSION:=0.8 +PKG_RELEASE=1 + +PKG_SOURCE_URL:=http://dl.2f30.org/releases +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_HASH:=afcd073d6d8d175eede2a28a7dd71b7150cb03290f99102261892c793f6b4cb1 + +include $(INCLUDE_DIR)/toolchain-build.mk + +define Host/Compile + true +endef + +define Host/Install + $(MAKE) -C $(HOST_BUILD_DIR) PREFIX="" DESTDIR="$(TOOLCHAIN_DIR)" install +endef + +$(eval $(call HostBuild)) diff --git a/toolchain/gcc/Config.in b/toolchain/gcc/Config.in index 61647d9874a..34c597c9e0f 100644 --- a/toolchain/gcc/Config.in +++ b/toolchain/gcc/Config.in @@ -2,35 +2,31 @@ choice prompt "GCC compiler Version" if TOOLCHAINOPTS - default GCC_USE_VERSION_4_6_LINARO if TARGET_octeon - default GCC_USE_VERSION_4_8_LINARO + default GCC_USE_VERSION_4_8_ARC if arc + default GCC_USE_VERSION_5 help Select the version of gcc you wish to use. - config GCC_USE_VERSION_4_6_LINARO - select GCC_VERSION_4_6_LINARO - bool "gcc 4.6.x with Linaro enhancements" - - config GCC_USE_VERSION_4_8_LINARO - select GCC_VERSION_4_8_LINARO - bool "gcc 4.8.x with Linaro enhancements" + config GCC_USE_VERSION_4_8_ARC + select GCC_VERSION_4_8_ARC + bool "gcc 4.8.x with support of ARC cores" + depends on arc config GCC_USE_VERSION_5 - select GCC_VERSION_5 bool "gcc 5.x" + depends on !arc + + config GCC_USE_VERSION_6 + bool "gcc 6.x" + depends on !arc endchoice config GCC_USE_GRAPHITE + depends on !GCC_VERSION_4_8_ARC bool prompt "Compile in support for the new Graphite framework in GCC 4.4+" if TOOLCHAINOPTS -config GCC_USE_SYSTEM_PPL_CLOOG - bool - prompt "Use the system versions of PPL and CLooG" - depends on GCC_USE_GRAPHITE - default n - config EXTRA_GCC_CONFIG_OPTIONS string prompt "Additional gcc configure options" if TOOLCHAINOPTS @@ -41,7 +37,8 @@ config EXTRA_GCC_CONFIG_OPTIONS config SSP_SUPPORT bool prompt "Enable Stack-Smashing Protection support" if TOOLCHAINOPTS - default n + depends on !USE_MUSL + default y if !USE_MUSL help Enable Stack-Smashing Protection support @@ -68,3 +65,11 @@ config INSTALL_GFORTRAN default n help Build/install GNU fortran compiler ? + +config INSTALL_GCCGO + bool + prompt "Build/install Go compiler?" if TOOLCHAINOPTS + depends on !GCC_VERSION_4_8 && (USE_GLIBC || BROKEN) + default n + help + Build/install GNU gccgo compiler ? diff --git a/toolchain/gcc/Config.version b/toolchain/gcc/Config.version index d23e092a8bd..2eefd37d5a6 100644 --- a/toolchain/gcc/Config.version +++ b/toolchain/gcc/Config.version @@ -1,26 +1,13 @@ -config GCC_VERSION_4_6_LINARO - default y if (!TOOLCHAINOPTS && TARGET_octeon) - bool - -config GCC_VERSION_4_8_LINARO - default y if (!TOOLCHAINOPTS && !TARGET_octeon) +config GCC_VERSION_4_8_ARC + default y if (!TOOLCHAINOPTS && arc) bool config GCC_VERSION string - default "4.6.3" if GCC_VERSION_4_6_3 - default "5.2.0" if GCC_VERSION_5 - default "4.6-linaro" if GCC_VERSION_4_6_LINARO - default "4.8-linaro" if GCC_VERSION_4_8_LINARO - default "4.6-linaro" - -config GCC_VERSION_4_6 - bool - default y if GCC_VERSION_4_6_LINARO + default "arc-2016.03" if GCC_VERSION_4_8_ARC + default "6.3.0" if GCC_USE_VERSION_6 + default "5.4.0" config GCC_VERSION_4_8 bool - default y if GCC_VERSION_4_8_LINARO - -config GCC_VERSION_5 - bool + default y if GCC_VERSION_4_8_ARC diff --git a/toolchain/gcc/common.mk b/toolchain/gcc/common.mk index 0a148ce97fa..c6e01b5758c 100644 --- a/toolchain/gcc/common.mk +++ b/toolchain/gcc/common.mk @@ -1,7 +1,7 @@ # # Copyright (C) 2002-2003 Erik Andersen # Copyright (C) 2004 Manuel Novoa III -# Copyright (C) 2005-2006 Felix Fietkau +# Copyright (C) 2005-2006 Felix Fietkau # Copyright (C) 2006-2014 OpenWrt.org # # This program is free software; you can redistribute it and/or modify @@ -25,54 +25,32 @@ GCC_VERSION:=$(call qstrip,$(CONFIG_GCC_VERSION)) PKG_VERSION:=$(firstword $(subst +, ,$(GCC_VERSION))) GCC_DIR:=$(PKG_NAME)-$(PKG_VERSION) -ifeq ($(findstring linaro, $(CONFIG_GCC_VERSION)),linaro) - LINARO_RELEASE:= - ifeq ($(CONFIG_GCC_VERSION),"4.6-linaro") - PKG_REV:=4.6-2013.05 - PKG_VERSION:=4.6.4 - PKG_VERSION_MAJOR:=4.6 - PKG_MD5SUM:=26b48802ae1203cd99415026fbf56ed7 - PKG_COMP:=bz2 - endif - ifeq ($(CONFIG_GCC_VERSION),"4.8-linaro") - PKG_REV:=4.8-2014.04 - PKG_VERSION:=4.8.3 - PKG_VERSION_MAJOR:=4.8 - PKG_MD5SUM:=5ba2f3a449b1658ccc09d27cc7ab3c03 - PKG_COMP:=xz - endif - ifneq ($(LINARO_RELEASE),) - PKG_SOURCE_URL:=http://releases.linaro.org/$(LINARO_RELEASE)/components/toolchain/gcc-linaro/$(PKG_VERSION_MAJOR) - else - PKG_SOURCE_URL:=http://launchpad.net/gcc-linaro/$(PKG_VERSION_MAJOR)/$(PKG_REV)/+download/ - endif - PKG_SOURCE:=$(PKG_NAME)-linaro-$(PKG_REV).tar.$(PKG_COMP) - GCC_DIR:=gcc-linaro-$(PKG_REV) - HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(GCC_DIR) -else - PKG_SOURCE_URL:=@GNU/gcc/gcc-$(PKG_VERSION) - PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:=@GNU/gcc/gcc-$(PKG_VERSION) +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 - ifeq ($(PKG_VERSION),4.6.3) - PKG_MD5SUM:=773092fe5194353b02bb0110052a972e - endif - ifeq ($(PKG_VERSION),4.8.0) - PKG_MD5SUM:=e6040024eb9e761c3bea348d1fa5abb0 - endif - ifeq ($(PKG_VERSION),5.2.0) - PKG_MD5SUM:=a51bcfeb3da7dd4c623e27207ed43467 - endif +ifeq ($(PKG_VERSION),5.4.0) + PKG_HASH:=608df76dec2d34de6558249d8af4cbee21eceddbcb580d666f7a5a583ca3303a endif -PATCH_DIR=../patches/$(GCC_VERSION) +ifeq ($(PKG_VERSION),6.3.0) + PKG_HASH:=f06ae7f3f790fbf0f018f6d40e844451e6bc3b7bc96e128e63b09825c1f8b29f +endif -BUGURL=https://dev.openwrt.org/ -ifeq ($(findstring linaro, $(CONFIG_GCC_VERSION)),linaro) - PKGVERSION=OpenWrt/Linaro GCC $(PKG_REV) $(REVISION) -else - PKGVERSION=OpenWrt GCC $(PKG_VERSION) $(REVISION) +ifneq ($(CONFIG_GCC_VERSION_4_8_ARC),) + PKG_VERSION:=4.8.5 + PKG_SOURCE_URL:=https://github.com/foss-for-synopsys-dwc-arc-processors/gcc/archive/arc-2016.03 + PKG_SOURCE:=$(PKG_NAME)-$(GCC_VERSION).tar.gz + PKG_HASH:=6a5eb0c83dca16f228ac836677a1fbb42a53c30334487ac37c2c18db80a38f35 + PKG_REV:=2016.03 + GCC_DIR:=gcc-arc-$(PKG_REV) + HOST_BUILD_DIR = $(BUILD_DIR_HOST)/$(PKG_NAME)-$(GCC_VERSION) endif +PATCH_DIR=../patches/$(GCC_VERSION) + +BUGURL=http://www.lede-project.org/bugs/ +PKGVERSION=LEDE GCC $(PKG_VERSION) $(REVISION) + HOST_BUILD_PARALLEL:=1 include $(INCLUDE_DIR)/toolchain-build.mk @@ -91,12 +69,27 @@ HOST_STAMP_CONFIGURED:=$(GCC_BUILD_DIR)/.configured HOST_STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.gcc_$(GCC_VARIANT)_installed SEP:=, -TARGET_LANGUAGES:="c,c++$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)$(if $(CONFIG_INSTALL_GFORTRAN),$(SEP)fortran)" +TARGET_LANGUAGES:="c,c++$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)$(if $(CONFIG_INSTALL_GFORTRAN),$(SEP)fortran)$(if $(CONFIG_INSTALL_GCCGO),$(SEP)go)" + +TAR_OPTIONS += --exclude='gcc/testsuite/*' --exclude=gcc/ada/*.ad* + +ifndef CONFIG_INSTALL_LIBGCJ + TAR_OPTIONS += --exclude=libjava +endif export libgcc_cv_fixed_point=no ifdef CONFIG_USE_UCLIBC export glibcxx_cv_c99_math_tr1=no endif +ifdef CONFIG_INSTALL_GCCGO + export libgo_cv_c_split_stack_supported=no +endif + +ifdef CONFIG_GCC_USE_GRAPHITE + GRAPHITE_CONFIGURE=--with-isl=$(REAL_STAGING_DIR_HOST) +else + GRAPHITE_CONFIGURE=--without-isl --without-cloog +endif GCC_CONFIGURE:= \ SHELL="$(BASH)" \ @@ -116,13 +109,15 @@ GCC_CONFIGURE:= \ --disable-libgomp \ --disable-libmudflap \ --disable-multilib \ + --disable-libmpx \ --disable-nls \ $(GRAPHITE_CONFIGURE) \ --with-host-libstdcxx=-lstdc++ \ $(SOFT_FLOAT_CONFIG_OPTION) \ $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \ $(if $(CONFIG_mips64)$(CONFIG_mips64el),--with-arch=mips64 \ - --with-abi=$(subst ",,$(CONFIG_MIPS64_ABI))) \ + --with-abi=$(call qstrip,$(CONFIG_MIPS64_ABI))) \ + $(if $(CONFIG_arc),--with-cpu=$(CONFIG_CPU_TYPE)) \ --with-gmp=$(TOPDIR)/staging_dir/host \ --with-mpfr=$(TOPDIR)/staging_dir/host \ --with-mpc=$(TOPDIR)/staging_dir/host \ @@ -131,6 +126,10 @@ ifneq ($(CONFIG_mips)$(CONFIG_mipsel),) GCC_CONFIGURE += --with-mips-plt endif +ifndef GCC_VERSION_4_8 + GCC_CONFIGURE += --with-diagnostics-color=auto-if-env +endif + ifneq ($(CONFIG_SSP_SUPPORT),) GCC_CONFIGURE+= \ --enable-libssp @@ -170,17 +169,42 @@ ifneq ($(CONFIG_SOFT_FLOAT),y) endif endif +ifeq ($(CONFIG_TARGET_x86)$(CONFIG_USE_GLIBC)$(CONFIG_INSTALL_GCCGO),yyy) + TARGET_CFLAGS+=-fno-split-stack +endif + GCC_MAKE:= \ export SHELL="$(BASH)"; \ $(MAKE) \ CFLAGS="$(HOST_CFLAGS)" \ CFLAGS_FOR_TARGET="$(TARGET_CFLAGS)" \ - CXXFLAGS_FOR_TARGET="$(TARGET_CFLAGS)" + CXXFLAGS_FOR_TARGET="$(TARGET_CFLAGS)" \ + GOCFLAGS_FOR_TARGET="$(TARGET_CFLAGS)" -define Host/Prepare - mkdir -p $(GCC_BUILD_DIR) +define Host/SetToolchainInfo + $(SED) 's,TARGET_CROSS=.*,TARGET_CROSS=$(REAL_GNU_TARGET_NAME)-,' $(TOOLCHAIN_DIR)/info.mk + $(SED) 's,GCC_VERSION=.*,GCC_VERSION=$(GCC_VERSION),' $(TOOLCHAIN_DIR)/info.mk endef +ifneq ($(GCC_PREPARE),) + define Host/Prepare + $(call Host/SetToolchainInfo) + $(call Host/Prepare/Default) + ln -snf $(GCC_DIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) + $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_SOURCE_DIR)/ + $(SED) 's,^MULTILIB_OSDIRNAMES,# MULTILIB_OSDIRNAMES,' $(HOST_SOURCE_DIR)/gcc/config/*/t-* + $(SED) 'd' $(HOST_SOURCE_DIR)/gcc/DEV-PHASE + $(SED) 's, DATESTAMP,,' $(HOST_SOURCE_DIR)/gcc/version.c + #(cd $(HOST_SOURCE_DIR)/libstdc++-v3; autoconf;); + $(SED) 's,gcc_no_link=yes,gcc_no_link=no,' $(HOST_SOURCE_DIR)/libstdc++-v3/configure + mkdir -p $(GCC_BUILD_DIR) + endef +else + define Host/Prepare + mkdir -p $(GCC_BUILD_DIR) + endef +endif + define Host/Configure (cd $(GCC_BUILD_DIR) && rm -f config.cache; \ $(GCC_CONFIGURE) \ @@ -188,7 +212,7 @@ define Host/Configure endef define Host/Clean - rm -rf \ + rm -rf $(if $(GCC_PREPARE),$(HOST_SOURCE_DIR)) \ $(STAGING_DIR_HOST)/stamp/.gcc_* \ $(STAGING_DIR_HOST)/stamp/.binutils_* \ $(GCC_BUILD_DIR) \ diff --git a/toolchain/gcc/final/Makefile b/toolchain/gcc/final/Makefile index 1212d145abd..b815f677d66 100644 --- a/toolchain/gcc/final/Makefile +++ b/toolchain/gcc/final/Makefile @@ -8,13 +8,9 @@ GCC_CONFIGURE += \ --enable-languages=$(TARGET_LANGUAGES) \ --enable-shared \ --enable-threads \ - --with-slibdir=$(TOOLCHAIN_DIR)/lib - -ifneq ($(CONFIG_GCC_VERSION_4_5)$(CONFIG_GCC_VERSION_4_6),) - GCC_CONFIGURE += \ + --with-slibdir=$(TOOLCHAIN_DIR)/lib \ --enable-lto \ --with-libelf=$(TOPDIR)/staging_dir/host -endif ifdef CONFIG_USE_MUSL GCC_MAKE += gcc_cv_libc_provides_ssp=yes @@ -43,7 +39,16 @@ define Host/Configure ); endef +ifeq ($(CONFIG_USE_GLIBC)$(CONFIG_INSTALL_GCCGO),yy) +define FixGogccCrt + # link crtX.o for gotools + mkdir -p $(GCC_BUILD_DIR)/gotools + $(foreach crt, i 1 n, ln -sf ../../glibc-dev/lib/crt$(crt).o $(GCC_BUILD_DIR)/gotools/ ; ) +endef +endif + define Host/Compile + $(FixGogccCrt) +$(GCC_MAKE) $(HOST_JOBS) -C $(GCC_BUILD_DIR) all endef @@ -62,7 +67,7 @@ endef define Host/Install $(CleanupToolchain) - $(_SINGLE)$(GCC_MAKE) -C $(GCC_BUILD_DIR) install + +$(GCC_MAKE) $(HOST_JOBS) -C $(GCC_BUILD_DIR) install # Set up the symlinks to enable lying about target name. set -e; \ (cd $(TOOLCHAIN_DIR); \ diff --git a/toolchain/gcc/initial/Makefile b/toolchain/gcc/initial/Makefile index f0c65b528c8..c71b17dd87b 100644 --- a/toolchain/gcc/initial/Makefile +++ b/toolchain/gcc/initial/Makefile @@ -1,4 +1,5 @@ GCC_VARIANT:=initial +GCC_PREPARE=$(CONFIG_USE_MUSL) include ../common.mk @@ -10,7 +11,6 @@ GCC_CONFIGURE += \ --disable-threads \ define Host/Compile - $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/ +$(GCC_MAKE) $(HOST_JOBS) -C $(GCC_BUILD_DIR) \ all-build-libiberty \ all-gcc \ @@ -18,7 +18,7 @@ define Host/Compile endef define Host/Install - $(GCC_MAKE) -C $(GCC_BUILD_DIR) \ + +$(GCC_MAKE) $(HOST_JOBS) -C $(GCC_BUILD_DIR) \ prefix="$(TOOLCHAIN_DIR)/initial" \ install-gcc \ install-target-libgcc diff --git a/toolchain/gcc/minimal/Makefile b/toolchain/gcc/minimal/Makefile index 0344e1a7eca..31d6f675abe 100644 --- a/toolchain/gcc/minimal/Makefile +++ b/toolchain/gcc/minimal/Makefile @@ -1,4 +1,5 @@ GCC_VARIANT:=minimal +GCC_PREPARE=$(if $(CONFIG_USE_MUSL),,1) include ../common.mk @@ -11,24 +12,6 @@ GCC_CONFIGURE += \ --disable-shared \ --disable-threads -define Host/SetToolchainInfo - $(SED) 's,TARGET_CROSS=.*,TARGET_CROSS=$(REAL_GNU_TARGET_NAME)-,' $(TOOLCHAIN_DIR)/info.mk - $(SED) 's,GCC_VERSION=.*,GCC_VERSION=$(GCC_VERSION),' $(TOOLCHAIN_DIR)/info.mk -endef - -define Host/Prepare - $(call Host/SetToolchainInfo) - $(call Host/Prepare/Default) - ln -snf $(GCC_DIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) - $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/ - $(SED) 's,^MULTILIB_OSDIRNAMES,# MULTILIB_OSDIRNAMES,' $(HOST_BUILD_DIR)/gcc/config/*/t-* - $(SED) 'd' $(HOST_BUILD_DIR)/gcc/DEV-PHASE - $(SED) 's, DATESTAMP,,' $(HOST_BUILD_DIR)/gcc/version.c - #(cd $(HOST_BUILD_DIR)/libstdc++-v3; autoconf;); - $(SED) 's,gcc_no_link=yes,gcc_no_link=no,' $(HOST_BUILD_DIR)/libstdc++-v3/configure - mkdir -p $(GCC_BUILD_DIR) -endef - define Host/Compile +$(GCC_MAKE) $(HOST_JOBS) -C $(GCC_BUILD_DIR) all-gcc all-target-libgcc endef diff --git a/toolchain/gcc/patches/4.6-linaro/020-gcc_bug_54295.patch b/toolchain/gcc/patches/4.6-linaro/020-gcc_bug_54295.patch deleted file mode 100644 index 5bef9eab048..00000000000 --- a/toolchain/gcc/patches/4.6-linaro/020-gcc_bug_54295.patch +++ /dev/null @@ -1,70 +0,0 @@ -diff -urN a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c ---- a/gcc/tree-ssa-math-opts.c 2012-12-12 18:05:23.000000000 +0100 -+++ b/gcc/tree-ssa-math-opts.c 2013-04-29 15:54:00.051998936 +0200 -@@ -1280,6 +1280,47 @@ - return result; - } - -+/* Return true if stmt is a type conversion operation that can be stripped -+ when used in a widening multiply operation. */ -+static bool -+widening_mult_conversion_strippable_p (tree result_type, gimple stmt) -+{ -+ enum tree_code rhs_code = gimple_assign_rhs_code (stmt); -+ -+ if (TREE_CODE (result_type) == INTEGER_TYPE) -+ { -+ tree op_type; -+ tree inner_op_type; -+ -+ if (!CONVERT_EXPR_CODE_P (rhs_code)) -+ return false; -+ -+ op_type = TREE_TYPE (gimple_assign_lhs (stmt)); -+ -+ /* If the type of OP has the same precision as the result, then -+ we can strip this conversion. The multiply operation will be -+ selected to create the correct extension as a by-product. */ -+ if (TYPE_PRECISION (result_type) == TYPE_PRECISION (op_type)) -+ return true; -+ -+ /* We can also strip a conversion if it preserves the signed-ness of -+ the operation and doesn't narrow the range. */ -+ inner_op_type = TREE_TYPE (gimple_assign_rhs1 (stmt)); -+ -+ /* If the inner-most type is unsigned, then we can strip any -+ intermediate widening operation. If it's signed, then the -+ intermediate widening operation must also be signed. */ -+ if ((TYPE_UNSIGNED (inner_op_type) -+ || TYPE_UNSIGNED (op_type) == TYPE_UNSIGNED (inner_op_type)) -+ && TYPE_PRECISION (op_type) > TYPE_PRECISION (inner_op_type)) -+ return true; -+ -+ return false; -+ } -+ -+ return rhs_code == FIXED_CONVERT_EXPR; -+} -+ - /* Return true if RHS is a suitable operand for a widening multiplication, - assuming a target type of TYPE. - There are two cases: -@@ -1296,17 +1337,13 @@ - { - gimple stmt; - tree type1, rhs1; -- enum tree_code rhs_code; - - if (TREE_CODE (rhs) == SSA_NAME) - { - stmt = SSA_NAME_DEF_STMT (rhs); - if (is_gimple_assign (stmt)) - { -- rhs_code = gimple_assign_rhs_code (stmt); -- if (TREE_CODE (type) == INTEGER_TYPE -- ? !CONVERT_EXPR_CODE_P (rhs_code) -- : rhs_code != FIXED_CONVERT_EXPR) -+ if (! widening_mult_conversion_strippable_p (type, stmt)) - rhs1 = rhs; - else - { diff --git a/toolchain/gcc/patches/4.6-linaro/030-gcc_bug_48403.patch b/toolchain/gcc/patches/4.6-linaro/030-gcc_bug_48403.patch deleted file mode 100644 index 69569de7637..00000000000 --- a/toolchain/gcc/patches/4.6-linaro/030-gcc_bug_48403.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/gcc/haifa-sched.c -+++ b/gcc/haifa-sched.c -@@ -4654,10 +4654,12 @@ schedule_block (basic_block *target_bb) - - if (recog_memoized (insn) >= 0) - { -+ memcpy (temp_state, curr_state, dfa_state_size); - cost = state_transition (curr_state, insn); - if (sched_pressure != SCHED_PRESSURE_WEIGHTED) - gcc_assert (cost < 0); -- cycle_issued_insns++; -+ if (memcmp (temp_state, curr_state, dfa_state_size) != 0) -+ cycle_issued_insns++; - asm_p = false; - } - else diff --git a/toolchain/gcc/patches/4.6-linaro/040-gcc_bug_49696.patch b/toolchain/gcc/patches/4.6-linaro/040-gcc_bug_49696.patch deleted file mode 100644 index 74b9a86a8eb..00000000000 --- a/toolchain/gcc/patches/4.6-linaro/040-gcc_bug_49696.patch +++ /dev/null @@ -1,65 +0,0 @@ ---- a/gcc/config/mips/sync.md -+++ b/gcc/config/mips/sync.md -@@ -136,7 +136,7 @@ - [(match_operand:SI 1 "register_operand" "d") - (match_operand:SI 2 "register_operand" "d") - (atomic_hiqi_op:SI (match_dup 0) -- (match_operand:SI 3 "register_operand" "dJ"))] -+ (match_operand:SI 3 "reg_or_0_operand" "dJ"))] - UNSPEC_SYNC_OLD_OP_12)) - (clobber (match_scratch:SI 4 "=&d"))] - "GENERATE_LL_SC" -@@ -177,7 +177,7 @@ - [(match_operand:SI 2 "register_operand" "d") - (match_operand:SI 3 "register_operand" "d") - (atomic_hiqi_op:SI (match_dup 0) -- (match_operand:SI 4 "register_operand" "dJ"))] -+ (match_operand:SI 4 "reg_or_0_operand" "dJ"))] - UNSPEC_SYNC_OLD_OP_12)) - (clobber (match_scratch:SI 5 "=&d"))] - "GENERATE_LL_SC" -@@ -218,7 +218,7 @@ - (match_operand:SI 2 "register_operand" "d") - (match_operand:SI 3 "register_operand" "d") - (atomic_hiqi_op:SI (match_dup 0) -- (match_operand:SI 4 "register_operand" "dJ"))] -+ (match_operand:SI 4 "reg_or_0_operand" "dJ"))] - UNSPEC_SYNC_NEW_OP_12)) - (set (match_dup 1) - (unspec_volatile:SI -@@ -259,7 +259,7 @@ - [(match_operand:SI 1 "register_operand" "d") - (match_operand:SI 2 "register_operand" "d") - (match_dup 0) -- (match_operand:SI 3 "register_operand" "dJ")] -+ (match_operand:SI 3 "reg_or_0_operand" "dJ")] - UNSPEC_SYNC_OLD_OP_12)) - (clobber (match_scratch:SI 4 "=&d"))] - "GENERATE_LL_SC" -@@ -298,7 +298,7 @@ - (unspec_volatile:SI - [(match_operand:SI 2 "register_operand" "d") - (match_operand:SI 3 "register_operand" "d") -- (match_operand:SI 4 "register_operand" "dJ")] -+ (match_operand:SI 4 "reg_or_0_operand" "dJ")] - UNSPEC_SYNC_OLD_OP_12)) - (clobber (match_scratch:SI 5 "=&d"))] - "GENERATE_LL_SC" -@@ -337,7 +337,7 @@ - [(match_operand:SI 1 "memory_operand" "+R") - (match_operand:SI 2 "register_operand" "d") - (match_operand:SI 3 "register_operand" "d") -- (match_operand:SI 4 "register_operand" "dJ")] -+ (match_operand:SI 4 "reg_or_0_operand" "dJ")] - UNSPEC_SYNC_NEW_OP_12)) - (set (match_dup 1) - (unspec_volatile:SI -@@ -546,7 +546,7 @@ - (set (match_dup 1) - (unspec_volatile:SI [(match_operand:SI 2 "register_operand" "d") - (match_operand:SI 3 "register_operand" "d") -- (match_operand:SI 4 "arith_operand" "dJ")] -+ (match_operand:SI 4 "reg_or_0_operand" "dJ")] - UNSPEC_SYNC_EXCHANGE_12))] - "GENERATE_LL_SC" - { return mips_output_sync_loop (insn, operands); } diff --git a/toolchain/gcc/patches/4.6-linaro/100-uclibc-conf.patch b/toolchain/gcc/patches/4.6-linaro/100-uclibc-conf.patch deleted file mode 100644 index ff9ad94f62a..00000000000 --- a/toolchain/gcc/patches/4.6-linaro/100-uclibc-conf.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/contrib/regression/objs-gcc.sh -+++ b/contrib/regression/objs-gcc.sh -@@ -106,6 +106,10 @@ if [ $H_REAL_TARGET = $H_REAL_HOST -a $H - then - make all-gdb all-dejagnu all-ld || exit 1 - make install-gdb install-dejagnu install-ld || exit 1 -+elif [ $H_REAL_TARGET = $H_REAL_HOST -a $H_REAL_TARGET = i686-pc-linux-uclibc ] -+ then -+ make all-gdb all-dejagnu all-ld || exit 1 -+ make install-gdb install-dejagnu install-ld || exit 1 - elif [ $H_REAL_TARGET = $H_REAL_HOST ] ; then - make bootstrap || exit 1 - make install || exit 1 ---- a/libjava/classpath/ltconfig -+++ b/libjava/classpath/ltconfig -@@ -603,7 +603,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)- - - # Transform linux* to *-*-linux-gnu*, to support old configure scripts. - case $host_os in --linux-gnu*) ;; -+linux-gnu*|linux-uclibc*) ;; - linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` - esac - -@@ -1247,7 +1247,7 @@ linux-gnuoldld* | linux-gnuaout* | linux - ;; - - # This must be Linux ELF. --linux-gnu*) -+linux*) - version_type=linux - need_lib_prefix=no - need_version=no diff --git a/toolchain/gcc/patches/4.6-linaro/200-musl.patch b/toolchain/gcc/patches/4.6-linaro/200-musl.patch deleted file mode 100644 index 1cc5756dfb7..00000000000 --- a/toolchain/gcc/patches/4.6-linaro/200-musl.patch +++ /dev/null @@ -1,240 +0,0 @@ ---- a/config.sub -+++ b/config.sub -@@ -125,6 +125,7 @@ esac - maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` - case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ -+ linux-musl* | \ - linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | \ - kopensolaris*-gnu* | \ ---- a/gcc/config.gcc -+++ b/gcc/config.gcc -@@ -485,7 +485,7 @@ case ${target} in - esac - - # Common C libraries. --tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3" -+tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4" - - # Common parts for widely ported systems. - case ${target} in -@@ -598,6 +598,9 @@ case ${target} in - *-*-*uclibc*) - tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC" - ;; -+ *-*-*musl*) -+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL" -+ ;; - *) - tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC" - ;; ---- a/gcc/config/arm/linux-eabi.h -+++ b/gcc/config/arm/linux-eabi.h -@@ -78,6 +78,10 @@ - %{mfloat-abi=soft*:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "} \ - %{!mfloat-abi=*:" GLIBC_DYNAMIC_LINKER_DEFAULT "}" - -+/* musl has no "classic" (i.e. broken) mode */ -+#undef MUSL_DYNAMIC_LINKER -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-arm.so.1" -+ - /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to - use the GNU/Linux version, not the generic BPABI version. */ - #undef LINK_SPEC ---- a/gcc/config/i386/linux.h -+++ b/gcc/config/i386/linux.h -@@ -93,6 +93,7 @@ along with GCC; see the file COPYING3. - /* These macros may be overridden in k*bsd-gnu.h and i386/k*bsd-gnu.h. */ - #define LINK_EMULATION "elf_i386" - #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1" - - #undef ASM_SPEC - #define ASM_SPEC \ ---- a/gcc/config/i386/linux64.h -+++ b/gcc/config/i386/linux64.h -@@ -65,6 +65,9 @@ see the files COPYING3 and COPYING.RUNTI - #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2" - #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2" - -+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1" -+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1" -+ - #if TARGET_64BIT_DEFAULT - #define SPEC_32 "m32" - #define SPEC_64 "!m32" ---- a/gcc/config/linux.h -+++ b/gcc/config/linux.h -@@ -33,10 +33,12 @@ see the files COPYING3 and COPYING.RUNTI - #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC) - #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC) - #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC) -+#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL) - #else - #define OPTION_GLIBC (linux_libc == LIBC_GLIBC) - #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC) - #define OPTION_BIONIC (linux_libc == LIBC_BIONIC) -+#define OPTION_MUSL (linux_libc == LIBC_MUSL) - #endif - - #define LINUX_TARGET_OS_CPP_BUILTINS() \ -@@ -54,18 +56,21 @@ see the files COPYING3 and COPYING.RUNTI - uClibc or Bionic is the default C library and whether - -muclibc or -mglibc or -mbionic has been passed to change the default. */ - --#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \ -- "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}" -+#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \ -+ "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}" - - #if DEFAULT_LIBC == LIBC_GLIBC --#define CHOOSE_DYNAMIC_LINKER(G, U, B) \ -- CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B) -+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ -+ CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M) - #elif DEFAULT_LIBC == LIBC_UCLIBC --#define CHOOSE_DYNAMIC_LINKER(G, U, B) \ -- CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B) -+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ -+ CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M) - #elif DEFAULT_LIBC == LIBC_BIONIC --#define CHOOSE_DYNAMIC_LINKER(G, U, B) \ -- CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U) -+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ -+ CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M) -+#elif DEFAULT_LIBC == LIBC_MUSL -+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ -+ CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B) - #else - #error "Unsupported DEFAULT_LIBC" - #endif /* DEFAULT_LIBC */ -@@ -83,13 +88,13 @@ see the files COPYING3 and COPYING.RUNTI - - #define LINUX_DYNAMIC_LINKER \ - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \ -- BIONIC_DYNAMIC_LINKER) -+ BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER) - #define LINUX_DYNAMIC_LINKER32 \ - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \ -- BIONIC_DYNAMIC_LINKER32) -+ BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32) - #define LINUX_DYNAMIC_LINKER64 \ - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \ -- BIONIC_DYNAMIC_LINKER64) -+ BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64) - - /* Determine whether the entire c99 runtime - is present in the runtime library. */ ---- a/gcc/config/linux.opt -+++ b/gcc/config/linux.opt -@@ -30,3 +30,7 @@ Use GNU C library - muclibc - Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic) - Use uClibc C library -+ -+mmusl -+Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc) -+Use musl C library ---- a/gcc/config/mips/linux.h -+++ b/gcc/config/mips/linux.h -@@ -63,6 +63,8 @@ along with GCC; see the file COPYING3. - - #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1" - -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips.so.1" -+ - /* Borrowed from sparc/linux.h */ - #undef LINK_SPEC - #define LINK_SPEC \ ---- a/gcc/ginclude/stddef.h -+++ b/gcc/ginclude/stddef.h -@@ -184,6 +184,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; - #ifndef _GCC_SIZE_T - #ifndef _SIZET_ - #ifndef __size_t -+#ifndef __DEFINED_size_t /* musl */ - #define __size_t__ /* BeOS */ - #define __SIZE_T__ /* Cray Unicos/Mk */ - #define _SIZE_T -@@ -200,6 +201,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; - #define ___int_size_t_h - #define _GCC_SIZE_T - #define _SIZET_ -+#define __DEFINED_size_t /* musl */ - #if defined (__FreeBSD__) && (__FreeBSD__ >= 5) - /* __size_t is a typedef on FreeBSD 5!, must not trash it. */ - #else -@@ -214,6 +216,7 @@ typedef __SIZE_TYPE__ size_t; - typedef long ssize_t; - #endif /* __BEOS__ */ - #endif /* !(defined (__GNUG__) && defined (size_t)) */ -+#endif /* __DEFINED_size_t */ - #endif /* __size_t */ - #endif /* _SIZET_ */ - #endif /* _GCC_SIZE_T */ ---- a/libgomp/config/posix/time.c -+++ b/libgomp/config/posix/time.c -@@ -28,6 +28,8 @@ - The following implementation uses the most simple POSIX routines. - If present, POSIX 4 clocks should be used instead. */ - -+#define _POSIX_C_SOURCE 199309L /* for clocks */ -+ - #include "libgomp.h" - #include - #if TIME_WITH_SYS_TIME ---- a/libstdc++-v3/configure.host -+++ b/libstdc++-v3/configure.host -@@ -237,6 +237,13 @@ case "${host_os}" in - os_include_dir="os/bsd/freebsd" - ;; - gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu) -+ # check for musl by target -+ case "${host_os}" in -+ *-musl*) -+ os_include_dir="os/generic" -+ ;; -+ *) -+ - if [ "$uclibc" = "yes" ]; then - os_include_dir="os/uclibc" - elif [ "$bionic" = "yes" ]; then -@@ -245,6 +252,9 @@ case "${host_os}" in - os_include_dir="os/gnu-linux" - fi - ;; -+ -+ esac -+ ;; - hpux*) - os_include_dir="os/hpux" - ;; ---- a/gcc/config/mips/linux64.h -+++ b/gcc/config/mips/linux64.h -@@ -40,9 +40,12 @@ along with GCC; see the file COPYING3. - #define GLIBC_DYNAMIC_LINKERN32 "/lib32/ld.so.1" - #define UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0" - #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32" -+#define MUSL_DYNAMIC_LINKERN32 "/lib/ld-musl-mips.so.1" -+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-mips.so.1" -+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-mips.so.1" - #define LINUX_DYNAMIC_LINKERN32 \ - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \ -- BIONIC_DYNAMIC_LINKERN32) -+ BIONIC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32) - - #undef LINK_SPEC - #define LINK_SPEC "\ ---- a/gcc/config/sparc/linux64.h 2013-09-10 10:02:45.663973856 +0100 -+++ b/gcc/config/sparc/linux64.h 2013-09-10 10:03:17.871972435 +0100 -@@ -104,6 +104,9 @@ - #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2" - #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux.so.2" - -+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-sparc.so.1" -+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-sparc.so.1" -+ - #ifdef SPARC_BI_ARCH - - #undef SUBTARGET_EXTRA_SPECS diff --git a/toolchain/gcc/patches/4.6-linaro/301-missing-execinfo_h.patch b/toolchain/gcc/patches/4.6-linaro/301-missing-execinfo_h.patch deleted file mode 100644 index b3f1e68d3be..00000000000 --- a/toolchain/gcc/patches/4.6-linaro/301-missing-execinfo_h.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/boehm-gc/include/gc.h -+++ b/boehm-gc/include/gc.h -@@ -503,7 +503,7 @@ GC_API GC_PTR GC_malloc_atomic_ignore_of - #if defined(__linux__) || defined(__GLIBC__) - # include - # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2) \ -- && !defined(__ia64__) -+ && !defined(__ia64__) && !defined(__UCLIBC__) - # ifndef GC_HAVE_BUILTIN_BACKTRACE - # define GC_HAVE_BUILTIN_BACKTRACE - # endif diff --git a/toolchain/gcc/patches/4.6-linaro/302-c99-snprintf.patch b/toolchain/gcc/patches/4.6-linaro/302-c99-snprintf.patch deleted file mode 100644 index eda1854df15..00000000000 --- a/toolchain/gcc/patches/4.6-linaro/302-c99-snprintf.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/libstdc++-v3/include/c_global/cstdio -+++ b/libstdc++-v3/include/c_global/cstdio -@@ -137,7 +137,7 @@ namespace std - using ::vsprintf; - } // namespace - --#if _GLIBCXX_USE_C99 -+#if _GLIBCXX_USE_C99 || defined __UCLIBC__ - - #undef snprintf - #undef vfscanf diff --git a/toolchain/gcc/patches/4.6-linaro/305-libmudflap-susv3-legacy.patch b/toolchain/gcc/patches/4.6-linaro/305-libmudflap-susv3-legacy.patch deleted file mode 100644 index 8e2d15f81ae..00000000000 --- a/toolchain/gcc/patches/4.6-linaro/305-libmudflap-susv3-legacy.patch +++ /dev/null @@ -1,47 +0,0 @@ ---- a/libmudflap/mf-hooks2.c -+++ b/libmudflap/mf-hooks2.c -@@ -421,7 +421,7 @@ WRAPPER2(void, bzero, void *s, size_t n) - { - TRACE ("%s\n", __PRETTY_FUNCTION__); - MF_VALIDATE_EXTENT(s, n, __MF_CHECK_WRITE, "bzero region"); -- bzero (s, n); -+ memset (s, 0, n); - } - - -@@ -431,7 +431,7 @@ WRAPPER2(void, bcopy, const void *src, v - TRACE ("%s\n", __PRETTY_FUNCTION__); - MF_VALIDATE_EXTENT(src, n, __MF_CHECK_READ, "bcopy src"); - MF_VALIDATE_EXTENT(dest, n, __MF_CHECK_WRITE, "bcopy dest"); -- bcopy (src, dest, n); -+ memmove (dest, src, n); - } - - -@@ -441,7 +441,7 @@ WRAPPER2(int, bcmp, const void *s1, cons - TRACE ("%s\n", __PRETTY_FUNCTION__); - MF_VALIDATE_EXTENT(s1, n, __MF_CHECK_READ, "bcmp 1st arg"); - MF_VALIDATE_EXTENT(s2, n, __MF_CHECK_READ, "bcmp 2nd arg"); -- return bcmp (s1, s2, n); -+ return n == 0 ? 0 : memcmp (s1, s2, n); - } - - -@@ -450,7 +450,7 @@ WRAPPER2(char *, index, const char *s, i - size_t n = strlen (s); - TRACE ("%s\n", __PRETTY_FUNCTION__); - MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "index region"); -- return index (s, c); -+ return strchr (s, c); - } - - -@@ -459,7 +459,7 @@ WRAPPER2(char *, rindex, const char *s, - size_t n = strlen (s); - TRACE ("%s\n", __PRETTY_FUNCTION__); - MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "rindex region"); -- return rindex (s, c); -+ return strrchr (s, c); - } - - /* XXX: stpcpy, memccpy */ diff --git a/toolchain/gcc/patches/4.6-linaro/800-arm_v5te_no_ldrd_strd.patch b/toolchain/gcc/patches/4.6-linaro/800-arm_v5te_no_ldrd_strd.patch deleted file mode 100644 index 4b7770d5d9e..00000000000 --- a/toolchain/gcc/patches/4.6-linaro/800-arm_v5te_no_ldrd_strd.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/gcc/config/arm/arm.h -+++ b/gcc/config/arm/arm.h -@@ -232,7 +232,7 @@ extern void (*arm_lang_output_object_att - #define TARGET_BACKTRACE (leaf_function_p () \ - ? TARGET_TPCS_LEAF_FRAME \ - : TARGET_TPCS_FRAME) --#define TARGET_LDRD (arm_arch5e && ARM_DOUBLEWORD_ALIGN) -+#define TARGET_LDRD (arm_arch6 && ARM_DOUBLEWORD_ALIGN) - #define TARGET_AAPCS_BASED \ - (arm_abi != ARM_ABI_APCS && arm_abi != ARM_ABI_ATPCS) - diff --git a/toolchain/gcc/patches/4.6-linaro/810-arm-softfloat-libgcc.patch b/toolchain/gcc/patches/4.6-linaro/810-arm-softfloat-libgcc.patch deleted file mode 100644 index 60cfde4078d..00000000000 --- a/toolchain/gcc/patches/4.6-linaro/810-arm-softfloat-libgcc.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/gcc/config/arm/linux-elf.h -+++ b/gcc/config/arm/linux-elf.h -@@ -60,7 +60,7 @@ - %{shared:-lc} \ - %{!shared:%{profile:-lc_p}%{!profile:-lc}}" - --#define LIBGCC_SPEC "%{msoft-float:-lfloat} %{mfloat-abi=soft*:-lfloat} -lgcc" -+#define LIBGCC_SPEC "-lgcc" - - #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" - ---- a/gcc/config/arm/t-linux -+++ b/gcc/config/arm/t-linux -@@ -23,7 +23,11 @@ TARGET_LIBGCC2_CFLAGS = -fomit-frame-poi - - LIB1ASMSRC = arm/lib1funcs.asm - LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx _clzsi2 _clzdi2 \ -- _arm_addsubdf3 _arm_addsubsf3 -+ _arm_addsubdf3 _arm_addsubsf3 \ -+ _arm_negdf2 _arm_muldivdf3 _arm_cmpdf2 _arm_unorddf2 \ -+ _arm_fixdfsi _arm_fixunsdfsi _arm_truncdfsf2 \ -+ _arm_negsf2 _arm_muldivsf3 _arm_cmpsf2 _arm_unordsf2 \ -+ _arm_fixsfsi _arm_fixunssfsi - - # MULTILIB_OPTIONS = mhard-float/msoft-float - # MULTILIB_DIRNAMES = hard-float soft-float diff --git a/toolchain/gcc/patches/4.6-linaro/830-arm_unbreak_armv4t.patch b/toolchain/gcc/patches/4.6-linaro/830-arm_unbreak_armv4t.patch deleted file mode 100644 index 7e2ed6987bb..00000000000 --- a/toolchain/gcc/patches/4.6-linaro/830-arm_unbreak_armv4t.patch +++ /dev/null @@ -1,13 +0,0 @@ -http://sourceware.org/ml/crossgcc/2008-05/msg00009.html - ---- a/gcc/config/arm/linux-eabi.h -+++ b/gcc/config/arm/linux-eabi.h -@@ -46,7 +46,7 @@ - The ARM10TDMI core is the default for armv5t, so set - SUBTARGET_CPU_DEFAULT to achieve this. */ - #undef SUBTARGET_CPU_DEFAULT --#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm10tdmi -+#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm9tdmi - - /* TARGET_BIG_ENDIAN_DEFAULT is set in - config.gcc for big endian configurations. */ diff --git a/toolchain/gcc/patches/4.6-linaro/840-armv4_pass_fix-v4bx_to_ld.patch b/toolchain/gcc/patches/4.6-linaro/840-armv4_pass_fix-v4bx_to_ld.patch deleted file mode 100644 index 3be371be63d..00000000000 --- a/toolchain/gcc/patches/4.6-linaro/840-armv4_pass_fix-v4bx_to_ld.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/gcc/config/arm/linux-eabi.h -+++ b/gcc/config/arm/linux-eabi.h -@@ -82,10 +82,15 @@ - #undef MUSL_DYNAMIC_LINKER - #define MUSL_DYNAMIC_LINKER "/lib/ld-musl-arm.so.1" - -+/* For armv4 we pass --fix-v4bx to linker to support EABI */ -+#undef TARGET_FIX_V4BX_SPEC -+#define TARGET_FIX_V4BX_SPEC " %{mcpu=arm8|mcpu=arm810|mcpu=strongarm*"\ -+ "|march=armv4|mcpu=fa526|mcpu=fa626:--fix-v4bx}" -+ - /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to - use the GNU/Linux version, not the generic BPABI version. */ - #undef LINK_SPEC --#define LINK_SPEC BE8_LINK_SPEC \ -+#define LINK_SPEC BE8_LINK_SPEC TARGET_FIX_V4BX_SPEC \ - LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC, \ - LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC) - diff --git a/toolchain/gcc/patches/4.6-linaro/850-use_shared_libgcc.patch b/toolchain/gcc/patches/4.6-linaro/850-use_shared_libgcc.patch deleted file mode 100644 index 61e1035d350..00000000000 --- a/toolchain/gcc/patches/4.6-linaro/850-use_shared_libgcc.patch +++ /dev/null @@ -1,86 +0,0 @@ ---- a/gcc/config/arm/linux-eabi.h -+++ b/gcc/config/arm/linux-eabi.h -@@ -115,10 +115,6 @@ - #define ENDFILE_SPEC \ - LINUX_OR_ANDROID_LD (GNU_USER_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC) - --/* Use the default LIBGCC_SPEC, not the version in linux-elf.h, as we -- do not use -lfloat. */ --#undef LIBGCC_SPEC -- - /* Clear the instruction cache from `beg' to `end'. This is - implemented in lib1funcs.asm, so ensure an error if this definition - is used. */ ---- a/gcc/config/arm/linux-elf.h -+++ b/gcc/config/arm/linux-elf.h -@@ -60,8 +60,6 @@ - %{shared:-lc} \ - %{!shared:%{profile:-lc_p}%{!profile:-lc}}" - --#define LIBGCC_SPEC "-lgcc" -- - #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" - - #define LINUX_TARGET_LINK_SPEC "%{h*} \ ---- a/gcc/config/linux.h -+++ b/gcc/config/linux.h -@@ -52,6 +52,10 @@ see the files COPYING3 and COPYING.RUNTI - builtin_assert ("system=posix"); \ - } while (0) - -+#ifndef LIBGCC_SPEC -+#define LIBGCC_SPEC "%{static|static-libgcc:-lgcc}%{!static:%{!static-libgcc:-lgcc_s}}" -+#endif -+ - /* Determine which dynamic linker to use depending on whether GLIBC or - uClibc or Bionic is the default C library and whether - -muclibc or -mglibc or -mbionic has been passed to change the default. */ ---- a/gcc/config/rs6000/linux.h -+++ b/gcc/config/rs6000/linux.h -@@ -88,6 +88,8 @@ - #define USE_LD_AS_NEEDED 1 - #endif - -+#define LIBGCC_SPEC "%{!static:%{!static-libgcc:-lgcc_s}} -lgcc" -+ - #undef TARGET_VERSION - #define TARGET_VERSION fprintf (stderr, " (PowerPC GNU/Linux)"); - ---- a/gcc/mkmap-symver.awk -+++ b/gcc/mkmap-symver.awk -@@ -132,5 +132,5 @@ function output(lib) { - else if (inherit[lib]) - printf("} %s;\n", inherit[lib]); - else -- printf ("\n local:\n\t*;\n};\n"); -+ printf ("\n\t*;\n};\n"); - } ---- a/libgcc/Makefile.in -+++ b/libgcc/Makefile.in -@@ -269,6 +269,12 @@ ifeq ($(enable_shared),yes) - install-libunwind = install-libunwind - endif - -+else -+# Not enable_shared. -+iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/static-object.mk,$(iter-items)) -+endif -+ -+ - # For -fvisibility=hidden. We need both a -fvisibility=hidden on - # the command line, and a #define to prevent libgcc2.h etc from - # overriding that with #pragmas. -@@ -291,13 +297,6 @@ else - gen-hide-list = echo > $@ - endif - --else --# Not enable_shared. --iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/static-object.mk,$(iter-items)) --vis_hide = --gen-hide-list = echo > \$@ --endif -- - ifneq ($(EXTRA_PARTS),) - extra-parts = libgcc-extra-parts - INSTALL_PARTS = $(EXTRA_PARTS) diff --git a/toolchain/gcc/patches/4.6-linaro/860-uclibc_use_eh_frame.patch b/toolchain/gcc/patches/4.6-linaro/860-uclibc_use_eh_frame.patch deleted file mode 100644 index 381a14bc9aa..00000000000 --- a/toolchain/gcc/patches/4.6-linaro/860-uclibc_use_eh_frame.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/gcc/crtstuff.c -+++ b/gcc/crtstuff.c -@@ -100,15 +100,20 @@ call_ ## FUNC (void) \ - #if defined(OBJECT_FORMAT_ELF) \ - && !defined(OBJECT_FORMAT_FLAT) \ - && defined(HAVE_LD_EH_FRAME_HDR) \ -- && !defined(inhibit_libc) && !defined(CRTSTUFFT_O) \ -- && defined(__GLIBC__) && __GLIBC__ >= 2 -+ && !defined(inhibit_libc) && !defined(CRTSTUFFT_O) - #include - /* uClibc pretends to be glibc 2.2 and DT_CONFIG is defined in its link.h. - But it doesn't use PT_GNU_EH_FRAME ELF segment currently. */ --# if !defined(__UCLIBC__) \ -- && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \ -- || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG))) --# define USE_PT_GNU_EH_FRAME -+# if defined(__UCLIBC__) -+# if (__UCLIBC_MAJOR__ > 0 || __UCLIBC_MINOR__ > 9 || \ -+ (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ >= 33)) -+# define USE_PT_GNU_EH_FRAME -+# endif -+# elif defined(__GLIBC__) -+# if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \ -+ || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG))) -+# define USE_PT_GNU_EH_FRAME -+# endif - # endif - #endif - #if defined(EH_FRAME_SECTION_NAME) && !defined(USE_PT_GNU_EH_FRAME) diff --git a/toolchain/gcc/patches/4.6-linaro/870-ppc_no_crtsavres.patch b/toolchain/gcc/patches/4.6-linaro/870-ppc_no_crtsavres.patch deleted file mode 100644 index 0e15ffc3918..00000000000 --- a/toolchain/gcc/patches/4.6-linaro/870-ppc_no_crtsavres.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/gcc/config/rs6000/sysv4.h -+++ b/gcc/config/rs6000/sysv4.h -@@ -248,13 +248,13 @@ do { \ - - /* Define cutoff for using external functions to save floating point. - When optimizing for size, use external functions when profitable. */ --#define FP_SAVE_INLINE(FIRST_REG) (optimize_size \ -+#define FP_SAVE_INLINE(FIRST_REG) (1 || (optimize_size \ - ? ((FIRST_REG) == 62 \ - || (FIRST_REG) == 63) \ -- : (FIRST_REG) < 64) -+ : (FIRST_REG) < 64)) - /* And similarly for general purpose registers. */ --#define GP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) < 32 \ -- && !optimize_size) -+#define GP_SAVE_INLINE(FIRST_REG) (1 || ((FIRST_REG) < 32 \ -+ && !optimize_size)) - - /* Put jump tables in read-only memory, rather than in .text. */ - #define JUMP_TABLES_IN_TEXT_SECTION 0 diff --git a/toolchain/gcc/patches/4.6-linaro/900-bad-mips16-crt b/toolchain/gcc/patches/4.6-linaro/900-bad-mips16-crt deleted file mode 100644 index 5bb2ffb4888..00000000000 --- a/toolchain/gcc/patches/4.6-linaro/900-bad-mips16-crt +++ /dev/null @@ -1,9 +0,0 @@ ---- gcc/gcc/config/mips/t-libgcc-mips16~ 2013-03-26 09:09:34.209077496 -0400 -+++ gcc/gcc/config/mips/t-libgcc-mips16 2013-03-26 18:21:01.717303669 -0400 -@@ -43,3 +43,6 @@ - - # Version these symbols if building libgcc.so. - SHLIB_MAPFILES += $(srcdir)/config/mips/libgcc-mips16.ver -+ -+CRTSTUFF_T_CFLAGS += -mno-mips16 -+CRTSTUFF_T_CFLAGS_S += -mno-mips16 diff --git a/toolchain/gcc/patches/4.6-linaro/920-specs_nonfatal_getenv.patch b/toolchain/gcc/patches/4.6-linaro/920-specs_nonfatal_getenv.patch deleted file mode 100644 index 5055ae898e6..00000000000 --- a/toolchain/gcc/patches/4.6-linaro/920-specs_nonfatal_getenv.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -7772,7 +7772,10 @@ getenv_spec_function (int argc, const ch - - value = getenv (argv[0]); - if (!value) -- fatal_error ("environment variable %qs not defined", argv[0]); -+ { -+ warning (0, "environment variable %qs not defined", argv[0]); -+ value = ""; -+ } - - /* We have to escape every character of the environment variable so - they are not interpreted as active spec characters. A diff --git a/toolchain/gcc/patches/4.6-linaro/999-coldfire.patch b/toolchain/gcc/patches/4.6-linaro/999-coldfire.patch deleted file mode 100644 index 0913f3497e8..00000000000 --- a/toolchain/gcc/patches/4.6-linaro/999-coldfire.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/gcc/config.gcc -+++ b/gcc/config.gcc -@@ -1805,7 +1805,7 @@ m68k-*-linux*) # Motorola m68k's runnin - default_m68k_cpu=68020 - default_cf_cpu=5475 - with_arch=${with_arch:-m68k} -- tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h m68k/linux.h ./sysroot-suffix.h" -+ tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h m68k/linux.h" - extra_options="${extra_options} m68k/ieee.opt" - tm_defines="${tm_defines} MOTOROLA=1" - tmake_file="${tmake_file} m68k/t-floatlib m68k/t-linux m68k/t-mlibs" diff --git a/toolchain/gcc/patches/4.8-linaro/100-uclibc-conf.patch b/toolchain/gcc/patches/4.8-linaro/100-uclibc-conf.patch deleted file mode 100644 index ff9ad94f62a..00000000000 --- a/toolchain/gcc/patches/4.8-linaro/100-uclibc-conf.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/contrib/regression/objs-gcc.sh -+++ b/contrib/regression/objs-gcc.sh -@@ -106,6 +106,10 @@ if [ $H_REAL_TARGET = $H_REAL_HOST -a $H - then - make all-gdb all-dejagnu all-ld || exit 1 - make install-gdb install-dejagnu install-ld || exit 1 -+elif [ $H_REAL_TARGET = $H_REAL_HOST -a $H_REAL_TARGET = i686-pc-linux-uclibc ] -+ then -+ make all-gdb all-dejagnu all-ld || exit 1 -+ make install-gdb install-dejagnu install-ld || exit 1 - elif [ $H_REAL_TARGET = $H_REAL_HOST ] ; then - make bootstrap || exit 1 - make install || exit 1 ---- a/libjava/classpath/ltconfig -+++ b/libjava/classpath/ltconfig -@@ -603,7 +603,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)- - - # Transform linux* to *-*-linux-gnu*, to support old configure scripts. - case $host_os in --linux-gnu*) ;; -+linux-gnu*|linux-uclibc*) ;; - linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` - esac - -@@ -1247,7 +1247,7 @@ linux-gnuoldld* | linux-gnuaout* | linux - ;; - - # This must be Linux ELF. --linux-gnu*) -+linux*) - version_type=linux - need_lib_prefix=no - need_version=no diff --git a/toolchain/gcc/patches/4.8-linaro/200-musl_config.patch b/toolchain/gcc/patches/4.8-linaro/200-musl_config.patch deleted file mode 100644 index 0142745c836..00000000000 --- a/toolchain/gcc/patches/4.8-linaro/200-musl_config.patch +++ /dev/null @@ -1,204 +0,0 @@ ---- a/gcc/config.gcc -+++ b/gcc/config.gcc -@@ -559,7 +559,7 @@ case ${target} in - esac - - # Common C libraries. --tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3" -+tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4" - - # Common parts for widely ported systems. - case ${target} in -@@ -662,6 +662,9 @@ case ${target} in - *-*-*uclibc*) - tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC" - ;; -+ *-*-*musl*) -+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL" -+ ;; - *) - tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC" - ;; ---- a/gcc/config/linux.h -+++ b/gcc/config/linux.h -@@ -32,10 +32,12 @@ see the files COPYING3 and COPYING.RUNTI - #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC) - #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC) - #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC) -+#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL) - #else - #define OPTION_GLIBC (linux_libc == LIBC_GLIBC) - #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC) - #define OPTION_BIONIC (linux_libc == LIBC_BIONIC) -+#define OPTION_MUSL (linux_libc == LIBC_MUSL) - #endif - - #define GNU_USER_TARGET_OS_CPP_BUILTINS() \ -@@ -53,18 +55,21 @@ see the files COPYING3 and COPYING.RUNTI - uClibc or Bionic is the default C library and whether - -muclibc or -mglibc or -mbionic has been passed to change the default. */ - --#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \ -- "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}" -+#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \ -+ "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}" - - #if DEFAULT_LIBC == LIBC_GLIBC --#define CHOOSE_DYNAMIC_LINKER(G, U, B) \ -- CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B) -+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ -+ CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M) - #elif DEFAULT_LIBC == LIBC_UCLIBC --#define CHOOSE_DYNAMIC_LINKER(G, U, B) \ -- CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B) -+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ -+ CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M) - #elif DEFAULT_LIBC == LIBC_BIONIC --#define CHOOSE_DYNAMIC_LINKER(G, U, B) \ -- CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U) -+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ -+ CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M) -+#elif DEFAULT_LIBC == LIBC_MUSL -+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ -+ CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B) - #else - #error "Unsupported DEFAULT_LIBC" - #endif /* DEFAULT_LIBC */ -@@ -84,21 +89,21 @@ see the files COPYING3 and COPYING.RUNTI - - #define GNU_USER_DYNAMIC_LINKER \ - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \ -- BIONIC_DYNAMIC_LINKER) -+ BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER) - #define GNU_USER_DYNAMIC_LINKER32 \ - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \ -- BIONIC_DYNAMIC_LINKER32) -+ BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32) - #define GNU_USER_DYNAMIC_LINKER64 \ - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \ -- BIONIC_DYNAMIC_LINKER64) -+ BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64) - #define GNU_USER_DYNAMIC_LINKERX32 \ - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \ -- BIONIC_DYNAMIC_LINKERX32) -+ BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32) - - /* Determine whether the entire c99 runtime - is present in the runtime library. */ - #undef TARGET_C99_FUNCTIONS --#define TARGET_C99_FUNCTIONS (OPTION_GLIBC) -+#define TARGET_C99_FUNCTIONS (OPTION_GLIBC || OPTION_MUSL) - - /* Whether we have sincos that follows the GNU extension. */ - #undef TARGET_HAS_SINCOS -@@ -107,3 +112,74 @@ see the files COPYING3 and COPYING.RUNTI - /* Whether we have Bionic libc runtime */ - #undef TARGET_HAS_BIONIC - #define TARGET_HAS_BIONIC (OPTION_BIONIC) -+ -+/* musl avoids problematic includes by rearranging the include directories. -+ * Unfortunately, this is mostly duplicated from cppdefault.c */ -+#if DEFAULT_LIBC == LIBC_MUSL -+#define INCLUDE_DEFAULTS_MUSL_GPP \ -+ { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \ -+ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \ -+ { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \ -+ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \ -+ { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \ -+ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, -+ -+#ifdef LOCAL_INCLUDE_DIR -+#define INCLUDE_DEFAULTS_MUSL_LOCAL \ -+ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \ -+ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 }, -+#else -+#define INCLUDE_DEFAULTS_MUSL_LOCAL -+#endif -+ -+#ifdef PREFIX_INCLUDE_DIR -+#define INCLUDE_DEFAULTS_MUSL_PREFIX \ -+ { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0}, -+#else -+#define INCLUDE_DEFAULTS_MUSL_PREFIX -+#endif -+ -+#ifdef CROSS_INCLUDE_DIR -+#define INCLUDE_DEFAULTS_MUSL_CROSS \ -+ { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0}, -+#else -+#define INCLUDE_DEFAULTS_MUSL_CROSS -+#endif -+ -+#ifdef TOOL_INCLUDE_DIR -+#define INCLUDE_DEFAULTS_MUSL_TOOL \ -+ { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0}, -+#else -+#define INCLUDE_DEFAULTS_MUSL_TOOL -+#endif -+ -+#ifdef NATIVE_SYSTEM_HEADER_DIR -+#define INCLUDE_DEFAULTS_MUSL_NATIVE \ -+ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \ -+ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 }, -+#else -+#define INCLUDE_DEFAULTS_MUSL_NATIVE -+#endif -+ -+#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT) -+# undef INCLUDE_DEFAULTS_MUSL_LOCAL -+# define INCLUDE_DEFAULTS_MUSL_LOCAL -+# undef INCLUDE_DEFAULTS_MUSL_NATIVE -+# define INCLUDE_DEFAULTS_MUSL_NATIVE -+#else -+# undef INCLUDE_DEFAULTS_MUSL_CROSS -+# define INCLUDE_DEFAULTS_MUSL_CROSS -+#endif -+ -+#undef INCLUDE_DEFAULTS -+#define INCLUDE_DEFAULTS \ -+ { \ -+ INCLUDE_DEFAULTS_MUSL_GPP \ -+ INCLUDE_DEFAULTS_MUSL_PREFIX \ -+ INCLUDE_DEFAULTS_MUSL_CROSS \ -+ INCLUDE_DEFAULTS_MUSL_TOOL \ -+ INCLUDE_DEFAULTS_MUSL_NATIVE \ -+ { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \ -+ { 0, 0, 0, 0, 0, 0 } \ -+ } -+#endif ---- a/gcc/config/linux.opt -+++ b/gcc/config/linux.opt -@@ -30,3 +30,7 @@ Use GNU C library - muclibc - Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic) - Use uClibc C library -+ -+mmusl -+Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc) -+Use musl C library ---- a/gcc/ginclude/stddef.h -+++ b/gcc/ginclude/stddef.h -@@ -181,6 +181,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; - #ifndef _GCC_SIZE_T - #ifndef _SIZET_ - #ifndef __size_t -+#ifndef __DEFINED_size_t /* musl */ - #define __size_t__ /* BeOS */ - #define __SIZE_T__ /* Cray Unicos/Mk */ - #define _SIZE_T -@@ -197,6 +198,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; - #define ___int_size_t_h - #define _GCC_SIZE_T - #define _SIZET_ -+#define __DEFINED_size_t /* musl */ - #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \ - || defined(__FreeBSD_kernel__) - /* __size_t is a typedef on FreeBSD 5, must not trash it. */ -@@ -214,6 +216,7 @@ typedef __SIZE_TYPE__ size_t; - typedef long ssize_t; - #endif /* __BEOS__ */ - #endif /* !(defined (__GNUG__) && defined (size_t)) */ -+#endif /* __DEFINED_size_t */ - #endif /* __size_t */ - #endif /* _SIZET_ */ - #endif /* _GCC_SIZE_T */ diff --git a/toolchain/gcc/patches/4.8-linaro/202-musl_mips.patch b/toolchain/gcc/patches/4.8-linaro/202-musl_mips.patch deleted file mode 100644 index 42a2648f02c..00000000000 --- a/toolchain/gcc/patches/4.8-linaro/202-musl_mips.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/gcc/config/mips/linux.h -+++ b/gcc/config/mips/linux.h -@@ -18,3 +18,10 @@ along with GCC; see the file COPYING3. - . */ - - #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1" -+ -+#if TARGET_ENDIAN_DEFAULT == 0 /* LE */ -+#define MUSL_DYNAMIC_LINKER_E "%{EB:;:el}" -+#else -+#define MUSL_DYNAMIC_LINKER_E "%{EL:el}" -+#endif -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E ".so.1" diff --git a/toolchain/gcc/patches/4.8-linaro/203-musl_powerpc.patch b/toolchain/gcc/patches/4.8-linaro/203-musl_powerpc.patch deleted file mode 100644 index 7a70148fabb..00000000000 --- a/toolchain/gcc/patches/4.8-linaro/203-musl_powerpc.patch +++ /dev/null @@ -1,100 +0,0 @@ ---- a/gcc/config.gcc -+++ b/gcc/config.gcc -@@ -2122,6 +2122,10 @@ powerpc*-*-linux*) - powerpc*-*-linux*paired*) - tm_file="${tm_file} rs6000/750cl.h" ;; - esac -+ case ${target} in -+ *-linux*-musl*) -+ enable_secureplt=yes ;; -+ esac - if test x${enable_secureplt} = xyes; then - tm_file="rs6000/secureplt.h ${tm_file}" - fi ---- a/gcc/config/rs6000/linux64.h -+++ b/gcc/config/rs6000/linux64.h -@@ -354,17 +354,21 @@ extern int dot_symbols; - #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld64.so.1" - #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0" - #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0" -+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc.so.1" -+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64.so.1" - #if DEFAULT_LIBC == LIBC_UCLIBC --#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}" -+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}" - #elif DEFAULT_LIBC == LIBC_GLIBC --#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}" -+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}" -+#elif DEFAULT_LIBC == LIBC_MUSL -+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}" - #else - #error "Unsupported DEFAULT_LIBC" - #endif - #define GNU_USER_DYNAMIC_LINKER32 \ -- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32) -+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32) - #define GNU_USER_DYNAMIC_LINKER64 \ -- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64) -+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64) - - #undef DEFAULT_ASM_ENDIAN - #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN) ---- a/gcc/config/rs6000/secureplt.h -+++ b/gcc/config/rs6000/secureplt.h -@@ -18,3 +18,4 @@ along with GCC; see the file COPYING3. - . */ - - #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt" -+#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt" ---- a/gcc/config/rs6000/sysv4.h -+++ b/gcc/config/rs6000/sysv4.h -@@ -550,6 +550,9 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF - #ifndef CC1_SECURE_PLT_DEFAULT_SPEC - #define CC1_SECURE_PLT_DEFAULT_SPEC "" - #endif -+#ifndef LINK_SECURE_PLT_DEFAULT_SPEC -+#define LINK_SECURE_PLT_DEFAULT_SPEC "" -+#endif - - /* Pass -G xxx to the compiler and set correct endian mode. */ - #define CC1_SPEC "%{G*} %(cc1_cpu)" \ -@@ -600,7 +603,8 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF - - /* Override the default target of the linker. */ - #define LINK_TARGET_SPEC \ -- ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") -+ ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") \ -+ "%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}" - - /* Any specific OS flags. */ - #define LINK_OS_SPEC "\ -@@ -778,15 +782,18 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF - - #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1" - #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0" -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc.so.1" - #if DEFAULT_LIBC == LIBC_UCLIBC --#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}" -+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}" -+#elif DEFAULT_LIBC == LIBC_MUSL -+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}" - #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC --#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}" -+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}" - #else - #error "Unsupported DEFAULT_LIBC" - #endif - #define GNU_USER_DYNAMIC_LINKER \ -- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER) -+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER) - - #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \ - %{rdynamic:-export-dynamic} \ -@@ -912,6 +919,7 @@ ncrtn.o%s" - { "cc1_endian_little", CC1_ENDIAN_LITTLE_SPEC }, \ - { "cc1_endian_default", CC1_ENDIAN_DEFAULT_SPEC }, \ - { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \ -+ { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \ - { "cpp_os_ads", CPP_OS_ADS_SPEC }, \ - { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \ - { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \ diff --git a/toolchain/gcc/patches/4.8-linaro/204-musl_sh.patch b/toolchain/gcc/patches/4.8-linaro/204-musl_sh.patch deleted file mode 100644 index 9a50c227e82..00000000000 --- a/toolchain/gcc/patches/4.8-linaro/204-musl_sh.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- a/gcc/config/sh/linux.h -+++ b/gcc/config/sh/linux.h -@@ -43,7 +43,14 @@ along with GCC; see the file COPYING3. - - #define TARGET_ASM_FILE_END file_end_indicate_exec_stack - -+#if TARGET_BIG_ENDIAN_DEFAULT /* BE */ -+#define MUSL_DYNAMIC_LINKER_E "eb" -+#else -+#define MUSL_DYNAMIC_LINKER_E -+#endif -+ - #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E ".so.1" - - #undef SUBTARGET_LINK_EMUL_SUFFIX - #define SUBTARGET_LINK_EMUL_SUFFIX "_linux" diff --git a/toolchain/gcc/patches/4.8-linaro/205-musl_x86.patch b/toolchain/gcc/patches/4.8-linaro/205-musl_x86.patch deleted file mode 100644 index 9a251133190..00000000000 --- a/toolchain/gcc/patches/4.8-linaro/205-musl_x86.patch +++ /dev/null @@ -1,48 +0,0 @@ ---- a/gcc/config/i386/linux.h -+++ b/gcc/config/i386/linux.h -@@ -21,3 +21,4 @@ along with GCC; see the file COPYING3. - - #define GNU_USER_LINK_EMULATION "elf_i386" - #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1" ---- a/gcc/config/i386/linux64.h -+++ b/gcc/config/i386/linux64.h -@@ -30,3 +30,7 @@ see the files COPYING3 and COPYING.RUNTI - #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2" - #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2" - #define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2" -+ -+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1" -+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1" -+#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1" ---- a/libitm/config/linux/x86/tls.h -+++ b/libitm/config/linux/x86/tls.h -@@ -25,16 +25,19 @@ - #ifndef LIBITM_X86_TLS_H - #define LIBITM_X86_TLS_H 1 - --#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10) -+#if defined(__GLIBC_PREREQ) -+#if __GLIBC_PREREQ(2, 10) - /* Use slots in the TCB head rather than __thread lookups. - GLIBC has reserved words 10 through 13 for TM. */ - #define HAVE_ARCH_GTM_THREAD 1 - #define HAVE_ARCH_GTM_THREAD_DISP 1 - #endif -+#endif - - #include "config/generic/tls.h" - --#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10) -+#if defined(__GLIBC_PREREQ) -+#if __GLIBC_PREREQ(2, 10) - namespace GTM HIDDEN { - - #ifdef __x86_64__ -@@ -101,5 +104,6 @@ static inline void set_abi_disp(struct a - - } // namespace GTM - #endif /* >= GLIBC 2.10 */ -+#endif - - #endif // LIBITM_X86_TLS_H diff --git a/toolchain/gcc/patches/4.8-linaro/206-musl_aarch64.patch b/toolchain/gcc/patches/4.8-linaro/206-musl_aarch64.patch deleted file mode 100644 index 9d75dc94935..00000000000 --- a/toolchain/gcc/patches/4.8-linaro/206-musl_aarch64.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/gcc/config/aarch64/aarch64-linux.h -+++ b/gcc/config/aarch64/aarch64-linux.h -@@ -21,7 +21,11 @@ - #ifndef GCC_AARCH64_LINUX_H - #define GCC_AARCH64_LINUX_H - -+/* The AArch64 port currently supports two dynamic linkers: -+ - ld-linux-aarch64.so.1 - GLIBC dynamic linker -+ - ld-musl-aarch64.so.1 - musl libc dynamic linker */ - #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64.so.1" -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64.so.1" - - #define CPP_SPEC "%{pthread:-D_REENTRANT}" - diff --git a/toolchain/gcc/patches/4.8-linaro/207-musl_fixincludes.patch b/toolchain/gcc/patches/4.8-linaro/207-musl_fixincludes.patch deleted file mode 100644 index e6fa47f7e60..00000000000 --- a/toolchain/gcc/patches/4.8-linaro/207-musl_fixincludes.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/fixincludes/mkfixinc.sh -+++ b/fixincludes/mkfixinc.sh -@@ -19,7 +19,8 @@ case $machine in - powerpc-*-eabi* | \ - powerpc-*-rtems* | \ - powerpcle-*-eabisim* | \ -- powerpcle-*-eabi* ) -+ powerpcle-*-eabi* | \ -+ *-musl* ) - # IF there is no include fixing, - # THEN create a no-op fixer and exit - (echo "#! /bin/sh" ; echo "exit 0" ) > ${target} diff --git a/toolchain/gcc/patches/4.8-linaro/208-musl_gomp.patch b/toolchain/gcc/patches/4.8-linaro/208-musl_gomp.patch deleted file mode 100644 index 84c781ee7d4..00000000000 --- a/toolchain/gcc/patches/4.8-linaro/208-musl_gomp.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/libgomp/config/posix/time.c -+++ b/libgomp/config/posix/time.c -@@ -28,6 +28,8 @@ - The following implementation uses the most simple POSIX routines. - If present, POSIX 4 clocks should be used instead. */ - -+#define _POSIX_C_SOURCE 199309L /* for clocks */ -+ - #include "libgomp.h" - #include - #if TIME_WITH_SYS_TIME diff --git a/toolchain/gcc/patches/4.8-linaro/209-musl_libstdc++.patch b/toolchain/gcc/patches/4.8-linaro/209-musl_libstdc++.patch deleted file mode 100644 index 6643935b180..00000000000 --- a/toolchain/gcc/patches/4.8-linaro/209-musl_libstdc++.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/libstdc++-v3/configure.host -+++ b/libstdc++-v3/configure.host -@@ -264,6 +264,13 @@ case "${host_os}" in - os_include_dir="os/bsd/freebsd" - ;; - gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu) -+ # check for musl by target -+ case "${host_os}" in -+ *-musl*) -+ os_include_dir="os/generic" -+ ;; -+ *) -+ - if [ "$uclibc" = "yes" ]; then - os_include_dir="os/uclibc" - elif [ "$bionic" = "yes" ]; then -@@ -272,6 +279,9 @@ case "${host_os}" in - os_include_dir="os/gnu-linux" - fi - ;; -+ -+ esac -+ ;; - hpux*) - os_include_dir="os/hpux" - ;; diff --git a/toolchain/gcc/patches/4.8-linaro/220-musl_mips_softfloat.patch b/toolchain/gcc/patches/4.8-linaro/220-musl_mips_softfloat.patch deleted file mode 100644 index b86adf59b9c..00000000000 --- a/toolchain/gcc/patches/4.8-linaro/220-musl_mips_softfloat.patch +++ /dev/null @@ -1,8 +0,0 @@ ---- a/gcc/config/mips/linux.h -+++ b/gcc/config/mips/linux.h -@@ -24,4 +24,4 @@ along with GCC; see the file COPYING3. - #else - #define MUSL_DYNAMIC_LINKER_E "%{EL:el}" - #endif --#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E ".so.1" -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" diff --git a/toolchain/gcc/patches/4.8-linaro/221-musl_mips64.patch b/toolchain/gcc/patches/4.8-linaro/221-musl_mips64.patch deleted file mode 100644 index 7447dbd307d..00000000000 --- a/toolchain/gcc/patches/4.8-linaro/221-musl_mips64.patch +++ /dev/null @@ -1,22 +0,0 @@ -Index: gcc-linaro-4.8-2014.04/gcc/config/mips/linux64.h -=================================================================== ---- gcc-linaro-4.8-2014.04.orig/gcc/config/mips/linux64.h 2014-10-23 15:52:48.999134219 -0700 -+++ gcc-linaro-4.8-2014.04/gcc/config/mips/linux64.h 2014-10-23 15:59:19.815116979 -0700 -@@ -27,6 +27,16 @@ - #define GLIBC_DYNAMIC_LINKERN32 "/lib32/ld.so.1" - #define UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0" - #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32" -+ -+#if TARGET_ENDIAN_DEFAULT == 0 /* LE */ -+#define MUSL_DYNAMIC_LINKER_E "%{EB:;:el}" -+#else -+#define MUSL_DYNAMIC_LINKER_E "%{EL:el}" -+#endif -+ -+#define MUSL_DYNAMIC_LINKERN32 "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" -+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" -+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" - #define GNU_USER_DYNAMIC_LINKERN32 \ - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \ -- BIONIC_DYNAMIC_LINKERN32) -+ BIONIC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32) diff --git a/toolchain/gcc/patches/4.8-linaro/230-musl_libssp.patch b/toolchain/gcc/patches/4.8-linaro/230-musl_libssp.patch deleted file mode 100644 index 682a5a4df10..00000000000 --- a/toolchain/gcc/patches/4.8-linaro/230-musl_libssp.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- gcc-4.8.1/gcc/gcc.c.orig 2013-09-24 06:27:32.133894539 +0000 -+++ gcc-4.8.1/gcc/gcc.c 2013-09-24 06:29:35.790562854 +0000 -@@ -656,7 +656,9 @@ - #endif - - #ifndef LINK_SSP_SPEC --#ifdef TARGET_LIBC_PROVIDES_SSP -+#if DEFAULT_LIBC == LIBC_MUSL -+#define LINK_SSP_SPEC "-lssp_nonshared" -+#elif defined(TARGET_LIBC_PROVIDES_SSP) - #define LINK_SSP_SPEC "%{fstack-protector:}" - #else - #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all:-lssp_nonshared -lssp}" -Index: gcc-linaro-4.8-2014.04/libssp/Makefile.in -=================================================================== ---- gcc-linaro-4.8-2014.04.org/libssp/Makefile.in 2011-02-13 17:15:53.000000000 +0530 -+++ gcc-linaro-4.8-2014.04/libssp/Makefile.in 2018-07-31 15:20:43.475456077 +0530 -@@ -257,7 +257,7 @@ - @LIBSSP_USE_SYMVER_FALSE@version_dep = - @LIBSSP_USE_SYMVER_GNU_TRUE@@LIBSSP_USE_SYMVER_TRUE@version_dep = $(srcdir)/ssp.map - @LIBSSP_USE_SYMVER_SUN_TRUE@@LIBSSP_USE_SYMVER_TRUE@version_dep = ssp.map-sun --AM_CFLAGS = -Wall -+AM_CFLAGS = -Wall -Wl,-z,now -Wl,-z,relro - toolexeclib_LTLIBRARIES = libssp.la libssp_nonshared.la - libsubincludedir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/include - nobase_libsubinclude_HEADERS = ssp/ssp.h ssp/string.h ssp/stdio.h ssp/unistd.h diff --git a/toolchain/gcc/patches/4.8-linaro/951-arm_bug_58595.patch b/toolchain/gcc/patches/4.8-linaro/951-arm_bug_58595.patch deleted file mode 100644 index f487dbc8ffa..00000000000 --- a/toolchain/gcc/patches/4.8-linaro/951-arm_bug_58595.patch +++ /dev/null @@ -1,117 +0,0 @@ -https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58595 - ---- /dev/null -+++ b/gcc/testsuite/gcc.dg/tls/pr58595.c -@@ -0,0 +1,28 @@ -+/* PR target/58595 */ -+/* { dg-do run } */ -+/* { dg-options "-O2" } */ -+/* { dg-additional-options "-fpic" { target fpic } } */ -+/* { dg-require-effective-target tls } */ -+/* { dg-require-effective-target sync_int_long } */ -+ -+struct S { unsigned long a, b; }; -+__thread struct S s; -+void bar (unsigned long *); -+ -+__attribute__((noinline)) void -+foo (void) -+{ -+ int i; -+ for (i = 0; i < 10; i++) -+ __sync_fetch_and_add (&s.b, 1L); -+} -+ -+int -+main () -+{ -+ s.b = 12; -+ foo (); -+ if (s.b != 22) -+ __builtin_abort (); -+ return 0; -+} ---- a/gcc/config/arm/arm.c -+++ b/gcc/config/arm/arm.c -@@ -231,7 +231,6 @@ static tree arm_gimplify_va_arg_expr (tr - static void arm_option_override (void); - static unsigned HOST_WIDE_INT arm_shift_truncation_mask (enum machine_mode); - static bool arm_cannot_copy_insn_p (rtx); --static bool arm_tls_symbol_p (rtx x); - static int arm_issue_rate (void); - static void arm_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED; - static bool arm_output_addr_const_extra (FILE *, rtx); -@@ -6665,6 +6664,32 @@ legitimize_tls_address (rtx x, rtx reg) - rtx - arm_legitimize_address (rtx x, rtx orig_x, enum machine_mode mode) - { -+ if (arm_tls_referenced_p (x)) -+ { -+ rtx addend = NULL; -+ -+ if (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == PLUS) -+ { -+ addend = XEXP (XEXP (x, 0), 1); -+ x = XEXP (XEXP (x, 0), 0); -+ } -+ -+ if (GET_CODE (x) != SYMBOL_REF) -+ return x; -+ -+ gcc_assert (SYMBOL_REF_TLS_MODEL (x) != 0); -+ -+ x = legitimize_tls_address (x, NULL_RTX); -+ -+ if (addend) -+ { -+ x = gen_rtx_PLUS (SImode, x, addend); -+ orig_x = x; -+ } -+ else -+ return x; -+ } -+ - if (!TARGET_ARM) - { - /* TODO: legitimize_address for Thumb2. */ -@@ -6673,9 +6698,6 @@ arm_legitimize_address (rtx x, rtx orig_ - return thumb_legitimize_address (x, orig_x, mode); - } - -- if (arm_tls_symbol_p (x)) -- return legitimize_tls_address (x, NULL_RTX); -- - if (GET_CODE (x) == PLUS) - { - rtx xop0 = XEXP (x, 0); -@@ -6787,9 +6809,6 @@ arm_legitimize_address (rtx x, rtx orig_ - rtx - thumb_legitimize_address (rtx x, rtx orig_x, enum machine_mode mode) - { -- if (arm_tls_symbol_p (x)) -- return legitimize_tls_address (x, NULL_RTX); -- - if (GET_CODE (x) == PLUS - && CONST_INT_P (XEXP (x, 1)) - && (INTVAL (XEXP (x, 1)) >= 32 * GET_MODE_SIZE (mode) -@@ -7080,20 +7099,6 @@ thumb_legitimize_reload_address (rtx *x_ - - /* Test for various thread-local symbols. */ - --/* Return TRUE if X is a thread-local symbol. */ -- --static bool --arm_tls_symbol_p (rtx x) --{ -- if (! TARGET_HAVE_TLS) -- return false; -- -- if (GET_CODE (x) != SYMBOL_REF) -- return false; -- -- return SYMBOL_REF_TLS_MODEL (x) != 0; --} -- - /* Helper for arm_tls_referenced_p. */ - - static int diff --git a/toolchain/gcc/patches/4.9-linaro/100-uclibc-conf.patch b/toolchain/gcc/patches/4.9-linaro/100-uclibc-conf.patch deleted file mode 100644 index ff9ad94f62a..00000000000 --- a/toolchain/gcc/patches/4.9-linaro/100-uclibc-conf.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/contrib/regression/objs-gcc.sh -+++ b/contrib/regression/objs-gcc.sh -@@ -106,6 +106,10 @@ if [ $H_REAL_TARGET = $H_REAL_HOST -a $H - then - make all-gdb all-dejagnu all-ld || exit 1 - make install-gdb install-dejagnu install-ld || exit 1 -+elif [ $H_REAL_TARGET = $H_REAL_HOST -a $H_REAL_TARGET = i686-pc-linux-uclibc ] -+ then -+ make all-gdb all-dejagnu all-ld || exit 1 -+ make install-gdb install-dejagnu install-ld || exit 1 - elif [ $H_REAL_TARGET = $H_REAL_HOST ] ; then - make bootstrap || exit 1 - make install || exit 1 ---- a/libjava/classpath/ltconfig -+++ b/libjava/classpath/ltconfig -@@ -603,7 +603,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)- - - # Transform linux* to *-*-linux-gnu*, to support old configure scripts. - case $host_os in --linux-gnu*) ;; -+linux-gnu*|linux-uclibc*) ;; - linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` - esac - -@@ -1247,7 +1247,7 @@ linux-gnuoldld* | linux-gnuaout* | linux - ;; - - # This must be Linux ELF. --linux-gnu*) -+linux*) - version_type=linux - need_lib_prefix=no - need_version=no diff --git a/toolchain/gcc/patches/4.9-linaro/201-musl_arm.patch b/toolchain/gcc/patches/4.9-linaro/201-musl_arm.patch deleted file mode 100644 index f39ff524689..00000000000 --- a/toolchain/gcc/patches/4.9-linaro/201-musl_arm.patch +++ /dev/null @@ -1,40 +0,0 @@ ---- a/gcc/config/arm/linux-eabi.h -+++ b/gcc/config/arm/linux-eabi.h -@@ -77,6 +77,23 @@ - %{mfloat-abi=soft*:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "} \ - %{!mfloat-abi=*:" GLIBC_DYNAMIC_LINKER_DEFAULT "}" - -+/* For ARM musl currently supports four dynamic linkers: -+ - ld-musl-arm.so.1 - for the EABI-derived soft-float ABI -+ - ld-musl-armhf.so.1 - for the EABI-derived hard-float ABI -+ - ld-musl-armeb.so.1 - for the EABI-derived soft-float ABI, EB -+ - ld-musl-armebhf.so.1 - for the EABI-derived hard-float ABI, EB -+ musl does not support the legacy OABI mode. -+ All the dynamic linkers live in /lib. -+ We default to soft-float, EL. */ -+#undef MUSL_DYNAMIC_LINKER -+#if TARGET_BIG_ENDIAN_DEFAULT -+#define MUSL_DYNAMIC_LINKER_E "%{mlittle-endian:;:eb}" -+#else -+#define MUSL_DYNAMIC_LINKER_E "%{mbig-endian:eb}" -+#endif -+#define MUSL_DYNAMIC_LINKER \ -+ "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}.so.1" -+ - /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to - use the GNU/Linux version, not the generic BPABI version. */ - #undef LINK_SPEC ---- a/libitm/config/arm/hwcap.cc -+++ b/libitm/config/arm/hwcap.cc -@@ -40,7 +40,11 @@ int GTM_hwcap HIDDEN = 0 - - #ifdef __linux__ - #include -+#ifdef __GLIBC__ - #include -+#else -+#include -+#endif - #include - - static void __attribute__((constructor)) diff --git a/toolchain/gcc/patches/4.9-linaro/202-musl_mips.patch b/toolchain/gcc/patches/4.9-linaro/202-musl_mips.patch deleted file mode 100644 index 06d25d52e44..00000000000 --- a/toolchain/gcc/patches/4.9-linaro/202-musl_mips.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/gcc/config/mips/linux.h -+++ b/gcc/config/mips/linux.h -@@ -23,3 +23,10 @@ along with GCC; see the file COPYING3. - #undef UCLIBC_DYNAMIC_LINKER - #define UCLIBC_DYNAMIC_LINKER \ - "%{mnan=2008:/lib/ld-uClibc-mipsn8.so.0;:/lib/ld-uClibc.so.0}" -+ -+#if TARGET_ENDIAN_DEFAULT == 0 /* LE */ -+#define MUSL_DYNAMIC_LINKER_E "%{EB:;:el}" -+#else -+#define MUSL_DYNAMIC_LINKER_E "%{EL:el}" -+#endif -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E ".so.1" diff --git a/toolchain/gcc/patches/4.9-linaro/203-musl_powerpc.patch b/toolchain/gcc/patches/4.9-linaro/203-musl_powerpc.patch deleted file mode 100644 index 4340c5fd2f4..00000000000 --- a/toolchain/gcc/patches/4.9-linaro/203-musl_powerpc.patch +++ /dev/null @@ -1,100 +0,0 @@ ---- a/gcc/config.gcc -+++ b/gcc/config.gcc -@@ -2344,6 +2344,10 @@ powerpc*-*-linux*) - powerpc*-*-linux*paired*) - tm_file="${tm_file} rs6000/750cl.h" ;; - esac -+ case ${target} in -+ *-linux*-musl*) -+ enable_secureplt=yes ;; -+ esac - if test x${enable_secureplt} = xyes; then - tm_file="rs6000/secureplt.h ${tm_file}" - fi ---- a/gcc/config/rs6000/linux64.h -+++ b/gcc/config/rs6000/linux64.h -@@ -371,17 +371,21 @@ extern int dot_symbols; - #endif - #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0" - #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0" -+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc.so.1" -+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64.so.1" - #if DEFAULT_LIBC == LIBC_UCLIBC --#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}" -+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}" - #elif DEFAULT_LIBC == LIBC_GLIBC --#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}" -+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}" -+#elif DEFAULT_LIBC == LIBC_MUSL -+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}" - #else - #error "Unsupported DEFAULT_LIBC" - #endif - #define GNU_USER_DYNAMIC_LINKER32 \ -- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32) -+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32) - #define GNU_USER_DYNAMIC_LINKER64 \ -- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64) -+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64) - - #undef DEFAULT_ASM_ENDIAN - #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN) ---- a/gcc/config/rs6000/secureplt.h -+++ b/gcc/config/rs6000/secureplt.h -@@ -18,3 +18,4 @@ along with GCC; see the file COPYING3. - . */ - - #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt" -+#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt" ---- a/gcc/config/rs6000/sysv4.h -+++ b/gcc/config/rs6000/sysv4.h -@@ -537,6 +537,9 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF - #ifndef CC1_SECURE_PLT_DEFAULT_SPEC - #define CC1_SECURE_PLT_DEFAULT_SPEC "" - #endif -+#ifndef LINK_SECURE_PLT_DEFAULT_SPEC -+#define LINK_SECURE_PLT_DEFAULT_SPEC "" -+#endif - - /* Pass -G xxx to the compiler. */ - #define CC1_SPEC "%{G*} %(cc1_cpu)" \ -@@ -585,7 +588,8 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF - - /* Override the default target of the linker. */ - #define LINK_TARGET_SPEC \ -- ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") -+ ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") \ -+ "%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}" - - /* Any specific OS flags. */ - #define LINK_OS_SPEC "\ -@@ -763,15 +767,18 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF - - #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1" - #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0" -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc.so.1" - #if DEFAULT_LIBC == LIBC_UCLIBC --#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}" -+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}" -+#elif DEFAULT_LIBC == LIBC_MUSL -+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}" - #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC --#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}" -+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}" - #else - #error "Unsupported DEFAULT_LIBC" - #endif - #define GNU_USER_DYNAMIC_LINKER \ -- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER) -+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER) - - #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \ - %{rdynamic:-export-dynamic} \ -@@ -894,6 +901,7 @@ ncrtn.o%s" - { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \ - { "link_os_default", LINK_OS_DEFAULT_SPEC }, \ - { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \ -+ { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \ - { "cpp_os_ads", CPP_OS_ADS_SPEC }, \ - { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \ - { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \ diff --git a/toolchain/gcc/patches/4.9-linaro/204-musl_sh.patch b/toolchain/gcc/patches/4.9-linaro/204-musl_sh.patch deleted file mode 100644 index dfb5b517463..00000000000 --- a/toolchain/gcc/patches/4.9-linaro/204-musl_sh.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- a/gcc/config/sh/linux.h -+++ b/gcc/config/sh/linux.h -@@ -43,7 +43,14 @@ along with GCC; see the file COPYING3. - - #define TARGET_ASM_FILE_END file_end_indicate_exec_stack - -+#if TARGET_BIG_ENDIAN_DEFAULT /* BE */ -+#define MUSL_DYNAMIC_LINKER_E "eb" -+#else -+#define MUSL_DYNAMIC_LINKER_E -+#endif -+ - #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E ".so.1" - - #undef SUBTARGET_LINK_EMUL_SUFFIX - #define SUBTARGET_LINK_EMUL_SUFFIX "_linux" diff --git a/toolchain/gcc/patches/4.9-linaro/205-musl_x86.patch b/toolchain/gcc/patches/4.9-linaro/205-musl_x86.patch deleted file mode 100644 index d167105c006..00000000000 --- a/toolchain/gcc/patches/4.9-linaro/205-musl_x86.patch +++ /dev/null @@ -1,48 +0,0 @@ ---- a/gcc/config/i386/linux.h -+++ b/gcc/config/i386/linux.h -@@ -21,3 +21,4 @@ along with GCC; see the file COPYING3. - - #define GNU_USER_LINK_EMULATION "elf_i386" - #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1" ---- a/gcc/config/i386/linux64.h -+++ b/gcc/config/i386/linux64.h -@@ -30,3 +30,7 @@ see the files COPYING3 and COPYING.RUNTI - #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2" - #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2" - #define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2" -+ -+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1" -+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1" -+#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1" ---- a/libitm/config/linux/x86/tls.h -+++ b/libitm/config/linux/x86/tls.h -@@ -25,16 +25,19 @@ - #ifndef LIBITM_X86_TLS_H - #define LIBITM_X86_TLS_H 1 - --#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10) -+#if defined(__GLIBC_PREREQ) -+#if __GLIBC_PREREQ(2, 10) - /* Use slots in the TCB head rather than __thread lookups. - GLIBC has reserved words 10 through 13 for TM. */ - #define HAVE_ARCH_GTM_THREAD 1 - #define HAVE_ARCH_GTM_THREAD_DISP 1 - #endif -+#endif - - #include "config/generic/tls.h" - --#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10) -+#if defined(__GLIBC_PREREQ) -+#if __GLIBC_PREREQ(2, 10) - namespace GTM HIDDEN { - - #ifdef __x86_64__ -@@ -101,5 +104,6 @@ static inline void set_abi_disp(struct a - - } // namespace GTM - #endif /* >= GLIBC 2.10 */ -+#endif - - #endif // LIBITM_X86_TLS_H diff --git a/toolchain/gcc/patches/4.9-linaro/206-musl_aarch64.patch b/toolchain/gcc/patches/4.9-linaro/206-musl_aarch64.patch deleted file mode 100644 index caf42bf4e42..00000000000 --- a/toolchain/gcc/patches/4.9-linaro/206-musl_aarch64.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/gcc/config/aarch64/aarch64-linux.h -+++ b/gcc/config/aarch64/aarch64-linux.h -@@ -23,6 +23,8 @@ - - #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1" - -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64.so.1" -+ - #define CPP_SPEC "%{pthread:-D_REENTRANT}" - - #define LINUX_TARGET_LINK_SPEC "%{h*} \ diff --git a/toolchain/gcc/patches/4.9-linaro/207-musl_fixincludes.patch b/toolchain/gcc/patches/4.9-linaro/207-musl_fixincludes.patch deleted file mode 100644 index e6fa47f7e60..00000000000 --- a/toolchain/gcc/patches/4.9-linaro/207-musl_fixincludes.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/fixincludes/mkfixinc.sh -+++ b/fixincludes/mkfixinc.sh -@@ -19,7 +19,8 @@ case $machine in - powerpc-*-eabi* | \ - powerpc-*-rtems* | \ - powerpcle-*-eabisim* | \ -- powerpcle-*-eabi* ) -+ powerpcle-*-eabi* | \ -+ *-musl* ) - # IF there is no include fixing, - # THEN create a no-op fixer and exit - (echo "#! /bin/sh" ; echo "exit 0" ) > ${target} diff --git a/toolchain/gcc/patches/4.9-linaro/208-musl_gomp.patch b/toolchain/gcc/patches/4.9-linaro/208-musl_gomp.patch deleted file mode 100644 index 84c781ee7d4..00000000000 --- a/toolchain/gcc/patches/4.9-linaro/208-musl_gomp.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/libgomp/config/posix/time.c -+++ b/libgomp/config/posix/time.c -@@ -28,6 +28,8 @@ - The following implementation uses the most simple POSIX routines. - If present, POSIX 4 clocks should be used instead. */ - -+#define _POSIX_C_SOURCE 199309L /* for clocks */ -+ - #include "libgomp.h" - #include - #if TIME_WITH_SYS_TIME diff --git a/toolchain/gcc/patches/4.9-linaro/209-musl_libstdc++.patch b/toolchain/gcc/patches/4.9-linaro/209-musl_libstdc++.patch deleted file mode 100644 index 00d5d313db7..00000000000 --- a/toolchain/gcc/patches/4.9-linaro/209-musl_libstdc++.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/libstdc++-v3/configure.host -+++ b/libstdc++-v3/configure.host -@@ -263,6 +263,13 @@ case "${host_os}" in - os_include_dir="os/bsd/freebsd" - ;; - gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu) -+ # check for musl by target -+ case "${host_os}" in -+ *-musl*) -+ os_include_dir="os/generic" -+ ;; -+ *) -+ - if [ "$uclibc" = "yes" ]; then - os_include_dir="os/uclibc" - elif [ "$bionic" = "yes" ]; then -@@ -271,6 +278,9 @@ case "${host_os}" in - os_include_dir="os/gnu-linux" - fi - ;; -+ -+ esac -+ ;; - hpux*) - os_include_dir="os/hpux" - ;; diff --git a/toolchain/gcc/patches/4.9-linaro/210-disable_libsanitizer_off_t_check.patch b/toolchain/gcc/patches/4.9-linaro/210-disable_libsanitizer_off_t_check.patch deleted file mode 100644 index 56084692a18..00000000000 --- a/toolchain/gcc/patches/4.9-linaro/210-disable_libsanitizer_off_t_check.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/libsanitizer/interception/interception_type_test.cc -+++ b/libsanitizer/interception/interception_type_test.cc -@@ -31,7 +31,7 @@ COMPILER_CHECK(sizeof(OFF64_T) == sizeof - // rest (they depend on _FILE_OFFSET_BITS setting when building an application). - # if defined(__ANDROID__) || !defined _FILE_OFFSET_BITS || \ - _FILE_OFFSET_BITS != 64 --COMPILER_CHECK(sizeof(OFF_T) == sizeof(off_t)); -+// COMPILER_CHECK(sizeof(OFF_T) == sizeof(off_t)); - # endif - - #endif diff --git a/toolchain/gcc/patches/4.9-linaro/220-musl_mips_softfloat.patch b/toolchain/gcc/patches/4.9-linaro/220-musl_mips_softfloat.patch deleted file mode 100644 index 3b6b42a0a97..00000000000 --- a/toolchain/gcc/patches/4.9-linaro/220-musl_mips_softfloat.patch +++ /dev/null @@ -1,8 +0,0 @@ ---- a/gcc/config/mips/linux.h -+++ b/gcc/config/mips/linux.h -@@ -29,4 +29,4 @@ along with GCC; see the file COPYING3. - #else - #define MUSL_DYNAMIC_LINKER_E "%{EL:el}" - #endif --#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E ".so.1" -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" diff --git a/toolchain/gcc/patches/4.9-linaro/221-musl_mips64.patch b/toolchain/gcc/patches/4.9-linaro/221-musl_mips64.patch deleted file mode 100644 index f10fc59d062..00000000000 --- a/toolchain/gcc/patches/4.9-linaro/221-musl_mips64.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/gcc/config/mips/linux64.h -+++ b/gcc/config/mips/linux64.h -@@ -39,6 +39,16 @@ along with GCC; see the file COPYING3. - "%{mnan=2008:/lib32/ld-uClibc-mipsn8.so.0;:/lib32/ld-uClibc.so.0}" - - #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32" -+ -+#if TARGET_ENDIAN_DEFAULT == 0 /* LE */ -+#define MUSL_DYNAMIC_LINKER_E "%{EB:;:el}" -+#else -+#define MUSL_DYNAMIC_LINKER_E "%{EL:el}" -+#endif -+ -+#define MUSL_DYNAMIC_LINKERN32 "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" -+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" -+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" - #define GNU_USER_DYNAMIC_LINKERN32 \ - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \ -- BIONIC_DYNAMIC_LINKERN32) -+ BIONIC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32) diff --git a/toolchain/gcc/patches/4.9-linaro/860-use_eh_frame.patch b/toolchain/gcc/patches/4.9-linaro/860-use_eh_frame.patch deleted file mode 100644 index 1ac83fe4dc3..00000000000 --- a/toolchain/gcc/patches/4.9-linaro/860-use_eh_frame.patch +++ /dev/null @@ -1,42 +0,0 @@ ---- a/libgcc/unwind-dw2-fde-dip.c -+++ b/libgcc/unwind-dw2-fde-dip.c -@@ -46,33 +46,13 @@ - #include "unwind-compat.h" - #include "gthr.h" - --#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ -- && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \ -- || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG))) --# define USE_PT_GNU_EH_FRAME --#endif -- --#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ -- && defined(__BIONIC__) --# define USE_PT_GNU_EH_FRAME --#endif -- --#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ -- && defined(__FreeBSD__) && __FreeBSD__ >= 7 --# define ElfW __ElfN --# define USE_PT_GNU_EH_FRAME --#endif -- --#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ -- && defined(__OpenBSD__) --# define ElfW(type) Elf_##type --# define USE_PT_GNU_EH_FRAME --#endif -- --#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ -- && defined(TARGET_DL_ITERATE_PHDR) \ -- && defined(__sun__) && defined(__svr4__) -+#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) - # define USE_PT_GNU_EH_FRAME -+# ifdef __OpenBSD__ -+# define ElfW(type) Elf_##type -+# elif defined(__FreeBSD__) && __FreeBSD__ >= 7 -+# define ElfW __ElfN -+# endif - #endif - - #if defined(USE_PT_GNU_EH_FRAME) diff --git a/toolchain/gcc/patches/5.2.0/010-template.patch b/toolchain/gcc/patches/5.2.0/010-template.patch new file mode 100644 index 00000000000..0efc3d05955 --- /dev/null +++ b/toolchain/gcc/patches/5.2.0/010-template.patch @@ -0,0 +1,89 @@ +--- a/gcc/wide-int.h 2022-08-20 07:07:02.893459542 -0400 ++++ b/gcc/wide-int.h 2022-08-20 07:32:37.525321075 -0400 +@@ -365,21 +365,21 @@ + inputs. Note that CONST_PRECISION and VAR_PRECISION cannot be + mixed, in order to give stronger type checking. When both inputs + are CONST_PRECISION, they must have the same precision. */ +- template <> ++ + template + struct binary_traits + { + typedef widest_int result_type; + }; + +- template <> ++ + template + struct binary_traits + { + typedef wide_int result_type; + }; + +- template <> ++ + template + struct binary_traits + { +@@ -389,14 +389,14 @@ + ::precision> > result_type; + }; + +- template <> ++ + template + struct binary_traits + { + typedef wide_int result_type; + }; + +- template <> ++ + template + struct binary_traits + { +@@ -406,7 +406,7 @@ + ::precision> > result_type; + }; + +- template <> ++ + template + struct binary_traits + { +@@ -417,7 +417,7 @@ + ::precision> > result_type; + }; + +- template <> ++ + template + struct binary_traits + { +@@ -881,7 +881,7 @@ + + namespace wi + { +- template <> ++ + template + struct int_traits < generic_wide_int > + : public wi::int_traits +@@ -960,7 +960,7 @@ + + namespace wi + { +- template <> ++ + template + struct int_traits > + { +@@ -1147,7 +1147,7 @@ + + namespace wi + { +- template <> ++ + template + struct int_traits < fixed_wide_int_storage > + { diff --git a/toolchain/gcc/patches/5.2.0/100-uclibc-conf.patch b/toolchain/gcc/patches/5.2.0/100-uclibc-conf.patch deleted file mode 100644 index ff9ad94f62a..00000000000 --- a/toolchain/gcc/patches/5.2.0/100-uclibc-conf.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/contrib/regression/objs-gcc.sh -+++ b/contrib/regression/objs-gcc.sh -@@ -106,6 +106,10 @@ if [ $H_REAL_TARGET = $H_REAL_HOST -a $H - then - make all-gdb all-dejagnu all-ld || exit 1 - make install-gdb install-dejagnu install-ld || exit 1 -+elif [ $H_REAL_TARGET = $H_REAL_HOST -a $H_REAL_TARGET = i686-pc-linux-uclibc ] -+ then -+ make all-gdb all-dejagnu all-ld || exit 1 -+ make install-gdb install-dejagnu install-ld || exit 1 - elif [ $H_REAL_TARGET = $H_REAL_HOST ] ; then - make bootstrap || exit 1 - make install || exit 1 ---- a/libjava/classpath/ltconfig -+++ b/libjava/classpath/ltconfig -@@ -603,7 +603,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)- - - # Transform linux* to *-*-linux-gnu*, to support old configure scripts. - case $host_os in --linux-gnu*) ;; -+linux-gnu*|linux-uclibc*) ;; - linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` - esac - -@@ -1247,7 +1247,7 @@ linux-gnuoldld* | linux-gnuaout* | linux - ;; - - # This must be Linux ELF. --linux-gnu*) -+linux*) - version_type=linux - need_lib_prefix=no - need_version=no diff --git a/toolchain/gcc/patches/4.9-linaro/001-revert_register_mode_search.patch b/toolchain/gcc/patches/5.4.0/001-revert_register_mode_search.patch similarity index 97% rename from toolchain/gcc/patches/4.9-linaro/001-revert_register_mode_search.patch rename to toolchain/gcc/patches/5.4.0/001-revert_register_mode_search.patch index 5adb22ad42e..06373eb6a0d 100644 --- a/toolchain/gcc/patches/4.9-linaro/001-revert_register_mode_search.patch +++ b/toolchain/gcc/patches/5.4.0/001-revert_register_mode_search.patch @@ -14,7 +14,7 @@ Date: Thu Sep 5 14:09:07 2013 +0000 --- a/gcc/reginfo.c +++ b/gcc/reginfo.c -@@ -621,35 +621,40 @@ choose_hard_reg_mode (unsigned int regno +@@ -665,35 +665,40 @@ choose_hard_reg_mode (unsigned int regno mode = GET_MODE_WIDER_MODE (mode)) if ((unsigned) hard_regno_nregs[regno][mode] == nregs && HARD_REGNO_MODE_OK (regno, mode) diff --git a/toolchain/gcc/patches/4.9-linaro/002-case_insensitive.patch b/toolchain/gcc/patches/5.4.0/002-case_insensitive.patch similarity index 100% rename from toolchain/gcc/patches/4.9-linaro/002-case_insensitive.patch rename to toolchain/gcc/patches/5.4.0/002-case_insensitive.patch diff --git a/toolchain/gcc/patches/4.9-linaro/010-documentation.patch b/toolchain/gcc/patches/5.4.0/010-documentation.patch similarity index 91% rename from toolchain/gcc/patches/4.9-linaro/010-documentation.patch rename to toolchain/gcc/patches/5.4.0/010-documentation.patch index 9f17b64da9e..07064a97bc1 100644 --- a/toolchain/gcc/patches/4.9-linaro/010-documentation.patch +++ b/toolchain/gcc/patches/5.4.0/010-documentation.patch @@ -1,6 +1,6 @@ --- a/gcc/Makefile.in +++ b/gcc/Makefile.in -@@ -2847,18 +2847,10 @@ doc/gcc.info: $(TEXI_GCC_FILES) +@@ -2941,18 +2941,10 @@ doc/gcc.info: $(TEXI_GCC_FILES) doc/gccint.info: $(TEXI_GCCINT_FILES) doc/cppinternals.info: $(TEXI_CPPINT_FILES) diff --git a/toolchain/gcc/patches/4.9-linaro/020-no-plt-backport.patch b/toolchain/gcc/patches/5.4.0/020-no-plt-backport.patch similarity index 74% rename from toolchain/gcc/patches/4.9-linaro/020-no-plt-backport.patch rename to toolchain/gcc/patches/5.4.0/020-no-plt-backport.patch index 10cf323c080..b9702c9520a 100644 --- a/toolchain/gcc/patches/4.9-linaro/020-no-plt-backport.patch +++ b/toolchain/gcc/patches/5.4.0/020-no-plt-backport.patch @@ -1,12 +1,12 @@ --- a/gcc/calls.c +++ b/gcc/calls.c -@@ -184,6 +184,12 @@ prepare_call_address (tree fndecl, rtx f +@@ -225,6 +225,12 @@ prepare_call_address (tree fndecl_or_typ && targetm.small_register_classes_for_mode_p (FUNCTION_MODE)) ? force_not_mem (memory_address (FUNCTION_MODE, funexp)) : memory_address (FUNCTION_MODE, funexp)); -+ else if (flag_pic && !flag_plt && fndecl -+ && TREE_CODE (fndecl) == FUNCTION_DECL -+ && !targetm.binds_local_p (fndecl)) ++ else if (flag_pic && !flag_plt && fndecl_or_type ++ && TREE_CODE (fndecl_or_type) == FUNCTION_DECL ++ && !targetm.binds_local_p (fndecl_or_type)) + { + funexp = force_reg (Pmode, funexp); + } @@ -15,7 +15,7 @@ #ifndef NO_FUNCTION_CSE --- a/gcc/common.opt +++ b/gcc/common.opt -@@ -1659,6 +1659,10 @@ fpie +@@ -1779,6 +1779,10 @@ fpie Common Report Var(flag_pie,1) Negative(fPIC) Generate position-independent code for executables if possible (small mode) diff --git a/toolchain/gcc/patches/5.4.0/030-macos-header-fix-backport.patch b/toolchain/gcc/patches/5.4.0/030-macos-header-fix-backport.patch new file mode 100644 index 00000000000..37c774e0b28 --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/030-macos-header-fix-backport.patch @@ -0,0 +1,10 @@ +--- a/gcc/system.h ++++ b/gcc/system.h +@@ -216,6 +216,7 @@ extern int errno; + + #ifdef __cplusplus + # include ++# include + # include + # include + #endif diff --git a/toolchain/gcc/patches/5.4.0/040-fix-mips-ICE-PR-68400.patch b/toolchain/gcc/patches/5.4.0/040-fix-mips-ICE-PR-68400.patch new file mode 100644 index 00000000000..e88af340325 --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/040-fix-mips-ICE-PR-68400.patch @@ -0,0 +1,23 @@ +--- a/gcc/config/mips/mips.c ++++ b/gcc/config/mips/mips.c +@@ -8001,9 +8001,17 @@ mask_low_and_shift_p (machine_mode mode, + bool + and_operands_ok (machine_mode mode, rtx op1, rtx op2) + { +- return (memory_operand (op1, mode) +- ? and_load_operand (op2, mode) +- : and_reg_operand (op2, mode)); ++ if (!memory_operand (op1, mode)) ++ return and_reg_operand (op2, mode); ++ ++ if (!and_load_operand (op2, mode)) ++ return false; ++ ++ if (!TARGET_MIPS16 || si_mask_operand(op2, mode)) ++ return true; ++ ++ op1 = XEXP (op1, 0); ++ return !(REG_P (op1) && REGNO (op1) == STACK_POINTER_REGNUM); + } + + /* The canonical form of a mask-low-and-shift-left operation is diff --git a/toolchain/gcc/patches/4.9-linaro/200-musl_config.patch b/toolchain/gcc/patches/5.4.0/200-musl_config.patch similarity index 51% rename from toolchain/gcc/patches/4.9-linaro/200-musl_config.patch rename to toolchain/gcc/patches/5.4.0/200-musl_config.patch index f7c8adadc2f..b9a5b282746 100644 --- a/toolchain/gcc/patches/4.9-linaro/200-musl_config.patch +++ b/toolchain/gcc/patches/5.4.0/200-musl_config.patch @@ -1,6 +1,33 @@ +From: ktkachov +Date: Fri, 8 May 2015 08:25:47 +0000 (+0000) +Subject: [PATCH 2/13] musl libc config +X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=a9173ceabaf29c16f8ef226fbf98af373a4b2ceb + +[PATCH 2/13] musl libc config + +2015-05-08 Gregor Richards + Szabolcs Nagy + + * config.gcc (LIBC_MUSL): New tm_defines macro. + * config/linux.h (OPTION_MUSL): Define. + (MUSL_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER32,) + (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32,) + (INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,) + (INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,) + (INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define. + * config/linux.opt (mmusl): New option. + * doc/invoke.texi (GNU/Linux Options): Document -mmusl. + * configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*. + (gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*. + * configure: Regenerate. + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222904 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + --- a/gcc/config.gcc +++ b/gcc/config.gcc -@@ -595,7 +595,7 @@ case ${target} in +@@ -575,7 +575,7 @@ case ${target} in esac # Common C libraries. @@ -34,9 +61,15 @@ #endif #define GNU_USER_TARGET_OS_CPP_BUILTINS() \ -@@ -53,18 +55,21 @@ see the files COPYING3 and COPYING.RUNTI - uClibc or Bionic is the default C library and whether - -muclibc or -mglibc or -mbionic has been passed to change the default. */ +@@ -50,21 +52,25 @@ see the files COPYING3 and COPYING.RUNTI + } while (0) + + /* Determine which dynamic linker to use depending on whether GLIBC or +- uClibc or Bionic is the default C library and whether +- -muclibc or -mglibc or -mbionic has been passed to change the default. */ ++ uClibc or Bionic or musl is the default C library and whether ++ -muclibc or -mglibc or -mbionic or -mmusl has been passed to change ++ the default. */ -#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \ - "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}" @@ -64,7 +97,15 @@ #else #error "Unsupported DEFAULT_LIBC" #endif /* DEFAULT_LIBC */ -@@ -84,21 +89,92 @@ see the files COPYING3 and COPYING.RUNTI +@@ -81,24 +87,100 @@ see the files COPYING3 and COPYING.RUNTI + #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker" + #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64" + #define BIONIC_DYNAMIC_LINKERX32 "/system/bin/linkerx32" ++/* Should be redefined for each target that supports musl. */ ++#define MUSL_DYNAMIC_LINKER "/dev/null" ++#define MUSL_DYNAMIC_LINKER32 "/dev/null" ++#define MUSL_DYNAMIC_LINKER64 "/dev/null" ++#define MUSL_DYNAMIC_LINKERX32 "/dev/null" #define GNU_USER_DYNAMIC_LINKER \ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \ @@ -163,37 +204,106 @@ versions, because doing so would require *uclinux* targets to include --- a/gcc/config/linux.opt +++ b/gcc/config/linux.opt -@@ -30,3 +30,7 @@ Use GNU C library +@@ -28,5 +28,9 @@ Target Report RejectNegative Var(linux_l + Use GNU C library + muclibc - Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic) +-Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic) ++Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mmusl) Use uClibc C library + +mmusl -+Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc) ++Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mbionic) +Use musl C library ---- a/gcc/ginclude/stddef.h -+++ b/gcc/ginclude/stddef.h -@@ -181,6 +181,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; - #ifndef _GCC_SIZE_T - #ifndef _SIZET_ - #ifndef __size_t -+#ifndef __DEFINED_size_t /* musl */ - #define __size_t__ /* BeOS */ - #define __SIZE_T__ /* Cray Unicos/Mk */ - #define _SIZE_T -@@ -197,6 +198,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; - #define ___int_size_t_h - #define _GCC_SIZE_T - #define _SIZET_ -+#define __DEFINED_size_t /* musl */ - #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \ - || defined(__FreeBSD_kernel__) - /* __size_t is a typedef on FreeBSD 5, must not trash it. */ -@@ -214,6 +216,7 @@ typedef __SIZE_TYPE__ size_t; - typedef long ssize_t; - #endif /* __BEOS__ */ - #endif /* !(defined (__GNUG__) && defined (size_t)) */ -+#endif /* __DEFINED_size_t */ - #endif /* __size_t */ - #endif /* _SIZET_ */ - #endif /* _GCC_SIZE_T */ +--- a/gcc/configure ++++ b/gcc/configure +@@ -27833,6 +27833,9 @@ if test "${gcc_cv_libc_provides_ssp+set} + else + gcc_cv_libc_provides_ssp=no + case "$target" in ++ *-*-musl*) ++ # All versions of musl provide stack protector ++ gcc_cv_libc_provides_ssp=yes;; + *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu) + # glibc 2.4 and later provides __stack_chk_fail and + # either __stack_chk_guard, or TLS access to stack guard canary. +@@ -27865,6 +27868,7 @@ fi + # ) and for now + # simply assert that glibc does provide this, which is true for all + # realistically usable GNU/Hurd configurations. ++ # All supported versions of musl provide it as well + gcc_cv_libc_provides_ssp=yes;; + *-*-darwin* | *-*-freebsd*) + ac_fn_c_check_func "$LINENO" "__stack_chk_fail" "ac_cv_func___stack_chk_fail" +@@ -27961,6 +27965,9 @@ case "$target" in + gcc_cv_target_dl_iterate_phdr=no + fi + ;; ++ *-linux-musl*) ++ gcc_cv_target_dl_iterate_phdr=yes ++ ;; + esac + + if test x$gcc_cv_target_dl_iterate_phdr = xyes; then +--- a/gcc/configure.ac ++++ b/gcc/configure.ac +@@ -5287,6 +5287,9 @@ AC_CACHE_CHECK(__stack_chk_fail in targe + gcc_cv_libc_provides_ssp, + [gcc_cv_libc_provides_ssp=no + case "$target" in ++ *-*-musl*) ++ # All versions of musl provide stack protector ++ gcc_cv_libc_provides_ssp=yes;; + *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu) + # glibc 2.4 and later provides __stack_chk_fail and + # either __stack_chk_guard, or TLS access to stack guard canary. +@@ -5313,6 +5316,7 @@ AC_CACHE_CHECK(__stack_chk_fail in targe + # ) and for now + # simply assert that glibc does provide this, which is true for all + # realistically usable GNU/Hurd configurations. ++ # All supported versions of musl provide it as well + gcc_cv_libc_provides_ssp=yes;; + *-*-darwin* | *-*-freebsd*) + AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes], +@@ -5386,6 +5390,9 @@ case "$target" in + gcc_cv_target_dl_iterate_phdr=no + fi + ;; ++ *-linux-musl*) ++ gcc_cv_target_dl_iterate_phdr=yes ++ ;; + esac + GCC_TARGET_TEMPLATE([TARGET_DL_ITERATE_PHDR]) + if test x$gcc_cv_target_dl_iterate_phdr = xyes; then +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -667,7 +667,7 @@ Objective-C and Objective-C++ Dialects}. + -mcpu=@var{cpu}} + + @emph{GNU/Linux Options} +-@gccoptlist{-mglibc -muclibc -mbionic -mandroid @gol ++@gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid @gol + -tno-android-cc -tno-android-ld} + + @emph{H8/300 Options} +@@ -15340,13 +15340,19 @@ These @samp{-m} options are defined for + @item -mglibc + @opindex mglibc + Use the GNU C library. This is the default except +-on @samp{*-*-linux-*uclibc*} and @samp{*-*-linux-*android*} targets. ++on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and ++@samp{*-*-linux-*android*} targets. + + @item -muclibc + @opindex muclibc + Use uClibc C library. This is the default on + @samp{*-*-linux-*uclibc*} targets. + ++@item -mmusl ++@opindex mmusl ++Use the musl C library. This is the default on ++@samp{*-*-linux-*musl*} targets. ++ + @item -mbionic + @opindex mbionic + Use Bionic C library. This is the default on diff --git a/toolchain/gcc/patches/4.8-linaro/201-musl_arm.patch b/toolchain/gcc/patches/5.4.0/201-musl_arm.patch similarity index 66% rename from toolchain/gcc/patches/4.8-linaro/201-musl_arm.patch rename to toolchain/gcc/patches/5.4.0/201-musl_arm.patch index f39ff524689..27a26afc05c 100644 --- a/toolchain/gcc/patches/4.8-linaro/201-musl_arm.patch +++ b/toolchain/gcc/patches/5.4.0/201-musl_arm.patch @@ -1,3 +1,20 @@ +From: ktkachov +Date: Wed, 27 May 2015 13:17:11 +0000 (+0000) +Subject: [PATCH 4/13] arm musl support +X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=de799bd087ab9a179768fea75bd195a31d3432a4 + +[PATCH 4/13] arm musl support + +On behalf of szabolcs.nagy@arm.com + +2015-05-27 Gregor Richards + + * config/arm/linux-eabi.h (MUSL_DYNAMIC_LINKER): Define. + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223749 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + --- a/gcc/config/arm/linux-eabi.h +++ b/gcc/config/arm/linux-eabi.h @@ -77,6 +77,23 @@ @@ -24,17 +41,3 @@ /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to use the GNU/Linux version, not the generic BPABI version. */ #undef LINK_SPEC ---- a/libitm/config/arm/hwcap.cc -+++ b/libitm/config/arm/hwcap.cc -@@ -40,7 +40,11 @@ int GTM_hwcap HIDDEN = 0 - - #ifdef __linux__ - #include -+#ifdef __GLIBC__ - #include -+#else -+#include -+#endif - #include - - static void __attribute__((constructor)) diff --git a/toolchain/gcc/patches/5.4.0/202-musl_mips.patch b/toolchain/gcc/patches/5.4.0/202-musl_mips.patch new file mode 100644 index 00000000000..816dd8d1013 --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/202-musl_mips.patch @@ -0,0 +1,35 @@ +From: ktkachov +Date: Fri, 8 May 2015 15:16:50 +0000 (+0000) +Subject: [PATCH 6/13] mips musl support +X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=2550b6a866c887472b587bef87d433c51cf1ebc8 + +[PATCH 6/13] mips musl support + +2015-05-08 Gregor Richards + Szabolcs Nagy + + * config/mips/linux.h (MUSL_DYNAMIC_LINKER32): Define. + (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERN32): Define. + (GNU_USER_DYNAMIC_LINKERN32): Update. + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222915 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + +--- a/gcc/config/mips/linux.h ++++ b/gcc/config/mips/linux.h +@@ -37,7 +37,13 @@ along with GCC; see the file COPYING3. + #define UCLIBC_DYNAMIC_LINKERN32 \ + "%{mnan=2008:/lib32/ld-uClibc-mipsn8.so.0;:/lib32/ld-uClibc.so.0}" + ++#undef MUSL_DYNAMIC_LINKER32 ++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-mips%{EL:el}%{msoft-float:-sf}.so.1" ++#undef MUSL_DYNAMIC_LINKER64 ++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-mips64%{EL:el}%{msoft-float:-sf}.so.1" ++#define MUSL_DYNAMIC_LINKERN32 "/lib/ld-musl-mipsn32%{EL:el}%{msoft-float:-sf}.so.1" ++ + #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32" + #define GNU_USER_DYNAMIC_LINKERN32 \ + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \ +- BIONIC_DYNAMIC_LINKERN32) ++ BIONIC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32) diff --git a/toolchain/gcc/patches/5.4.0/203-musl_powerpc.patch b/toolchain/gcc/patches/5.4.0/203-musl_powerpc.patch new file mode 100644 index 00000000000..b4f34e81ca9 --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/203-musl_powerpc.patch @@ -0,0 +1,209 @@ + +gcc/Changelog: + +2015-04-24 Gregor Richards + Szabolcs Nagy + + * config.gcc (secure_plt): Add *-linux*-musl*. + * config/rs6000/linux64.h (MUSL_DYNAMIC_LINKER32): Define. + (MUSL_DYNAMIC_LINKER64): Define. + (GNU_USER_DYNAMIC_LINKER32): Update. + (GNU_USER_DYNAMIC_LINKER64): Update. + (CHOOSE_DYNAMIC_LINKER): Update. + + * config/rs6000/secureplt.h (LINK_SECURE_PLT_DEFAULT_SPEC): Define. + * config/rs6000/sysv4.h (GNU_USER_DYNAMIC_LINKER): Update. + (MUSL_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER_E,) + (INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,) + (INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,) + (INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define. + (LINK_SECURE_PLT_DEFAULT_SPEC): Define. + (CHOOSE_DYNAMIC_LINKER, LINK_TARGET_SPEC, LINK_OS_LINUX_SPEC): Update. + + * config/rs6000/sysv4le.h (MUSL_DYNAMIC_LINKER_E): Define. + +--- a/gcc/config/rs6000/linux64.h ++++ b/gcc/config/rs6000/linux64.h +@@ -365,17 +365,21 @@ extern int dot_symbols; + #endif + #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0" + #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0" ++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E ".so.1" ++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E ".so.1" + #if DEFAULT_LIBC == LIBC_UCLIBC +-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}" ++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}" + #elif DEFAULT_LIBC == LIBC_GLIBC +-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}" ++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}" ++#elif DEFAULT_LIBC == LIBC_MUSL ++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}" + #else + #error "Unsupported DEFAULT_LIBC" + #endif + #define GNU_USER_DYNAMIC_LINKER32 \ +- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32) ++ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32) + #define GNU_USER_DYNAMIC_LINKER64 \ +- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64) ++ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64) + + #undef DEFAULT_ASM_ENDIAN + #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN) +--- a/gcc/config/rs6000/secureplt.h ++++ b/gcc/config/rs6000/secureplt.h +@@ -18,3 +18,4 @@ along with GCC; see the file COPYING3. + . */ + + #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt" ++#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt" +--- a/gcc/config/rs6000/sysv4.h ++++ b/gcc/config/rs6000/sysv4.h +@@ -537,6 +537,9 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF + #ifndef CC1_SECURE_PLT_DEFAULT_SPEC + #define CC1_SECURE_PLT_DEFAULT_SPEC "" + #endif ++#ifndef LINK_SECURE_PLT_DEFAULT_SPEC ++#define LINK_SECURE_PLT_DEFAULT_SPEC "" ++#endif + + /* Pass -G xxx to the compiler. */ + #undef CC1_SPEC +@@ -574,7 +577,8 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF + %{R*} \ + %(link_shlib) \ + %{!T*: %(link_start) } \ +-%(link_os)" ++%(link_os)" \ ++"%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}" + + /* Shared libraries are not default. */ + #define LINK_SHLIB_SPEC "\ +@@ -757,17 +761,22 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF + + #define LINK_START_LINUX_SPEC "" + ++#define MUSL_DYNAMIC_LINKER_E ENDIAN_SELECT("","le","") ++ + #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1" + #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0" ++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E ".so.1" + #if DEFAULT_LIBC == LIBC_UCLIBC +-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}" ++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}" ++#elif DEFAULT_LIBC == LIBC_MUSL ++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}" + #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC +-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}" ++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}" + #else + #error "Unsupported DEFAULT_LIBC" + #endif + #define GNU_USER_DYNAMIC_LINKER \ +- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER) ++ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER) + + #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \ + %{rdynamic:-export-dynamic} \ +@@ -889,6 +898,7 @@ ncrtn.o%s" + { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \ + { "link_os_default", LINK_OS_DEFAULT_SPEC }, \ + { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \ ++ { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \ + { "cpp_os_ads", CPP_OS_ADS_SPEC }, \ + { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \ + { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \ +@@ -943,3 +953,72 @@ ncrtn.o%s" + /* This target uses the sysv4.opt file. */ + #define TARGET_USES_SYSV4_OPT 1 + ++/* Include order changes for musl, same as in generic linux.h. */ ++#if DEFAULT_LIBC == LIBC_MUSL ++#define INCLUDE_DEFAULTS_MUSL_GPP \ ++ { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \ ++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \ ++ { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \ ++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \ ++ { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \ ++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, ++ ++#ifdef LOCAL_INCLUDE_DIR ++#define INCLUDE_DEFAULTS_MUSL_LOCAL \ ++ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \ ++ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 }, ++#else ++#define INCLUDE_DEFAULTS_MUSL_LOCAL ++#endif ++ ++#ifdef PREFIX_INCLUDE_DIR ++#define INCLUDE_DEFAULTS_MUSL_PREFIX \ ++ { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0}, ++#else ++#define INCLUDE_DEFAULTS_MUSL_PREFIX ++#endif ++ ++#ifdef CROSS_INCLUDE_DIR ++#define INCLUDE_DEFAULTS_MUSL_CROSS \ ++ { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0}, ++#else ++#define INCLUDE_DEFAULTS_MUSL_CROSS ++#endif ++ ++#ifdef TOOL_INCLUDE_DIR ++#define INCLUDE_DEFAULTS_MUSL_TOOL \ ++ { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0}, ++#else ++#define INCLUDE_DEFAULTS_MUSL_TOOL ++#endif ++ ++#ifdef NATIVE_SYSTEM_HEADER_DIR ++#define INCLUDE_DEFAULTS_MUSL_NATIVE \ ++ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \ ++ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 }, ++#else ++#define INCLUDE_DEFAULTS_MUSL_NATIVE ++#endif ++ ++#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT) ++# undef INCLUDE_DEFAULTS_MUSL_LOCAL ++# define INCLUDE_DEFAULTS_MUSL_LOCAL ++# undef INCLUDE_DEFAULTS_MUSL_NATIVE ++# define INCLUDE_DEFAULTS_MUSL_NATIVE ++#else ++# undef INCLUDE_DEFAULTS_MUSL_CROSS ++# define INCLUDE_DEFAULTS_MUSL_CROSS ++#endif ++ ++#undef INCLUDE_DEFAULTS ++#define INCLUDE_DEFAULTS \ ++ { \ ++ INCLUDE_DEFAULTS_MUSL_GPP \ ++ INCLUDE_DEFAULTS_MUSL_PREFIX \ ++ INCLUDE_DEFAULTS_MUSL_CROSS \ ++ INCLUDE_DEFAULTS_MUSL_TOOL \ ++ INCLUDE_DEFAULTS_MUSL_NATIVE \ ++ { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \ ++ { 0, 0, 0, 0, 0, 0 } \ ++ } ++#endif +--- a/gcc/config/rs6000/sysv4le.h ++++ b/gcc/config/rs6000/sysv4le.h +@@ -31,3 +31,5 @@ + /* Little-endian PowerPC64 Linux uses the ELF v2 ABI by default. */ + #define LINUX64_DEFAULT_ABI_ELFv2 + ++#undef MUSL_DYNAMIC_LINKER_E ++#define MUSL_DYNAMIC_LINKER_E ENDIAN_SELECT("","le","le") +--- a/gcc/config.gcc ++++ b/gcc/config.gcc +@@ -2416,6 +2416,10 @@ powerpc*-*-linux*) + powerpc*-*-linux*paired*) + tm_file="${tm_file} rs6000/750cl.h" ;; + esac ++ case ${target} in ++ *-linux*-musl*) ++ enable_secureplt=yes ;; ++ esac + if test x${enable_secureplt} = xyes; then + tm_file="rs6000/secureplt.h ${tm_file}" + fi diff --git a/toolchain/gcc/patches/5.4.0/204-musl_sh.patch b/toolchain/gcc/patches/5.4.0/204-musl_sh.patch new file mode 100644 index 00000000000..8c3753d5301 --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/204-musl_sh.patch @@ -0,0 +1,39 @@ +gcc/Changelog: + +2015-04-27 Gregor Richards + Szabolcs Nagy + + * config/sh/linux.h (MUSL_DYNAMIC_LINKER): Define. + (MUSL_DYNAMIC_LINKER_E, MUSL_DYNAMIC_LINKER_FP): Define. + +--- a/gcc/config/sh/linux.h ++++ b/gcc/config/sh/linux.h +@@ -43,6 +43,28 @@ along with GCC; see the file COPYING3. + + #define TARGET_ASM_FILE_END file_end_indicate_exec_stack + ++#if TARGET_ENDIAN_DEFAULT == MASK_LITTLE_ENDIAN ++#define MUSL_DYNAMIC_LINKER_E "%{mb:eb}" ++#else ++#define MUSL_DYNAMIC_LINKER_E "%{!ml:eb}" ++#endif ++ ++#if TARGET_CPU_DEFAULT & ( MASK_HARD_SH2A_DOUBLE | MASK_SH4 ) ++/* "-nofpu" if any nofpu option is specified */ ++#define MUSL_DYNAMIC_LINKER_FP \ ++ "%{m1|m2|m2a-nofpu|m3|m4-nofpu|m4-100-nofpu|m4-200-nofpu|m4-300-nofpu|" \ ++ "m4-340|m4-400|m4-500|m4al|m5-32media-nofpu|m5-64media-nofpu|" \ ++ "m5-compact-nofpu:-nofpu}" ++#else ++/* "-nofpu" if none of the hard fpu options are specified */ ++#define MUSL_DYNAMIC_LINKER_FP \ ++ "%{m2a|m4|m4-100|m4-200|m4-300|m4a|m5-32media|m5-64media|m5-compact:;:-nofpu}" ++#endif ++ ++#undef MUSL_DYNAMIC_LINKER ++#define MUSL_DYNAMIC_LINKER \ ++ "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP ".so.1" ++ + #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" + + #undef SUBTARGET_LINK_EMUL_SUFFIX diff --git a/toolchain/gcc/patches/5.4.0/205-musl_x86.patch b/toolchain/gcc/patches/5.4.0/205-musl_x86.patch new file mode 100644 index 00000000000..8772328d64d --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/205-musl_x86.patch @@ -0,0 +1,41 @@ +From: ktkachov +Date: Fri, 15 May 2015 13:20:01 +0000 (+0000) +Subject: [PATCH 9/13] x86 musl support +X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=5551c8d927c17f60837f15f8dfe46f945ba3fa9c + +[PATCH 9/13] x86 musl support + +On behalf of Szabolcs Nagy. + +2015-05-15 Gregor Richards + + * config/i386/linux.h (MUSL_DYNAMIC_LINKER): Define. + * config/i386/linux64.h (MUSL_DYNAMIC_LINKER32): Define. + (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32): Define. + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223218 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + +--- a/gcc/config/i386/linux.h ++++ b/gcc/config/i386/linux.h +@@ -21,3 +21,6 @@ along with GCC; see the file COPYING3. + + #define GNU_USER_LINK_EMULATION "elf_i386" + #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" ++ ++#undef MUSL_DYNAMIC_LINKER ++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1" +--- a/gcc/config/i386/linux64.h ++++ b/gcc/config/i386/linux64.h +@@ -30,3 +30,10 @@ see the files COPYING3 and COPYING.RUNTI + #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2" + #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2" + #define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2" ++ ++#undef MUSL_DYNAMIC_LINKER32 ++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1" ++#undef MUSL_DYNAMIC_LINKER64 ++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1" ++#undef MUSL_DYNAMIC_LINKERX32 ++#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1" diff --git a/toolchain/gcc/patches/5.4.0/206-musl_aarch64.patch b/toolchain/gcc/patches/5.4.0/206-musl_aarch64.patch new file mode 100644 index 00000000000..6925a026e7e --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/206-musl_aarch64.patch @@ -0,0 +1,31 @@ +From: jgreenhalgh +Date: Wed, 27 May 2015 16:46:39 +0000 (+0000) +Subject: [PATCH 3/13] aarch64 musl support +X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=b3ff21cf0531be91bc3fb8200296a7633090ec78 + +[PATCH 3/13] aarch64 musl support + +gcc/Changelog: + +2015-05-27 Gregor Richards + Szabolcs Nagy + + * config/aarch64/aarch64-linux.h (MUSL_DYNAMIC_LINKER): Define. + + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223766 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + +--- a/gcc/config/aarch64/aarch64-linux.h ++++ b/gcc/config/aarch64/aarch64-linux.h +@@ -23,6 +23,9 @@ + + #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1" + ++#undef MUSL_DYNAMIC_LINKER ++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1" ++ + #undef ASAN_CC1_SPEC + #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}" + diff --git a/toolchain/gcc/patches/5.4.0/207-musl_fixincludes.patch b/toolchain/gcc/patches/5.4.0/207-musl_fixincludes.patch new file mode 100644 index 00000000000..0ff33d39d8c --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/207-musl_fixincludes.patch @@ -0,0 +1,30 @@ +From: ktkachov +Date: Wed, 22 Apr 2015 14:18:16 +0000 (+0000) +Subject: fixincludes update for musl support +X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=2dc727de2e87c2756a514cbb43cea23c99deaa3d + +fixincludes update for musl support + +On behalf of Szabolcs.Nagy@arm.com + +2015-04-22 Gregor Richards + + * mkfixinc.sh: Add *-musl* with no fixes. + + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222327 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + +--- a/fixincludes/mkfixinc.sh ++++ b/fixincludes/mkfixinc.sh +@@ -19,7 +19,8 @@ case $machine in + powerpc-*-eabi* | \ + powerpc-*-rtems* | \ + powerpcle-*-eabisim* | \ +- powerpcle-*-eabi* ) ++ powerpcle-*-eabi* | \ ++ *-musl* ) + # IF there is no include fixing, + # THEN create a no-op fixer and exit + (echo "#! /bin/sh" ; echo "exit 0" ) > ${target} diff --git a/toolchain/gcc/patches/5.4.0/209-musl_libstdc++.patch b/toolchain/gcc/patches/5.4.0/209-musl_libstdc++.patch new file mode 100644 index 00000000000..d2414d02326 --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/209-musl_libstdc++.patch @@ -0,0 +1,72 @@ +From: ktkachov +Date: Wed, 22 Apr 2015 14:24:11 +0000 (+0000) +Subject: libstdc++, libgfortran gthr workaround for musl +X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=1e5f711c11cb80ce609db9e9c1d8b2da0f7b5b61 + +libstdc++, libgfortran gthr workaround for musl + +On behalf of szabolcs.nagy@arm.com + +[libstdc++-v3/] +2015-04-22 Szabolcs Nagy + + * config/os/generic/os_defines.h (_GLIBCXX_GTHREAD_USE_WEAK): Define. + * configure.host (os_include_dir): Set to "os/generic" for linux-musl*. + +[libgfortran/] +2015-04-22 Szabolcs Nagy + + * acinclude.m4 (GTHREAD_USE_WEAK): Define as 0 for *-*-musl*. + * configure: Regenerate. + + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222329 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + +--- a/libgfortran/acinclude.m4 ++++ b/libgfortran/acinclude.m4 +@@ -100,7 +100,7 @@ void foo (void); + [Define to 1 if the target supports #pragma weak]) + fi + case "$host" in +- *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* ) ++ *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* | *-*-musl* ) + AC_DEFINE(GTHREAD_USE_WEAK, 0, + [Define to 0 if the target shouldn't use #pragma weak]) + ;; +--- a/libgfortran/configure ++++ b/libgfortran/configure +@@ -26456,7 +26456,7 @@ $as_echo "#define SUPPORTS_WEAK 1" >>con + + fi + case "$host" in +- *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* ) ++ *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* | *-*-musl* ) + + $as_echo "#define GTHREAD_USE_WEAK 0" >>confdefs.h + +--- a/libstdc++-v3/config/os/generic/os_defines.h ++++ b/libstdc++-v3/config/os/generic/os_defines.h +@@ -33,4 +33,9 @@ + // System-specific #define, typedefs, corrections, etc, go here. This + // file will come before all others. + ++// Disable the weak reference logic in gthr.h for os/generic because it ++// is broken on every platform unless there is implementation specific ++// workaround in gthr-posix.h and at link-time for static linking. ++#define _GLIBCXX_GTHREAD_USE_WEAK 0 ++ + #endif +--- a/libstdc++-v3/configure.host ++++ b/libstdc++-v3/configure.host +@@ -273,6 +273,9 @@ case "${host_os}" in + freebsd*) + os_include_dir="os/bsd/freebsd" + ;; ++ linux-musl*) ++ os_include_dir="os/generic" ++ ;; + gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu) + if [ "$uclibc" = "yes" ]; then + os_include_dir="os/uclibc" diff --git a/toolchain/gcc/patches/5.4.0/230-musl_libssp.patch b/toolchain/gcc/patches/5.4.0/230-musl_libssp.patch new file mode 100644 index 00000000000..30f42e9f7c7 --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/230-musl_libssp.patch @@ -0,0 +1,13 @@ +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -727,7 +727,9 @@ proper position among the other output f + #endif + + #ifndef LINK_SSP_SPEC +-#ifdef TARGET_LIBC_PROVIDES_SSP ++#if DEFAULT_LIBC == LIBC_MUSL ++#define LINK_SSP_SPEC "-lssp_nonshared" ++#elif defined(TARGET_LIBC_PROVIDES_SSP) + #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ + "|fstack-protector-strong|fstack-protector-explicit:}" + #else diff --git a/toolchain/gcc/patches/5.4.0/240-musl-libitm-fixes.patch b/toolchain/gcc/patches/5.4.0/240-musl-libitm-fixes.patch new file mode 100644 index 00000000000..533cb68499d --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/240-musl-libitm-fixes.patch @@ -0,0 +1,61 @@ +From: ktkachov +Date: Wed, 22 Apr 2015 14:11:25 +0000 (+0000) +Subject: libitm fixes for musl support +X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=e53a4d49c3d03ab8eaddb073cf972c1c46d75338 + +libitm fixes for musl support + +On behalf of Szabolcs.Nagy@arm.com + +2015-04-22 Gregor Richards + + * config/arm/hwcap.cc: Use fcntl.h instead of sys/fcntl.h. + * config/linux/x86/tls.h: Only use __GLIBC_PREREQ if defined. + + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222325 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + +--- a/libitm/config/arm/hwcap.cc ++++ b/libitm/config/arm/hwcap.cc +@@ -40,7 +40,7 @@ int GTM_hwcap HIDDEN = 0 + + #ifdef __linux__ + #include +-#include ++#include + #include + + static void __attribute__((constructor)) +--- a/libitm/config/linux/x86/tls.h ++++ b/libitm/config/linux/x86/tls.h +@@ -25,16 +25,19 @@ + #ifndef LIBITM_X86_TLS_H + #define LIBITM_X86_TLS_H 1 + +-#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10) ++#if defined(__GLIBC_PREREQ) ++#if __GLIBC_PREREQ(2, 10) + /* Use slots in the TCB head rather than __thread lookups. + GLIBC has reserved words 10 through 13 for TM. */ + #define HAVE_ARCH_GTM_THREAD 1 + #define HAVE_ARCH_GTM_THREAD_DISP 1 + #endif ++#endif + + #include "config/generic/tls.h" + +-#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10) ++#if defined(__GLIBC_PREREQ) ++#if __GLIBC_PREREQ(2, 10) + namespace GTM HIDDEN { + + #ifdef __x86_64__ +@@ -101,5 +104,6 @@ static inline void set_abi_disp(struct a + + } // namespace GTM + #endif /* >= GLIBC 2.10 */ ++#endif + + #endif // LIBITM_X86_TLS_H diff --git a/toolchain/gcc/patches/5.4.0/250-add-musl.patch b/toolchain/gcc/patches/5.4.0/250-add-musl.patch new file mode 100644 index 00000000000..8cbeddea33f --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/250-add-musl.patch @@ -0,0 +1,120 @@ +From: ktkachov +Date: Fri, 8 May 2015 08:30:40 +0000 (+0000) +Subject: [PATCH 0/13] Add musl support to GCC +X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=f2d678afa5b8385d763b93772d73d6bf80a9739e + +[PATCH 0/13] Add musl support to GCC + +2015-05-08 Szabolcs Nagy + + * config/glibc-stdint.h (OPTION_MUSL): Define. + (INT_FAST16_TYPE, INT_FAST32_TYPE, UINT_FAST16_TYPE, UINT_FAST32_TYPE): + Change the definition based on OPTION_MUSL for 64 bit targets. + * config/linux.h (OPTION_MUSL): Redefine. + * config/alpha/linux.h (OPTION_MUSL): Redefine. + * config/rs6000/linux.h (OPTION_MUSL): Redefine. + * config/rs6000/linux64.h (OPTION_MUSL): Redefine. + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222905 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + +--- a/gcc/config/alpha/linux.h ++++ b/gcc/config/alpha/linux.h +@@ -61,10 +61,14 @@ along with GCC; see the file COPYING3. + #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC) + #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC) + #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC) ++#undef OPTION_MUSL ++#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL) + #else + #define OPTION_GLIBC (linux_libc == LIBC_GLIBC) + #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC) + #define OPTION_BIONIC (linux_libc == LIBC_BIONIC) ++#undef OPTION_MUSL ++#define OPTION_MUSL (linux_libc == LIBC_MUSL) + #endif + + /* Determine what functions are present at the runtime; +--- a/gcc/config/glibc-stdint.h ++++ b/gcc/config/glibc-stdint.h +@@ -22,6 +22,12 @@ a copy of the GCC Runtime Library Except + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + . */ + ++/* Systems using musl libc should use this header and make sure ++ OPTION_MUSL is defined correctly before using the TYPE macros. */ ++#ifndef OPTION_MUSL ++#define OPTION_MUSL 0 ++#endif ++ + #define SIG_ATOMIC_TYPE "int" + + #define INT8_TYPE "signed char" +@@ -43,12 +49,12 @@ see the files COPYING3 and COPYING.RUNTI + #define UINT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int") + + #define INT_FAST8_TYPE "signed char" +-#define INT_FAST16_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int") +-#define INT_FAST32_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int") ++#define INT_FAST16_TYPE (LONG_TYPE_SIZE == 64 && !OPTION_MUSL ? "long int" : "int") ++#define INT_FAST32_TYPE (LONG_TYPE_SIZE == 64 && !OPTION_MUSL ? "long int" : "int") + #define INT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int") + #define UINT_FAST8_TYPE "unsigned char" +-#define UINT_FAST16_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int") +-#define UINT_FAST32_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int") ++#define UINT_FAST16_TYPE (LONG_TYPE_SIZE == 64 && !OPTION_MUSL ? "long unsigned int" : "unsigned int") ++#define UINT_FAST32_TYPE (LONG_TYPE_SIZE == 64 && !OPTION_MUSL ? "long unsigned int" : "unsigned int") + #define UINT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int") + + #define INTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int") +--- a/gcc/config/linux.h ++++ b/gcc/config/linux.h +@@ -32,11 +32,13 @@ see the files COPYING3 and COPYING.RUNTI + #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC) + #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC) + #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC) ++#undef OPTION_MUSL + #define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL) + #else + #define OPTION_GLIBC (linux_libc == LIBC_GLIBC) + #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC) + #define OPTION_BIONIC (linux_libc == LIBC_BIONIC) ++#undef OPTION_MUSL + #define OPTION_MUSL (linux_libc == LIBC_MUSL) + #endif + +--- a/gcc/config/rs6000/linux.h ++++ b/gcc/config/rs6000/linux.h +@@ -30,10 +30,14 @@ + #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC) + #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC) + #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC) ++#undef OPTION_MUSL ++#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL) + #else + #define OPTION_GLIBC (linux_libc == LIBC_GLIBC) + #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC) + #define OPTION_BIONIC (linux_libc == LIBC_BIONIC) ++#undef OPTION_MUSL ++#define OPTION_MUSL (linux_libc == LIBC_MUSL) + #endif + + /* Determine what functions are present at the runtime; +--- a/gcc/config/rs6000/linux64.h ++++ b/gcc/config/rs6000/linux64.h +@@ -299,10 +299,14 @@ extern int dot_symbols; + #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC) + #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC) + #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC) ++#undef OPTION_MUSL ++#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL) + #else + #define OPTION_GLIBC (linux_libc == LIBC_GLIBC) + #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC) + #define OPTION_BIONIC (linux_libc == LIBC_BIONIC) ++#undef OPTION_MUSL ++#define OPTION_MUSL (linux_libc == LIBC_MUSL) + #endif + + /* Determine what functions are present at the runtime; diff --git a/toolchain/gcc/patches/5.4.0/260-musl-add-unwind-fix.patch b/toolchain/gcc/patches/5.4.0/260-musl-add-unwind-fix.patch new file mode 100644 index 00000000000..a3b83e20746 --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/260-musl-add-unwind-fix.patch @@ -0,0 +1,34 @@ +From: ktkachov +Date: Wed, 22 Apr 2015 14:20:01 +0000 (+0000) +Subject: unwind fix for musl +X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=a2e31d0681d8a47389b8a3552622fbd9827bcef4 + +unwind fix for musl + +On behalf of szabolcs.nagy@arm.com + +2015-04-22 Gregor Richards + Szabolcs Nagy + + * unwind-dw2-fde-dip.c (USE_PT_GNU_EH_FRAME): Define it on + Linux if target provides dl_iterate_phdr. + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222328 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + +--- a/libgcc/unwind-dw2-fde-dip.c ++++ b/libgcc/unwind-dw2-fde-dip.c +@@ -59,6 +59,12 @@ + + #if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ + && defined(TARGET_DL_ITERATE_PHDR) \ ++ && defined(__linux__) ++# define USE_PT_GNU_EH_FRAME ++#endif ++ ++#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ ++ && defined(TARGET_DL_ITERATE_PHDR) \ + && (defined(__DragonFly__) || defined(__FreeBSD__)) + # define ElfW __ElfN + # define USE_PT_GNU_EH_FRAME diff --git a/toolchain/gcc/patches/5.4.0/270-musl-add-powerpc-softfloat-fix.patch b/toolchain/gcc/patches/5.4.0/270-musl-add-powerpc-softfloat-fix.patch new file mode 100644 index 00000000000..bdebf6c01f4 --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/270-musl-add-powerpc-softfloat-fix.patch @@ -0,0 +1,24 @@ +--- a/gcc/config/rs6000/linux64.h ++++ b/gcc/config/rs6000/linux64.h +@@ -369,8 +369,8 @@ extern int dot_symbols; + #endif + #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0" + #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0" +-#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E ".so.1" +-#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E ".so.1" ++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" ++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" + #if DEFAULT_LIBC == LIBC_UCLIBC + #define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}" + #elif DEFAULT_LIBC == LIBC_GLIBC +--- a/gcc/config/rs6000/sysv4.h ++++ b/gcc/config/rs6000/sysv4.h +@@ -765,7 +765,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF + + #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1" + #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0" +-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E ".so.1" ++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" + #if DEFAULT_LIBC == LIBC_UCLIBC + #define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}" + #elif DEFAULT_LIBC == LIBC_MUSL diff --git a/toolchain/gcc/patches/5.4.0/280-musl-disable-ifunc-by-default.patch b/toolchain/gcc/patches/5.4.0/280-musl-disable-ifunc-by-default.patch new file mode 100644 index 00000000000..af5acf8cc90 --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/280-musl-disable-ifunc-by-default.patch @@ -0,0 +1,38 @@ +From 450fb05e2a7510d37744f044009f8237d902f65c Mon Sep 17 00:00:00 2001 +From: nsz +Date: Tue, 30 Aug 2016 10:26:22 +0000 +Subject: [PATCH] disable ifunc on *-musl by default + +gcc/ + * config.gcc (*-*-*musl*): Disable gnu-indirect-function. + + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239859 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + gcc/ChangeLog | 4 ++++ + gcc/config.gcc | 4 ++-- + 2 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/gcc/config.gcc b/gcc/config.gcc +index 8827dc8..e544d76 100644 +--- a/gcc/config.gcc ++++ b/gcc/config.gcc +@@ -1465,7 +1465,7 @@ i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-gnu* | i[34567]8 + extra_options="${extra_options} linux-android.opt" + # Assume modern glibc if not targeting Android nor uclibc. + case ${target} in +- *-*-*android*|*-*-*uclibc*) ++ *-*-*android*|*-*-*uclibc*|*-*-*musl*) + ;; + *) + default_gnu_indirect_function=yes +@@ -1531,7 +1531,7 @@ x86_64-*-linux* | x86_64-*-kfreebsd*-gnu) + extra_options="${extra_options} linux-android.opt" + # Assume modern glibc if not targeting Android nor uclibc. + case ${target} in +- *-*-*android*|*-*-*uclibc*) ++ *-*-*android*|*-*-*uclibc*|*-*-*musl*) + ;; + *) + default_gnu_indirect_function=yes diff --git a/toolchain/gcc/patches/5.4.0/300-mips_Os_cpu_rtx_cost_model.patch b/toolchain/gcc/patches/5.4.0/300-mips_Os_cpu_rtx_cost_model.patch new file mode 100644 index 00000000000..1743658ac6c --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/300-mips_Os_cpu_rtx_cost_model.patch @@ -0,0 +1,14 @@ +Use the proper rtx cost model for the selected CPU, even when optimizing +for size. This generates better code. + +--- a/gcc/config/mips/mips.c ++++ b/gcc/config/mips/mips.c +@@ -17483,7 +17483,7 @@ mips_option_override (void) + flag_pcc_struct_return = 0; + + /* Decide which rtx_costs structure to use. */ +- if (optimize_size) ++ if (0 && optimize_size) + mips_cost = &mips_rtx_cost_optimize_size; + else + mips_cost = &mips_rtx_cost_data[mips_tune]; diff --git a/toolchain/gcc/patches/4.9-linaro/800-arm_v5te_no_ldrd_strd.patch b/toolchain/gcc/patches/5.4.0/800-arm_v5te_no_ldrd_strd.patch similarity index 100% rename from toolchain/gcc/patches/4.9-linaro/800-arm_v5te_no_ldrd_strd.patch rename to toolchain/gcc/patches/5.4.0/800-arm_v5te_no_ldrd_strd.patch diff --git a/toolchain/gcc/patches/4.9-linaro/810-arm-softfloat-libgcc.patch b/toolchain/gcc/patches/5.4.0/810-arm-softfloat-libgcc.patch similarity index 100% rename from toolchain/gcc/patches/4.9-linaro/810-arm-softfloat-libgcc.patch rename to toolchain/gcc/patches/5.4.0/810-arm-softfloat-libgcc.patch diff --git a/toolchain/gcc/patches/4.6-linaro/820-libgcc_pic.patch b/toolchain/gcc/patches/5.4.0/820-libgcc_pic.patch similarity index 85% rename from toolchain/gcc/patches/4.6-linaro/820-libgcc_pic.patch rename to toolchain/gcc/patches/5.4.0/820-libgcc_pic.patch index 3760ac2b9bd..42bf0c8cccf 100644 --- a/toolchain/gcc/patches/4.6-linaro/820-libgcc_pic.patch +++ b/toolchain/gcc/patches/5.4.0/820-libgcc_pic.patch @@ -1,6 +1,6 @@ --- a/libgcc/Makefile.in +++ b/libgcc/Makefile.in -@@ -747,11 +747,12 @@ $(libgcov-objects): %$(objext): $(gcc_sr +@@ -887,11 +887,12 @@ $(libgcov-driver-objects): %$(objext): $ # Static libraries. libgcc.a: $(libgcc-objects) @@ -14,7 +14,7 @@ -rm -f $@ objects="$(objects)"; \ -@@ -773,7 +774,7 @@ libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_E +@@ -913,7 +914,7 @@ libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_E endif ifeq ($(enable_shared),yes) @@ -23,7 +23,7 @@ ifneq ($(LIBUNWIND),) all: libunwind$(SHLIB_EXT) endif -@@ -954,6 +955,10 @@ install-shared: +@@ -1108,6 +1109,10 @@ install-shared: chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a diff --git a/toolchain/gcc/patches/4.8-linaro/830-arm_unbreak_armv4t.patch b/toolchain/gcc/patches/5.4.0/830-arm_unbreak_armv4t.patch similarity index 100% rename from toolchain/gcc/patches/4.8-linaro/830-arm_unbreak_armv4t.patch rename to toolchain/gcc/patches/5.4.0/830-arm_unbreak_armv4t.patch diff --git a/toolchain/gcc/patches/4.9-linaro/840-armv4_pass_fix-v4bx_to_ld.patch b/toolchain/gcc/patches/5.4.0/840-armv4_pass_fix-v4bx_to_ld.patch similarity index 100% rename from toolchain/gcc/patches/4.9-linaro/840-armv4_pass_fix-v4bx_to_ld.patch rename to toolchain/gcc/patches/5.4.0/840-armv4_pass_fix-v4bx_to_ld.patch diff --git a/toolchain/gcc/patches/4.9-linaro/850-use_shared_libgcc.patch b/toolchain/gcc/patches/5.4.0/850-use_shared_libgcc.patch similarity index 81% rename from toolchain/gcc/patches/4.9-linaro/850-use_shared_libgcc.patch rename to toolchain/gcc/patches/5.4.0/850-use_shared_libgcc.patch index cef79d8206d..5818cf4da0a 100644 --- a/toolchain/gcc/patches/4.9-linaro/850-use_shared_libgcc.patch +++ b/toolchain/gcc/patches/5.4.0/850-use_shared_libgcc.patch @@ -13,7 +13,7 @@ is used. */ --- a/gcc/config/linux.h +++ b/gcc/config/linux.h -@@ -51,6 +51,10 @@ see the files COPYING3 and COPYING.RUNTI +@@ -53,6 +53,10 @@ see the files COPYING3 and COPYING.RUNTI builtin_assert ("system=posix"); \ } while (0) @@ -22,8 +22,8 @@ +#endif + /* Determine which dynamic linker to use depending on whether GLIBC or - uClibc or Bionic is the default C library and whether - -muclibc or -mglibc or -mbionic has been passed to change the default. */ + uClibc or Bionic or musl is the default C library and whether + -muclibc or -mglibc or -mbionic or -mmusl has been passed to change --- a/libgcc/mkmap-symver.awk +++ b/libgcc/mkmap-symver.awk @@ -132,5 +132,5 @@ function output(lib) { @@ -35,9 +35,9 @@ } --- a/gcc/config/rs6000/linux.h +++ b/gcc/config/rs6000/linux.h -@@ -62,6 +62,9 @@ - #undef CPLUSPLUS_CPP_SPEC - #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)" +@@ -60,6 +60,9 @@ + #undef CPP_OS_DEFAULT_SPEC + #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)" +#undef LIBGCC_SPEC +#define LIBGCC_SPEC "%{!static:%{!static-libgcc:-lgcc_s}} -lgcc" diff --git a/toolchain/gcc/patches/4.8-linaro/851-libgcc_no_compat.patch b/toolchain/gcc/patches/5.4.0/851-libgcc_no_compat.patch similarity index 100% rename from toolchain/gcc/patches/4.8-linaro/851-libgcc_no_compat.patch rename to toolchain/gcc/patches/5.4.0/851-libgcc_no_compat.patch diff --git a/toolchain/gcc/patches/4.9-linaro/870-ppc_no_crtsavres.patch b/toolchain/gcc/patches/5.4.0/870-ppc_no_crtsavres.patch similarity index 84% rename from toolchain/gcc/patches/4.9-linaro/870-ppc_no_crtsavres.patch rename to toolchain/gcc/patches/5.4.0/870-ppc_no_crtsavres.patch index 4e9b50c017d..0e64a4164b6 100644 --- a/toolchain/gcc/patches/4.9-linaro/870-ppc_no_crtsavres.patch +++ b/toolchain/gcc/patches/5.4.0/870-ppc_no_crtsavres.patch @@ -1,6 +1,6 @@ --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c -@@ -20869,7 +20869,7 @@ rs6000_savres_strategy (rs6000_stack_t * +@@ -21500,7 +21500,7 @@ rs6000_savres_strategy (rs6000_stack_t * /* Define cutoff for using out-of-line functions to save registers. */ if (DEFAULT_ABI == ABI_V4 || TARGET_ELF) { diff --git a/toolchain/gcc/patches/4.8-linaro/880-no_java_section.patch b/toolchain/gcc/patches/5.4.0/880-no_java_section.patch similarity index 100% rename from toolchain/gcc/patches/4.8-linaro/880-no_java_section.patch rename to toolchain/gcc/patches/5.4.0/880-no_java_section.patch diff --git a/toolchain/gcc/patches/5.4.0/881-no_tm_section.patch b/toolchain/gcc/patches/5.4.0/881-no_tm_section.patch new file mode 100644 index 00000000000..fab5db3be55 --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/881-no_tm_section.patch @@ -0,0 +1,11 @@ +--- a/libgcc/crtstuff.c ++++ b/libgcc/crtstuff.c +@@ -152,7 +152,7 @@ call_ ## FUNC (void) \ + #endif + + #if !defined(USE_TM_CLONE_REGISTRY) && defined(OBJECT_FORMAT_ELF) +-# define USE_TM_CLONE_REGISTRY 1 ++# define USE_TM_CLONE_REGISTRY 0 + #endif + + /* We do not want to add the weak attribute to the declarations of these diff --git a/toolchain/gcc/patches/4.8-linaro/900-bad-mips16-crt.patch b/toolchain/gcc/patches/5.4.0/900-bad-mips16-crt.patch similarity index 100% rename from toolchain/gcc/patches/4.8-linaro/900-bad-mips16-crt.patch rename to toolchain/gcc/patches/5.4.0/900-bad-mips16-crt.patch diff --git a/toolchain/gcc/patches/4.9-linaro/910-mbsd_multi.patch b/toolchain/gcc/patches/5.4.0/910-mbsd_multi.patch similarity index 83% rename from toolchain/gcc/patches/4.9-linaro/910-mbsd_multi.patch rename to toolchain/gcc/patches/5.4.0/910-mbsd_multi.patch index 0f699816412..2d7272ef951 100644 --- a/toolchain/gcc/patches/4.9-linaro/910-mbsd_multi.patch +++ b/toolchain/gcc/patches/5.4.0/910-mbsd_multi.patch @@ -16,7 +16,7 @@ --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c -@@ -105,6 +105,9 @@ static size_t include_cursor; +@@ -122,6 +122,9 @@ static int class_dump_flags; /* Whether any standard preincluded header has been preincluded. */ static bool done_preinclude; @@ -26,17 +26,7 @@ static void handle_OPT_d (const char *); static void set_std_cxx98 (int); static void set_std_cxx11 (int); -@@ -384,6 +387,9 @@ c_common_handle_option (size_t scode, co - cpp_opts->warn_endif_labels = value; - break; - -+ case OPT_Werror_maybe_reset: -+ break; -+ - case OPT_Winvalid_pch: - cpp_opts->warn_invalid_pch = value; - break; -@@ -492,6 +498,12 @@ c_common_handle_option (size_t scode, co +@@ -449,6 +452,12 @@ c_common_handle_option (size_t scode, co flag_no_builtin = !value; break; @@ -49,7 +39,7 @@ case OPT_fconstant_string_class_: constant_string_class_name = arg; break; -@@ -1048,6 +1060,47 @@ c_common_init (void) +@@ -1034,6 +1043,47 @@ c_common_init (void) return false; } @@ -99,7 +89,7 @@ --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt -@@ -391,6 +391,10 @@ Wfloat-conversion +@@ -431,6 +431,10 @@ Wfloat-conversion C ObjC C++ ObjC++ Var(warn_float_conversion) LangEnabledBy(C ObjC C++ ObjC++,Wconversion) Warn for implicit type conversions that cause loss of floating point precision @@ -110,7 +100,7 @@ Wfloat-equal C ObjC C++ ObjC++ Var(warn_float_equal) Warning Warn if testing floating point numbers for equality -@@ -972,6 +976,9 @@ C++ ObjC++ Optimization Alias(fexception +@@ -1161,6 +1165,9 @@ C++ ObjC++ Optimization Alias(fexception fhonor-std C++ ObjC++ Ignore Warn(switch %qs is no longer supported) @@ -122,7 +112,7 @@ Assume normal C execution environment --- a/gcc/common.opt +++ b/gcc/common.opt -@@ -549,6 +549,10 @@ Werror= +@@ -561,6 +561,10 @@ Werror= Common Joined Treat specified warning as error @@ -133,7 +123,7 @@ Wextra Common Var(extra_warnings) Warning Print extra (possibly unwanted) warnings -@@ -1287,6 +1291,9 @@ fguess-branch-probability +@@ -1360,6 +1364,9 @@ fguess-branch-probability Common Report Var(flag_guess_branch_prob) Optimization Enable guessing of branch probabilities @@ -145,7 +135,7 @@ ; On SVR4 targets, it also controls whether or not to emit a --- a/gcc/opts.c +++ b/gcc/opts.c -@@ -1572,6 +1572,17 @@ common_handle_option (struct gcc_options +@@ -1699,6 +1699,17 @@ common_handle_option (struct gcc_options opts, opts_set, loc, dc); break; @@ -169,8 +159,8 @@ Make all warnings into hard errors. Source code which triggers warnings will be rejected. -+ at item -Werror-maybe-reset -+ at opindex Werror-maybe-reset ++@item -Werror-maybe-reset ++@opindex Werror-maybe-reset +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment +variable is set to anything other than 0 or empty. + @@ -179,26 +169,26 @@ Issue warnings for code in system headers. These are normally unhelpful --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi -@@ -243,7 +243,7 @@ Objective-C and Objective-C++ Dialects}. - -Wconversion -Wcoverage-mismatch -Wdate-time -Wdelete-incomplete -Wno-cpp @gol - -Wno-deprecated -Wno-deprecated-declarations -Wdisabled-optimization @gol +@@ -251,7 +251,7 @@ Objective-C and Objective-C++ Dialects}. + -Wdisabled-optimization @gol + -Wno-discarded-qualifiers -Wno-discarded-array-qualifiers @gol -Wno-div-by-zero -Wdouble-promotion -Wempty-body -Wenum-compare @gol --Wno-endif-labels -Werror -Werror=* @gol +-Wno-endif-labels -Werror -Werror=* -Werror-maybe-reset @gol -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral @gol - -Wformat-security -Wformat-y2k @gol -@@ -5042,6 +5042,22 @@ This option is only supported for C and + -Wformat-security -Wformat-signedness -Wformat-y2k @gol +@@ -5382,6 +5382,22 @@ This option is only supported for C and @option{-Wall} and by @option{-Wpedantic}, which can be disabled with @option{-Wno-pointer-sign}. -+ at item -Werror-maybe-reset -+ at opindex Werror-maybe-reset ++@item -Werror-maybe-reset ++@opindex Werror-maybe-reset +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment +variable is set to anything other than 0 or empty. + -+ at item -fhonour-copts -+ at opindex fhonour-copts ++@item -fhonour-copts ++@opindex fhonour-copts +If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not +given at least once, and warn if it is given more than once. +If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not @@ -211,7 +201,7 @@ @item -Wstack-protector @opindex Wstack-protector @opindex Wno-stack-protector -@@ -7194,7 +7210,7 @@ so, the first branch is redirected to ei +@@ -7860,7 +7876,7 @@ so, the first branch is redirected to ei second branch or a point immediately following it, depending on whether the condition is known to be true or false. @@ -222,7 +212,7 @@ @opindex fsplit-wide-types --- a/gcc/java/jvspec.c +++ b/gcc/java/jvspec.c -@@ -626,6 +626,7 @@ lang_specific_pre_link (void) +@@ -629,6 +629,7 @@ lang_specific_pre_link (void) class name. Append dummy `.c' that can be stripped by set_input so %b is correct. */ set_input (concat (main_class_name, "main.c", NULL)); diff --git a/toolchain/gcc/patches/4.9-linaro/920-specs_nonfatal_getenv.patch b/toolchain/gcc/patches/5.4.0/920-specs_nonfatal_getenv.patch similarity index 51% rename from toolchain/gcc/patches/4.9-linaro/920-specs_nonfatal_getenv.patch rename to toolchain/gcc/patches/5.4.0/920-specs_nonfatal_getenv.patch index 75379e494c5..3d708f24c31 100644 --- a/toolchain/gcc/patches/4.9-linaro/920-specs_nonfatal_getenv.patch +++ b/toolchain/gcc/patches/5.4.0/920-specs_nonfatal_getenv.patch @@ -1,12 +1,13 @@ --- a/gcc/gcc.c +++ b/gcc/gcc.c -@@ -8105,7 +8105,10 @@ getenv_spec_function (int argc, const ch +@@ -8807,8 +8807,10 @@ getenv_spec_function (int argc, const ch value = getenv (argv[0]); if (!value) -- fatal_error ("environment variable %qs not defined", argv[0]); +- fatal_error (input_location, +- "environment variable %qs not defined", argv[0]); + { -+ warning (0, "environment variable %qs not defined", argv[0]); ++ warning (input_location, "environment variable %qs not defined", argv[0]); + value = ""; + } diff --git a/toolchain/gcc/patches/4.9-linaro/930-fix-mips-noexecstack.patch b/toolchain/gcc/patches/5.4.0/930-fix-mips-noexecstack.patch similarity index 94% rename from toolchain/gcc/patches/4.9-linaro/930-fix-mips-noexecstack.patch rename to toolchain/gcc/patches/5.4.0/930-fix-mips-noexecstack.patch index 8d94933ce9c..c05844d2e46 100644 --- a/toolchain/gcc/patches/4.9-linaro/930-fix-mips-noexecstack.patch +++ b/toolchain/gcc/patches/5.4.0/930-fix-mips-noexecstack.patch @@ -48,9 +48,9 @@ sellcey@mips.com --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c -@@ -19142,6 +19142,9 @@ mips_atomic_assign_expand_fenv (tree *ho - #define TARGET_USE_BY_PIECES_INFRASTRUCTURE_P \ - mips_use_by_pieces_infrastructure_p +@@ -19629,6 +19629,9 @@ mips_lra_p (void) + #undef TARGET_LRA_P + #define TARGET_LRA_P mips_lra_p +#undef TARGET_ASM_FILE_END +#define TARGET_ASM_FILE_END file_end_indicate_exec_stack @@ -85,7 +85,7 @@ sellcey@mips.com --- a/libgcc/config/mips/mips16.S +++ b/libgcc/config/mips/mips16.S -@@ -35,6 +35,10 @@ see the files COPYING3 and COPYING.RUNTI +@@ -48,6 +48,10 @@ see the files COPYING3 and COPYING.RUNTI values using the soft-float calling convention, but do the actual operation using the hard floating point instructions. */ diff --git a/toolchain/gcc/patches/5.4.0/931-fix-MIPS-softfloat-build-issue.patch b/toolchain/gcc/patches/5.4.0/931-fix-MIPS-softfloat-build-issue.patch new file mode 100644 index 00000000000..c8461a9618c --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/931-fix-MIPS-softfloat-build-issue.patch @@ -0,0 +1,174 @@ +From 2b46f9187b6f994fc450628a7cd97fc703dd23e0 Mon Sep 17 00:00:00 2001 +From: BangLang Huang +Date: Wed, 9 Nov 2016 10:36:49 +0800 +Subject: [PATCH] fix MIPS softfloat build issue + + This patch is backport from github/libffi #272 + +Signed-off-by: BangLang Huang +--- + libffi/src/mips/n32.S | 17 +++++++++++++++++ + libffi/src/mips/o32.S | 17 +++++++++++++++++ + 2 files changed, 34 insertions(+) + +diff --git a/libffi/src/mips/n32.S b/libffi/src/mips/n32.S +index c6985d3..8f25994 100644 +--- a/libffi/src/mips/n32.S ++++ b/libffi/src/mips/n32.S +@@ -107,6 +107,16 @@ loadregs: + + REG_L t6, 3*FFI_SIZEOF_ARG($fp) # load the flags word into t6. + ++#ifdef __mips_soft_float ++ REG_L a0, 0*FFI_SIZEOF_ARG(t9) ++ REG_L a1, 1*FFI_SIZEOF_ARG(t9) ++ REG_L a2, 2*FFI_SIZEOF_ARG(t9) ++ REG_L a3, 3*FFI_SIZEOF_ARG(t9) ++ REG_L a4, 4*FFI_SIZEOF_ARG(t9) ++ REG_L a5, 5*FFI_SIZEOF_ARG(t9) ++ REG_L a6, 6*FFI_SIZEOF_ARG(t9) ++ REG_L a7, 7*FFI_SIZEOF_ARG(t9) ++#else + and t4, t6, ((1< Add to the end of the quote include path + ++iremap ++C ObjC C++ ObjC++ Joined Separate ++-iremap Convert to if it occurs as prefix in __FILE__. ++ + iwithprefix + C ObjC C++ ObjC++ Joined Separate + -iwithprefix Add to the end of the system include path +--- a/gcc/doc/cpp.texi ++++ b/gcc/doc/cpp.texi +@@ -4441,6 +4441,7 @@ without notice. + @c man begin SYNOPSIS + cpp [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}] + [@option{-I}@var{dir}@dots{}] [@option{-iquote}@var{dir}@dots{}] ++ [@option{-iremap}@var{src}:@var{dst}] + [@option{-W}@var{warn}@dots{}] + [@option{-M}|@option{-MM}] [@option{-MG}] [@option{-MF} @var{filename}] + [@option{-MP}] [@option{-MQ} @var{target}@dots{}] +--- a/gcc/doc/cppopts.texi ++++ b/gcc/doc/cppopts.texi +@@ -532,6 +532,12 @@ Search @var{dir} only for header files r + If @var{dir} begins with @code{=}, then the @code{=} will be replaced + by the sysroot prefix; see @option{--sysroot} and @option{-isysroot}. + ++@item -iremap @var{src}:@var{dst} ++@opindex iremap ++Replace the prefix @var{src} in __FILE__ with @var{dst} at expansion time. ++This option can be specified more than once. Processing stops at the first ++match. ++ + @item -fdirectives-only + @opindex fdirectives-only + When preprocessing, handle directives, but do not expand macros. +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -494,8 +494,8 @@ Objective-C and Objective-C++ Dialects}. + @item Directory Options + @xref{Directory Options,,Options for Directory Search}. + @gccoptlist{-B@var{prefix} -I@var{dir} -iplugindir=@var{dir} @gol +--iquote@var{dir} -L@var{dir} -specs=@var{file} -I- @gol +---sysroot=@var{dir} --no-sysroot-suffix} ++-iquote@var{dir} -iremap@var{src}:@var{dst} -L@var{dir} -specs=@var{file} @gol ++-I- --sysroot=@var{dir} --no-sysroot-suffix} + + @item Machine Dependent Options + @xref{Submodel Options,,Hardware Models and Configurations}. +@@ -11479,6 +11479,12 @@ be searched for header files only for th + "@var{file}"}; they are not searched for @code{#include <@var{file}>}, + otherwise just like @option{-I}. + ++@item -iremap @var{src}:@var{dst} ++@opindex iremap ++Replace the prefix @var{src} in __FILE__ with @var{dst} at expansion time. ++This option can be specified more than once. Processing stops at the first ++match. ++ + @item -L@var{dir} + @opindex L + Add directory @var{dir} to the list of directories to be searched +--- a/libcpp/include/cpplib.h ++++ b/libcpp/include/cpplib.h +@@ -751,6 +751,9 @@ extern void cpp_set_lang (cpp_reader *, + /* Set the include paths. */ + extern void cpp_set_include_chains (cpp_reader *, cpp_dir *, cpp_dir *, int); + ++/* Provide src:dst pair for __FILE__ remapping. */ ++extern void add_cpp_remap_path (const char *); ++ + /* Call these to get pointers to the options, callback, and deps + structures for a given reader. These pointers are good until you + call cpp_finish on that reader. You can either edit the callbacks +--- a/libcpp/macro.c ++++ b/libcpp/macro.c +@@ -224,6 +224,64 @@ static const char * const monthnames[] = + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }; + ++static size_t remap_pairs; ++static char **remap_src; ++static char **remap_dst; ++ ++void ++add_cpp_remap_path (const char *arg) ++{ ++ const char *arg_dst; ++ size_t len; ++ ++ arg_dst = strchr(arg, ':'); ++ if (arg_dst == NULL) ++ { ++ fprintf(stderr, "Invalid argument for -iremap\n"); ++ exit(1); ++ } ++ ++ len = arg_dst - arg; ++ ++arg_dst; ++ ++ remap_src = (char **) xrealloc(remap_src, sizeof(char *) * (remap_pairs + 1)); ++ remap_dst = (char **) xrealloc(remap_dst, sizeof(char *) * (remap_pairs + 1)); ++ ++ remap_src[remap_pairs] = (char *) xmalloc(len + 1); ++ memcpy(remap_src[remap_pairs], arg, len); ++ remap_src[remap_pairs][len] = '\0'; ++ remap_dst[remap_pairs] = xstrdup(arg_dst); ++ ++remap_pairs; ++} ++ ++static const char * ++cpp_remap_file (const char *arg, char **tmp_name) ++{ ++ char *result; ++ size_t i, len; ++ ++ for (i = 0; i < remap_pairs; ++i) ++ { ++ len = strlen (remap_src[i]); ++ if (strncmp (remap_src[i], arg, len)) ++ continue; ++ if (arg[len] == '\0') ++ return xstrdup (remap_dst[i]); ++ if (arg[len] != '/') ++ continue; ++ arg += len; ++ len = strlen (remap_dst[i]); ++ result = (char *) xmalloc (len + strlen (arg) + 1); ++ memcpy(result, remap_dst[i], len); ++ strcpy(result + len, arg); ++ *tmp_name = result; ++ ++ return result; ++ } ++ ++ return arg; ++} ++ + /* Helper function for builtin_macro. Returns the text generated by + a builtin macro. */ + const uchar * +@@ -286,6 +344,7 @@ _cpp_builtin_macro_text (cpp_reader *pfi + { + unsigned int len; + const char *name; ++ char *tmp_name = NULL; + uchar *buf; + + if (node->value.builtin == BT_FILE) +@@ -297,6 +356,7 @@ _cpp_builtin_macro_text (cpp_reader *pfi + if (!name) + abort (); + } ++ name = cpp_remap_file (name, &tmp_name); + len = strlen (name); + buf = _cpp_unaligned_alloc (pfile, len * 2 + 3); + result = buf; +@@ -304,6 +364,7 @@ _cpp_builtin_macro_text (cpp_reader *pfi + buf = cpp_quote_string (buf + 1, (const unsigned char *) name, len); + *buf++ = '"'; + *buf = '\0'; ++ free (tmp_name); + } + break; + diff --git a/toolchain/gcc/patches/5.4.0/960-go_libm.patch b/toolchain/gcc/patches/5.4.0/960-go_libm.patch new file mode 100644 index 00000000000..d16b0200c06 --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/960-go_libm.patch @@ -0,0 +1,11 @@ +--- a/gcc/go/Make-lang.in ++++ b/gcc/go/Make-lang.in +@@ -74,7 +74,7 @@ go_OBJS = $(GO_OBJS) go/gospec.o + + go1$(exeext): $(GO_OBJS) attribs.o $(BACKEND) $(LIBDEPS) + +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ +- $(GO_OBJS) attribs.o $(BACKEND) $(LIBS) $(BACKENDLIBS) ++ $(GO_OBJS) attribs.o $(BACKEND) $(LIBS) $(BACKENDLIBS) -lm + + # Documentation. + diff --git a/toolchain/gcc/patches/5.4.0/970-warn_bug.patch b/toolchain/gcc/patches/5.4.0/970-warn_bug.patch new file mode 100644 index 00000000000..2c5cf9be208 --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/970-warn_bug.patch @@ -0,0 +1,11 @@ +--- a/libgo/runtime/mprof.goc ++++ b/libgo/runtime/mprof.goc +@@ -403,7 +403,7 @@ func ThreadCreateProfile(p Slice) (n int + + func Stack(b Slice, all bool) (n int) { + byte *pc, *sp; +- bool enablegc; ++ bool enablegc = false; /* workaround GCC bug #36550 */ + + sp = runtime_getcallersp(&b); + pc = (byte*)(uintptr)runtime_getcallerpc(&b); diff --git a/toolchain/gcc/patches/5.4.0/971-gcc11-compat.patch b/toolchain/gcc/patches/5.4.0/971-gcc11-compat.patch new file mode 100644 index 00000000000..d6d250f75ab --- /dev/null +++ b/toolchain/gcc/patches/5.4.0/971-gcc11-compat.patch @@ -0,0 +1,12 @@ +diff '--color=auto' -aur a/Makefile.in b/Makefile.in +--- a/Makefile.in 2022-08-28 07:51:26.608346062 -0400 ++++ b/Makefile.in 2022-08-28 07:53:50.128063834 -0400 +@@ -408,7 +408,7 @@ + CFLAGS = @CFLAGS@ + LDFLAGS = @LDFLAGS@ + LIBCFLAGS = $(CFLAGS) +-CXXFLAGS = @CXXFLAGS@ ++CXXFLAGS = @CXXFLAGS@ --std=c++03 + LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates + GOCFLAGS = $(CFLAGS) + diff --git a/toolchain/gcc/patches/6.3.0/001-revert_register_mode_search.patch b/toolchain/gcc/patches/6.3.0/001-revert_register_mode_search.patch new file mode 100644 index 00000000000..bd6fbdb4a9d --- /dev/null +++ b/toolchain/gcc/patches/6.3.0/001-revert_register_mode_search.patch @@ -0,0 +1,65 @@ +Revert of: + +commit 275035b56823b26d5fb7e90fad945b998648edf2 +Author: bergner +Date: Thu Sep 5 14:09:07 2013 +0000 + + PR target/58139 + * reginfo.c (choose_hard_reg_mode): Scan through all mode classes + looking for widest mode. + + + git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202286 138bc75d-0d04-0410-961f-82ee72b054a4 + + +--- a/gcc/reginfo.c ++++ b/gcc/reginfo.c +@@ -625,35 +625,40 @@ choose_hard_reg_mode (unsigned int regno + mode = GET_MODE_WIDER_MODE (mode)) + if ((unsigned) hard_regno_nregs[regno][mode] == nregs + && HARD_REGNO_MODE_OK (regno, mode) +- && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)) +- && GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode)) ++ && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))) + found_mode = mode; + ++ if (found_mode != VOIDmode) ++ return found_mode; ++ + for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT); + mode != VOIDmode; + mode = GET_MODE_WIDER_MODE (mode)) + if ((unsigned) hard_regno_nregs[regno][mode] == nregs + && HARD_REGNO_MODE_OK (regno, mode) +- && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)) +- && GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode)) ++ && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))) + found_mode = mode; + ++ if (found_mode != VOIDmode) ++ return found_mode; ++ + for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_FLOAT); + mode != VOIDmode; + mode = GET_MODE_WIDER_MODE (mode)) + if ((unsigned) hard_regno_nregs[regno][mode] == nregs + && HARD_REGNO_MODE_OK (regno, mode) +- && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)) +- && GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode)) ++ && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))) + found_mode = mode; + ++ if (found_mode != VOIDmode) ++ return found_mode; ++ + for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_INT); + mode != VOIDmode; + mode = GET_MODE_WIDER_MODE (mode)) + if ((unsigned) hard_regno_nregs[regno][mode] == nregs + && HARD_REGNO_MODE_OK (regno, mode) +- && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)) +- && GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode)) ++ && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))) + found_mode = mode; + + if (found_mode != VOIDmode) diff --git a/toolchain/gcc/patches/4.8-linaro/004-case_insensitive.patch b/toolchain/gcc/patches/6.3.0/002-case_insensitive.patch similarity index 100% rename from toolchain/gcc/patches/4.8-linaro/004-case_insensitive.patch rename to toolchain/gcc/patches/6.3.0/002-case_insensitive.patch diff --git a/toolchain/gcc/patches/4.6-linaro/010-documentation.patch b/toolchain/gcc/patches/6.3.0/010-documentation.patch similarity index 91% rename from toolchain/gcc/patches/4.6-linaro/010-documentation.patch rename to toolchain/gcc/patches/6.3.0/010-documentation.patch index 25773a3d31e..2adb28c83de 100644 --- a/toolchain/gcc/patches/4.6-linaro/010-documentation.patch +++ b/toolchain/gcc/patches/6.3.0/010-documentation.patch @@ -1,6 +1,6 @@ --- a/gcc/Makefile.in +++ b/gcc/Makefile.in -@@ -4251,18 +4251,10 @@ +@@ -3021,18 +3021,10 @@ doc/gcc.info: $(TEXI_GCC_FILES) doc/gccint.info: $(TEXI_GCCINT_FILES) doc/cppinternals.info: $(TEXI_CPPINT_FILES) diff --git a/toolchain/gcc/patches/6.3.0/230-musl_libssp.patch b/toolchain/gcc/patches/6.3.0/230-musl_libssp.patch new file mode 100644 index 00000000000..8dfd1fc2874 --- /dev/null +++ b/toolchain/gcc/patches/6.3.0/230-musl_libssp.patch @@ -0,0 +1,13 @@ +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -858,7 +858,9 @@ proper position among the other output f + #endif + + #ifndef LINK_SSP_SPEC +-#ifdef TARGET_LIBC_PROVIDES_SSP ++#if DEFAULT_LIBC == LIBC_MUSL ++#define LINK_SSP_SPEC "-lssp_nonshared" ++#elif defined(TARGET_LIBC_PROVIDES_SSP) + #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ + "|fstack-protector-strong|fstack-protector-explicit:}" + #else diff --git a/toolchain/gcc/patches/6.3.0/280-musl-disable-ifunc-by-default.patch b/toolchain/gcc/patches/6.3.0/280-musl-disable-ifunc-by-default.patch new file mode 100644 index 00000000000..df09e4f6366 --- /dev/null +++ b/toolchain/gcc/patches/6.3.0/280-musl-disable-ifunc-by-default.patch @@ -0,0 +1,36 @@ +From 450fb05e2a7510d37744f044009f8237d902f65c Mon Sep 17 00:00:00 2001 +From: nsz +Date: Tue, 30 Aug 2016 10:26:22 +0000 +Subject: [PATCH] disable ifunc on *-musl by default + +gcc/ + * config.gcc (*-*-*musl*): Disable gnu-indirect-function. + + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239859 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + gcc/ChangeLog | 4 ++++ + gcc/config.gcc | 4 ++-- + 2 files changed, 6 insertions(+), 2 deletions(-) + +--- a/gcc/config.gcc ++++ b/gcc/config.gcc +@@ -1495,7 +1495,7 @@ i[34567]86-*-linux* | i[34567]86-*-kfree + extra_options="${extra_options} linux-android.opt" + # Assume modern glibc if not targeting Android nor uclibc. + case ${target} in +- *-*-*android*|*-*-*uclibc*) ++ *-*-*android*|*-*-*uclibc*|*-*-*musl*) + ;; + *) + default_gnu_indirect_function=yes +@@ -1564,7 +1564,7 @@ x86_64-*-linux* | x86_64-*-kfreebsd*-gnu + extra_options="${extra_options} linux-android.opt" + # Assume modern glibc if not targeting Android nor uclibc. + case ${target} in +- *-*-*android*|*-*-*uclibc*) ++ *-*-*android*|*-*-*uclibc*|*-*-*musl*) + ;; + *) + default_gnu_indirect_function=yes diff --git a/toolchain/gcc/patches/6.3.0/300-mips_Os_cpu_rtx_cost_model.patch b/toolchain/gcc/patches/6.3.0/300-mips_Os_cpu_rtx_cost_model.patch new file mode 100644 index 00000000000..d76bd8cb1dc --- /dev/null +++ b/toolchain/gcc/patches/6.3.0/300-mips_Os_cpu_rtx_cost_model.patch @@ -0,0 +1,11 @@ +--- a/gcc/config/mips/mips.c ++++ b/gcc/config/mips/mips.c +@@ -17928,7 +17928,7 @@ mips_option_override (void) + flag_pcc_struct_return = 0; + + /* Decide which rtx_costs structure to use. */ +- if (optimize_size) ++ if (0 && optimize_size) + mips_cost = &mips_rtx_cost_optimize_size; + else + mips_cost = &mips_rtx_cost_data[mips_tune]; diff --git a/toolchain/gcc/patches/4.8-linaro/800-arm_v5te_no_ldrd_strd.patch b/toolchain/gcc/patches/6.3.0/800-arm_v5te_no_ldrd_strd.patch similarity index 85% rename from toolchain/gcc/patches/4.8-linaro/800-arm_v5te_no_ldrd_strd.patch rename to toolchain/gcc/patches/6.3.0/800-arm_v5te_no_ldrd_strd.patch index efa9789c677..2e7c23f8513 100644 --- a/toolchain/gcc/patches/4.8-linaro/800-arm_v5te_no_ldrd_strd.patch +++ b/toolchain/gcc/patches/6.3.0/800-arm_v5te_no_ldrd_strd.patch @@ -1,6 +1,6 @@ --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h -@@ -277,7 +277,7 @@ extern void (*arm_lang_output_object_att +@@ -166,7 +166,7 @@ extern void (*arm_lang_output_object_att /* Thumb-1 only. */ #define TARGET_THUMB1_ONLY (TARGET_THUMB1 && !arm_arch_notm) diff --git a/toolchain/gcc/patches/4.8-linaro/810-arm-softfloat-libgcc.patch b/toolchain/gcc/patches/6.3.0/810-arm-softfloat-libgcc.patch similarity index 97% rename from toolchain/gcc/patches/4.8-linaro/810-arm-softfloat-libgcc.patch rename to toolchain/gcc/patches/6.3.0/810-arm-softfloat-libgcc.patch index 33cf8add30d..1d06f5b2ec0 100644 --- a/toolchain/gcc/patches/4.8-linaro/810-arm-softfloat-libgcc.patch +++ b/toolchain/gcc/patches/6.3.0/810-arm-softfloat-libgcc.patch @@ -14,7 +14,7 @@ # difference. --- a/gcc/config/arm/linux-elf.h +++ b/gcc/config/arm/linux-elf.h -@@ -55,8 +55,6 @@ +@@ -60,8 +60,6 @@ %{shared:-lc} \ %{!shared:%{profile:-lc_p}%{!profile:-lc}}" diff --git a/toolchain/gcc/patches/4.9-linaro/820-libgcc_pic.patch b/toolchain/gcc/patches/6.3.0/820-libgcc_pic.patch similarity index 84% rename from toolchain/gcc/patches/4.9-linaro/820-libgcc_pic.patch rename to toolchain/gcc/patches/6.3.0/820-libgcc_pic.patch index ebd87f58260..f925d96f66f 100644 --- a/toolchain/gcc/patches/4.9-linaro/820-libgcc_pic.patch +++ b/toolchain/gcc/patches/6.3.0/820-libgcc_pic.patch @@ -1,6 +1,6 @@ --- a/libgcc/Makefile.in +++ b/libgcc/Makefile.in -@@ -881,11 +881,12 @@ $(libgcov-driver-objects): %$(objext): $ +@@ -888,11 +888,12 @@ $(libgcov-driver-objects): %$(objext): $ # Static libraries. libgcc.a: $(libgcc-objects) @@ -14,7 +14,7 @@ -rm -f $@ objects="$(objects)"; \ -@@ -907,7 +908,7 @@ libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_E +@@ -913,7 +914,7 @@ all: libunwind.a endif ifeq ($(enable_shared),yes) @@ -22,8 +22,8 @@ +all: libgcc_eh.a libgcc_pic.a libgcc_s$(SHLIB_EXT) ifneq ($(LIBUNWIND),) all: libunwind$(SHLIB_EXT) - endif -@@ -1090,6 +1091,10 @@ install-shared: + libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_EXT) +@@ -1115,6 +1116,10 @@ install-shared: chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a diff --git a/toolchain/gcc/patches/4.9-linaro/830-arm_unbreak_armv4t.patch b/toolchain/gcc/patches/6.3.0/830-arm_unbreak_armv4t.patch similarity index 100% rename from toolchain/gcc/patches/4.9-linaro/830-arm_unbreak_armv4t.patch rename to toolchain/gcc/patches/6.3.0/830-arm_unbreak_armv4t.patch diff --git a/toolchain/gcc/patches/4.8-linaro/840-armv4_pass_fix-v4bx_to_ld.patch b/toolchain/gcc/patches/6.3.0/840-armv4_pass_fix-v4bx_to_ld.patch similarity index 87% rename from toolchain/gcc/patches/4.8-linaro/840-armv4_pass_fix-v4bx_to_ld.patch rename to toolchain/gcc/patches/6.3.0/840-armv4_pass_fix-v4bx_to_ld.patch index 2283b83c5f2..cb1fb982356 100644 --- a/toolchain/gcc/patches/4.8-linaro/840-armv4_pass_fix-v4bx_to_ld.patch +++ b/toolchain/gcc/patches/6.3.0/840-armv4_pass_fix-v4bx_to_ld.patch @@ -12,8 +12,8 @@ /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to use the GNU/Linux version, not the generic BPABI version. */ #undef LINK_SPEC --#define LINK_SPEC BE8_LINK_SPEC \ -+#define LINK_SPEC BE8_LINK_SPEC TARGET_FIX_V4BX_SPEC \ +-#define LINK_SPEC EABI_LINK_SPEC \ ++#define LINK_SPEC EABI_LINK_SPEC TARGET_FIX_V4BX_SPEC \ LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC, \ LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC) diff --git a/toolchain/gcc/patches/6.3.0/850-use_shared_libgcc.patch b/toolchain/gcc/patches/6.3.0/850-use_shared_libgcc.patch new file mode 100644 index 00000000000..cd20244c690 --- /dev/null +++ b/toolchain/gcc/patches/6.3.0/850-use_shared_libgcc.patch @@ -0,0 +1,47 @@ +--- a/gcc/config/arm/linux-eabi.h ++++ b/gcc/config/arm/linux-eabi.h +@@ -132,10 +132,6 @@ + "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} " \ + LINUX_OR_ANDROID_LD (GNU_USER_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC) + +-/* Use the default LIBGCC_SPEC, not the version in linux-elf.h, as we +- do not use -lfloat. */ +-#undef LIBGCC_SPEC +- + /* Clear the instruction cache from `beg' to `end'. This is + implemented in lib1funcs.S, so ensure an error if this definition + is used. */ +--- a/gcc/config/linux.h ++++ b/gcc/config/linux.h +@@ -53,6 +53,10 @@ see the files COPYING3 and COPYING.RUNTI + builtin_assert ("system=posix"); \ + } while (0) + ++#ifndef LIBGCC_SPEC ++#define LIBGCC_SPEC "%{static|static-libgcc:-lgcc}%{!static:%{!static-libgcc:-lgcc_s}}" ++#endif ++ + /* Determine which dynamic linker to use depending on whether GLIBC or + uClibc or Bionic or musl is the default C library and whether + -muclibc or -mglibc or -mbionic or -mmusl has been passed to change +--- a/libgcc/mkmap-symver.awk ++++ b/libgcc/mkmap-symver.awk +@@ -132,5 +132,5 @@ function output(lib) { + else if (inherit[lib]) + printf("} %s;\n", inherit[lib]); + else +- printf ("\n local:\n\t*;\n};\n"); ++ printf ("\n\t*;\n};\n"); + } +--- a/gcc/config/rs6000/linux.h ++++ b/gcc/config/rs6000/linux.h +@@ -60,6 +60,9 @@ + #undef CPP_OS_DEFAULT_SPEC + #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)" + ++#undef LIBGCC_SPEC ++#define LIBGCC_SPEC "%{!static:%{!static-libgcc:-lgcc_s}} -lgcc" ++ + #undef LINK_SHLIB_SPEC + #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}" + diff --git a/toolchain/gcc/patches/4.9-linaro/851-libgcc_no_compat.patch b/toolchain/gcc/patches/6.3.0/851-libgcc_no_compat.patch similarity index 100% rename from toolchain/gcc/patches/4.9-linaro/851-libgcc_no_compat.patch rename to toolchain/gcc/patches/6.3.0/851-libgcc_no_compat.patch diff --git a/toolchain/gcc/patches/6.3.0/870-ppc_no_crtsavres.patch b/toolchain/gcc/patches/6.3.0/870-ppc_no_crtsavres.patch new file mode 100644 index 00000000000..9e543a0fc20 --- /dev/null +++ b/toolchain/gcc/patches/6.3.0/870-ppc_no_crtsavres.patch @@ -0,0 +1,11 @@ +--- a/gcc/config/rs6000/rs6000.c ++++ b/gcc/config/rs6000/rs6000.c +@@ -24171,7 +24171,7 @@ rs6000_savres_strategy (rs6000_stack_t * + /* Define cutoff for using out-of-line functions to save registers. */ + if (DEFAULT_ABI == ABI_V4 || TARGET_ELF) + { +- if (!optimize_size) ++ if (1) + { + strategy |= SAVE_INLINE_FPRS | REST_INLINE_FPRS; + strategy |= SAVE_INLINE_GPRS | REST_INLINE_GPRS; diff --git a/toolchain/gcc/patches/4.6-linaro/880-no_java_section.patch b/toolchain/gcc/patches/6.3.0/880-no_java_section.patch similarity index 86% rename from toolchain/gcc/patches/4.6-linaro/880-no_java_section.patch rename to toolchain/gcc/patches/6.3.0/880-no_java_section.patch index 404b7d31f74..0fa9e627c2a 100644 --- a/toolchain/gcc/patches/4.6-linaro/880-no_java_section.patch +++ b/toolchain/gcc/patches/6.3.0/880-no_java_section.patch @@ -1,6 +1,6 @@ --- a/gcc/defaults.h +++ b/gcc/defaults.h -@@ -383,7 +383,7 @@ see the files COPYING3 and COPYING.RUNTI +@@ -395,7 +395,7 @@ see the files COPYING3 and COPYING.RUNTI /* If we have named section and we support weak symbols, then use the .jcr section for recording java classes which need to be registered at program start-up time. */ diff --git a/toolchain/gcc/patches/6.3.0/881-no_tm_section.patch b/toolchain/gcc/patches/6.3.0/881-no_tm_section.patch new file mode 100644 index 00000000000..fab5db3be55 --- /dev/null +++ b/toolchain/gcc/patches/6.3.0/881-no_tm_section.patch @@ -0,0 +1,11 @@ +--- a/libgcc/crtstuff.c ++++ b/libgcc/crtstuff.c +@@ -152,7 +152,7 @@ call_ ## FUNC (void) \ + #endif + + #if !defined(USE_TM_CLONE_REGISTRY) && defined(OBJECT_FORMAT_ELF) +-# define USE_TM_CLONE_REGISTRY 1 ++# define USE_TM_CLONE_REGISTRY 0 + #endif + + /* We do not want to add the weak attribute to the declarations of these diff --git a/toolchain/gcc/patches/4.9-linaro/900-bad-mips16-crt.patch b/toolchain/gcc/patches/6.3.0/900-bad-mips16-crt.patch similarity index 100% rename from toolchain/gcc/patches/4.9-linaro/900-bad-mips16-crt.patch rename to toolchain/gcc/patches/6.3.0/900-bad-mips16-crt.patch diff --git a/toolchain/gcc/patches/4.6-linaro/910-mbsd_multi.patch b/toolchain/gcc/patches/6.3.0/910-mbsd_multi.patch similarity index 62% rename from toolchain/gcc/patches/4.6-linaro/910-mbsd_multi.patch rename to toolchain/gcc/patches/6.3.0/910-mbsd_multi.patch index 51bbc7f2bcf..b747935f0f8 100644 --- a/toolchain/gcc/patches/4.6-linaro/910-mbsd_multi.patch +++ b/toolchain/gcc/patches/6.3.0/910-mbsd_multi.patch @@ -10,36 +10,23 @@ to be able to use -Werror in "make" but prevent GNU autoconf generated configure scripts from freaking out. - * Make -fno-strict-aliasing and -fno-delete-null-pointer-checks - the default for -O2/-Os, because they trigger gcc bugs - and can delete code with security implications. This patch was authored by Thorsten Glaser with copyright assignment to the FSF in effect. --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c -@@ -103,6 +103,9 @@ static size_t deferred_count; - /* Number of deferred options scanned for -include. */ - static size_t include_cursor; +@@ -107,6 +107,9 @@ static int class_dump_flags; + /* Whether any standard preincluded header has been preincluded. */ + static bool done_preinclude; +/* Check if a port honours COPTS. */ +static int honour_copts = 0; + static void handle_OPT_d (const char *); static void set_std_cxx98 (int); - static void set_std_cxx0x (int); -@@ -441,6 +444,9 @@ c_common_handle_option (size_t scode, co - global_dc->warning_as_error_requested = value; - break; - -+ case OPT_Werror_maybe_reset: -+ break; -+ - case OPT_Wformat: - set_Wformat (value); - break; -@@ -584,6 +590,12 @@ c_common_handle_option (size_t scode, co + static void set_std_cxx11 (int); +@@ -442,6 +445,12 @@ c_common_handle_option (size_t scode, co flag_no_builtin = !value; break; @@ -52,7 +39,7 @@ case OPT_fconstant_string_class_: constant_string_class_name = arg; break; -@@ -1058,6 +1070,47 @@ c_common_init (void) +@@ -1041,6 +1050,47 @@ c_common_init (void) return false; } @@ -102,9 +89,9 @@ --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt -@@ -363,6 +363,10 @@ Werror-implicit-function-declaration - C ObjC RejectNegative Warning Alias(Werror=, implicit-function-declaration) - This switch is deprecated; use -Werror=implicit-function-declaration instead +@@ -438,6 +438,10 @@ Wfloat-conversion + C ObjC C++ ObjC++ Var(warn_float_conversion) Warning LangEnabledBy(C ObjC C++ ObjC++,Wconversion) + Warn for implicit type conversions that cause loss of floating point precision. +Werror-maybe-reset +C ObjC C++ ObjC++ @@ -112,8 +99,8 @@ + Wfloat-equal C ObjC C++ ObjC++ Var(warn_float_equal) Warning - Warn if testing floating point numbers for equality -@@ -794,6 +798,9 @@ C++ ObjC++ Optimization Alias(fexception + Warn if testing floating point numbers for equality. +@@ -1252,6 +1256,9 @@ C++ ObjC++ Optimization Alias(fexception fhonor-std C++ ObjC++ Ignore Warn(switch %qs is no longer supported) @@ -122,12 +109,12 @@ + fhosted C ObjC - Assume normal C execution environment + Assume normal C execution environment. --- a/gcc/common.opt +++ b/gcc/common.opt -@@ -520,6 +520,10 @@ Werror= +@@ -581,6 +581,10 @@ Werror= Common Joined - Treat specified warning as error + Treat specified warning as error. +Werror-maybe-reset +Common @@ -135,10 +122,10 @@ + Wextra Common Var(extra_warnings) Warning - Print extra (possibly unwanted) warnings -@@ -1156,6 +1160,9 @@ fguess-branch-probability + Print extra (possibly unwanted) warnings. +@@ -1432,6 +1436,9 @@ fguess-branch-probability Common Report Var(flag_guess_branch_prob) Optimization - Enable guessing of branch probabilities + Enable guessing of branch probabilities. +fhonour-copts +Common RejectNegative @@ -148,25 +135,7 @@ ; On SVR4 targets, it also controls whether or not to emit a --- a/gcc/opts.c +++ b/gcc/opts.c -@@ -477,8 +477,6 @@ static const struct default_options defa - { OPT_LEVELS_2_PLUS, OPT_fschedule_insns2, NULL, 1 }, - #endif - { OPT_LEVELS_2_PLUS, OPT_fregmove, NULL, 1 }, -- { OPT_LEVELS_2_PLUS, OPT_fstrict_aliasing, NULL, 1 }, -- { OPT_LEVELS_2_PLUS, OPT_fstrict_overflow, NULL, 1 }, - { OPT_LEVELS_2_PLUS, OPT_freorder_blocks, NULL, 1 }, - { OPT_LEVELS_2_PLUS, OPT_freorder_functions, NULL, 1 }, - { OPT_LEVELS_2_PLUS, OPT_ftree_vrp, NULL, 1 }, -@@ -494,6 +492,8 @@ static const struct default_options defa - { OPT_LEVELS_2_PLUS, OPT_falign_functions, NULL, 1 }, - - /* -O3 optimizations. */ -+ { OPT_LEVELS_3_PLUS, OPT_fstrict_aliasing, NULL, 1 }, -+ { OPT_LEVELS_3_PLUS, OPT_fstrict_overflow, NULL, 1 }, - { OPT_LEVELS_3_PLUS, OPT_ftree_loop_distribute_patterns, NULL, 1 }, - { OPT_LEVELS_3_PLUS, OPT_fpredictive_commoning, NULL, 1 }, - /* Inlining of functions reducing size is a good idea with -Os -@@ -1405,6 +1405,17 @@ common_handle_option (struct gcc_options +@@ -1783,6 +1783,17 @@ common_handle_option (struct gcc_options opts, opts_set, loc, dc); break; @@ -186,12 +155,12 @@ opts->x_warn_larger_than = value != -1; --- a/gcc/doc/cppopts.texi +++ b/gcc/doc/cppopts.texi -@@ -164,6 +164,11 @@ in older programs. This warning is on b +@@ -163,6 +163,11 @@ in older programs. This warning is on b Make all warnings into hard errors. Source code which triggers warnings will be rejected. -+ at item -Werror-maybe-reset -+ at opindex Werror-maybe-reset ++@item -Werror-maybe-reset ++@opindex Werror-maybe-reset +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment +variable is set to anything other than 0 or empty. + @@ -200,26 +169,26 @@ Issue warnings for code in system headers. These are normally unhelpful --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi -@@ -240,7 +240,7 @@ Objective-C and Objective-C++ Dialects}. - -Wconversion -Wcoverage-mismatch -Wno-cpp -Wno-deprecated @gol - -Wno-deprecated-declarations -Wdisabled-optimization @gol - -Wno-div-by-zero -Wdouble-promotion -Wempty-body -Wenum-compare @gol ---Wno-endif-labels -Werror -Werror=* @gol -+-Wno-endif-labels -Werror -Werror=* -Werror-maybe-reset @gol - -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol +@@ -263,7 +263,7 @@ Objective-C and Objective-C++ Dialects}. + -Wno-discarded-qualifiers -Wno-discarded-array-qualifiers @gol + -Wno-div-by-zero -Wdouble-promotion -Wduplicated-cond @gol + -Wempty-body -Wenum-compare -Wno-endif-labels @gol +--Werror -Werror=* -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol ++-Werror -Werror=* -Werror-maybe-reset -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral @gol - -Wformat-security -Wformat-y2k @gol -@@ -4498,6 +4498,22 @@ This option is only supported for C and - @option{-Wall} and by @option{-pedantic}, which can be disabled with + -Wformat-security -Wformat-signedness -Wformat-y2k -Wframe-address @gol + -Wframe-larger-than=@var{len} -Wno-free-nonheap-object -Wjump-misses-init @gol +@@ -5737,6 +5737,22 @@ This option is only supported for C and + @option{-Wall} and by @option{-Wpedantic}, which can be disabled with @option{-Wno-pointer-sign}. -+ at item -Werror-maybe-reset -+ at opindex Werror-maybe-reset ++@item -Werror-maybe-reset ++@opindex Werror-maybe-reset +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment +variable is set to anything other than 0 or empty. + -+ at item -fhonour-copts -+ at opindex fhonour-copts ++@item -fhonour-copts ++@opindex fhonour-copts +If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not +given at least once, and warn if it is given more than once. +If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not @@ -232,7 +201,7 @@ @item -Wstack-protector @opindex Wstack-protector @opindex Wno-stack-protector -@@ -6317,7 +6333,7 @@ so, the first branch is redirected to ei +@@ -6605,7 +6621,7 @@ so, the first branch is redirected to ei second branch or a point immediately following it, depending on whether the condition is known to be true or false. @@ -243,7 +212,7 @@ @opindex fsplit-wide-types --- a/gcc/java/jvspec.c +++ b/gcc/java/jvspec.c -@@ -627,6 +627,7 @@ lang_specific_pre_link (void) +@@ -629,6 +629,7 @@ lang_specific_pre_link (void) class name. Append dummy `.c' that can be stripped by set_input so %b is correct. */ set_input (concat (main_class_name, "main.c", NULL)); diff --git a/toolchain/gcc/patches/6.3.0/920-specs_nonfatal_getenv.patch b/toolchain/gcc/patches/6.3.0/920-specs_nonfatal_getenv.patch new file mode 100644 index 00000000000..dc0acb95a8e --- /dev/null +++ b/toolchain/gcc/patches/6.3.0/920-specs_nonfatal_getenv.patch @@ -0,0 +1,15 @@ +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -9198,8 +9198,10 @@ getenv_spec_function (int argc, const ch + value = varname; + + if (!value) +- fatal_error (input_location, +- "environment variable %qs not defined", varname); ++ { ++ warning (input_location, "environment variable %qs not defined", varname); ++ value = ""; ++ } + + /* We have to escape every character of the environment variable so + they are not interpreted as active spec characters. A diff --git a/toolchain/gcc/patches/4.8-linaro/930-fix-mips-noexecstack.patch b/toolchain/gcc/patches/6.3.0/930-fix-mips-noexecstack.patch similarity index 93% rename from toolchain/gcc/patches/4.8-linaro/930-fix-mips-noexecstack.patch rename to toolchain/gcc/patches/6.3.0/930-fix-mips-noexecstack.patch index e72ed3a4cfd..2a99840b636 100644 --- a/toolchain/gcc/patches/4.8-linaro/930-fix-mips-noexecstack.patch +++ b/toolchain/gcc/patches/6.3.0/930-fix-mips-noexecstack.patch @@ -48,9 +48,9 @@ sellcey@mips.com --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c -@@ -18223,6 +18223,9 @@ mips_expand_vec_minmax (rtx target, rtx - #undef TARGET_VECTORIZE_VEC_PERM_CONST_OK - #define TARGET_VECTORIZE_VEC_PERM_CONST_OK mips_vectorize_vec_perm_const_ok +@@ -20228,6 +20228,9 @@ mips_promote_function_mode (const_tree t + #undef TARGET_HARD_REGNO_SCRATCH_OK + #define TARGET_HARD_REGNO_SCRATCH_OK mips_hard_regno_scratch_ok +#undef TARGET_ASM_FILE_END +#define TARGET_ASM_FILE_END file_end_indicate_exec_stack @@ -85,7 +85,7 @@ sellcey@mips.com --- a/libgcc/config/mips/mips16.S +++ b/libgcc/config/mips/mips16.S -@@ -27,6 +27,10 @@ see the files COPYING3 and COPYING.RUNTI +@@ -48,6 +48,10 @@ see the files COPYING3 and COPYING.RUNTI values using the soft-float calling convention, but do the actual operation using the hard floating point instructions. */ diff --git a/toolchain/gcc/patches/4.9-linaro/940-no-clobber-stamp-bits.patch b/toolchain/gcc/patches/6.3.0/940-no-clobber-stamp-bits.patch similarity index 87% rename from toolchain/gcc/patches/4.9-linaro/940-no-clobber-stamp-bits.patch rename to toolchain/gcc/patches/6.3.0/940-no-clobber-stamp-bits.patch index 32417942af6..68e62865b12 100644 --- a/toolchain/gcc/patches/4.9-linaro/940-no-clobber-stamp-bits.patch +++ b/toolchain/gcc/patches/6.3.0/940-no-clobber-stamp-bits.patch @@ -1,6 +1,6 @@ --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in -@@ -1366,7 +1366,7 @@ stamp-bits: ${bits_headers} +@@ -1459,7 +1459,7 @@ stamp-bits: ${bits_headers} @$(STAMP) stamp-bits stamp-bits-sup: stamp-bits ${bits_sup_headers} diff --git a/toolchain/gcc/patches/6.3.0/950-cpp_file_path_translation.patch b/toolchain/gcc/patches/6.3.0/950-cpp_file_path_translation.patch new file mode 100644 index 00000000000..d467eb7c9a1 --- /dev/null +++ b/toolchain/gcc/patches/6.3.0/950-cpp_file_path_translation.patch @@ -0,0 +1,182 @@ +Forward ported from attachment to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47047 + +--- a/gcc/c-family/c-opts.c ++++ b/gcc/c-family/c-opts.c +@@ -574,6 +574,10 @@ c_common_handle_option (size_t scode, co + add_path (xstrdup (arg), SYSTEM, 0, true); + break; + ++ case OPT_iremap: ++ add_cpp_remap_path (arg); ++ break; ++ + case OPT_iwithprefix: + add_prefixed_path (arg, SYSTEM); + break; +--- a/gcc/c-family/c.opt ++++ b/gcc/c-family/c.opt +@@ -1632,6 +1632,10 @@ iquote + C ObjC C++ ObjC++ Joined Separate MissingArgError(missing path after %qs) + -iquote Add to the end of the quote include path. + ++iremap ++C ObjC C++ ObjC++ Joined Separate ++-iremap Convert to if it occurs as prefix in __FILE__. ++ + iwithprefix + C ObjC C++ ObjC++ Joined Separate + -iwithprefix Add to the end of the system include path. +--- a/gcc/doc/cpp.texi ++++ b/gcc/doc/cpp.texi +@@ -4444,6 +4444,7 @@ without notice. + @c man begin SYNOPSIS + cpp [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}] + [@option{-I}@var{dir}@dots{}] [@option{-iquote}@var{dir}@dots{}] ++ [@option{-iremap}@var{src}:@var{dst}] + [@option{-W}@var{warn}@dots{}] + [@option{-M}|@option{-MM}] [@option{-MG}] [@option{-MF} @var{filename}] + [@option{-MP}] [@option{-MQ} @var{target}@dots{}] +--- a/gcc/doc/cppopts.texi ++++ b/gcc/doc/cppopts.texi +@@ -532,6 +532,12 @@ Search @var{dir} only for header files r + If @var{dir} begins with @code{=}, then the @code{=} will be replaced + by the sysroot prefix; see @option{--sysroot} and @option{-isysroot}. + ++@item -iremap @var{src}:@var{dst} ++@opindex iremap ++Replace the prefix @var{src} in __FILE__ with @var{dst} at expansion time. ++This option can be specified more than once. Processing stops at the first ++match. ++ + @item -fdirectives-only + @opindex fdirectives-only + When preprocessing, handle directives, but do not expand macros. +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -476,8 +476,8 @@ Objective-C and Objective-C++ Dialects}. + @item Directory Options + @xref{Directory Options,,Options for Directory Search}. + @gccoptlist{-B@var{prefix} -I@var{dir} -iplugindir=@var{dir} @gol +--iquote@var{dir} -L@var{dir} -no-canonical-prefixes -I- @gol +---sysroot=@var{dir} --no-sysroot-suffix} ++-iquote@var{dir} -iremap@var{src}:@var{dst} -L@var{dir} -no-canonical-prefixes @gol ++-I- --sysroot=@var{dir} --no-sysroot-suffix} + + @item Code Generation Options + @xref{Code Gen Options,,Options for Code Generation Conventions}. +@@ -10861,6 +10861,12 @@ be searched for header files only for th + "@var{file}"}; they are not searched for @code{#include <@var{file}>}, + otherwise just like @option{-I}. + ++@item -iremap @var{src}:@var{dst} ++@opindex iremap ++Replace the prefix @var{src} in __FILE__ with @var{dst} at expansion time. ++This option can be specified more than once. Processing stops at the first ++match. ++ + @item -L@var{dir} + @opindex L + Add directory @var{dir} to the list of directories to be searched +--- a/libcpp/include/cpplib.h ++++ b/libcpp/include/cpplib.h +@@ -760,6 +760,9 @@ extern void cpp_set_lang (cpp_reader *, + /* Set the include paths. */ + extern void cpp_set_include_chains (cpp_reader *, cpp_dir *, cpp_dir *, int); + ++/* Provide src:dst pair for __FILE__ remapping. */ ++extern void add_cpp_remap_path (const char *); ++ + /* Call these to get pointers to the options, callback, and deps + structures for a given reader. These pointers are good until you + call cpp_finish on that reader. You can either edit the callbacks +--- a/libcpp/macro.c ++++ b/libcpp/macro.c +@@ -227,6 +227,64 @@ static const char * const monthnames[] = + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }; + ++static size_t remap_pairs; ++static char **remap_src; ++static char **remap_dst; ++ ++void ++add_cpp_remap_path (const char *arg) ++{ ++ const char *arg_dst; ++ size_t len; ++ ++ arg_dst = strchr(arg, ':'); ++ if (arg_dst == NULL) ++ { ++ fprintf(stderr, "Invalid argument for -iremap\n"); ++ exit(1); ++ } ++ ++ len = arg_dst - arg; ++ ++arg_dst; ++ ++ remap_src = (char **) xrealloc(remap_src, sizeof(char *) * (remap_pairs + 1)); ++ remap_dst = (char **) xrealloc(remap_dst, sizeof(char *) * (remap_pairs + 1)); ++ ++ remap_src[remap_pairs] = (char *) xmalloc(len + 1); ++ memcpy(remap_src[remap_pairs], arg, len); ++ remap_src[remap_pairs][len] = '\0'; ++ remap_dst[remap_pairs] = xstrdup(arg_dst); ++ ++remap_pairs; ++} ++ ++static const char * ++cpp_remap_file (const char *arg, char **tmp_name) ++{ ++ char *result; ++ size_t i, len; ++ ++ for (i = 0; i < remap_pairs; ++i) ++ { ++ len = strlen (remap_src[i]); ++ if (strncmp (remap_src[i], arg, len)) ++ continue; ++ if (arg[len] == '\0') ++ return xstrdup (remap_dst[i]); ++ if (arg[len] != '/') ++ continue; ++ arg += len; ++ len = strlen (remap_dst[i]); ++ result = (char *) xmalloc (len + strlen (arg) + 1); ++ memcpy(result, remap_dst[i], len); ++ strcpy(result + len, arg); ++ *tmp_name = result; ++ ++ return result; ++ } ++ ++ return arg; ++} ++ + /* Helper function for builtin_macro. Returns the text generated by + a builtin macro. */ + const uchar * +@@ -290,6 +348,7 @@ _cpp_builtin_macro_text (cpp_reader *pfi + { + unsigned int len; + const char *name; ++ char *tmp_name = NULL; + uchar *buf; + + if (node->value.builtin == BT_FILE) +@@ -301,6 +360,7 @@ _cpp_builtin_macro_text (cpp_reader *pfi + if (!name) + abort (); + } ++ name = cpp_remap_file (name, &tmp_name); + len = strlen (name); + buf = _cpp_unaligned_alloc (pfile, len * 2 + 3); + result = buf; +@@ -308,6 +368,7 @@ _cpp_builtin_macro_text (cpp_reader *pfi + buf = cpp_quote_string (buf + 1, (const unsigned char *) name, len); + *buf++ = '"'; + *buf = '\0'; ++ free (tmp_name); + } + break; + diff --git a/toolchain/gcc/patches/6.3.0/960-fix-ubsan-defref.patch b/toolchain/gcc/patches/6.3.0/960-fix-ubsan-defref.patch new file mode 100644 index 00000000000..72d86c14984 --- /dev/null +++ b/toolchain/gcc/patches/6.3.0/960-fix-ubsan-defref.patch @@ -0,0 +1,11 @@ +--- a/gcc/ubsan.c ++++ b/gcc/ubsan.c +@@ -1471,7 +1471,7 @@ ubsan_use_new_style_p (location_t loc) + + expanded_location xloc = expand_location (loc); + if (xloc.file == NULL || strncmp (xloc.file, "\1", 2) == 0 +- || xloc.file == '\0' || xloc.file[0] == '\xff' ++ || xloc.file[0] == '\0' || xloc.file[0] == '\xff' + || xloc.file[1] == '\xff') + return false; + diff --git a/toolchain/gcc/patches/4.8-linaro/001-revert_register_mode_search.patch b/toolchain/gcc/patches/arc-2016.03/001-revert_register_mode_search.patch similarity index 100% rename from toolchain/gcc/patches/4.8-linaro/001-revert_register_mode_search.patch rename to toolchain/gcc/patches/arc-2016.03/001-revert_register_mode_search.patch diff --git a/toolchain/gcc/patches/4.8-linaro/002-weak_data_fix.patch b/toolchain/gcc/patches/arc-2016.03/002-weak_data_fix.patch similarity index 100% rename from toolchain/gcc/patches/4.8-linaro/002-weak_data_fix.patch rename to toolchain/gcc/patches/arc-2016.03/002-weak_data_fix.patch diff --git a/toolchain/gcc/patches/4.8-linaro/003-universal_initializer.patch b/toolchain/gcc/patches/arc-2016.03/003-universal_initializer.patch similarity index 100% rename from toolchain/gcc/patches/4.8-linaro/003-universal_initializer.patch rename to toolchain/gcc/patches/arc-2016.03/003-universal_initializer.patch diff --git a/toolchain/gcc/patches/arc-2016.03/004-case_insensitive.patch b/toolchain/gcc/patches/arc-2016.03/004-case_insensitive.patch new file mode 100644 index 00000000000..b3d2dbe291f --- /dev/null +++ b/toolchain/gcc/patches/arc-2016.03/004-case_insensitive.patch @@ -0,0 +1,14 @@ +--- a/include/filenames.h ++++ b/include/filenames.h +@@ -43,11 +43,6 @@ extern "C" { + # define IS_DIR_SEPARATOR(c) IS_DOS_DIR_SEPARATOR (c) + # define IS_ABSOLUTE_PATH(f) IS_DOS_ABSOLUTE_PATH (f) + #else /* not DOSish */ +-# if defined(__APPLE__) +-# ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM +-# define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1 +-# endif +-# endif /* __APPLE__ */ + # define HAS_DRIVE_SPEC(f) (0) + # define IS_DIR_SEPARATOR(c) IS_UNIX_DIR_SEPARATOR (c) + # define IS_ABSOLUTE_PATH(f) IS_UNIX_ABSOLUTE_PATH (f) diff --git a/toolchain/gcc/patches/4.8-linaro/010-documentation.patch b/toolchain/gcc/patches/arc-2016.03/010-documentation.patch similarity index 100% rename from toolchain/gcc/patches/4.8-linaro/010-documentation.patch rename to toolchain/gcc/patches/arc-2016.03/010-documentation.patch diff --git a/toolchain/gcc/patches/4.8-linaro/020-no-plt-backport.patch b/toolchain/gcc/patches/arc-2016.03/020-no-plt-backport.patch similarity index 100% rename from toolchain/gcc/patches/4.8-linaro/020-no-plt-backport.patch rename to toolchain/gcc/patches/arc-2016.03/020-no-plt-backport.patch diff --git a/toolchain/gcc/patches/4.8-linaro/210-disable_libsanitizer_off_t_check.patch b/toolchain/gcc/patches/arc-2016.03/210-disable_libsanitizer_off_t_check.patch similarity index 100% rename from toolchain/gcc/patches/4.8-linaro/210-disable_libsanitizer_off_t_check.patch rename to toolchain/gcc/patches/arc-2016.03/210-disable_libsanitizer_off_t_check.patch diff --git a/toolchain/gcc/patches/arc-2016.03/800-arc-disablelibgmon.patch b/toolchain/gcc/patches/arc-2016.03/800-arc-disablelibgmon.patch new file mode 100644 index 00000000000..612883c98cf --- /dev/null +++ b/toolchain/gcc/patches/arc-2016.03/800-arc-disablelibgmon.patch @@ -0,0 +1,18 @@ +diff --git a/libgcc/config.host b/libgcc/config.host +index e768389..aec10c7 100644 +--- a/libgcc/config.host ++++ b/libgcc/config.host +@@ -320,11 +320,11 @@ alpha*-dec-*vms*) + ;; + arc*-*-elf*) + tmake_file="arc/t-arc-newlib arc/t-arc" +- extra_parts="crti.o crtn.o crtend.o crtbegin.o crtendS.o crtbeginS.o libgmon.a crtg.o crtgend.o crttls_r25.o crttls_r30.o" ++ extra_parts="crti.o crtn.o crtend.o crtbegin.o crtendS.o crtbeginS.o crtg.o crtgend.o crttls_r25.o crttls_r30.o" + ;; + arc*-*-linux-uclibc*) + tmake_file="${tmake_file} t-slibgcc-libgcc t-slibgcc-nolc-override arc/t-arc700-uClibc arc/t-arc" +- extra_parts="crti.o crtn.o crtend.o crtbegin.o crtendS.o crtbeginS.o libgmon.a crtg.o crtgend.o" ++ extra_parts="crti.o crtn.o crtend.o crtbegin.o crtendS.o crtbeginS.o crtg.o crtgend.o" + ;; + arm-wrs-vxworks) + tmake_file="$tmake_file arm/t-arm arm/t-vxworks t-softfp-sfdf t-softfp-excl arm/t-softfp t-softfp" diff --git a/toolchain/gcc/patches/4.8-linaro/820-libgcc_pic.patch b/toolchain/gcc/patches/arc-2016.03/820-libgcc_pic.patch similarity index 100% rename from toolchain/gcc/patches/4.8-linaro/820-libgcc_pic.patch rename to toolchain/gcc/patches/arc-2016.03/820-libgcc_pic.patch diff --git a/toolchain/gcc/patches/4.8-linaro/850-use_shared_libgcc.patch b/toolchain/gcc/patches/arc-2016.03/850-use_shared_libgcc.patch similarity index 100% rename from toolchain/gcc/patches/4.8-linaro/850-use_shared_libgcc.patch rename to toolchain/gcc/patches/arc-2016.03/850-use_shared_libgcc.patch diff --git a/toolchain/gcc/patches/arc-2016.03/851-libgcc_no_compat.patch b/toolchain/gcc/patches/arc-2016.03/851-libgcc_no_compat.patch new file mode 100644 index 00000000000..80c34768414 --- /dev/null +++ b/toolchain/gcc/patches/arc-2016.03/851-libgcc_no_compat.patch @@ -0,0 +1,12 @@ +--- a/libgcc/config/t-libunwind ++++ b/libgcc/config/t-libunwind +@@ -2,8 +2,7 @@ + + HOST_LIBGCC2_CFLAGS += -DUSE_GAS_SYMVER + +-LIB2ADDEH = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c \ +- $(srcdir)/unwind-compat.c $(srcdir)/unwind-dw2-fde-compat.c ++LIB2ADDEH = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c + LIB2ADDEHSTATIC = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c + + # Override the default value from t-slibgcc-elf-ver and mention -lunwind diff --git a/toolchain/gcc/patches/4.8-linaro/860-use_eh_frame.patch b/toolchain/gcc/patches/arc-2016.03/860-use_eh_frame.patch similarity index 100% rename from toolchain/gcc/patches/4.8-linaro/860-use_eh_frame.patch rename to toolchain/gcc/patches/arc-2016.03/860-use_eh_frame.patch diff --git a/toolchain/gcc/patches/4.8-linaro/870-ppc_no_crtsavres.patch b/toolchain/gcc/patches/arc-2016.03/870-ppc_no_crtsavres.patch similarity index 100% rename from toolchain/gcc/patches/4.8-linaro/870-ppc_no_crtsavres.patch rename to toolchain/gcc/patches/arc-2016.03/870-ppc_no_crtsavres.patch diff --git a/toolchain/gcc/patches/4.9-linaro/880-no_java_section.patch b/toolchain/gcc/patches/arc-2016.03/880-no_java_section.patch similarity index 100% rename from toolchain/gcc/patches/4.9-linaro/880-no_java_section.patch rename to toolchain/gcc/patches/arc-2016.03/880-no_java_section.patch diff --git a/toolchain/gcc/patches/4.8-linaro/910-mbsd_multi.patch b/toolchain/gcc/patches/arc-2016.03/910-mbsd_multi.patch similarity index 100% rename from toolchain/gcc/patches/4.8-linaro/910-mbsd_multi.patch rename to toolchain/gcc/patches/arc-2016.03/910-mbsd_multi.patch diff --git a/toolchain/gcc/patches/4.8-linaro/920-specs_nonfatal_getenv.patch b/toolchain/gcc/patches/arc-2016.03/920-specs_nonfatal_getenv.patch similarity index 100% rename from toolchain/gcc/patches/4.8-linaro/920-specs_nonfatal_getenv.patch rename to toolchain/gcc/patches/arc-2016.03/920-specs_nonfatal_getenv.patch diff --git a/toolchain/gcc/patches/4.8-linaro/940-no-clobber-stamp-bits.patch b/toolchain/gcc/patches/arc-2016.03/940-no-clobber-stamp-bits.patch similarity index 100% rename from toolchain/gcc/patches/4.8-linaro/940-no-clobber-stamp-bits.patch rename to toolchain/gcc/patches/arc-2016.03/940-no-clobber-stamp-bits.patch diff --git a/toolchain/gcc/patches/4.8-linaro/030-gcc-6-compile.patch b/toolchain/gcc/patches/arc-2016.03/950-fix-building-with-gcc6.patch similarity index 73% rename from toolchain/gcc/patches/4.8-linaro/030-gcc-6-compile.patch rename to toolchain/gcc/patches/arc-2016.03/950-fix-building-with-gcc6.patch index c74f2aa1409..e958380696b 100644 --- a/toolchain/gcc/patches/4.8-linaro/030-gcc-6-compile.patch +++ b/toolchain/gcc/patches/arc-2016.03/950-fix-building-with-gcc6.patch @@ -1,10 +1,33 @@ -Upstream commit r233721 +From 5dce741e00f86a08a4c174fb3605d896f210ab52 Mon Sep 17 00:00:00 2001 +From: Bernd Edlinger +Date: Wed, 27 Jul 2016 13:30:03 +0300 +Subject: [PATCH] 2016-02-19 Jakub Jelinek Bernd Edlinger + + + * Make-lang.in: Invoke gperf with -L C++. + * cfns.gperf: Remove prototypes for hash and libc_name_p + inlines. + * cfns.h: Regenerated. + * except.c (nothrow_libfn_p): Adjust. + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233572138bc75d-0d04-0410-961f-82ee72b054a4 + +This patch fixes building of gcc-4.x by gcc-6.x, for more details see +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69959 + +Signed-off-by: Alexey Brodkin +--- + gcc/cp/Make-lang.in | 2 +- + gcc/cp/cfns.gperf | 10 ++-------- + gcc/cp/cfns.h | 41 ++++++++++++++--------------------------- + gcc/cp/except.c | 3 ++- + 4 files changed, 19 insertions(+), 37 deletions(-) diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in -index bd1c1d7..a0ea0d4 100644 +index dce523a..36a1a97 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in -@@ -111,7 +111,7 @@ else +@@ -115,7 +115,7 @@ else # deleting the $(srcdir)/cp/cfns.h file. $(srcdir)/cp/cfns.h: endif @@ -14,14 +37,14 @@ index bd1c1d7..a0ea0d4 100644 # diff --git a/gcc/cp/cfns.gperf b/gcc/cp/cfns.gperf -index 05ca753..d9b16b8 100644 +index c4c4e2a..5c40933 100644 --- a/gcc/cp/cfns.gperf +++ b/gcc/cp/cfns.gperf @@ -1,3 +1,5 @@ +%language=C++ +%define class-name libc_name %{ - /* Copyright (C) 2000-2014 Free Software Foundation, Inc. + /* Copyright (C) 2000-2013 Free Software Foundation, Inc. @@ -16,14 +18,6 @@ for more details. You should have received a copy of the GNU General Public License @@ -39,7 +62,7 @@ index 05ca753..d9b16b8 100644 %% # The standard C library functions, for feeding to gperf; the result is used diff --git a/gcc/cp/cfns.h b/gcc/cp/cfns.h -index c845ddf..65801d1 100644 +index 42dd3cf..6c79864 100644 --- a/gcc/cp/cfns.h +++ b/gcc/cp/cfns.h @@ -1,5 +1,5 @@ @@ -57,7 +80,7 @@ index c845ddf..65801d1 100644 -#line 1 "cfns.gperf" +#line 3 "cfns.gperf" - /* Copyright (C) 2000-2014 Free Software Foundation, Inc. + /* Copyright (C) 2000-2013 Free Software Foundation, Inc. @@ -47,25 +47,18 @@ for more details. You should have received a copy of the GNU General Public License @@ -112,10 +135,10 @@ index c845ddf..65801d1 100644 enum { diff --git a/gcc/cp/except.c b/gcc/cp/except.c -index 221971a..32340f5 100644 +index 604f274..c3298cb 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c -@@ -1030,7 +1030,8 @@ nothrow_libfn_p (const_tree fn) +@@ -1025,7 +1025,8 @@ nothrow_libfn_p (const_tree fn) unless the system headers are playing rename tricks, and if they are, we don't want to be confused by them. */ id = DECL_NAME (fn); @@ -126,5 +149,5 @@ index 221971a..32340f5 100644 /* Returns nonzero if an exception of type FROM will be caught by a -- -1.7.1 +2.7.4 diff --git a/toolchain/gdb/Makefile b/toolchain/gdb/Makefile index d437c9afb46..e6c845a819d 100644 --- a/toolchain/gdb/Makefile +++ b/toolchain/gdb/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2013 OpenWrt.org +# Copyright (C) 2006-2016 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -7,34 +7,49 @@ include $(TOPDIR)/rules.mk PKG_NAME:=gdb -PKG_REV:=7.6-2013.05 -PKG_VERSION_MAJOR:=7.6 -PKG_VERSION:=linaro-$(PKG_REV) -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 -PKG_MD5SUM:=816290b91cff03912320089d353e8a12 -PKG_SOURCE_URL:=https://releases.linaro.org/archive/13.05/components/toolchain/gdb-linaro/ +ifeq ($(CONFIG_arc),y) +PKG_VERSION:=arc-2016.03-gdb + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=https://github.com/foss-for-synopsys-dwc-arc-processors/binutils-gdb/archive/arc-2016.03-gdb +PKG_HASH:=6a91f86cc487c1548d3f5d4f29f7226d2019c0db8a63633aeabd5914a340f3f9 +GDB_DIR:=binutils-$(PKG_NAME)-$(PKG_VERSION) +PATCH_DIR:=./patches-arc +else +PKG_VERSION:=8.0.1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=@GNU/gdb +PKG_HASH:=3dbd5f93e36ba2815ad0efab030dcd0c7b211d7b353a40a53f4c02d7d56295e3 +GDB_DIR:=$(PKG_NAME)-$(PKG_VERSION) +endif + +HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(GDB_DIR) HOST_BUILD_PARALLEL:=1 include $(INCLUDE_DIR)/toolchain-build.mk -define Host/Configure - (cd $(HOST_BUILD_DIR); \ - gdb_cv_func_sigsetjmp=yes \ - CFLAGS="-O2" \ - $(HOST_BUILD_DIR)/configure \ - --prefix=$(TOOLCHAIN_DIR) \ - --build=$(GNU_HOST_NAME) \ - --host=$(GNU_HOST_NAME) \ - --target=$(REAL_GNU_TARGET_NAME) \ - --disable-werror \ - --without-uiout \ - --disable-tui --disable-gdbtk --without-x \ - --without-included-gettext \ - --enable-threads \ - ); -endef +HOST_CONFIGURE_VARS += \ + gdb_cv_func_sigsetjmp=yes + +HOST_CONFIGURE_ARGS = \ + --prefix=$(TOOLCHAIN_DIR) \ + --build=$(GNU_HOST_NAME) \ + --host=$(GNU_HOST_NAME) \ + --target=$(REAL_GNU_TARGET_NAME) \ + --disable-werror \ + --without-uiout \ + --disable-tui --disable-gdbtk --without-x \ + --without-included-gettext \ + --enable-threads \ + --with-expat \ + --without-python \ + --disable-binutils \ + --disable-ld \ + --disable-gas \ + --disable-sim define Host/Install mkdir -p $(TOOLCHAIN_DIR)/bin diff --git a/toolchain/gdb/patches/110-no_extern_inline.patch b/toolchain/gdb/patches-arc/100-no_extern_inline.patch similarity index 91% rename from toolchain/gdb/patches/110-no_extern_inline.patch rename to toolchain/gdb/patches-arc/100-no_extern_inline.patch index bbae1d774d4..8c18c6e2e74 100644 --- a/toolchain/gdb/patches/110-no_extern_inline.patch +++ b/toolchain/gdb/patches-arc/100-no_extern_inline.patch @@ -21,11 +21,11 @@ +#endif /* DEFINE_NON_INLINE_P */ --- a/sim/common/sim-arange.h +++ b/sim/common/sim-arange.h -@@ -62,7 +62,7 @@ extern void sim_addr_range_delete (ADDR_ +@@ -73,7 +73,7 @@ extern void sim_addr_range_delete (ADDR_ /* Return non-zero if ADDR is in range AR, traversing the entire tree. If no range is specified, that is defined to mean "everything". */ --extern INLINE int +-SIM_ARANGE_INLINE int +extern int sim_addr_range_hit_p (ADDR_RANGE * /*ar*/, address_word /*addr*/); #define ADDR_RANGE_HIT_P(ar, addr) \ diff --git a/toolchain/gdb/patches-arc/110-no_testsuite.patch b/toolchain/gdb/patches-arc/110-no_testsuite.patch new file mode 100644 index 00000000000..1b284ea7675 --- /dev/null +++ b/toolchain/gdb/patches-arc/110-no_testsuite.patch @@ -0,0 +1,21 @@ +--- a/gdb/configure ++++ b/gdb/configure +@@ -870,8 +870,7 @@ MAKEINFOFLAGS + YACC + YFLAGS + XMKMF' +-ac_subdirs_all='testsuite +-gdbtk ++ac_subdirs_all='gdbtk + multi-ice + gdbserver' + +@@ -5610,7 +5610,7 @@ $as_echo "$with_auto_load_safe_path" >&6 + + + +-subdirs="$subdirs testsuite" ++subdirs="$subdirs" + + + # Check whether to support alternative target configurations diff --git a/toolchain/gdb/patches-arc/120-fix-compile-flag-mismatch.patch b/toolchain/gdb/patches-arc/120-fix-compile-flag-mismatch.patch new file mode 100644 index 00000000000..c8b41f264a0 --- /dev/null +++ b/toolchain/gdb/patches-arc/120-fix-compile-flag-mismatch.patch @@ -0,0 +1,11 @@ +--- a/gdb/gdbserver/configure ++++ b/gdb/gdbserver/configure +@@ -2468,7 +2468,7 @@ $as_echo "$as_me: error: \`$ac_var' was + ac_cache_corrupted=: ;; + ,);; + *) +- if test "x$ac_old_val" != "x$ac_new_val"; then ++ if test "`echo x$ac_old_val`" != "`echo x$ac_new_val`"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` diff --git a/toolchain/gdb/patches/100-no_extern_inline.patch b/toolchain/gdb/patches/100-no_extern_inline.patch new file mode 100644 index 00000000000..8c18c6e2e74 --- /dev/null +++ b/toolchain/gdb/patches/100-no_extern_inline.patch @@ -0,0 +1,32 @@ +--- a/sim/common/sim-arange.c ++++ b/sim/common/sim-arange.c +@@ -280,11 +280,7 @@ sim_addr_range_delete (ADDR_RANGE *ar, a + build_search_tree (ar); + } + +-#endif /* DEFINE_NON_INLINE_P */ +- +-#if DEFINE_INLINE_P +- +-SIM_ARANGE_INLINE int ++int + sim_addr_range_hit_p (ADDR_RANGE *ar, address_word addr) + { + ADDR_RANGE_TREE *t = ar->range_tree; +@@ -301,4 +297,4 @@ sim_addr_range_hit_p (ADDR_RANGE *ar, ad + return 0; + } + +-#endif /* DEFINE_INLINE_P */ ++#endif /* DEFINE_NON_INLINE_P */ +--- a/sim/common/sim-arange.h ++++ b/sim/common/sim-arange.h +@@ -73,7 +73,7 @@ extern void sim_addr_range_delete (ADDR_ + + /* Return non-zero if ADDR is in range AR, traversing the entire tree. + If no range is specified, that is defined to mean "everything". */ +-SIM_ARANGE_INLINE int ++extern int + sim_addr_range_hit_p (ADDR_RANGE * /*ar*/, address_word /*addr*/); + #define ADDR_RANGE_HIT_P(ar, addr) \ + ((ar)->range_tree == NULL || sim_addr_range_hit_p ((ar), (addr))) diff --git a/toolchain/gdb/patches/100-ppc_compile_fix.patch b/toolchain/gdb/patches/100-ppc_compile_fix.patch deleted file mode 100644 index 9ecaaed8e43..00000000000 --- a/toolchain/gdb/patches/100-ppc_compile_fix.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/sim/ppc/Makefile.in -+++ b/sim/ppc/Makefile.in -@@ -550,7 +550,7 @@ PACKAGE_SRC = @sim_pk_src@ - PACKAGE_OBJ = @sim_pk_obj@ - - --psim: $(TARGETLIB) main.o $(LIBIBERTY_LIB) $(BFD_LIB) $(LIBS) $(LIBINTL_DEP) -+psim: $(TARGETLIB) main.o $(LIBIBERTY_LIB) $(BFD_LIB) $(LIBINTL_DEP) - $(CC) $(CFLAGS) $(SIM_CFLAGS) $(LDFLAGS) -o psim$(EXEEXT) main.o $(TARGETLIB) $(BFD_LIB) $(LIBINTL) $(LIBIBERTY_LIB) $(LIBS) - - run: psim diff --git a/toolchain/gdb/patches/110-no_testsuite.patch b/toolchain/gdb/patches/110-no_testsuite.patch new file mode 100644 index 00000000000..e86ba6d0cd7 --- /dev/null +++ b/toolchain/gdb/patches/110-no_testsuite.patch @@ -0,0 +1,21 @@ +--- a/gdb/configure ++++ b/gdb/configure +@@ -869,8 +869,7 @@ MAKEINFOFLAGS + YACC + YFLAGS + XMKMF' +-ac_subdirs_all='testsuite +-gdbtk ++ac_subdirs_all='gdbtk + multi-ice + gdbserver' + +@@ -6473,7 +6472,7 @@ $as_echo "$with_auto_load_safe_path" >&6 + + + +-subdirs="$subdirs testsuite" ++subdirs="$subdirs" + + + # Check whether to support alternative target configurations diff --git a/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch b/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch new file mode 100644 index 00000000000..9ce91a024b0 --- /dev/null +++ b/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch @@ -0,0 +1,11 @@ +--- a/gdb/gdbserver/configure ++++ b/gdb/gdbserver/configure +@@ -2469,7 +2469,7 @@ $as_echo "$as_me: error: \`$ac_var' was + ac_cache_corrupted=: ;; + ,);; + *) +- if test "x$ac_old_val" != "x$ac_new_val"; then ++ if test "`echo x$ac_old_val`" != "`echo x$ac_new_val`"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` diff --git a/toolchain/gdb/patches/600-fix-compile-flag-mismatch.patch b/toolchain/gdb/patches/600-fix-compile-flag-mismatch.patch deleted file mode 100644 index 127bee46d8d..00000000000 --- a/toolchain/gdb/patches/600-fix-compile-flag-mismatch.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- a/gdb/configure -+++ b/gdb/configure -@@ -834,8 +834,7 @@ MAKEINFOFLAGS - YACC - YFLAGS - XMKMF' --ac_subdirs_all='testsuite --gdbtk -+ac_subdirs_all='gdbtk - multi-ice - gdbserver' - -@@ -5033,7 +5032,7 @@ $as_echo "$with_auto_load_safe_path" >&6 - - - --subdirs="$subdirs testsuite" -+subdirs="$subdirs" - - - # Check whether to support alternative target configurations ---- a/gdb/gdbserver/configure -+++ b/gdb/gdbserver/configure -@@ -2181,7 +2181,7 @@ $as_echo "$as_me: error: \`$ac_var' was - ac_cache_corrupted=: ;; - ,);; - *) -- if test "x$ac_old_val" != "x$ac_new_val"; then -+ if test "`echo x$ac_old_val`" != "`echo x$ac_new_val`"; then - # differences in whitespace do not lead to failure. - ac_old_val_w=`echo x $ac_old_val` - ac_new_val_w=`echo x $ac_new_val` diff --git a/toolchain/glibc/Config.in b/toolchain/glibc/Config.in index 59225999a39..5adbeb6f824 100644 --- a/toolchain/glibc/Config.in +++ b/toolchain/glibc/Config.in @@ -5,17 +5,8 @@ choice help Select the version of glibc you wish to use. - config EGLIBC_USE_VERSION_2_19 - bool "eglibc 2.19" - select EGLIBC_VERSION_2_19 - - config GLIBC_USE_VERSION_2_21 - bool "glibc 2.21" - select GLIBC_VERSION_2_21 + config GLIBC_USE_VERSION_2_24 + bool "glibc 2.24" + select GLIBC_VERSION_2_24 endchoice - -menu "eglibc configuration" - depends on TOOLCHAINOPTS && USE_GLIBC && EGLIBC_USE_VERSION_2_19 - source toolchain/glibc/config/Config.in -endmenu diff --git a/toolchain/glibc/Config.version b/toolchain/glibc/Config.version index 4ceed09adfc..1df7719ac86 100644 --- a/toolchain/glibc/Config.version +++ b/toolchain/glibc/Config.version @@ -2,19 +2,10 @@ if USE_GLIBC config GLIBC_VERSION string - default "2.19" if EGLIBC_VERSION_2_19 - default "2.21" if GLIBC_VERSION_2_21 + default "2.24" if GLIBC_VERSION_2_24 -config EGLIBC_VERSION_2_19 +config GLIBC_VERSION_2_24 default y if !TOOLCHAINOPTS bool -config GLIBC_VERSION_2_21 - bool - endif - -menu "eglibc configuration" - depends on !TOOLCHAINOPTS && USE_GLIBC - source toolchain/glibc/config/Config.in -endmenu diff --git a/toolchain/glibc/Makefile b/toolchain/glibc/Makefile index f880db81edb..974691c1c9f 100644 --- a/toolchain/glibc/Makefile +++ b/toolchain/glibc/Makefile @@ -1,11 +1,11 @@ PATH_PREFIX := . VARIANT:=final -HOST_BUILD_PARALLEL:=0 +HOST_BUILD_PARALLEL:=1 include ./common.mk define Host/Compile - $(MAKE) -C $(CUR_BUILD_DIR) \ + +$(MAKE) -C $(CUR_BUILD_DIR) \ PARALLELMFLAGS="$(HOST_JOBS)" \ BUILD_CFLAGS="$(HOST_CFLAGS)" \ all diff --git a/toolchain/glibc/common.mk b/toolchain/glibc/common.mk index 3d680bbcf60..3078c267cc8 100644 --- a/toolchain/glibc/common.mk +++ b/toolchain/glibc/common.mk @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2011 OpenWrt.org +# Copyright (C) 2006-2016 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -7,32 +7,23 @@ include $(TOPDIR)/rules.mk -MD5SUM_2.19 = 42dad4edd3bcb38006d13b5640b00b38 -REVISION_2.19 = 25243 - -MD5SUM_2.21 = 76050a65c444d58b5c4aa0d6034736ed -REVISION_2.21 = 16d0a0c +HASH_2.24 = 714d26c0daf6a8acf73fc8b6053349880c79f240f96ca57b00ab0ecbbead2b73 +REVISION_2.24 = 8c716c2 PKG_NAME:=glibc PKG_VERSION:=$(call qstrip,$(CONFIG_GLIBC_VERSION)) PKG_REVISION:=$(REVISION_$(PKG_VERSION)) -PKG_MIRROR_MD5SUM:=$(MD5SUM_$(PKG_VERSION)) +PKG_MIRROR_HASH:=$(HASH_$(PKG_VERSION)) PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=git://sourceware.org/git/glibc.git PKG_SOURCE_VERSION:=$(PKG_REVISION) -PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)-r$(PKG_REVISION) +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_REVISION) PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.bz2 GLIBC_PATH:= -ifneq ($(CONFIG_EGLIBC_VERSION_2_19),) - GLIBC_PATH:=libc/ - PKG_SOURCE_PROTO:=svn - PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.bz2 - PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_19 -endif PATCH_DIR:=$(PATH_PREFIX)/patches/$(PKG_VERSION) @@ -58,10 +49,14 @@ ifeq ($(ARCH),mips64) endif endif + +# -Os miscompiles w. 2.24 gcc5/gcc6 +# only -O2 tested by upstream changeset +# "Optimize i386 syscall inlining for GCC 5" GLIBC_CONFIGURE:= \ BUILD_CC="$(HOSTCC)" \ $(TARGET_CONFIGURE_OPTS) \ - CFLAGS="$(TARGET_CFLAGS)" \ + CFLAGS="-O2 $(filter-out -Os,$(call qstrip,$(TARGET_CFLAGS)))" \ libc_cv_slibdir="/lib" \ use_ldconfig=no \ $(HOST_BUILD_DIR)/$(GLIBC_PATH)configure \ @@ -77,16 +72,13 @@ GLIBC_CONFIGURE:= \ --$(if $(CONFIG_SOFT_FLOAT),without,with)-fp export libc_cv_ssp=no +export libc_cv_ssp_strong=no export ac_cv_header_cpuid_h=yes export HOST_CFLAGS := $(HOST_CFLAGS) -idirafter $(CURDIR)/$(PATH_PREFIX)/include define Host/SetToolchainInfo $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk -ifneq ($(CONFIG_GLIBC_VERSION_2_21),) $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.gnu.org/software/libc/,' $(TOOLCHAIN_DIR)/info.mk -else - $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.eglibc.org/,' $(TOOLCHAIN_DIR)/info.mk -endif $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk $(SED) 's,^\(LIBC_SO_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk endef @@ -98,7 +90,6 @@ define Host/Configure touch $(HOST_BUILD_DIR)/.autoconf; \ } mkdir -p $(CUR_BUILD_DIR) - grep 'CONFIG_EGLIBC_OPTION_' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_EGLIBC_\\(.*\\),\\1\\2,g" > $(CUR_BUILD_DIR)/option-groups.config ( cd $(CUR_BUILD_DIR); rm -f config.cache; \ $(GLIBC_CONFIGURE) \ ); @@ -107,9 +98,6 @@ endef define Host/Prepare $(call Host/Prepare/Default) ln -snf $(PKG_SOURCE_SUBDIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) -ifeq ($(CONFIG_GLIBC_VERSION_2_21),) - $(SED) 's,y,n,' $(HOST_BUILD_DIR)/libc/option-groups.defaults -endif endef define Host/Clean diff --git a/toolchain/glibc/config/Config.in b/toolchain/glibc/config/Config.in deleted file mode 100644 index 6f022234a63..00000000000 --- a/toolchain/glibc/config/Config.in +++ /dev/null @@ -1,903 +0,0 @@ -config EGLIBC_OPTION_EGLIBC_ADVANCED_INET6 - bool "IPv6 Advanced Sockets API support (RFC3542)" - default y - select EGLIBC_OPTION_EGLIBC_INET - help - This option group includes the functions specified by RFC 3542, - "Advanced Sockets Application Program Interface (API) for - IPv6". - - This option group includes the following functions: - - inet6_opt_append - inet6_opt_find - inet6_opt_finish - inet6_opt_get_val - inet6_opt_init - inet6_option_alloc - inet6_option_append - inet6_option_find - inet6_option_init - inet6_option_next - inet6_option_space - inet6_opt_next - inet6_opt_set_val - inet6_rth_add - inet6_rth_getaddr - inet6_rth_init - inet6_rth_reverse - inet6_rth_segments - inet6_rth_space - - -config EGLIBC_OPTION_EGLIBC_BACKTRACE - bool "Functions for producing backtraces" - default y - help - This option group includes functions for producing a list of - the function calls that are currently active in a thread, from - within the thread itself. These functions are often used - within signal handlers, to produce diagnostic output. - - This option group includes the following functions: - - backtrace - backtrace_symbols - backtrace_symbols_fd - - -config EGLIBC_OPTION_EGLIBC_BIG_MACROS - bool "Use extensive inline code" - default y - help - This option group specifies whether certain pieces of code - should be inlined to achieve maximum speed. If this option - group is not selected, function calls will be used instead, - hence reducing the library footprint. - - -config EGLIBC_OPTION_EGLIBC_BSD - bool "BSD-specific functions, and their compatibility stubs" - default y - help - This option group includes functions specific to BSD kernels. - A number of these functions have stub versions that are also - included in libraries built for non-BSD systems for - compatibility. - - This option group includes the following functions: - - chflags - fchflags - lchmod - revoke - setlogin - - -config EGLIBC_OPTION_EGLIBC_CXX_TESTS - bool "Tests that link against the standard C++ library." - default y - select EGLIBC_OPTION_POSIX_WIDE_CHAR_DEVICE_IO - select EGLIBC_OPTION_EGLIBC_LIBM - help - This option group does not include any C library functions; - instead, it controls which EGLIBC tests an ordinary 'make - tests' runs. With this group disabled, tests that would - normally link against the standard C++ library are not - run. - - The standard C++ library depends on the math library 'libm' and - the wide character I/O functions included in EGLIBC. If those - option groups are disabled, this test must also be disabled. - - -config EGLIBC_OPTION_EGLIBC_CATGETS - bool "Functions for accessing message catalogs" - default y - select EGLIBC_OPTION_EGLIBC_LOCALE_CODE - help - This option group includes functions for accessing message - catalogs: catopen, catclose, and catgets. - - This option group depends on the EGLIBC_OPTION_EGLIBC_LOCALE_CODE - option group; if you disable that, you must also disable this. - - -config EGLIBC_OPTION_EGLIBC_CHARSETS - bool "iconv/gconv character set conversion libraries" - default y - help - - This option group includes support for character sets other - than ASCII (ANSI_X3.4-1968) and Unicode and ISO-10646 in their - various encodings. This affects both the character sets - supported by the wide and multibyte character functions, and - those supported by the 'iconv' functions. - - With this option group disabled, EGLIBC supports only the - following character sets: - - ANSI_X3.4 - ASCII - ANSI_X3.4-1968 - ANSI_X3.4-1986 - ASCII - CP367 - CSASCII - IBM367 - ISO-IR-6 - ISO646-US - ISO_646.IRV:1991 - OSF00010020 - US - US-ASCII - - 10646-1:1993 - ISO 10646, in big-endian UCS4 form - 10646-1:1993/UCS4 - CSUCS4 - ISO-10646 - ISO-10646/UCS4 - OSF00010104 - OSF00010105 - OSF00010106 - UCS-4 - UCS-4BE - UCS4 - - UCS-4LE - ISO 10646, in little-endian UCS4 form - - ISO-10646/UTF-8 - ISO 10646, in UTF-8 form - ISO-10646/UTF8 - ISO-IR-193 - OSF05010001 - UTF-8 - UTF8 - - ISO-10646/UCS2 - ISO 10646, in target-endian UCS2 form - OSF00010100 - OSF00010101 - OSF00010102 - UCS-2 - UCS2 - - UCS-2BE - ISO 10646, in big-endian UCS2 form - UNICODEBIG - - UCS-2LE - ISO 10646, in little-endian UCS2 form - UNICODELITTLE - - WCHAR_T - EGLIBC's internal form (target-endian, - 32-bit ISO 10646) - - -config EGLIBC_OPTION_EGLIBC_CRYPT - bool "Encryption library" - default y - help - This option group includes the `libcrypt' library which - provides functions for one-way encryption. Supported - encryption algorithms include MD5, SHA-256, SHA-512 and DES. - - -config EGLIBC_OPTION_EGLIBC_CRYPT_UFC - bool "Ultra fast `crypt' implementation" - default y - select EGLIBC_OPTION_EGLIBC_CRYPT - help - This option group provides ultra fast DES-based implementation of - the `crypt' function. When this option group is disabled, - (a) the library will not provide the setkey[_r] and encrypt[_r] - functions and (b) the crypt[_r] function will return NULL and set the - errno to ENOSYS if /salt/ passed does not correspond to either MD5, - SHA-256 or SHA-512 algorithm. - - -config EGLIBC_OPTION_EGLIBC_DB_ALIASES - bool "Functions for accessing the mail aliases database" - default y - help - This option group includes functions for looking up mail - aliases in '/etc/aliases' or using nsswitch. It includes the - following functions: - - endaliasent - getaliasbyname - getaliasbyname_r - getaliasent - getaliasent_r - setaliasent - - When this option group is disabled, the NSS service libraries - also lack support for querying their mail alias tables. - - -config EGLIBC_OPTION_EGLIBC_ENVZ - bool "Functions for handling envz-style environment vectors." - default y - help - This option group contains functions for creating and operating - on envz vectors. An "envz vector" is a vector of strings in a - contiguous block of memory, where each element is a name-value - pair, and elements are separated from their neighbors by null - characters. - - This option group includes the following functions: - - envz_add envz_merge - envz_entry envz_remove - envz_get envz_strip - - -config EGLIBC_OPTION_EGLIBC_FCVT - bool "Functions for converting floating-point numbers to strings" - default y - help - This option group includes functions for converting - floating-point numbers to strings. - - This option group includes the following functions: - - ecvt qecvt - ecvt_r qecvt_r - fcvt qfcvt - fcvt_r qfcvt_r - gcvt qgcvt - - -config EGLIBC_OPTION_EGLIBC_FMTMSG - bool "Functions for formatting messages" - default y - help - This option group includes the following functions: - - addseverity fmtmsg - - -config EGLIBC_OPTION_EGLIBC_FSTAB - bool "Access functions for 'fstab'" - default y - help - This option group includes functions for reading the mount - point specification table, '/etc/fstab'. These functions are - not included in the POSIX standard, which provides the - 'getmntent' family of functions instead. - - This option group includes the following functions: - - endfsent getfsspec - getfsent setfsent - getfsfile - - -config EGLIBC_OPTION_EGLIBC_FTRAVERSE - bool "Functions for traversing file hierarchies" - default y - help - This option group includes functions for traversing file - UNIX file hierachies. - - This option group includes the following functions: - - fts_open ftw - fts_read nftw - fts_children ftw64 - fts_set nftw64 - fts_close - - -config EGLIBC_OPTION_EGLIBC_GETLOGIN - bool "The getlogin function" - default y - select EGLIBC_OPTION_EGLIBC_UTMP - help - This function group includes the 'getlogin' and 'getlogin_r' - functions, which return the user name associated by the login - activity with the current process's controlling terminal. - - With this option group disabled, the 'glob' function will not - fall back on 'getlogin' to find the user's login name for tilde - expansion when the 'HOME' environment variable is not set. - - -config EGLIBC_OPTION_EGLIBC_IDN - bool "International domain names support" - default y - help - This option group includes the `libcidn' library which - provides support for international domain names. - - -config EGLIBC_OPTION_EGLIBC_INET - bool "Networking support" - default y - help - This option group includes networking-specific functions and - data. With EGLIBC_OPTION_EGLIBC_INET disabled, the EGLIBC - installation and API changes as follows: - - - The following libraries are not installed: - - libanl - libnsl - libnss_compat - libnss_dns - libnss_hesiod - libnss_nis - libnss_nisplus - libresolv - - - The following functions and variables are omitted from libc: - - authdes_create hstrerror svc_fdset - authdes_getucred htonl svc_getreq - authdes_pk_create htons svc_getreq_common - authnone_create if_freenameindex svc_getreq_poll - authunix_create if_indextoname svc_getreqset - authunix_create_default if_nameindex svc_max_pollfd - bindresvport if_nametoindex svc_pollfd - callrpc in6addr_any svcraw_create - cbc_crypt in6addr_loopback svc_register - clnt_broadcast inet6_opt_append svc_run - clnt_create inet6_opt_find svc_sendreply - clnt_pcreateerror inet6_opt_finish svctcp_create - clnt_perrno inet6_opt_get_val svcudp_bufcreate - clnt_perror inet6_opt_init svcudp_create - clntraw_create inet6_option_alloc svcudp_enablecache - clnt_spcreateerror inet6_option_append svcunix_create - clnt_sperrno inet6_option_find svcunixfd_create - clnt_sperror inet6_option_init svc_unregister - clnttcp_create inet6_option_next user2netname - clntudp_bufcreate inet6_option_space xdecrypt - clntudp_create inet6_opt_next xdr_accepted_reply - clntunix_create inet6_opt_set_val xdr_array - des_setparity inet6_rth_add xdr_authdes_cred - ecb_crypt inet6_rth_getaddr xdr_authdes_verf - endaliasent inet6_rth_init xdr_authunix_parms - endhostent inet6_rth_reverse xdr_bool - endnetent inet6_rth_segments xdr_bytes - endnetgrent inet6_rth_space xdr_callhdr - endprotoent inet_addr xdr_callmsg - endrpcent inet_aton xdr_char - endservent inet_lnaof xdr_cryptkeyarg - ether_aton inet_makeaddr xdr_cryptkeyarg2 - ether_aton_r inet_netof xdr_cryptkeyres - ether_hostton inet_network xdr_des_block - ether_line inet_nsap_addr xdr_double - ether_ntoa inet_nsap_ntoa xdr_enum - ether_ntoa_r inet_ntoa xdr_float - ether_ntohost inet_ntop xdr_free - freeaddrinfo inet_pton xdr_getcredres - freeifaddrs innetgr xdr_hyper - gai_strerror iruserok xdr_int - getaddrinfo iruserok_af xdr_int16_t - getaliasbyname key_decryptsession xdr_int32_t - getaliasbyname_r key_decryptsession_pk xdr_int64_t - getaliasent key_encryptsession xdr_int8_t - getaliasent_r key_encryptsession_pk xdr_keybuf - gethostbyaddr key_gendes xdr_key_netstarg - gethostbyaddr_r key_get_conv xdr_key_netstres - gethostbyname key_secretkey_is_set xdr_keystatus - gethostbyname2 key_setnet xdr_long - gethostbyname2_r key_setsecret xdr_longlong_t - gethostbyname_r netname2host xdrmem_create - gethostent netname2user xdr_netnamestr - gethostent_r ntohl xdr_netobj - getifaddrs ntohs xdr_opaque - getipv4sourcefilter passwd2des xdr_opaque_auth - get_myaddress pmap_getmaps xdr_pmap - getnameinfo pmap_getport xdr_pmaplist - getnetbyaddr pmap_rmtcall xdr_pointer - getnetbyaddr_r pmap_set xdr_quad_t - getnetbyname pmap_unset xdrrec_create - getnetbyname_r rcmd xdrrec_endofrecord - getnetent rcmd_af xdrrec_eof - getnetent_r registerrpc xdrrec_skiprecord - getnetgrent res_init xdr_reference - getnetgrent_r rexec xdr_rejected_reply - getnetname rexec_af xdr_replymsg - getprotobyname rexecoptions xdr_rmtcall_args - getprotobyname_r rpc_createerr xdr_rmtcallres - getprotobynumber rresvport xdr_short - getprotobynumber_r rresvport_af xdr_sizeof - getprotoent rtime xdrstdio_create - getprotoent_r ruserok xdr_string - getpublickey ruserok_af xdr_u_char - getrpcbyname ruserpass xdr_u_hyper - getrpcbyname_r setaliasent xdr_u_int - getrpcbynumber sethostent xdr_uint16_t - getrpcbynumber_r setipv4sourcefilter xdr_uint32_t - getrpcent setnetent xdr_uint64_t - getrpcent_r setnetgrent xdr_uint8_t - getrpcport setprotoent xdr_u_long - getsecretkey setrpcent xdr_u_longlong_t - getservbyname setservent xdr_union - getservbyname_r setsourcefilter xdr_unixcred - getservbyport svcauthdes_stats xdr_u_quad_t - getservbyport_r svcerr_auth xdr_u_short - getservent svcerr_decode xdr_vector - getservent_r svcerr_noproc xdr_void - getsourcefilter svcerr_noprog xdr_wrapstring - h_errlist svcerr_progvers xencrypt - h_errno svcerr_systemerr xprt_register - herror svcerr_weakauth xprt_unregister - h_nerr svc_exit - host2netname svcfd_create - - - The rpcgen, nscd, and rpcinfo commands are not installed. - - - The 'rpc' file (a text file listing RPC services) is not installed. - - Socket-related system calls do not fall in this option group, - because many are also used for other inter-process - communication mechanisms. For example, the 'syslog' routines - use Unix-domain sockets to communicate with the syslog daemon; - syslog is valuable in non-networked contexts. - - -config EGLIBC_OPTION_EGLIBC_INET_ANL - bool "Asynchronous name lookup" - default y - select EGLIBC_OPTION_EGLIBC_INET - help - This option group includes the `libanl' library which - provides support for asynchronous name lookup. - - -config EGLIBC_OPTION_EGLIBC_LIBM - bool "libm (math library)" - default y - help - This option group includes the 'libm' library, containing - mathematical functions. If this option group is omitted, then - an EGLIBC installation does not include shared or unshared versions - of the math library. - - Note that this does not remove all floating-point related - functionality from EGLIBC; for example, 'printf' and 'scanf' - can still print and read floating-point values with this option - group disabled. - - Note that the ISO Standard C++ library 'libstdc++' depends on - EGLIBC's math library 'libm'. If you disable this option - group, you will not be able to build 'libstdc++' against the - resulting EGLIBC installation. - - -config EGLIBC_OPTION_EGLIBC_LIBM_BIG - bool "Math library size" - default y - help - This option group enables default configuration of the math library. - Not selecting this option group removes most of the extended and - double precision math functions and replaces them with wrappers - to the single precision couterparts. - Doing so greatly degrades quality of calculations carried - out by the functions of the math library, but also significantly - reduces the size of the libm. - This option group is useful for systems that do not rely on precise - floating point math. - - -config EGLIBC_OPTION_EGLIBC_LOCALES - bool "Locale definitions" - default y - help - This option group includes all locale definitions other than - that for the "C" locale. If this option group is omitted, then - only the "C" locale is supported. - - -config EGLIBC_OPTION_EGLIBC_LOCALE_CODE - bool "Locale functions" - default y - select EGLIBC_OPTION_POSIX_C_LANG_WIDE_CHAR - help - This option group includes locale support functions, programs, - and libraries. With EGLIBC_OPTION_EGLIBC_LOCALE_CODE disabled, - EGLIBC supports only the 'C' locale (also known as 'POSIX'), - and ignores the settings of the 'LANG' and 'LC_*' environment - variables. - - With EGLIBC_OPTION_EGLIBC_LOCALE_CODE disabled, the following - functions are omitted from libc: - - duplocale localeconv nl_langinfo rpmatch strfmon_l - freelocale newlocale nl_langinfo_l strfmon uselocale - - Furthermore, only the LC_CTYPE and LC_TIME categories of the - standard "C" locale are available. - - The EGLIBC_OPTION_EGLIBC_CATGETS option group depends on this option - group; if you disable EGLIBC_OPTION_EGLIBC_LOCALE_CODE, you must also - disable EGLIBC_OPTION_EGLIBC_CATGETS. - - -config EGLIBC_OPTION_EGLIBC_MEMUSAGE - bool "Memory profiling library" - default y - help - This option group includes the `libmemusage' library and - the `memusage' and `memusagestat' utilities. - These components provide memory profiling functions. - - EGLIBC_OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE - - Libmemusage library buffers the profiling data in memory - before writing it out to disk. By default, the library - allocates 1.5M buffer, which can be substantial for some - systems. EGLIBC_OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE option - allows to change the default buffer size. It specifies - the number of entries the buffer should have. - On most architectures one buffer entry amounts to 48 bytes, - so setting this option to the value of 512 will reduce the size of - the memory buffer to 24K. - - -config EGLIBC_OPTION_EGLIBC_NIS - bool "Support for NIS, NIS+, and the special 'compat' services." - default n - select EGLIBC_OPTION_EGLIBC_INET - select EGLIBC_OPTION_EGLIBC_SUNRPC - help - This option group includes the NIS, NIS+, and 'compat' Name - Service Switch service libraries. When it is disabled, those - services libraries are not installed; you should remove any - references to them from your 'nsswitch.conf' file. - - This option group depends on the EGLIBC_OPTION_EGLIBC_INET option - group; you must enable that to enable this option group. - - -config EGLIBC_OPTION_EGLIBC_NSSWITCH - bool "Name service switch (nsswitch) support" - default y - select EGLIBC_OPTION_EGLIBC_INET - help - - This option group includes support for the 'nsswitch' facility. - With this option group enabled, all EGLIBC functions for - accessing various system databases (passwords and groups; - networking; aliases; public keys; and so on) consult the - '/etc/nsswitch.conf' configuration file to decide how to handle - queries. - - With this option group disabled, EGLIBC uses a fixed list of - services to satisfy queries on each database, as requested by - configuration files specified when EGLIBC is built. Your - 'option-groups.config' file must set the following two - variables: - - EGLIBC_OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG - - Set this to the name of a file whose contents observe the - same syntax as an ordinary '/etc/nsswitch.conf' file. The - EGLIBC build process parses this file just as EGLIBC would - at run time if EGLIBC_NSSWITCH were enabled, and - produces a C library that uses the nsswitch service - libraries to search for database entries as this file - specifies, instead of consulting '/etc/nsswitch.conf' at run - time. - - This should be an absolute filename. The EGLIBC build - process may use it from several different working - directories. It may include references to Makefile - variables like 'common-objpfx' (the top of the build tree, - with a trailing slash), or '..' (the top of the source tree, - with a trailing slash). - - The EGLIBC source tree includes a sample configuration file - named 'nss/fixed-nsswitch.conf'; for simple configurations, - you will probably want to delete references to databases not - needed on your system. - - EGLIBC_OPTION_EGLIBC_NSSWITCH_FIXED_FUNCTIONS - - The EGLIBC build process uses this file to decide which - functions to make available from which service libraries. - The file 'nss/fixed-nsswitch.functions' serves as a sample - configuration file for this setting, and explains its syntax - and meaning in more detail. - - This should be an absolute file name. The EGLIBC build - process may use it from several different working - directories. It may include references to Makefile - variables like 'common-objpfx' (the top of the build tree, - with a trailing slash), or '..' (the top of the source tree, - with a trailing slash). - - Be sure to mention each function in each service you wish to - use. If you do not mention a service's function here, the - EGLIBC database access functions will not find it, even if - it is listed in the EGLIBC_OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG - file. - - In this arrangement, EGLIBC will not use the 'dlopen' and - 'dlsym' functions to find database access functions. Instead, - libc hard-codes references to the service libraries' database - access functions. You must explicitly link your program - against the name service libraries (those whose names start - with 'libnss_', in the sysroot's '/lib' directory) whose - functions you intend to use. This arrangement helps - system-wide static analysis tools decide which functions a - system actually uses. - - Note that some nsswitch service libraries require other option - groups to be enabled; for example, the EGLIBC_OPTION_EGLIBC_INET - option group must be enabled to use the 'libnss_dns.so.2' - service library, which uses the Domain Name System network - protocol to answer queries. - - -config EGLIBC_OPTION_EGLIBC_RCMD - bool "Support for 'rcmd' and related library functions" - default y - select EGLIBC_OPTION_EGLIBC_INET - help - This option group includes functions for running commands on - remote machines via the 'rsh' protocol, and doing authentication - related to those functions. This also includes functions that - use the 'rexec' protocol. - - This option group includes the following functions: - - rcmd ruserok - rcmd_af ruserok_af - rexec iruserok - rexec_af iruserok_af - rresvport ruserpass - rresvport_af - - -config EGLIBC_OPTION_EGLIBC_RTLD_DEBUG - bool "Runtime linker debug print outs" - default y - help - This option group enables debug output of the runtime linker - which is activated via LD_DEBUG and LD_TRACE_PRELINKING - environment variables. Disabling this option group yields - a smaller runtime linker binary. - BEWARE: Disabling this option group is likely to break - the `ldd' utility which may also be used by the prelinker. - In particular, the `--unused' ldd option will not work correctly. - - -config EGLIBC_OPTION_EGLIBC_SPAWN - bool "Support for POSIX posix_spawn functions" - default y - help - This option group includes the POSIX functions for executing - programs in child processes without using 'fork' or 'vfork'. - - This option group includes the following functions: - - posix_spawn - posix_spawnattr_destroy - posix_spawnattr_getflags - posix_spawnattr_getpgroup - posix_spawnattr_getschedparam - posix_spawnattr_getschedpolicy - posix_spawnattr_getsigdefault - posix_spawnattr_getsigmask - posix_spawnattr_init - posix_spawnattr_setflags - posix_spawnattr_setpgroup - posix_spawnattr_setschedparam - posix_spawnattr_setschedpolicy - posix_spawnattr_setsigdefault - posix_spawnattr_setsigmask - posix_spawn_file_actions_addclose - posix_spawn_file_actions_adddup2 - posix_spawn_file_actions_addopen - posix_spawn_file_actions_destroy - posix_spawn_file_actions_init - posix_spawnp - - This option group also provides the ability for the iconv, - localedef, and locale programs to operate transparently on - compressed charset definitions. When this option group is - disabled, those programs will only operate on uncompressed - charmap files. - - -config EGLIBC_OPTION_EGLIBC_STREAMS - bool "Support for accessing STREAMS." - default y - help - This option group includes functions for reading and writing - messages to and from STREAMS. The STREAMS interface provides a - uniform mechanism for implementing networking services and other - character-based I/O. (STREAMS are not to be confused with - FILE objects, also called 'streams'.) - - This option group includes the following functions: - - getmsg putpmsg - getpmsg fattach - isastream fdetach - putmsg - - -config EGLIBC_OPTION_EGLIBC_SUNRPC - bool "Support for the Sun 'RPC' protocol." - default n - select EGLIBC_OPTION_EGLIBC_INET - help - This option group includes support for the Sun RPC protocols, - including the 'rpcgen' and 'rpcinfo' programs. - - -config EGLIBC_OPTION_EGLIBC_UTMP - bool "Older access functions for 'utmp' login records" - default y - help - This option group includes the older 'utent' family of - functions for accessing user login records in the 'utmp' file. - POSIX omits these functions in favor of the 'utxent' family, - and they are obsolete on systems other than Linux. - - This option group includes the following functions: - - endutent - getutent - getutent_r - getutid - getutid_r - getutline - getutline_r - logwtmp - pututline - setutent - updwtmp - utmpname - - This option group includes the following libraries: - - libutil.so (and libutil.a) - - -config EGLIBC_OPTION_EGLIBC_UTMPX - bool "POSIX access functions for 'utmp' login records" - default y - select EGLIBC_OPTION_EGLIBC_UTMP - help - This option group includes the POSIX functions for reading and - writing user login records in the 'utmp' file (usually - '/var/run/utmp'). The POSIX functions operate on 'struct - utmpx' structures, as opposed to the family of older 'utent' - functions, which operate on 'struct utmp' structures. - - This option group includes the following functions: - - endutxent - getutmp - getutmpx - getutxent - getutxid - getutxline - pututxline - setutxent - updwtmpx - utmpxname - - -config EGLIBC_OPTION_EGLIBC_WORDEXP - bool "Shell-style word expansion" - default y - help - This option group includes the 'wordexp' function for - performing word expansion in the manner of the shell, and the - accompanying 'wordfree' function. - - -config EGLIBC_OPTION_POSIX_C_LANG_WIDE_CHAR - bool "ISO C library wide character functions, excluding I/O" - default y - help - This option group includes the functions defined by the ISO C - standard for working with wide and multibyte characters in - memory. Functions for reading and writing wide and multibyte - characters from and to files call in the - EGLIBC_OPTION_POSIX_WIDE_CHAR_DEVICE_IO option group. - - This option group includes the following functions: - - btowc mbsinit wcscspn wcstoll - iswalnum mbsrtowcs wcsftime wcstombs - iswalpha mbstowcs wcslen wcstoul - iswblank mbtowc wcsncat wcstoull - iswcntrl swprintf wcsncmp wcstoumax - iswctype swscanf wcsncpy wcsxfrm - iswdigit towctrans wcspbrk wctob - iswgraph towlower wcsrchr wctomb - iswlower towupper wcsrtombs wctrans - iswprint vswprintf wcsspn wctype - iswpunct vswscanf wcsstr wmemchr - iswspace wcrtomb wcstod wmemcmp - iswupper wcscat wcstof wmemcpy - iswxdigit wcschr wcstoimax wmemmove - mblen wcscmp wcstok wmemset - mbrlen wcscoll wcstol - mbrtowc wcscpy wcstold - - -config EGLIBC_OPTION_POSIX_REGEXP - bool "Regular expressions" - default y - help - This option group includes the POSIX regular expression - functions, and the associated non-POSIX extensions and - compatibility functions. - - With EGLIBC_OPTION_POSIX_REGEXP disabled, the following functions are - omitted from libc: - - re_comp re_max_failures regcomp - re_compile_fastmap re_search regerror - re_compile_pattern re_search_2 regexec - re_exec re_set_registers regfree - re_match re_set_syntax rpmatch - re_match_2 re_syntax_options - - Furthermore, the compatibility regexp interface defined in the - header file, 'compile', 'step', and 'advance', is - omitted. - - -config EGLIBC_OPTION_POSIX_REGEXP_GLIBC - bool "Regular expressions from GLIBC" - default y - select EGLIBC_OPTION_POSIX_REGEXP - help - This option group specifies which regular expression - library to use. The choice is between regex - implementation from GLIBC and regex implementation from - libiberty. The GLIBC variant is fully POSIX conformant and - optimized for speed; regex from libiberty is more than twice - as small while still is enough for most practical purposes. - - -config EGLIBC_OPTION_POSIX_WIDE_CHAR_DEVICE_IO - bool "Input and output functions for wide characters" - default y - select EGLIBC_OPTION_POSIX_C_LANG_WIDE_CHAR - help - This option group includes functions for reading and writing - wide characters to and from streams. - - This option group includes the following functions: - - fgetwc fwprintf putwchar vwscanf - fgetws fwscanf ungetwc wprintf - fputwc getwc vfwprintf wscanf - fputws getwchar vfwscanf - fwide putwc vwprintf - - This option group further includes the following unlocked - variants of the above functions: - - fgetwc_unlocked getwc_unlocked - fgetws_unlocked getwchar_unlocked - fputwc_unlocked putwc_unlocked - fputws_unlocked putwchar_unlocked - - Note that the GNU standard C++ library, 'libstdc++.so', uses - some of these functions; you will not be able to link or run - C++ programs if you disable this option group. - - This option group also affects the behavior of the following - functions: - - fdopen - fopen - fopen64 - freopen - freopen64 - - These functions all take an OPENTYPE parameter which may - contain a string of the form ",ccs=CHARSET", indicating that - the underlying file uses the character set named CHARSET. - This produces a wide-oriented stream, which is only useful - when the functions included in this option group are present. - If the user attempts to open a file specifying a character set - in the OPENTYPE parameter, and EGLIBC was built with this - option group disabled, the function returns NULL, and sets - errno to EINVAL. diff --git a/toolchain/glibc/headers/Makefile b/toolchain/glibc/headers/Makefile index f9f411b1f0a..f1d8a8bc61e 100644 --- a/toolchain/glibc/headers/Makefile +++ b/toolchain/glibc/headers/Makefile @@ -15,6 +15,7 @@ define Host/Install install_root="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev" \ install-bootstrap-headers=yes \ install-headers + $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/ $(MAKE) -C $(CUR_BUILD_DIR) \ csu/subdir_lib ( cd $(CUR_BUILD_DIR); \ diff --git a/toolchain/glibc/patches/2.15/001-fix_autoconf_macro.patch b/toolchain/glibc/patches/2.15/001-fix_autoconf_macro.patch deleted file mode 100644 index 55b26c7dad9..00000000000 --- a/toolchain/glibc/patches/2.15/001-fix_autoconf_macro.patch +++ /dev/null @@ -1,48 +0,0 @@ ---- a/libc/aclocal.m4 -+++ b/libc/aclocal.m4 -@@ -88,6 +88,12 @@ - fi - rm -fr contest*]) - -+dnl Test a compiler option or options with an empty input file. -+dnl LIBC_TRY_CC_OPTION([options], [action-if-true], [action-if-false]) -+AC_DEFUN([LIBC_TRY_CC_OPTION], -+[AS_IF([AC_TRY_COMMAND([${CC-cc} $1 -xc /dev/null -S -o /dev/null])], -+ [$2], [$3])]) -+ - AC_DEFUN([LIBC_PROG_BINUTILS], - [# Was a --with-binutils option given? - if test -n "$path_binutils"; then ---- a/libc/configure -+++ b/libc/configure -@@ -7404,7 +7404,14 @@ - else - libc_cv_cc_nofma= - for opt in -ffp-contract=off -mno-fused-madd; do -- LIBC_TRY_CC_OPTION($opt, libc_cv_cc_nofma=$opt; break) -+ if { ac_try='${CC-cc} $opt -xc /dev/null -S -o /dev/null' -+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 -+ test $ac_status = 0; }; }; then : -+ libc_cv_cc_nofma=$opt; break -+fi - done - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_nofma" >&5 ---- a/libc/configure.in -+++ b/libc/configure.in -@@ -2238,10 +2238,9 @@ - libc_cv_cc_submachine, [dnl - libc_cv_cc_submachine=no - for opt in "-march=$submachine" "-mcpu=$submachine"; do -- if AC_TRY_COMMAND([${CC-cc} $opt -xc /dev/null -S -o /dev/null]); then -+ LIBC_TRY_CC_OPTION([$opt], [ - libc_cv_cc_submachine="$opt" -- break -- fi -+ break], []) - done]) - if test "x$libc_cv_cc_submachine" = xno; then - AC_MSG_ERROR([${CC-cc} does not support $submachine]) diff --git a/toolchain/glibc/patches/2.15/005-versions.patch b/toolchain/glibc/patches/2.15/005-versions.patch deleted file mode 100644 index da9d2bacb59..00000000000 --- a/toolchain/glibc/patches/2.15/005-versions.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/libc/configure.in -+++ b/libc/configure.in -@@ -1037,7 +1037,7 @@ - critic_missing="$critic_missing gcc") - AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version, - [GNU Make[^0-9]*\([0-9][0-9.]*\)], -- [3.79* | 3.[89]*], critic_missing="$critic_missing make") -+ [3.79* | 3.[89]* | 4.* ], critic_missing="$critic_missing make") - - AC_CHECK_PROG_VER(MSGFMT, gnumsgfmt gmsgfmt msgfmt, --version, - [GNU gettext.* \([0-9]*\.[0-9.]*\)], diff --git a/toolchain/glibc/patches/2.15/050-all_glibc-2.14-leak-revert-crash.patch b/toolchain/glibc/patches/2.15/050-all_glibc-2.14-leak-revert-crash.patch deleted file mode 100644 index d1e19aa4482..00000000000 --- a/toolchain/glibc/patches/2.15/050-all_glibc-2.14-leak-revert-crash.patch +++ /dev/null @@ -1,110 +0,0 @@ -partially revert commit 4bff6e0175ed195871f4e01cc4c4c33274b8f6e3 - caused segmentation faults in dlopen - -References: -http://comments.gmane.org/gmane.comp.lib.glibc.user/1227 -http://sourceware.org/ml/libc-alpha/2011-06/msg00006.html - -diff --git a/libc/elf/dl-close.c b/libc/elf/dl-close.c -index 4b17bf8..733cc1b 100644 ---- a/libc/elf/dl-close.c -+++ b/libc/elf/dl-close.c -@@ -119,17 +119,8 @@ _dl_close_worker (struct link_map *map) - if (map->l_direct_opencount > 0 || map->l_type != lt_loaded - || dl_close_state != not_pending) - { -- if (map->l_direct_opencount == 0) -- { -- if (map->l_type == lt_loaded) -- dl_close_state = rerun; -- else if (map->l_type == lt_library) -- { -- struct link_map **oldp = map->l_initfini; -- map->l_initfini = map->l_orig_initfini; -- _dl_scope_free (oldp); -- } -- } -+ if (map->l_direct_opencount == 0 && map->l_type == lt_loaded) -+ dl_close_state = rerun; - - /* There are still references to this object. Do nothing more. */ - if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_FILES, 0)) -diff --git a/libc/elf/dl-deps.c b/libc/elf/dl-deps.c -index 51cb2fa..eddcbf0 100644 ---- a/libc/elf/dl-deps.c -+++ b/libc/elf/dl-deps.c -@@ -489,6 +489,7 @@ _dl_map_object_deps (struct link_map *map, - nneeded * sizeof needed[0]); - atomic_write_barrier (); - l->l_initfini = l_initfini; -+ l->l_free_initfini = 1; - } - - /* If we have no auxiliary objects just go on to the next map. */ -@@ -689,6 +690,7 @@ Filters not supported with LD_TRACE_PRELINKING")); - l_initfini[nlist] = NULL; - atomic_write_barrier (); - map->l_initfini = l_initfini; -+ map->l_free_initfini = 1; - if (l_reldeps != NULL) - { - atomic_write_barrier (); -@@ -697,7 +699,7 @@ Filters not supported with LD_TRACE_PRELINKING")); - _dl_scope_free (old_l_reldeps); - } - if (old_l_initfini != NULL) -- map->l_orig_initfini = old_l_initfini; -+ _dl_scope_free (old_l_initfini); - - if (errno_reason) - _dl_signal_error (errno_reason == -1 ? 0 : errno_reason, objname, -diff --git a/libc/elf/dl-libc.c b/libc/elf/dl-libc.c -index f44fa10..7563093 100644 ---- a/libc/elf/dl-libc.c -+++ b/libc/elf/dl-libc.c -@@ -284,6 +284,10 @@ libc_freeres_fn (free_mem) - if (! old->dont_free) - free (old); - } -+ -+ /* Free the initfini dependency list. */ -+ if (l->l_free_initfini) -+ free (l->l_initfini); - } - - if (__builtin_expect (GL(dl_ns)[ns]._ns_global_scope_alloc, 0) != 0 -diff --git a/libc/elf/rtld.c b/libc/elf/rtld.c -index b93a01f..2fc83ce 100644 ---- a/libc/elf/rtld.c -+++ b/libc/elf/rtld.c -@@ -2277,6 +2277,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", - lnp->dont_free = 1; - lnp = lnp->next; - } -+ l->l_free_initfini = 0; - - if (l != &GL(dl_rtld_map)) - _dl_relocate_object (l, l->l_scope, GLRO(dl_lazy) ? RTLD_LAZY : 0, -diff --git a/libc/include/link.h b/libc/include/link.h -index e877104..b1b4065 100644 ---- a/libc/include/link.h -+++ b/libc/include/link.h -@@ -192,6 +192,9 @@ struct link_map - during LD_TRACE_PRELINKING=1 - contains any DT_SYMBOLIC - libraries. */ -+ unsigned int l_free_initfini:1; /* Nonzero if l_initfini can be -+ freed, ie. not allocated with -+ the dummy malloc in ld.so. */ - - /* Collected information about own RPATH directories. */ - struct r_search_path_struct l_rpath_dirs; -@@ -240,9 +243,6 @@ struct link_map - - /* List of object in order of the init and fini calls. */ - struct link_map **l_initfini; -- /* The init and fini list generated at startup, saved when the -- object is also loaded dynamically. */ -- struct link_map **l_orig_initfini; - - /* List of the dependencies introduced through symbol binding. */ - struct link_map_reldeps diff --git a/toolchain/glibc/patches/2.15/100-fix_cross_rpcgen.patch b/toolchain/glibc/patches/2.15/100-fix_cross_rpcgen.patch deleted file mode 100644 index 8fe5cf3f7c2..00000000000 --- a/toolchain/glibc/patches/2.15/100-fix_cross_rpcgen.patch +++ /dev/null @@ -1,71 +0,0 @@ ---- a/libc/sunrpc/proto.h -+++ b/libc/sunrpc/proto.h -@@ -56,12 +56,14 @@ void add_type(int len, const char *type) - $build's C library and $host's GLIBC. */ - #ifdef _CROSS_RPCGEN_ - -+#undef stpcpy -+ - /* Rather then defining _GNU_SOURCE before including $build's - we just declare stpcpy here. */ - extern char *stpcpy (char *, const char *); - --/* Use $build's i18n support as we can't use $host's. */ --#define _(X) (gettext (X)) -+/* Do not use i18n support */ -+#define _(X) (X) - - /* rpcgen sources check for __GNU_LIBRARY__ to tweak for GLIBC code - that rpcgen generates. The proper fix would be to rename all those checks ---- a/libc/sunrpc/rpc/types.h -+++ b/libc/sunrpc/rpc/types.h -@@ -70,18 +70,23 @@ typedef unsigned long rpcport_t; - #endif - - #ifndef __u_char_defined --typedef __u_char u_char; --typedef __u_short u_short; --typedef __u_int u_int; --typedef __u_long u_long; --typedef __quad_t quad_t; --typedef __u_quad_t u_quad_t; --typedef __fsid_t fsid_t; -+typedef unsigned char u_char; -+typedef unsigned short u_short; -+typedef unsigned int u_int; -+typedef unsigned long u_long; -+#if __WORDSIZE == 64 -+typedef long int quad_t; -+typedef unsigned long int u_quad_t; -+#elif defined __GLIBC_HAVE_LONG_LONG -+typedef long long int quad_t; -+typedef unsigned long long int u_quad_t; -+#endif -+typedef u_quad_t fsid_t; - # define __u_char_defined - #endif --#ifndef __daddr_t_defined --typedef __daddr_t daddr_t; --typedef __caddr_t caddr_t; -+#if !defined(__daddr_t_defined) && defined(linux) -+typedef long int daddr_t; -+typedef char *caddr_t; - # define __daddr_t_defined - #endif - ---- a/libc/sunrpc/rpc_main.c -+++ b/libc/sunrpc/rpc_main.c -@@ -997,9 +997,10 @@ mkfile_output (struct commandline *cmd) - abort (); - temp = rindex (cmd->infile, '.'); - cp = stpcpy (mkfilename, "Makefile."); -- if (temp != NULL) -- *((char *) stpncpy (cp, cmd->infile, temp - cmd->infile)) = '\0'; -- else -+ if (temp != NULL) { -+ strncpy(cp, cmd->infile, temp - cmd->infile); -+ cp[temp - cmd->infile - 1] = 0; -+ } else - stpcpy (cp, cmd->infile); - - } diff --git a/toolchain/glibc/patches/2.15/110-fix_cross_zic.patch b/toolchain/glibc/patches/2.15/110-fix_cross_zic.patch deleted file mode 100644 index 221eb28709a..00000000000 --- a/toolchain/glibc/patches/2.15/110-fix_cross_zic.patch +++ /dev/null @@ -1,27 +0,0 @@ ---- a/libc/timezone/zic.c -+++ b/libc/timezone/zic.c -@@ -8,6 +8,8 @@ static char elsieid[] = "@(#)zic.c 8.19" - #ifdef CROSS_ZIC - #define REPORT_BUGS_TO "" - #define PKGVERSION "" -+#undef _ -+#define _(X) (X) - #else - #include "config.h" - #endif -@@ -490,6 +492,7 @@ char * argv[]; - #ifdef unix - (void) umask(umask(S_IWGRP | S_IWOTH) | (S_IWGRP | S_IWOTH)); - #endif /* defined unix */ -+#ifndef CROSS_ZIC - #if HAVE_GETTEXT - (void) setlocale(LC_ALL, ""); - #ifdef TZ_DOMAINDIR -@@ -497,6 +500,7 @@ char * argv[]; - #endif /* defined TEXTDOMAINDIR */ - (void) textdomain(TZ_DOMAIN); - #endif /* HAVE_GETTEXT */ -+#endif - progname = argv[0]; - if (TYPE_BIT(zic_t) < 64) { - (void) fprintf(stderr, "%s: %s\n", progname, diff --git a/toolchain/glibc/patches/2.15/120-use_host_cflags.patch b/toolchain/glibc/patches/2.15/120-use_host_cflags.patch deleted file mode 100644 index 4c58fb4fb4a..00000000000 --- a/toolchain/glibc/patches/2.15/120-use_host_cflags.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/libc/sunrpc/Makefile -+++ b/libc/sunrpc/Makefile -@@ -175,7 +175,7 @@ $(objpfx)rpcgen: $(addprefix $(objpfx),$ - $(+link) - - $(addprefix $(objpfx)cross-,$(rpcgen-objs)): $(objpfx)cross-%.o: %.c -- gcc $< -c -D_RPC_THREAD_SAFE_ -D_CROSS_RPCGEN_ \ -+ gcc $< -c -D_RPC_THREAD_SAFE_ -D_CROSS_RPCGEN_ $(HOST_CFLAGS) \ - $(OUTPUT_OPTION) $(compile-mkdep-flags) - - $(objpfx)cross-rpcgen: $(addprefix $(objpfx)cross-,$(rpcgen-objs)) ---- a/libc/timezone/Makefile -+++ b/libc/timezone/Makefile -@@ -182,7 +182,7 @@ $(objpfx)zic: $(addprefix $(objpfx), $(z - - $(addprefix $(objpfx)cross-,$(zic-objs)): $(objpfx)cross-%.o: %.c - gcc $< -c $(OUTPUT_OPTION) $(CFLAGS-$*.c) $(CPPFLAGS-$*) \ -- -DCROSS_ZIC $(compile-mkdep-flags) -+ -DCROSS_ZIC $(HOST_CFLAGS) $(compile-mkdep-flags) - - $(objpfx)cross-zic: $(addprefix $(objpfx)cross-,$(zic-objs)) - gcc $(addprefix $(objpfx)cross-,$(zic-objs)) -o $@ diff --git a/toolchain/glibc/patches/2.15/200-add-dl-search-paths.patch b/toolchain/glibc/patches/2.15/200-add-dl-search-paths.patch deleted file mode 100644 index 70e7e604de6..00000000000 --- a/toolchain/glibc/patches/2.15/200-add-dl-search-paths.patch +++ /dev/null @@ -1,14 +0,0 @@ -add /usr/lib to default search path for the dynamic linker - ---- a/libc/Makeconfig -+++ b/libc/Makeconfig -@@ -539,6 +539,9 @@ - default-rpath = $(libdir) - endif - -+# Add /usr/lib to default search path for the dynamic linker -+user-defined-trusted-dirs := /usr/lib -+ - ifndef link-extra-libs - link-extra-libs = $(LDLIBS-$(@F)) - link-extra-libs-static = $(link-extra-libs) diff --git a/toolchain/glibc/patches/2.19/100-fix_cross_rpcgen.patch b/toolchain/glibc/patches/2.19/100-fix_cross_rpcgen.patch deleted file mode 100644 index 5c0d45b5305..00000000000 --- a/toolchain/glibc/patches/2.19/100-fix_cross_rpcgen.patch +++ /dev/null @@ -1,52 +0,0 @@ ---- a/libc/sunrpc/rpc/types.h -+++ b/libc/sunrpc/rpc/types.h -@@ -75,18 +75,23 @@ typedef unsigned long rpcport_t; - #endif - - #ifndef __u_char_defined --typedef __u_char u_char; --typedef __u_short u_short; --typedef __u_int u_int; --typedef __u_long u_long; --typedef __quad_t quad_t; --typedef __u_quad_t u_quad_t; --typedef __fsid_t fsid_t; -+typedef unsigned char u_char; -+typedef unsigned short u_short; -+typedef unsigned int u_int; -+typedef unsigned long u_long; -+#if __WORDSIZE == 64 -+typedef long int quad_t; -+typedef unsigned long int u_quad_t; -+#elif defined __GLIBC_HAVE_LONG_LONG -+typedef long long int quad_t; -+typedef unsigned long long int u_quad_t; -+#endif -+typedef u_quad_t fsid_t; - # define __u_char_defined - #endif --#ifndef __daddr_t_defined --typedef __daddr_t daddr_t; --typedef __caddr_t caddr_t; -+#if !defined(__daddr_t_defined) && defined(linux) -+typedef long int daddr_t; -+typedef char *caddr_t; - # define __daddr_t_defined - #endif - ---- a/libc/sunrpc/rpc_main.c -+++ b/libc/sunrpc/rpc_main.c -@@ -958,9 +958,10 @@ mkfile_output (struct commandline *cmd) - abort (); - temp = rindex (cmd->infile, '.'); - cp = stpcpy (mkfilename, "Makefile."); -- if (temp != NULL) -- *((char *) stpncpy (cp, cmd->infile, temp - cmd->infile)) = '\0'; -- else -+ if (temp != NULL) { -+ strncpy(cp, cmd->infile, temp - cmd->infile); -+ cp[temp - cmd->infile - 1] = 0; -+ } else - stpcpy (cp, cmd->infile); - - } diff --git a/toolchain/glibc/patches/2.19/200-add-dl-search-paths.patch b/toolchain/glibc/patches/2.19/200-add-dl-search-paths.patch deleted file mode 100644 index fa192ca1cd1..00000000000 --- a/toolchain/glibc/patches/2.19/200-add-dl-search-paths.patch +++ /dev/null @@ -1,14 +0,0 @@ -add /usr/lib to default search path for the dynamic linker - ---- a/libc/Makeconfig -+++ b/libc/Makeconfig -@@ -501,6 +501,9 @@ else - default-rpath = $(libdir) - endif - -+# Add /usr/lib to default search path for the dynamic linker -+user-defined-trusted-dirs := /usr/lib -+ - ifndef link-extra-libs - link-extra-libs = $(LDLIBS-$(@F)) - link-extra-libs-static = $(link-extra-libs) diff --git a/toolchain/glibc/patches/2.19/300-require-autoconf-2.69.patch b/toolchain/glibc/patches/2.19/300-require-autoconf-2.69.patch deleted file mode 100644 index 623885ca8fa..00000000000 --- a/toolchain/glibc/patches/2.19/300-require-autoconf-2.69.patch +++ /dev/null @@ -1,13 +0,0 @@ -Index: eglibc-2.19-r25243/libc/aclocal.m4 -=================================================================== ---- eglibc-2.19-r25243.orig/libc/aclocal.m4 2013-11-06 15:03:08.000000000 -0800 -+++ eglibc-2.19-r25243/libc/aclocal.m4 2014-11-22 15:43:05.343256863 -0800 -@@ -1,7 +1,7 @@ - dnl We require that everyone use exactly the same Autoconf version so that - dnl the internal functions defined and used by the main configure script - dnl match those expected by the fragments. --m4_define([GLIBC_AUTOCONF_VERSION], [2.68]) -+m4_define([GLIBC_AUTOCONF_VERSION], [2.69]) - m4_if(m4_defn([AC_AUTOCONF_VERSION]), GLIBC_AUTOCONF_VERSION, [], - [m4_fatal(m4_flatten( - Exactly version GLIBC_AUTOCONF_VERSION of Autoconf is required but you have diff --git a/toolchain/glibc/patches/2.19/301-add-strlcpy-support.patch b/toolchain/glibc/patches/2.19/301-add-strlcpy-support.patch deleted file mode 100644 index 4e06b03b9ad..00000000000 --- a/toolchain/glibc/patches/2.19/301-add-strlcpy-support.patch +++ /dev/null @@ -1,179 +0,0 @@ ---- a/libc/string/Makefile -+++ b/libc/string/Makefile -@@ -41,9 +41,9 @@ - addsep replace) \ - basename \ - strcoll_l strxfrm_l string-inlines memrchr \ -- xpg-strerror strerror_l -+ xpg-strerror strerror_l strlcat strlcpy - --routines-$(OPTION_EGLIBC_ENVZ) += envz -+routines-$(OPTION_EGLIBC_ENVZ) += envz - - strop-tests := memchr memcmp memcpy memmove mempcpy memset memccpy \ - stpcpy stpncpy strcat strchr strcmp strcpy strcspn \ -@@ -56,7 +56,7 @@ - tst-strtok tst-strfry \ - bug-strtok1 $(addprefix test-,$(strop-tests)) \ - tst-strxfrm2 tst-endian tst-svc2 tst-strtok_r --tests-$(OPTION_EGLIBC_ENVZ) += bug-envz1 -+tests-$(OPTION_EGLIBC_ENVZ) += bug-envz1 - tests-$(OPTION_EGLIBC_LOCALE_CODE) \ - += tst-strxfrm bug-strcoll1 - ---- a/libc/string/Versions -+++ b/libc/string/Versions -@@ -35,7 +35,7 @@ - rindex; - - # s* -- stpcpy; stpncpy; strcasecmp; strcat; strchr; strcmp; strcoll; strcpy; -+ stpcpy; stpncpy; strcasecmp; strcat; strlcat; strlcpy; strchr; strcmp; strcoll; strcpy; - strcspn; strdup; strerror; strerror_r; strfry; strlen; strncasecmp; - strncat; strncmp; strncpy; strndup; strnlen; strpbrk; strrchr; strsep; - strsignal; strspn; strstr; strtok; strtok_r; strxfrm; swab; ---- a/libc/string/string.h -+++ b/libc/string/string.h -@@ -558,6 +558,24 @@ - const char *__restrict __delim) - __THROW __nonnull ((1, 2)); - #endif -+/* -+ * Appends __src to string __dst of size __n (unlike strncat, __n is the -+ * full size of __dst, not space left). At most __n-1 characters -+ * will be copied. Always NUL terminates (unless __n <= strlen(__dst)). -+ * Returns strlen(__src) + MIN(__n, strlen(initial __dst)). -+ * If retval >= __n, truncation occurred. -+ */ -+extern size_t strlcat (char *__dst, __const char *__src, size_t __n) -+ __THROW __nonnull ((1, 2)); -+ -+/* -+ * Copy __src to string __dst of size __n. At most __n-1 characters -+ * will be copied. Always NUL terminates (unless __n == 0). -+ * Returns strlen(__src); if retval >= __n, truncation occurred. -+ */ -+extern size_t strlcpy (char *__dst, __const char *__src, size_t __n) -+ __THROW __nonnull ((1, 2)); -+ - - #ifdef __USE_XOPEN2K8 - /* Return a string describing the meaning of the signal number in SIG. */ ---- a/dev/null -+++ b/libc/string/strlcat.c -@@ -0,0 +1,58 @@ -+/* $OpenBSD: strlcat.c,v 1.11 2003/06/17 21:56:24 millert Exp $ */ -+ -+/* -+* Copyright (c) 1998 Todd C. Miller -+ * -+ * Permission to use, copy, modify, and distribute this software for any -+ * purpose with or without fee is hereby granted, provided that the above -+ * copyright notice and this permission notice appear in all copies. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -+ */ -+ -+#if defined(LIBC_SCCS) && !defined(lint) -+static char *rcsid = "$OpenBSD: strlcat.c,v 1.11 2003/06/17 21:56:24 millert Exp $"; -+#endif /* LIBC_SCCS and not lint */ -+ -+#include -+#include -+ -+/* -+ * Appends src to string dst of size siz (unlike strncat, siz is the -+ * full size of dst, not space left). At most siz-1 characters -+ * will be copied. Always NUL terminates (unless siz <= strlen(dst)). -+ * Returns strlen(src) + MIN(siz, strlen(initial dst)). -+ * If retval >= siz, truncation occurred. -+ */ -+size_t strlcat(char *dst, const char *src, size_t siz) -+{ -+ register char *d = dst; -+ register const char *s = src; -+ register size_t n = siz; -+ size_t dlen; -+ -+ /* Find the end of dst and adjust bytes left but don't go past end */ -+ while (n-- != 0 && *d != '\0') -+ d++; -+ dlen = d - dst; -+ n = siz - dlen; -+ -+ if (n == 0) -+ return(dlen + strlen(s)); -+ while (*s != '\0') { -+ if (n != 1) { -+ *d++ = *s; -+ n--; -+ } -+ s++; -+ } -+ *d = '\0'; -+ -+ return(dlen + (s - src)); /* count does not include NUL */ -+} ---- a/dev/null -+++ b/libc/string/strlcpy.c -@@ -0,0 +1,54 @@ -+/* $OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp $ */ -+ -+/* -+ * Copyright (c) 1998 Todd C. Miller -+ * -+ * Permission to use, copy, modify, and distribute this software for any -+ * purpose with or without fee is hereby granted, provided that the above -+ * copyright notice and this permission notice appear in all copies. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -+ */ -+ -+#if defined(LIBC_SCCS) && !defined(lint) -+static char *rcsid = "$OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp $"; -+#endif /* LIBC_SCCS and not lint */ -+ -+#include -+#include -+ -+/* -+ * Copy src to string dst of size siz. At most siz-1 characters -+ * will be copied. Always NUL terminates (unless siz == 0). -+ * Returns strlen(src); if retval >= siz, truncation occurred. -+ */ -+size_t strlcpy(char *dst, const char *src, size_t siz) -+{ -+ register char *d = dst; -+ register const char *s = src; -+ register size_t n = siz; -+ -+ /* Copy as many bytes as will fit */ -+ if (n != 0 && --n != 0) { -+ do { -+ if ((*d++ = *s++) == 0) -+ break; -+ } while (--n != 0); -+ } -+ -+ /* Not enough room in dst, add NUL and traverse rest of src */ -+ if (n == 0) { -+ if (siz != 0) -+ *d = '\0'; /* NUL-terminate dst */ -+ while (*s++) -+ ; -+ } -+ -+ return(s - src - 1); /* count does not include NUL */ -+} diff --git a/toolchain/glibc/patches/2.21/100-fix_cross_rpcgen.patch b/toolchain/glibc/patches/2.24/100-fix_cross_rpcgen.patch similarity index 100% rename from toolchain/glibc/patches/2.21/100-fix_cross_rpcgen.patch rename to toolchain/glibc/patches/2.24/100-fix_cross_rpcgen.patch diff --git a/toolchain/glibc/patches/2.21/200-add-dl-search-paths.patch b/toolchain/glibc/patches/2.24/200-add-dl-search-paths.patch similarity index 93% rename from toolchain/glibc/patches/2.21/200-add-dl-search-paths.patch rename to toolchain/glibc/patches/2.24/200-add-dl-search-paths.patch index 070f938fe36..d65a0bcdd01 100644 --- a/toolchain/glibc/patches/2.21/200-add-dl-search-paths.patch +++ b/toolchain/glibc/patches/2.24/200-add-dl-search-paths.patch @@ -2,7 +2,7 @@ add /usr/lib to default search path for the dynamic linker --- a/Makeconfig +++ b/Makeconfig -@@ -499,6 +499,9 @@ else +@@ -526,6 +526,9 @@ else default-rpath = $(libdir) endif diff --git a/toolchain/insight/Makefile b/toolchain/insight/Makefile index 3744f564511..60309ba094a 100644 --- a/toolchain/insight/Makefile +++ b/toolchain/insight/Makefile @@ -10,7 +10,7 @@ PKG_NAME:=insight PKG_VERSION:=6.8-1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)a.tar.bz2 -PKG_MD5SUM:=f7dd764a102beb75c2bb6b8d83455f8e +PKG_HASH:=51216df73adc4f68c67b60356270d5073f0ff094c1b477ecd96560f49707ea2a PKG_SOURCE_URL:=ftp://sourceware.org/pub/insight/releases PKG_CAT:=bzcat diff --git a/toolchain/kernel-headers/Makefile b/toolchain/kernel-headers/Makefile index 90f8eb1a3c2..1bf5598d6fd 100644 --- a/toolchain/kernel-headers/Makefile +++ b/toolchain/kernel-headers/Makefile @@ -19,7 +19,7 @@ PKG_VERSION:=$(LINUX_VERSION) PKG_SOURCE:=$(LINUX_SOURCE) PKG_SOURCE_URL:=$(LINUX_SITE) HOST_BUILD_DIR:=$(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) -PKG_MD5SUM:=$(LINUX_KERNEL_MD5SUM) +PKG_HASH:=$(LINUX_KERNEL_HASH) LINUX_DIR := $(HOST_BUILD_DIR) FILES_DIR := PATCH_DIR := ./patches$(if $(wildcard ./patches-$(LINUX_VERSION)),-$(LINUX_VERSION)) @@ -57,7 +57,7 @@ ifneq ($(CONFIG_mips)$(CONFIG_mipsel),) $(CP) \ $(HOST_BUILD_DIR)/arch/mips/include/asm/asm.h \ $(HOST_BUILD_DIR)/arch/mips/include/asm/regdef.h \ - $(if $(call kernel_patchver_ge,3.15.0),$(HOST_BUILD_DIR)/arch/mips/include/asm/asm-eva.h) \ + $(HOST_BUILD_DIR)/arch/mips/include/asm/asm-eva.h \ $(BUILD_DIR_TOOLCHAIN)/linux-dev/include/asm/ endef endif @@ -71,8 +71,10 @@ define Host/Configure/post/mipsel endef define Host/Prepare + rm -rf $(BUILD_DIR_TOOLCHAIN)/linux-* $(call Kernel/Prepare/Default) - ln -sf linux-$(LINUX_VERSION) $(BUILD_DIR_TOOLCHAIN)/linux + rm -f $(BUILD_DIR_TOOLCHAIN)/linux + ln -s linux-$(LINUX_VERSION) $(BUILD_DIR_TOOLCHAIN)/linux $(SED) 's/@expr length/@-expr length/' $(HOST_BUILD_DIR)/Makefile endef diff --git a/toolchain/musl/Config.in b/toolchain/musl/Config.in deleted file mode 100644 index 05caa6ab6f3..00000000000 --- a/toolchain/musl/Config.in +++ /dev/null @@ -1,6 +0,0 @@ -# Debug version. - -config MUSL_ENABLE_DEBUG - bool "Build with debug information" - depends on TOOLCHAINOPTS && USE_MUSL - default n diff --git a/toolchain/musl/Makefile b/toolchain/musl/Makefile index 1533f51a0d6..2b9312bcbf1 100644 --- a/toolchain/musl/Makefile +++ b/toolchain/musl/Makefile @@ -24,7 +24,7 @@ endef define Host/Install $(call Host/SetToolchainInfo) - $(MAKE) $(MUSL_MAKEOPTS) DESTDIR="$(TOOLCHAIN_DIR)/" install + +$(MAKE) $(HOST_JOBS) $(MUSL_MAKEOPTS) DESTDIR="$(TOOLCHAIN_DIR)/" install $(CP) ./include $(TOOLCHAIN_DIR)/ endef diff --git a/toolchain/musl/common.mk b/toolchain/musl/common.mk index 2c9809fc55b..bfe8eebc7b1 100644 --- a/toolchain/musl/common.mk +++ b/toolchain/musl/common.mk @@ -11,10 +11,13 @@ PKG_NAME:=musl PKG_VERSION:=$(call qstrip,$(CONFIG_MUSL_VERSION)) PKG_RELEASE=1 -PKG_MD5SUM:=ac52ccaec6b06ab0f289d37e8436859b +PKG_SOURCE_PROTO:=git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=769f53598e781ffc89191520f3f8a93cb58db91f +PKG_MIRROR_HASH:=c148c570cc46471ab30a1b36e96531519837e41c4347f3164bf610ab98741d80 +PKG_SOURCE_URL:=git://git.musl-libc.org/musl +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz -PKG_SOURCE_URL:=http://www.musl-libc.org/releases -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz LIBC_SO_VERSION:=$(PKG_VERSION) PATCH_DIR:=$(PATH_PREFIX)/patches @@ -31,12 +34,8 @@ MUSL_CONFIGURE:= \ --prefix=/ \ --host=$(GNU_HOST_NAME) \ --target=$(REAL_GNU_TARGET_NAME) \ - --disable-gcc-wrapper - -ifeq ($(CONFIG_MUSL_ENABLE_DEBUG),y) -MUSL_CONFIGURE+= \ - --enable-debug -endif + --disable-gcc-wrapper \ + --enable-debug define Host/Prepare $(call Host/Prepare/Default) diff --git a/toolchain/musl/headers/Makefile b/toolchain/musl/headers/Makefile deleted file mode 100644 index 21e6b3bd152..00000000000 --- a/toolchain/musl/headers/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -PATH_PREFIX:=.. - -include ../common.mk - -HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.headers_built -HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.uclibc_headers_installed - -define Host/Compile - -endef - -define Host/Install -endef - -$(eval $(call HostBuild)) - diff --git a/toolchain/musl/patches/010-CVE-2016-8859-musl-fix.patch b/toolchain/musl/patches/010-CVE-2016-8859-musl-fix.patch deleted file mode 100644 index cf3478de742..00000000000 --- a/toolchain/musl/patches/010-CVE-2016-8859-musl-fix.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 6582baa752a8facb2c8a7b5b3dcf67331429cdc1 Mon Sep 17 00:00:00 2001 -From: Rich Felker -Date: Tue, 14 Mar 2017 14:18:07 -0400 -Subject: fix free of uninitialized buffer pointer on error in regexec - -the fix in commit c3edc06d1e1360f3570db9155d6b318ae0d0f0f7 for -CVE-2016-8859 used gotos to exit on overflow conditions, but the code -in that error path assumed the buffer pointer was valid or null. thus, -the conditions which previously led to under-allocation and buffer -overflow could instead lead to an invalid pointer being passed to -free. ---- - src/regex/regexec.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/src/regex/regexec.c b/src/regex/regexec.c -index 5c4cb922..253b0e14 100644 ---- a/src/regex/regexec.c -+++ b/src/regex/regexec.c -@@ -215,15 +215,15 @@ tre_tnfa_run_parallel(const tre_tnfa_t *tnfa, const void *string, - /* Ensure that tbytes and xbytes*num_states cannot overflow, and that - * they don't contribute more than 1/8 of SIZE_MAX to total_bytes. */ - if (num_tags > SIZE_MAX/(8 * sizeof(regoff_t) * tnfa->num_states)) -- goto error_exit; -+ return REG_ESPACE; - - /* Likewise check rbytes. */ - if (tnfa->num_states+1 > SIZE_MAX/(8 * sizeof(*reach_next))) -- goto error_exit; -+ return REG_ESPACE; - - /* Likewise check pbytes. */ - if (tnfa->num_states > SIZE_MAX/(8 * sizeof(*reach_pos))) -- goto error_exit; -+ return REG_ESPACE; - - /* Compute the length of the block we need. */ - tbytes = sizeof(*tmp_tags) * num_tags; --- -cgit v1.2.1 - diff --git a/toolchain/musl/patches/020-CVE-2017-15650-musl-fix.patch b/toolchain/musl/patches/020-CVE-2017-15650-musl-fix.patch deleted file mode 100644 index 60cb4d10325..00000000000 --- a/toolchain/musl/patches/020-CVE-2017-15650-musl-fix.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 45ca5d3fcb6f874bf5ba55d0e9651cef68515395 Mon Sep 17 00:00:00 2001 -From: Rich Felker -Date: Wed, 18 Oct 2017 14:50:03 -0400 -Subject: in dns parsing callback, enforce MAXADDRS to preclude overflow - -MAXADDRS was chosen not to need enforcement, but the logic used to -compute it assumes the answers received match the RR types of the -queries. specifically, it assumes that only one replu contains A -record answers. if the replies to both the A and the AAAA query have -their answer sections filled with A records, MAXADDRS can be exceeded -and clobber the stack of the calling function. - -this bug was found and reported by Felix Wilhelm. ---- - src/network/lookup_name.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/src/network/lookup_name.c b/src/network/lookup_name.c -index 066be4d5..209c20f0 100644 ---- a/src/network/lookup_name.c -+++ b/src/network/lookup_name.c -@@ -111,6 +111,7 @@ static int dns_parse_callback(void *c, int rr, const void *data, int len, const - { - char tmp[256]; - struct dpc_ctx *ctx = c; -+ if (ctx->cnt >= MAXADDRS) return -1; - switch (rr) { - case RR_A: - if (len != 4) return -1; --- -cgit v1.2.1 - diff --git a/toolchain/musl/patches/040-Add-format-attribute-to-some-function-declarations.patch b/toolchain/musl/patches/400-Add-format-attribute-to-some-function-declarations.patch similarity index 100% rename from toolchain/musl/patches/040-Add-format-attribute-to-some-function-declarations.patch rename to toolchain/musl/patches/400-Add-format-attribute-to-some-function-declarations.patch index 67fedae30a0..c495d67e080 100644 --- a/toolchain/musl/patches/040-Add-format-attribute-to-some-function-declarations.patch +++ b/toolchain/musl/patches/400-Add-format-attribute-to-some-function-declarations.patch @@ -45,7 +45,11 @@ Signed-off-by: Hauke Mehrtens +#else +#define __fp(x, y) +#endif -+ + +-_Noreturn void err(int, const char *, ...); +-_Noreturn void verr(int, const char *, va_list); +-_Noreturn void errx(int, const char *, ...); +-_Noreturn void verrx(int, const char *, va_list); +void warn(const char *, ...) __fp(1, 2); +void vwarn(const char *, va_list) __fp(1, 0); +void warnx(const char *, ...) __fp(1, 2); @@ -55,11 +59,7 @@ Signed-off-by: Hauke Mehrtens +_Noreturn void verr(int, const char *, va_list) __fp(2, 0); +_Noreturn void errx(int, const char *, ...) __fp(2, 3); +_Noreturn void verrx(int, const char *, va_list) __fp(2, 0); - --_Noreturn void err(int, const char *, ...); --_Noreturn void verr(int, const char *, va_list); --_Noreturn void errx(int, const char *, ...); --_Noreturn void verrx(int, const char *, va_list); ++ +#undef __fp #ifdef __cplusplus diff --git a/toolchain/musl/patches/902-add-support-for-unbuffered-putc.patch b/toolchain/musl/patches/902-add-support-for-unbuffered-putc.patch deleted file mode 100644 index 4aec8793340..00000000000 --- a/toolchain/musl/patches/902-add-support-for-unbuffered-putc.patch +++ /dev/null @@ -1,25 +0,0 @@ -Index: musl-1.1.16/src/stdio/fputc.c -=================================================================== ---- musl-1.1.16.orig/src/stdio/fputc.c 2017-01-01 08:57:17.000000000 +0530 -+++ musl-1.1.16/src/stdio/fputc.c 2017-10-20 12:10:54.073719904 +0530 -@@ -1,5 +1,15 @@ - #include "stdio_impl.h" -+#define UNBUFFERED_PUTC - -+#ifdef UNBUFFERED_PUTC -+int fputc(int c, FILE *f) -+{ -+ FLOCK(f); -+ f->write(f, &c, 1); -+ FUNLOCK(f); -+ return c; -+} -+#else - int fputc(int c, FILE *f) - { - if (f->lock < 0 || !__lockfile(f)) -@@ -8,3 +18,4 @@ - __unlockfile(f); - return c; - } -+#endif diff --git a/toolchain/uClibc/common.mk b/toolchain/uClibc/common.mk index d7c21e0b37b..35f4f808548 100644 --- a/toolchain/uClibc/common.mk +++ b/toolchain/uClibc/common.mk @@ -16,13 +16,14 @@ CONFIG_DIR:=$(PATH_PREFIX)/config PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz LIBC_SO_VERSION:=$(PKG_VERSION) -PKG_MD5SUM=8eed7f3635216142c1c5e122874b89c6 +PKG_HASH:=3c63d9f8c8b98b65fa5c4040d1c8ab1b36e99a16e1093810cedad51ac15c9a9e HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)-$(PKG_VERSION) include $(INCLUDE_DIR)/toolchain-build.mk UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \ + -e 's/arc.*/arc/' \ -e 's/i.86/i386/' \ -e 's/sparc.*/sparc/' \ -e 's/arm.*/arm/g' \ @@ -40,8 +41,9 @@ GEN_CONFIG=$(SCRIPT_DIR)/kconfig.pl -n \ $(if $(CONFIG_UCLIBC_ENABLE_DEBUG),$(if $(wildcard $(CONFIG_DIR)/debug),'+' $(CONFIG_DIR)/debug)) \ $(CONFIG_DIR)/$(ARCH)$(strip \ $(if $(wildcard $(CONFIG_DIR)/$(ARCH).$(BOARD)),.$(BOARD), \ + $(if $(filter archs,$(subst ",,$(CONFIG_CPU_TYPE))),hs, \ $(if $(CONFIG_MIPS64_ABI),.$(subst ",,$(CONFIG_MIPS64_ABI)), \ - $(if $(CONFIG_HAS_SPE_FPU),$(if $(wildcard $(CONFIG_DIR)/$(ARCH).e500),.e500))))) + $(if $(CONFIG_HAS_SPE_FPU),$(if $(wildcard $(CONFIG_DIR)/$(ARCH).e500),.e500)))))) CPU_CFLAGS = \ -funsigned-char -fno-builtin -fno-asm \ @@ -75,7 +77,6 @@ define Host/Configure $(SED) 's,^KERNEL_HEADERS=.*,KERNEL_HEADERS=\"$(BUILD_DIR_TOOLCHAIN)/linux-dev/include\",g' \ -e 's,^.*UCLIBC_HAS_FPU.*,UCLIBC_HAS_FPU=$(if $(CONFIG_SOFT_FLOAT),n,y),g' \ -e 's,^.*UCLIBC_HAS_SOFT_FLOAT.*,UCLIBC_HAS_SOFT_FLOAT=$(if $(CONFIG_SOFT_FLOAT),y,n),g' \ - -e 's,^.*UCLIBC_HAS_SHADOW.*,UCLIBC_HAS_SHADOW=$(if $(CONFIG_SHADOW_PASSWORDS),y,n),g' \ -e 's,^.*UCLIBC_HAS_LOCALE.*,UCLIBC_HAS_LOCALE=$(if $(CONFIG_BUILD_NLS),y,n),g' \ -e 's,^.*UCLIBC_BUILD_ALL_LOCALE.*,UCLIBC_BUILD_ALL_LOCALE=$(if $(CONFIG_BUILD_NLS),y,n),g' \ -e 's,^.*UCLIBC_HAS_SSP[^_].*,UCLIBC_HAS_SSP=$(if $(or $(CONFIG_PKG_CC_STACKPROTECTOR_REGULAR),$(CONFIG_PKG_CC_STACKPROTECTOR_STRONG)),y,n),g' \ diff --git a/toolchain/uClibc/config-0.9.33.2/arm b/toolchain/uClibc/config-0.9.33.2/arm deleted file mode 100644 index b68617bb419..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/arm +++ /dev/null @@ -1,7 +0,0 @@ -ARCH_ANY_ENDIAN=y -ARCH_LITTLE_ENDIAN=y -ARCH_WANTS_LITTLE_ENDIAN=y -# COMPILE_IN_THUMB_MODE is not set -TARGET_ARCH="arm" -TARGET_arm=y -# USE_BX is not set diff --git a/toolchain/uClibc/config-0.9.33.2/armeb b/toolchain/uClibc/config-0.9.33.2/armeb deleted file mode 100644 index d4932e864f1..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/armeb +++ /dev/null @@ -1,7 +0,0 @@ -ARCH_ANY_ENDIAN=y -ARCH_BIG_ENDIAN=y -ARCH_WANTS_BIG_ENDIAN=y -# COMPILE_IN_THUMB_MODE is not set -TARGET_ARCH="arm" -TARGET_arm=y -# USE_BX is not set diff --git a/toolchain/uClibc/config-0.9.33.2/common b/toolchain/uClibc/config-0.9.33.2/common deleted file mode 100644 index 457d21f638a..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/common +++ /dev/null @@ -1,213 +0,0 @@ -# ARCH_ANY_ENDIAN is not set -ARCH_HAS_MMU=y -# ARCH_HAS_NO_LDSO is not set -# ARCH_HAS_NO_SHARED is not set -# ARCH_LITTLE_ENDIAN is not set -ARCH_USE_MMU=y -# ARCH_WANTS_BIG_ENDIAN is not set -# ARCH_WANTS_LITTLE_ENDIAN is not set -ASSUME_DEVPTS=y -# COMPAT_ATEXIT is not set -CROSS_COMPILER_PREFIX="" -DEVEL_PREFIX="/usr/" -# DOASSERTS is not set -# DODEBUG is not set -# DODEBUG_PT is not set -# DOMULTI is not set -DOPIC=y -DOSTRIP=y -DO_C99_MATH=y -# DO_XSI_MATH is not set -# EXTRA_WARNINGS is not set -FORCE_OPTIONS_FOR_ARCH=y -# FORCE_SHAREABLE_TEXT_SEGMENTS is not set -# HARDWIRED_ABSPATH is not set -# HAS_NO_THREADS is not set -HAVE_DOT_CONFIG=y -# HAVE_NO_PIC is not set -# HAVE_NO_SSP is not set -HAVE_SHARED=y -KERNEL_HEADERS="." -LDSO_BASE_FILENAME="ld.so" -LDSO_CACHE_SUPPORT=y -# LDSO_GNU_HASH_SUPPORT is not set -LDSO_LD_LIBRARY_PATH=y -LDSO_LDD_SUPPORT=y -# LDSO_NO_CLEANUP is not set -# LDSO_PRELINK_SUPPORT is not set -# LDSO_PRELOAD_FILE_SUPPORT is not set -LDSO_PRELOAD_ENV_SUPPORT=y -LDSO_RUNPATH=y -# LDSO_SEARCH_INTERP_PATH is not set -# LDSO_STANDALONE_SUPPORT is not set -# LINUXTHREADS_NEW is not set -# LINUXTHREADS_OLD is not set -# UCLIBC_HAS_BACKTRACE is not set -UCLIBC_HAS_THREADS_NATIVE=y -# MALLOC is not set -MALLOC_GLIBC_COMPAT=y -# MALLOC_SIMPLE is not set -MALLOC_STANDARD=y -MULTILIB_DIR="lib" -PTHREADS_DEBUG_SUPPORT=y -RUNTIME_PREFIX="/" -# SUPPORT_LD_DEBUG is not set -# SUPPORT_LD_DEBUG_EARLY is not set -TARGET_SUBARCH="" -# TARGET_alpha is not set -# TARGET_arm is not set -# TARGET_avr32 is not set -# TARGET_bfin is not set -# TARGET_c6x is not set -# TARGET_cris is not set -# TARGET_e1 is not set -# TARGET_frv is not set -# TARGET_h8300 is not set -# TARGET_hppa is not set -# TARGET_i386 is not set -# TARGET_i960 is not set -# TARGET_ia64 is not set -# TARGET_m68k is not set -# TARGET_microblaze is not set -# TARGET_mips is not set -# TARGET_nios is not set -# TARGET_nios2 is not set -# TARGET_powerpc is not set -# TARGET_sh is not set -# TARGET_sh64 is not set -# TARGET_sparc is not set -# TARGET_v850 is not set -# TARGET_vax is not set -# TARGET_x86_64 is not set -# TARGET_xtensa is not set -UCLIBC_BSD_SPECIFIC=y -UCLIBC_BUILD_NOEXECSTACK=y -# UCLIBC_BUILD_NOW is not set -# UCLIBC_BUILD_PIE is not set -UCLIBC_BUILD_RELRO=y -UCLIBC_CTOR_DTOR=y -UCLIBC_DYNAMIC_ATEXIT=y -UCLIBC_EXTRA_CFLAGS="" -UCLIBC_GRP_BUFFER_SIZE=256 -UCLIBC_HAS_ADVANCED_REALTIME=y -# UCLIBC_HAS_ARC4RANDOM is not set -UCLIBC_HAS_BSD_ERR=y -UCLIBC_HAS_BSD_RES_CLOSE=y -# UCLIBC_HAS_COMPAT_RES_STATE is not set -UCLIBC_HAS_CRYPT=y -UCLIBC_HAS_CRYPT_IMPL=y -UCLIBC_HAS_CTYPE_CHECKED=y -# UCLIBC_HAS_CTYPE_ENFORCED is not set -UCLIBC_HAS_CTYPE_SIGNED=y -UCLIBC_HAS_CTYPE_TABLES=y -# UCLIBC_HAS_CTYPE_UNSAFE is not set -UCLIBC_HAS_EPOLL=y -UCLIBC_HAS_ERRNO_MESSAGES=y -# UCLIBC_HAS_EXTRA_COMPAT_RES_STATE is not set -# UCLIBC_HAS_FENV is not set -UCLIBC_HAS_FLOATS=y -UCLIBC_HAS_FNMATCH=y -UCLIBC_HAS_FNMATCH_OLD=y -# UCLIBC_HAS_FOPEN_CLOSEEXEC_MODE is not set -UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE=y -# UCLIBC_HAS_FOPEN_LARGEFILE_MODE is not set -# UCLIBC_HAS_FPU is not set -UCLIBC_HAS_FTS=y -UCLIBC_HAS_FTW=y -# UCLIBC_HAS_FULL_RPC is not set -UCLIBC_HAS_GETPT=y -UCLIBC_HAS_GLIBC_CUSTOM_PRINTF=y -UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y -# UCLIBC_HAS_GLIBC_DIGIT_GROUPING is not set -UCLIBC_HAS_GLOB=y -UCLIBC_HAS_GNU_ERROR=y -UCLIBC_HAS_GNU_GETOPT=y -UCLIBC_HAS_GNU_GETSUBOPT=y -UCLIBC_HAS_GNU_GLOB=y -UCLIBC_HAS_HEXADECIMAL_FLOATS=y -UCLIBC_HAS_IPV4=y -UCLIBC_HAS_IPV6=y -UCLIBC_HAS_LFS=y -UCLIBC_HAS_LIBNSL_STUB=y -UCLIBC_HAS_LIBRESOLV_STUB=y -UCLIBC_HAS_LIBUTIL=y -# UCLIBC_HAS_LOCALE is not set -# UCLIBC_BUILD_ALL_LOCALE is not set -# UCLIBC_BUILD_MINIMAL_LOCALE is not set -# UCLIBC_PREGENERATED_LOCALE_DATA is not set -UCLIBC_HAS_LONG_DOUBLE_MATH=y -UCLIBC_HAS_NETWORK_SUPPORT=y -UCLIBC_HAS_NFTW=y -# UCLIBC_HAS_OBSOLETE_BSD_SIGNAL is not set -# UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL is not set -UCLIBC_HAS_PRINTF_M_SPEC=y -# UCLIBC_HAS_PROFILING is not set -UCLIBC_HAS_PROGRAM_INVOCATION_NAME=y -UCLIBC_HAS_PTY=y -UCLIBC_HAS_REALTIME=y -# UCLIBC_HAS_REENTRANT_RPC is not set -UCLIBC_HAS_REGEX=y -UCLIBC_HAS_REGEX_OLD=y -UCLIBC_HAS_RESOLVER_SUPPORT=y -# UCLIBC_HAS_RPC is not set -UCLIBC_HAS_SCANF_GLIBC_A_FLAG=y -# UCLIBC_HAS_SHA256_CRYPT_IMPL is not set -# UCLIBC_HAS_SHA512_CRYPT_IMPL is not set -UCLIBC_HAS_SHADOW=y -UCLIBC_HAS_SIGNUM_MESSAGES=y -UCLIBC_HAS_SOCKET=y -UCLIBC_HAS_SOFT_FLOAT=y -# UCLIBC_HAS_SSP is not set -UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION=y -# UCLIBC_HAS_STDIO_BUFSIZ_1024 is not set -# UCLIBC_HAS_STDIO_BUFSIZ_2048 is not set -# UCLIBC_HAS_STDIO_BUFSIZ_256 is not set -UCLIBC_HAS_STDIO_BUFSIZ_4096=y -# UCLIBC_HAS_STDIO_BUFSIZ_512 is not set -# UCLIBC_HAS_STDIO_BUFSIZ_8192 is not set -# UCLIBC_HAS_STDIO_BUFSIZ_NONE is not set -# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4 is not set -# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8 is not set -UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE=y -UCLIBC_HAS_STDIO_GETC_MACRO=y -UCLIBC_HAS_STDIO_PUTC_MACRO=y -# UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT is not set -UCLIBC_HAS_STRING_ARCH_OPT=y -UCLIBC_HAS_STRING_GENERIC_OPT=y -# UCLIBC_HAS_STUBS is not set -UCLIBC_HAS_SYSLOG=y -# UCLIBC_HAS_SYS_ERRLIST is not set -# UCLIBC_HAS_SYS_SIGLIST is not set -UCLIBC_HAS_THREADS=y -UCLIBC_HAS_TM_EXTENSIONS=y -UCLIBC_HAS_TZ_CACHING=y -UCLIBC_HAS_TZ_FILE=y -UCLIBC_HAS_TZ_FILE_READ_MANY=y -# UCLIBC_HAS_UTMPX is not set -UCLIBC_HAS_WCHAR=y -UCLIBC_HAS_WORDEXP=y -# UCLIBC_HAS_XATTR is not set -# UCLIBC_HAS_XLOCALE is not set -UCLIBC_HAS___PROGNAME=y -# UCLIBC_LINUX_MODULE_24 is not set -UCLIBC_LINUX_MODULE_26=y -UCLIBC_LINUX_SPECIFIC=y -# UCLIBC_MALLOC_DEBUGGING is not set -# UCLIBC_MJN3_ONLY is not set -# UCLIBC_NTP_LEGACY is not set -# USE_OLD_VFPRINTF is not set -UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS=9 -UCLIBC_PWD_BUFFER_SIZE=256 -# UCLIBC_STATIC_LDCONFIG is not set -# UCLIBC_STRICT_HEADERS is not set -UCLIBC_SUPPORT_AI_ADDRCONFIG=y -UCLIBC_SUSV3_LEGACY=y -UCLIBC_SUSV3_LEGACY_MACROS=y -UCLIBC_SUSV4_LEGACY=y -# UCLIBC_SV4_DEPRECATED is not set -UCLIBC_TZ_FILE_PATH="/etc/TZ" -# UCLIBC_FALLBACK_TO_ETC_LOCALTIME is not set -UCLIBC_USE_NETLINK=y -# UNIX98PTY_ONLY is not set -USE_BX=y -WARNINGS="-Wall" diff --git a/toolchain/uClibc/config-0.9.33.2/debug b/toolchain/uClibc/config-0.9.33.2/debug deleted file mode 100644 index b366e66e390..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/debug +++ /dev/null @@ -1,6 +0,0 @@ -DODEBUG=y -DODEBUG_PT=y -PTHREADS_DEBUG_SUPPORT=y -SUPPORT_LD_DEBUG=y -SUPPORT_LD_DEBUG_EARLY=y -UCLIBC_MALLOC_DEBUGGING=y diff --git a/toolchain/uClibc/config-0.9.33.2/i386 b/toolchain/uClibc/config-0.9.33.2/i386 deleted file mode 100644 index 5ef264c271d..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/i386 +++ /dev/null @@ -1,21 +0,0 @@ -ARCH_LITTLE_ENDIAN=y -# CONFIG_386 is not set -CONFIG_486=y -# CONFIG_586 is not set -# CONFIG_586MMX is not set -# CONFIG_686 is not set -# CONFIG_CRUSOE is not set -# CONFIG_CYRIXIII is not set -# CONFIG_ELAN is not set -# CONFIG_GENERIC_386 is not set -# CONFIG_K6 is not set -# CONFIG_K7 is not set -# CONFIG_NEHEMIAH is not set -# CONFIG_PENTIUM4 is not set -# CONFIG_PENTIUMII is not set -# CONFIG_PENTIUMIII is not set -# CONFIG_WINCHIP2 is not set -# CONFIG_WINCHIPC6 is not set -TARGET_ARCH="i386" -TARGET_i386=y -UCLIBC_HAS_FPU=y diff --git a/toolchain/uClibc/config-0.9.33.2/i686 b/toolchain/uClibc/config-0.9.33.2/i686 deleted file mode 100644 index ba615f6b86a..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/i686 +++ /dev/null @@ -1,21 +0,0 @@ -ARCH_LITTLE_ENDIAN=y -# CONFIG_386 is not set -# CONFIG_486 is not set -# CONFIG_586 is not set -# CONFIG_586MMX is not set -CONFIG_686=y -# CONFIG_CRUSOE is not set -# CONFIG_CYRIXIII is not set -# CONFIG_ELAN is not set -# CONFIG_GENERIC_386 is not set -# CONFIG_K6 is not set -# CONFIG_K7 is not set -# CONFIG_NEHEMIAH is not set -# CONFIG_PENTIUM4 is not set -# CONFIG_PENTIUMII is not set -# CONFIG_PENTIUMIII is not set -# CONFIG_WINCHIP2 is not set -# CONFIG_WINCHIPC6 is not set -TARGET_ARCH="i386" -TARGET_i386=y -UCLIBC_HAS_FPU=y diff --git a/toolchain/uClibc/config-0.9.33.2/m68k b/toolchain/uClibc/config-0.9.33.2/m68k deleted file mode 100644 index 14ce5aef7bb..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/m68k +++ /dev/null @@ -1,6 +0,0 @@ -ARCH_BIG_ENDIAN=y -LINUXTHREADS_OLD=y -TARGET_ARCH="m68k" -TARGET_SUBARCH="" -TARGET_m68k=y -# UCLIBC_HAS_THREADS_NATIVE is not set diff --git a/toolchain/uClibc/config-0.9.33.2/mips b/toolchain/uClibc/config-0.9.33.2/mips deleted file mode 100644 index 7398c669292..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/mips +++ /dev/null @@ -1,17 +0,0 @@ -ARCH_ANY_ENDIAN=y -ARCH_BIG_ENDIAN=y -ARCH_CFLAGS="-mno-split-addresses" -ARCH_WANTS_BIG_ENDIAN=y -# CONFIG_MIPS_ISA_1 is not set -# CONFIG_MIPS_ISA_2 is not set -# CONFIG_MIPS_ISA_3 is not set -# CONFIG_MIPS_ISA_4 is not set -CONFIG_MIPS_ISA_MIPS32=y -# CONFIG_MIPS_ISA_MIPS32R2 is not set -# CONFIG_MIPS_ISA_MIPS64 is not set -# CONFIG_MIPS_N32_ABI is not set -# CONFIG_MIPS_N64_ABI is not set -CONFIG_MIPS_O32_ABI=y -TARGET_ARCH="mips" -TARGET_mips=y -UCLIBC_HAS_FPU=y diff --git a/toolchain/uClibc/config-0.9.33.2/mips64 b/toolchain/uClibc/config-0.9.33.2/mips64 deleted file mode 100644 index fa5bee3aa50..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/mips64 +++ /dev/null @@ -1,17 +0,0 @@ -ARCH_ANY_ENDIAN=y -ARCH_BIG_ENDIAN=y -ARCH_CFLAGS="-mno-split-addresses" -ARCH_WANTS_BIG_ENDIAN=y -# CONFIG_MIPS_ISA_1 is not set -# CONFIG_MIPS_ISA_2 is not set -# CONFIG_MIPS_ISA_3 is not set -# CONFIG_MIPS_ISA_4 is not set -# CONFIG_MIPS_ISA_MIPS32 is not set -# CONFIG_MIPS_ISA_MIPS32R2 is not set -CONFIG_MIPS_ISA_MIPS64=y -# CONFIG_MIPS_N32_ABI is not set -CONFIG_MIPS_N64_ABI=y -# CONFIG_MIPS_O32_ABI is not set -TARGET_ARCH="mips" -TARGET_mips=y -UCLIBC_HAS_FPU=y diff --git a/toolchain/uClibc/config-0.9.33.2/mips64.32 b/toolchain/uClibc/config-0.9.33.2/mips64.32 deleted file mode 100644 index 03f7fbaeeaa..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/mips64.32 +++ /dev/null @@ -1,18 +0,0 @@ -ARCH_ANY_ENDIAN=y -ARCH_BIG_ENDIAN=y -ARCH_CFLAGS="-mno-split-addresses" -ARCH_WANTS_BIG_ENDIAN=y -# CONFIG_MIPS_ISA_1 is not set -# CONFIG_MIPS_ISA_2 is not set -# CONFIG_MIPS_ISA_3 is not set -# CONFIG_MIPS_ISA_4 is not set -# CONFIG_MIPS_ISA_MIPS32 is not set -# CONFIG_MIPS_ISA_MIPS32R2 is not set -CONFIG_MIPS_ISA_MIPS64=y -# CONFIG_MIPS_N32_ABI is not set -# CONFIG_MIPS_N64_ABI is not set -CONFIG_MIPS_O32_ABI=y -TARGET_ARCH="mips" -TARGET_mips=y -TARGET_SUBARCH="mips64" -UCLIBC_HAS_FPU=y diff --git a/toolchain/uClibc/config-0.9.33.2/mips64.64 b/toolchain/uClibc/config-0.9.33.2/mips64.64 deleted file mode 100644 index 7b66c2f7827..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/mips64.64 +++ /dev/null @@ -1,18 +0,0 @@ -ARCH_ANY_ENDIAN=y -ARCH_BIG_ENDIAN=y -ARCH_CFLAGS="-mno-split-addresses" -ARCH_WANTS_BIG_ENDIAN=y -# CONFIG_MIPS_ISA_1 is not set -# CONFIG_MIPS_ISA_2 is not set -# CONFIG_MIPS_ISA_3 is not set -# CONFIG_MIPS_ISA_4 is not set -# CONFIG_MIPS_ISA_MIPS32 is not set -# CONFIG_MIPS_ISA_MIPS32R2 is not set -CONFIG_MIPS_ISA_MIPS64=y -# CONFIG_MIPS_N32_ABI is not set -CONFIG_MIPS_N64_ABI=y -# CONFIG_MIPS_O32_ABI is not set -TARGET_ARCH="mips" -TARGET_mips=y -TARGET_SUBARCH="mips64" -UCLIBC_HAS_FPU=y diff --git a/toolchain/uClibc/config-0.9.33.2/mips64.n32 b/toolchain/uClibc/config-0.9.33.2/mips64.n32 deleted file mode 100644 index 84a5de64793..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/mips64.n32 +++ /dev/null @@ -1,18 +0,0 @@ -ARCH_ANY_ENDIAN=y -ARCH_BIG_ENDIAN=y -ARCH_CFLAGS="-mno-split-addresses" -ARCH_WANTS_BIG_ENDIAN=y -# CONFIG_MIPS_ISA_1 is not set -# CONFIG_MIPS_ISA_2 is not set -# CONFIG_MIPS_ISA_3 is not set -# CONFIG_MIPS_ISA_4 is not set -# CONFIG_MIPS_ISA_MIPS32 is not set -# CONFIG_MIPS_ISA_MIPS32R2 is not set -CONFIG_MIPS_ISA_MIPS64=y -CONFIG_MIPS_N32_ABI=y -# CONFIG_MIPS_N64_ABI is not set -# CONFIG_MIPS_O32_ABI is not set -TARGET_ARCH="mips" -TARGET_mips=y -TARGET_SUBARCH="mips64" -UCLIBC_HAS_FPU=y diff --git a/toolchain/uClibc/config-0.9.33.2/mips64el b/toolchain/uClibc/config-0.9.33.2/mips64el deleted file mode 100644 index 1ca764f6e29..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/mips64el +++ /dev/null @@ -1,17 +0,0 @@ -ARCH_ANY_ENDIAN=y -ARCH_CFLAGS="-mno-split-addresses" -ARCH_LITTLE_ENDIAN=y -ARCH_WANTS_LITTLE_ENDIAN=y -# CONFIG_MIPS_ISA_1 is not set -# CONFIG_MIPS_ISA_2 is not set -# CONFIG_MIPS_ISA_3 is not set -# CONFIG_MIPS_ISA_4 is not set -# CONFIG_MIPS_ISA_MIPS32 is not set -# CONFIG_MIPS_ISA_MIPS32R2 is not set -CONFIG_MIPS_ISA_MIPS64=y -# CONFIG_MIPS_N32_ABI is not set -CONFIG_MIPS_N64_ABI=y -# CONFIG_MIPS_O32_ABI is not set -TARGET_ARCH="mips" -TARGET_mips=y -UCLIBC_HAS_FPU=y diff --git a/toolchain/uClibc/config-0.9.33.2/mips64el.32 b/toolchain/uClibc/config-0.9.33.2/mips64el.32 deleted file mode 100644 index 73b1f9f1b43..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/mips64el.32 +++ /dev/null @@ -1,18 +0,0 @@ -ARCH_ANY_ENDIAN=y -ARCH_CFLAGS="-mno-split-addresses" -ARCH_LITTLE_ENDIAN=y -ARCH_WANTS_LITTLE_ENDIAN=y -# CONFIG_MIPS_ISA_1 is not set -# CONFIG_MIPS_ISA_2 is not set -# CONFIG_MIPS_ISA_3 is not set -# CONFIG_MIPS_ISA_4 is not set -# CONFIG_MIPS_ISA_MIPS32 is not set -# CONFIG_MIPS_ISA_MIPS32R2 is not set -CONFIG_MIPS_ISA_MIPS64=y -# CONFIG_MIPS_N32_ABI is not set -# CONFIG_MIPS_N64_ABI is not set -CONFIG_MIPS_O32_ABI=y -TARGET_ARCH="mips" -TARGET_mips=y -TARGET_SUBARCH="mips64" -UCLIBC_HAS_FPU=y diff --git a/toolchain/uClibc/config-0.9.33.2/mips64el.64 b/toolchain/uClibc/config-0.9.33.2/mips64el.64 deleted file mode 100644 index 790f210411e..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/mips64el.64 +++ /dev/null @@ -1,18 +0,0 @@ -ARCH_ANY_ENDIAN=y -ARCH_CFLAGS="-mno-split-addresses" -ARCH_LITTLE_ENDIAN=y -ARCH_WANTS_LITTLE_ENDIAN=y -# CONFIG_MIPS_ISA_1 is not set -# CONFIG_MIPS_ISA_2 is not set -# CONFIG_MIPS_ISA_3 is not set -# CONFIG_MIPS_ISA_4 is not set -# CONFIG_MIPS_ISA_MIPS32 is not set -# CONFIG_MIPS_ISA_MIPS32R2 is not set -CONFIG_MIPS_ISA_MIPS64=y -# CONFIG_MIPS_N32_ABI is not set -CONFIG_MIPS_N64_ABI=y -# CONFIG_MIPS_O32_ABI is not set -TARGET_ARCH="mips" -TARGET_mips=y -TARGET_SUBARCH="mips64" -UCLIBC_HAS_FPU=y diff --git a/toolchain/uClibc/config-0.9.33.2/mips64el.n32 b/toolchain/uClibc/config-0.9.33.2/mips64el.n32 deleted file mode 100644 index c2929bf7069..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/mips64el.n32 +++ /dev/null @@ -1,18 +0,0 @@ -ARCH_ANY_ENDIAN=y -ARCH_CFLAGS="-mno-split-addresses" -ARCH_LITTLE_ENDIAN=y -ARCH_WANTS_LITTLE_ENDIAN=y -# CONFIG_MIPS_ISA_1 is not set -# CONFIG_MIPS_ISA_2 is not set -# CONFIG_MIPS_ISA_3 is not set -# CONFIG_MIPS_ISA_4 is not set -# CONFIG_MIPS_ISA_MIPS32 is not set -# CONFIG_MIPS_ISA_MIPS32R2 is not set -CONFIG_MIPS_ISA_MIPS64=y -CONFIG_MIPS_N32_ABI=y -# CONFIG_MIPS_N64_ABI is not set -# CONFIG_MIPS_O32_ABI is not set -TARGET_ARCH="mips" -TARGET_mips=y -TARGET_SUBARCH="mips64" -UCLIBC_HAS_FPU=y diff --git a/toolchain/uClibc/config-0.9.33.2/mipsel b/toolchain/uClibc/config-0.9.33.2/mipsel deleted file mode 100644 index 7648f396bab..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/mipsel +++ /dev/null @@ -1,17 +0,0 @@ -ARCH_ANY_ENDIAN=y -ARCH_CFLAGS="-mno-split-addresses" -ARCH_LITTLE_ENDIAN=y -ARCH_WANTS_LITTLE_ENDIAN=y -# CONFIG_MIPS_ISA_1 is not set -# CONFIG_MIPS_ISA_2 is not set -# CONFIG_MIPS_ISA_3 is not set -# CONFIG_MIPS_ISA_4 is not set -CONFIG_MIPS_ISA_MIPS32=y -# CONFIG_MIPS_ISA_MIPS32R2 is not set -# CONFIG_MIPS_ISA_MIPS64 is not set -# CONFIG_MIPS_N32_ABI is not set -# CONFIG_MIPS_N64_ABI is not set -CONFIG_MIPS_O32_ABI=y -TARGET_ARCH="mips" -TARGET_mips=y -UCLIBC_HAS_FPU=y diff --git a/toolchain/uClibc/config-0.9.33.2/mipsel.cobalt b/toolchain/uClibc/config-0.9.33.2/mipsel.cobalt deleted file mode 100644 index 323b0aa52eb..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/mipsel.cobalt +++ /dev/null @@ -1,17 +0,0 @@ -ARCH_ANY_ENDIAN=y -ARCH_CFLAGS="-mno-split-addresses" -ARCH_LITTLE_ENDIAN=y -ARCH_WANTS_LITTLE_ENDIAN=y -# CONFIG_MIPS_ISA_1 is not set -# CONFIG_MIPS_ISA_2 is not set -CONFIG_MIPS_ISA_3=y -# CONFIG_MIPS_ISA_4 is not set -# CONFIG_MIPS_ISA_MIPS32 is not set -# CONFIG_MIPS_ISA_MIPS32R2 is not set -# CONFIG_MIPS_ISA_MIPS64 is not set -# CONFIG_MIPS_N32_ABI is not set -# CONFIG_MIPS_N64_ABI is not set -CONFIG_MIPS_O32_ABI=y -TARGET_ARCH="mips" -TARGET_mips=y -UCLIBC_HAS_FPU=y diff --git a/toolchain/uClibc/config-0.9.33.2/powerpc b/toolchain/uClibc/config-0.9.33.2/powerpc deleted file mode 100644 index 5b1292d12e5..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/powerpc +++ /dev/null @@ -1,6 +0,0 @@ -ARCH_BIG_ENDIAN=y -CONFIG_CLASSIC=y -# CONFIG_E500 is not set -TARGET_ARCH="powerpc" -TARGET_SUBARCH="classic" -TARGET_powerpc=y diff --git a/toolchain/uClibc/config-0.9.33.2/powerpc.e500 b/toolchain/uClibc/config-0.9.33.2/powerpc.e500 deleted file mode 100644 index a835c3d5e74..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/powerpc.e500 +++ /dev/null @@ -1,6 +0,0 @@ -ARCH_BIG_ENDIAN=y -# CONFIG_CLASSIC is not set -CONFIG_E500=y -TARGET_ARCH="powerpc" -TARGET_SUBARCH="classic" -TARGET_powerpc=y diff --git a/toolchain/uClibc/config-0.9.33.2/sparc b/toolchain/uClibc/config-0.9.33.2/sparc deleted file mode 100644 index e1596c41009..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/sparc +++ /dev/null @@ -1,8 +0,0 @@ -ARCH_BIG_ENDIAN=y -# CONFIG_SPARC_V7 is not set -# CONFIG_SPARC_V8 is not set -CONFIG_SPARC_V9=y -# CONFIG_SPARC_V9B is not set -TARGET_ARCH="sparc" -TARGET_sparc=y -UCLIBC_HAS_LONG_DOUBLE_MATH=y diff --git a/toolchain/uClibc/config-0.9.33.2/sparc.leon b/toolchain/uClibc/config-0.9.33.2/sparc.leon deleted file mode 100644 index eb725ac05df..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/sparc.leon +++ /dev/null @@ -1,8 +0,0 @@ -ARCH_BIG_ENDIAN=y -# CONFIG_SPARC_V7 is not set -CONFIG_SPARC_V8=y -# CONFIG_SPARC_V9 is not set -# CONFIG_SPARC_V9B is not set -TARGET_ARCH="sparc" -TARGET_sparc=y -UCLIBC_HAS_LONG_DOUBLE_MATH=y diff --git a/toolchain/uClibc/config-0.9.33.2/x86_64 b/toolchain/uClibc/config-0.9.33.2/x86_64 deleted file mode 100644 index 92f0e6569e9..00000000000 --- a/toolchain/uClibc/config-0.9.33.2/x86_64 +++ /dev/null @@ -1,6 +0,0 @@ -ARCH_LITTLE_ENDIAN=y -# LINUXTHREADS_NEW is not set -TARGET_ARCH="x86_64" -TARGET_x86_64=y -UCLIBC_BSD_SPECIFIC=y -UCLIBC_HAS_FPU=y diff --git a/toolchain/uClibc/config/arc b/toolchain/uClibc/config/arc new file mode 100644 index 00000000000..de1ffc44153 --- /dev/null +++ b/toolchain/uClibc/config/arc @@ -0,0 +1,10 @@ +ARCH_ANY_ENDIAN=y +ARCH_LITTLE_ENDIAN=y +ARCH_WANTS_LITTLE_ENDIAN=y +TARGET_ARCH="arc" +TARGET_arc=y +CONFIG_ARC_CPU_700=y +# CONFIG_ARC_CPU_HS is not set +CONFIG_ARC_PAGE_SIZE_8K=y +# CONFIG_ARC_PAGE_SIZE_16K is not set +# CONFIG_ARC_PAGE_SIZE_4K is not set diff --git a/toolchain/uClibc/config/archs b/toolchain/uClibc/config/archs new file mode 100644 index 00000000000..961628ed8c7 --- /dev/null +++ b/toolchain/uClibc/config/archs @@ -0,0 +1,10 @@ +ARCH_ANY_ENDIAN=y +ARCH_LITTLE_ENDIAN=y +ARCH_WANTS_LITTLE_ENDIAN=y +TARGET_ARCH="arc" +TARGET_arc=y +# CONFIG_ARC_CPU_700 is not set +CONFIG_ARC_CPU_HS=y +CONFIG_ARC_PAGE_SIZE_8K=y +# CONFIG_ARC_PAGE_SIZE_16K is not set +# CONFIG_ARC_PAGE_SIZE_4K is not set diff --git a/toolchain/uClibc/config/common b/toolchain/uClibc/config/common index 4c39da708c9..b679c0a1ec2 100644 --- a/toolchain/uClibc/config/common +++ b/toolchain/uClibc/config/common @@ -138,7 +138,7 @@ UCLIBC_HAS_LFS=y UCLIBC_HAS_LIBNSL_STUB=y UCLIBC_HAS_LIBRESOLV_STUB=y UCLIBC_HAS_LIBUTIL=y -UCLIBC_HAS_LOCALE=y +# UCLIBC_HAS_LOCALE is not set # UCLIBC_BUILD_ALL_LOCALE is not set # UCLIBC_BUILD_MINIMAL_LOCALE is not set # UCLIBC_PREGENERATED_LOCALE_DATA is not set @@ -156,7 +156,7 @@ UCLIBC_HAS_REALTIME=y UCLIBC_HAS_REGEX=y UCLIBC_HAS_REGEX_OLD=y UCLIBC_HAS_RESOLVER_SUPPORT=y -UCLIBC_HAS_RPC=y +# UCLIBC_HAS_RPC is not set UCLIBC_HAS_SCANF_GLIBC_A_FLAG=y # UCLIBC_HAS_SHA256_CRYPT_IMPL is not set # UCLIBC_HAS_SHA512_CRYPT_IMPL is not set @@ -166,8 +166,6 @@ UCLIBC_HAS_SOCKET=y UCLIBC_HAS_SOFT_FLOAT=y # UCLIBC_HAS_SSP is not set # UCLIBC_HAS_SSP_COMPAT is not set -# SSP_QUICK_CANARY is not set -# UCLIBC_BUILD_SSP is not set UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION=y # UCLIBC_HAS_STDIO_BUFSIZ_1024 is not set # UCLIBC_HAS_STDIO_BUFSIZ_2048 is not set @@ -198,7 +196,7 @@ UCLIBC_HAS_UTMP=y UCLIBC_HAS_WCHAR=y UCLIBC_HAS_WORDEXP=y UCLIBC_HAS_XATTR=y -UCLIBC_HAS_XLOCALE=y +# UCLIBC_HAS_XLOCALE is not set UCLIBC_HAS___PROGNAME=y # UCLIBC_LINUX_MODULE_24 is not set UCLIBC_LINUX_MODULE_26=y @@ -223,6 +221,6 @@ UCLIBC_USE_NETLINK=y USE_BX=y WARNINGS="-Wall" # UCLIBC_HAS_OBSTACK is not set -UCLIBC_SUSV2_LEGACY=y +# UCLIBC_SUSV2_LEGACY is not set # UCLIBC_HAS_CONTEXT_FUNCS is not set UCLIBC_HAS_GETOPT_LONG=y diff --git a/toolchain/uClibc/config/mips b/toolchain/uClibc/config/mips index 1b3e829e648..8cec22f4def 100644 --- a/toolchain/uClibc/config/mips +++ b/toolchain/uClibc/config/mips @@ -16,4 +16,3 @@ CONFIG_MIPS_O32_ABI=y TARGET_ARCH="mips" TARGET_mips=y UCLIBC_HAS_FPU=y -UCLIBC_USE_MIPS_PREFETCH=n diff --git a/toolchain/uClibc/headers/Makefile b/toolchain/uClibc/headers/Makefile index 67a2d95c378..abd3620d33e 100644 --- a/toolchain/uClibc/headers/Makefile +++ b/toolchain/uClibc/headers/Makefile @@ -20,6 +20,7 @@ define Host/Install ARCH="$(CONFIG_ARCH)" \ pregen \ install_headers + $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/ endef $(eval $(call HostBuild)) diff --git a/toolchain/uClibc/patches-0.9.33.2/009_backport_mount.h-update.patch b/toolchain/uClibc/patches-0.9.33.2/009_backport_mount.h-update.patch deleted file mode 100644 index 47fb624e98d..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/009_backport_mount.h-update.patch +++ /dev/null @@ -1,91 +0,0 @@ -From 76ff037059f6d387bde9d540f7e27a2b376d7cd7 Mon Sep 17 00:00:00 2001 -From: Bernhard Reutner-Fischer -Date: Fri, 18 Jan 2013 11:12:49 +0100 -Subject: [PATCH] mount.h: update - -Signed-off-by: Bernhard Reutner-Fischer ---- - include/sys/mount.h | 45 +++++++++++++++++++++++++++++++++++---------- - 1 file changed, 35 insertions(+), 10 deletions(-) - -diff --git a/include/sys/mount.h b/include/sys/mount.h -index fbd61fd..c0e7b84 100644 ---- a/include/sys/mount.h -+++ b/include/sys/mount.h -@@ -1,5 +1,5 @@ - /* Header file for mounting/unmount Linux filesystems. -- Copyright (C) 1996,1997,1998,1999,2000,2004 Free Software Foundation, Inc. -+ Copyright (C) 1996-2000, 2004, 2010, 2012 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or -@@ -46,23 +46,46 @@ enum - #define MS_REMOUNT MS_REMOUNT - MS_MANDLOCK = 64, /* Allow mandatory locks on an FS. */ - #define MS_MANDLOCK MS_MANDLOCK -- S_WRITE = 128, /* Write on file/directory/symlink. */ --#define S_WRITE S_WRITE -- S_APPEND = 256, /* Append-only file. */ --#define S_APPEND S_APPEND -- S_IMMUTABLE = 512, /* Immutable file. */ --#define S_IMMUTABLE S_IMMUTABLE -+ MS_DIRSYNC = 128, /* Directory modifications are synchronous. */ -+#define MS_DIRSYNC MS_DIRSYNC - MS_NOATIME = 1024, /* Do not update access times. */ - #define MS_NOATIME MS_NOATIME - MS_NODIRATIME = 2048, /* Do not update directory access times. */ - #define MS_NODIRATIME MS_NODIRATIME - MS_BIND = 4096, /* Bind directory at different place. */ - #define MS_BIND MS_BIND -+ MS_MOVE = 8192, -+#define MS_MOVE MS_MOVE -+ MS_REC = 16384, -+#define MS_REC MS_REC -+ MS_SILENT = 32768, -+#define MS_SILENT MS_SILENT -+ MS_POSIXACL = 1 << 16, /* VFS does not apply the umask. */ -+#define MS_POSIXACL MS_POSIXACL -+ MS_UNBINDABLE = 1 << 17, /* Change to unbindable. */ -+#define MS_UNBINDABLE MS_UNBINDABLE -+ MS_PRIVATE = 1 << 18, /* Change to private. */ -+#define MS_PRIVATE MS_PRIVATE -+ MS_SLAVE = 1 << 19, /* Change to slave. */ -+#define MS_SLAVE MS_SLAVE -+ MS_SHARED = 1 << 20, /* Change to shared. */ -+#define MS_SHARED MS_SHARED -+ MS_RELATIME = 1 << 21, /* Update atime relative to mtime/ctime. */ -+#define MS_RELATIME MS_RELATIME -+ MS_KERNMOUNT = 1 << 22, /* This is a kern_mount call. */ -+#define MS_KERNMOUNT MS_KERNMOUNT -+ MS_I_VERSION = 1 << 23, /* Update inode I_version field. */ -+#define MS_I_VERSION MS_I_VERSION -+ MS_STRICTATIME = 1 << 24, /* Always perform atime updates. */ -+#define MS_STRICTATIME MS_STRICTATIME -+ MS_ACTIVE = 1 << 30, -+#define MS_ACTIVE MS_ACTIVE -+ MS_NOUSER = 1 << 31 -+#define MS_NOUSER MS_NOUSER - }; - - /* Flags that can be altered by MS_REMOUNT */ --#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME \ -- |MS_NODIRATIME) -+#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION) - - - /* Magic mount flag number. Has to be or-ed to the flag values. */ -@@ -99,8 +122,10 @@ enum - #define MNT_FORCE MNT_FORCE - MNT_DETACH = 2, /* Just detach from the tree. */ - #define MNT_DETACH MNT_DETACH -- MNT_EXPIRE = 4 /* Mark for expiry. */ -+ MNT_EXPIRE = 4, /* Mark for expiry. */ - #define MNT_EXPIRE MNT_EXPIRE -+ UMOUNT_NOFOLLOW = 8 /* Don't follow symlink on umount. */ -+#define UMOUNT_NOFOLLOW UMOUNT_NOFOLLOW - }; - - --- -1.9.1 - diff --git a/toolchain/uClibc/patches-0.9.33.2/010-backport_sscanf_alloc.patch b/toolchain/uClibc/patches-0.9.33.2/010-backport_sscanf_alloc.patch deleted file mode 100644 index b5ce0912644..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/010-backport_sscanf_alloc.patch +++ /dev/null @@ -1,184 +0,0 @@ -From 8cfb43de636faa401634340d1a18404844f9ba5a Mon Sep 17 00:00:00 2001 -From: Mike Frysinger -Date: Sun, 6 May 2012 03:50:44 -0400 -Subject: [PATCH] stdio: implement assignment-allocation "m" character - -The latest POSIX spec introduces a "m" character to allocate buffers for -the user when using scanf type functions. This is like the old glibc "a" -flag, but now standardized. With packages starting to use these, we need -to implement it. - -for example: - char *s; - sscanf("foo", "%ms", &s); - printf("%s\n", s); - free(s); -This will automatically allocate storage for "s", read in "foo" to it, -and then display it. - -I'm not terribly familiar with the stdio layer, so this could be wrong. -But it seems to work for me. - -Signed-off-by: Mike Frysinger -Signed-off-by: Felix Fietkau ---- - extra/Configs/Config.in | 13 ---------- - libc/stdio/_scanf.c | 68 ++++++++++++++++++++++++++++--------------------- - 2 files changed, 39 insertions(+), 42 deletions(-) - ---- a/extra/Configs/Config.in -+++ b/extra/Configs/Config.in -@@ -1590,19 +1590,6 @@ config UCLIBC_PRINTF_SCANF_POSITIONAL_AR - - Most people will answer 9. - -- --config UCLIBC_HAS_SCANF_GLIBC_A_FLAG -- bool "Support glibc's 'a' flag for scanf string conversions (not implemented)" -- help -- NOTE!!! Currently Not Implemented!!! Just A Place Holder!! NOTE!!! -- NOTE!!! Conflicts with an ANSI/ISO C99 scanf flag!! NOTE!!! -- -- Answer Y to enable support for glibc's 'a' flag for the scanf string -- conversions '%s', '%[', '%ls', '%l[', and '%S'. This is used to -- auto-allocate sufficient memory to hold the data retrieved. -- -- Most people will answer N. -- - choice - prompt "Stdio buffer size" - default UCLIBC_HAS_STDIO_BUFSIZ_4096 ---- a/libc/stdio/_scanf.c -+++ b/libc/stdio/_scanf.c -@@ -77,14 +77,6 @@ - #include - #endif /* __UCLIBC_HAS_FLOATS__ */ - --#ifdef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ --#ifdef L_vfscanf --/* only emit this once */ --#warning Forcing undef of __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ until implemented! --#endif --#undef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ --#endif -- - #undef __STDIO_HAS_VSSCANF - #if defined(__STDIO_BUFFERS) || !defined(__UCLIBC_HAS_WCHAR__) || defined(__UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__) - #define __STDIO_HAS_VSSCANF 1 -@@ -433,8 +425,9 @@ libc_hidden_def(vswscanf) - - - /* float layout 0123456789012345678901 repeat n for "l[" */ --#define SPEC_CHARS "npxXoudifFeEgGaACSncs[" --/* npxXoudif eEgG CS cs[ */ -+#define SPEC_CHARS "npxXoudifFeEgGaACSnmcs[" -+/* npxXoudif eEgG CS cs[ */ -+/* NOTE: the 'm' flag must come before any convs that support it */ - - /* NOTE: Ordering is important! In particular, CONV_LEFTBRACKET - * must immediately precede CONV_c. */ -@@ -444,7 +437,7 @@ enum { - CONV_p, - CONV_x, CONV_X, CONV_o, CONV_u, CONV_d, CONV_i, - CONV_f, CONV_F, CONV_e, CONV_E, CONV_g, CONV_G, CONV_a, CONV_A, -- CONV_C, CONV_S, CONV_LEFTBRACKET, CONV_c, CONV_s, CONV_leftbracket, -+ CONV_C, CONV_S, CONV_LEFTBRACKET, CONV_m, CONV_c, CONV_s, CONV_leftbracket, - CONV_percent, CONV_whitespace /* not in SPEC_* and no flags */ - }; - -@@ -474,7 +467,7 @@ enum { - FLAG_SURPRESS = 0x10, /* MUST BE 1ST!! See DO_FLAGS. */ - FLAG_THOUSANDS = 0x20, - FLAG_I18N = 0x40, /* only works for d, i, u */ -- FLAG_MALLOC = 0x80, /* only works for s, S, and [ (and l[)*/ -+ FLAG_MALLOC = 0x80, /* only works for c, s, S, and [ (and l[)*/ - }; - - -@@ -491,7 +484,7 @@ enum { - /* fFeEgGaA */ (0x0c|FLAG_SURPRESS|FLAG_THOUSANDS|FLAG_I18N), \ - /* C */ ( 0|FLAG_SURPRESS), \ - /* S and l[ */ ( 0|FLAG_SURPRESS|FLAG_MALLOC), \ -- /* c */ (0x04|FLAG_SURPRESS), \ -+ /* c */ (0x04|FLAG_SURPRESS|FLAG_MALLOC), \ - /* s and [ */ (0x04|FLAG_SURPRESS|FLAG_MALLOC), \ - } - -@@ -904,17 +897,17 @@ int attribute_hidden __psfs_parse_spec(r - if (*psfs->fmt == *p) { - int p_m_spec_chars = p - spec_chars; - --#ifdef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ --#error implement gnu a flag -- if ((*p == 'a') -- && ((psfs->fmt[1] == '[') || ((psfs->fmt[1]|0x20) == 's')) -- ) { /* Assumes ascii for 's' and 'S' test. */ -- psfs->flags |= FLAG_MALLOC; -+ if (*p == 'm' && -+ (psfs->fmt[1] == '[' || psfs->fmt[1] == 'c' || -+ /* Assumes ascii for 's' and 'S' test. */ -+ (psfs->fmt[1] | 0x20) == 's')) -+ { -+ if (psfs->store) -+ psfs->flags |= FLAG_MALLOC; - ++psfs->fmt; - ++p; -- continue; /* The related conversions follow 'a'. */ -+ continue; /* The related conversions follow 'm'. */ - } --#endif /* __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ */ - - for (p = spec_ranges; p_m_spec_chars > *p ; ++p) {} - if (((psfs->dataargtype >> 8) | psfs->flags) -@@ -1265,12 +1258,6 @@ int VFSCANF (FILE *__restrict fp, const - while (*wf && __isascii(*wf) && (b < buf + sizeof(buf) - 1)) { - *b++ = *wf++; - } --#ifdef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ --#error this is wrong... we need to ched in __psfs_parse_spec instead since this checks last char in buffer and conversion my have stopped before it. -- if ((*b == 'a') && ((*wf == '[') || ((*wf|0x20) == 's'))) { -- goto DONE; /* Spec was excessively long. */ -- } --#endif /* __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ */ - *b = 0; - if (b == buf) { /* Bad conversion specifier! */ - goto DONE; -@@ -1390,13 +1377,36 @@ int VFSCANF (FILE *__restrict fp, const - } - - if (psfs.conv_num == CONV_s) { -+ /* We might have to handle the allocation ourselves */ -+ int len; -+ /* With 'm', we actually got a pointer to a pointer */ -+ unsigned char **ptr = (void *)b; -+ -+ i = 0; -+ if (psfs.flags & FLAG_MALLOC) { -+ len = 0; -+ b = NULL; -+ } else -+ len = -1; -+ - /* Yes, believe it or not, a %s conversion can store nuls. */ - while ((__scan_getc(&sc) >= 0) && !isspace(sc.cc)) { - zero_conversions = 0; -- *b = sc.cc; -- b += psfs.store; -+ if (i == len) { -+ /* Pick a size that won't trigger a lot of -+ * mallocs early on ... */ -+ len += 256; -+ b = realloc(b, len + 1); -+ } -+ b[i] = sc.cc; -+ i += psfs.store; - fail = 0; - } -+ -+ if (psfs.flags & FLAG_MALLOC) -+ *ptr = b; -+ /* The code below takes care of terminating NUL */ -+ b += i; - } else { - #ifdef __UCLIBC_HAS_WCHAR__ - assert((psfs.conv_num == CONV_LEFTBRACKET) || \ diff --git a/toolchain/uClibc/patches-0.9.33.2/011-dlsym_rtld_next_fix.patch b/toolchain/uClibc/patches-0.9.33.2/011-dlsym_rtld_next_fix.patch deleted file mode 100644 index f1a8ff51647..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/011-dlsym_rtld_next_fix.patch +++ /dev/null @@ -1,25 +0,0 @@ ---- a/ldso/libdl/libdl.c -+++ b/ldso/libdl/libdl.c -@@ -671,7 +671,7 @@ static void *do_dlsym(void *vhandle, con - { - struct elf_resolve *tpnt, *tfrom; - struct dyn_elf *handle; -- ElfW(Addr) from; -+ ElfW(Addr) from = 0; - struct dyn_elf *rpnt; - void *ret; - struct symbol_ref sym_ref = { NULL, NULL }; -@@ -729,7 +729,12 @@ static void *do_dlsym(void *vhandle, con - tpnt = NULL; - if (handle == _dl_symbol_tables) - tpnt = handle->dyn; /* Only search RTLD_GLOBAL objs if global object */ -- ret = _dl_find_hash(name2, &handle->dyn->symbol_scope, tpnt, ELF_RTYPE_CLASS_DLSYM, &sym_ref); -+ do { -+ ret = _dl_find_hash(name2, &handle->dyn->symbol_scope, tpnt, ELF_RTYPE_CLASS_DLSYM, &sym_ref); -+ if (ret != NULL) -+ break; -+ handle = handle->next; -+ } while (from && handle); - - #if defined(USE_TLS) && USE_TLS && defined SHARED - if (sym_ref.sym && (ELF_ST_TYPE(sym_ref.sym->st_info) == STT_TLS) && (sym_ref.tpnt)) { diff --git a/toolchain/uClibc/patches-0.9.33.2/012-elf-Add-STT_GNU_IFUNC-from-glibc.patch b/toolchain/uClibc/patches-0.9.33.2/012-elf-Add-STT_GNU_IFUNC-from-glibc.patch deleted file mode 100644 index 6cecfaad473..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/012-elf-Add-STT_GNU_IFUNC-from-glibc.patch +++ /dev/null @@ -1,37 +0,0 @@ -From be58779614b2fe9aa57a9315be9dc004dfd77b3b Mon Sep 17 00:00:00 2001 -From: Vineet Gupta -Date: Fri, 20 Feb 2015 15:27:08 +0530 -Subject: [PATCH] elf: Add STT_GNU_IFUNC from glibc - -perf in upstream Linux kernel 3.17 onwards expects STT_GNU_IFUNC -replicate it from glibc - -Signed-off-by: Vineet Gupta -Signed-off-by: Bernhard Reutner-Fischer ---- - include/elf.h | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/include/elf.h b/include/elf.h -index facf09c..917930b 100644 ---- a/include/elf.h -+++ b/include/elf.h -@@ -566,6 +566,7 @@ typedef struct - #define STB_WEAK 2 /* Weak symbol */ - #define STB_NUM 3 /* Number of defined types. */ - #define STB_LOOS 10 /* Start of OS-specific */ -+#define STB_GNU_UNIQUE 10 /* Unique symbol. */ - #define STB_HIOS 12 /* End of OS-specific */ - #define STB_LOPROC 13 /* Start of processor-specific */ - #define STB_HIPROC 15 /* End of processor-specific */ -@@ -581,6 +582,7 @@ typedef struct - #define STT_TLS 6 /* Symbol is thread-local data object*/ - #define STT_NUM 7 /* Number of defined types. */ - #define STT_LOOS 10 /* Start of OS-specific */ -+#define STT_GNU_IFUNC 10 /* Symbol is indirect code object */ - #define STT_HIOS 12 /* End of OS-specific */ - #define STT_LOPROC 13 /* Start of processor-specific */ - #define STT_HIPROC 15 /* End of processor-specific */ --- -2.1.4 - diff --git a/toolchain/uClibc/patches-0.9.33.2/020-endian.h-add-some-handy-macros-to-be-used-in-syscall.patch b/toolchain/uClibc/patches-0.9.33.2/020-endian.h-add-some-handy-macros-to-be-used-in-syscall.patch deleted file mode 100644 index 720104195ac..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/020-endian.h-add-some-handy-macros-to-be-used-in-syscall.patch +++ /dev/null @@ -1,28 +0,0 @@ -From: "Peter S. Mazinger" -Date: Thu, 21 Apr 2011 21:20:55 +0200 -Subject: [PATCH] endian.h: add some handy macros to be used in syscalls - -Signed-off-by: Peter S. Mazinger -Signed-off-by: Bernhard Reutner-Fischer ---- - ---- a/include/endian.h -+++ b/include/endian.h -@@ -55,6 +55,17 @@ - # define __LONG_LONG_PAIR(HI, LO) HI, LO - #endif - -+#ifdef _LIBC -+# ifndef __ASSEMBLER__ -+# include -+# define OFF_HI(offset) (offset >> 31) -+# define OFF_LO(offset) (offset) -+# define OFF64_HI(offset) (uint32_t)(offset >> 32) -+# define OFF64_LO(offset) (uint32_t)(offset & 0xffffffff) -+# define OFF_HI_LO(offset) __LONG_LONG_PAIR(OFF_HI(offset), OFF_LO(offset)) -+# define OFF64_HI_LO(offset) __LONG_LONG_PAIR(OFF64_HI(offset), OFF64_LO(offset)) -+# endif -+#endif - - #ifdef __USE_BSD - /* Conversion interfaces. */ diff --git a/toolchain/uClibc/patches-0.9.33.2/021-add-posix_madvise.c.patch b/toolchain/uClibc/patches-0.9.33.2/021-add-posix_madvise.c.patch deleted file mode 100644 index 2b18c258d95..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/021-add-posix_madvise.c.patch +++ /dev/null @@ -1,48 +0,0 @@ -From: "Peter S. Mazinger" -Date: Tue, 26 Apr 2011 23:03:44 +0200 -Subject: [PATCH] add posix_madvise.c - -Signed-off-by: Peter S. Mazinger -Signed-off-by: Bernhard Reutner-Fischer ---- - create mode 100644 libc/sysdeps/linux/common/posix_madvise.c - ---- a/libc/sysdeps/linux/common/Makefile.in -+++ b/libc/sysdeps/linux/common/Makefile.in -@@ -81,7 +81,7 @@ CSRC-$(UCLIBC_HAS_REALTIME) += clock_get - sched_get_priority_max.c sched_get_priority_min.c sched_getscheduler.c \ - sched_rr_get_interval.c sched_setparam.c sched_setscheduler.c sigqueue.c - # clock_getcpuclockid|clock_nanosleep|mq_timedreceive|mq_timedsend|posix_fadvise|posix_fallocate|posix_madvise|posix_memalign|posix_mem_offset|posix_spawnattr_destroy|posix_spawnattr_init|posix_spawnattr_getflags|posix_spawnattr_setflags|posix_spawnattr_getpgroup|posix_spawnattr_setpgroup|posix_spawnattr_getschedparam|posix_spawnattr_setschedparam|posix_spawnattr_getschedpolicy|posix_spawnattr_setschedpolicy|posix_spawnattr_getsigdefault|posix_spawnattr_setsigdefault|posix_spawnattr_getsigmask|posix_spawnattr_setsigmask|posix_spawnattr_init|posix_spawnattr_setflags|posix_spawnattr_setpgroup|posix_spawnattr_setschedparam|posix_spawnattr_setschedpolicy|posix_spawnattr_setsigdefault|posix_spawnattr_setsigmask|posix_spawn_file_actions_addclose|posix_spawn_file_actions_addopen|posix_spawn_file_actions_adddup2|posix_spawn_file_actions_addopen|posix_spawn_file_actions_destroy|posix_spawn_file_actions_init|posix_spawn_file_actions_init|posix_spawn|posix_spawnp|posix_spawnp|posix_typed_mem_get_info|pthread_mutex_timedlock|sem_timedwait --CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c -+CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c posix_madvise.c - CSRC-$(UCLIBC_SUSV4_LEGACY) += utime.c - CSRC-$(UCLIBC_HAS_EPOLL) += epoll.c - CSRC-$(UCLIBC_HAS_XATTR) += xattr.c ---- /dev/null -+++ b/libc/sysdeps/linux/common/posix_madvise.c -@@ -0,0 +1,25 @@ -+/* vi: set sw=4 ts=4: */ -+/* Licensed under the LGPL v2.1, see the file LICENSE in this tarball. */ -+ -+#include -+#include -+ -+#if defined __NR_madvise && defined __USE_XOPEN2K && defined __UCLIBC_HAS_ADVANCED_REALTIME__ -+int posix_madvise(void *addr, size_t len, int advice) -+{ -+ int result; -+ /* We have one problem: the kernel's MADV_DONTNEED does not -+ * correspond to POSIX's POSIX_MADV_DONTNEED. The former simply -+ * discards changes made to the memory without writing it back to -+ * disk, if this would be necessary. The POSIX behaviour does not -+ * allow this. There is no functionality mapping for the POSIX -+ * behaviour so far so we ignore that advice for now. */ -+ if (advice == POSIX_MADV_DONTNEED) -+ return 0; -+ -+ /* this part might use madvise function */ -+ INTERNAL_SYSCALL_DECL (err); -+ result = INTERNAL_SYSCALL (madvise, err, 3, addr, len, advice); -+ return INTERNAL_SYSCALL_ERRNO (result, err); -+} -+#endif diff --git a/toolchain/uClibc/patches-0.9.33.2/022-libc-add-posix_fallocate.patch b/toolchain/uClibc/patches-0.9.33.2/022-libc-add-posix_fallocate.patch deleted file mode 100644 index 504405a716d..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/022-libc-add-posix_fallocate.patch +++ /dev/null @@ -1,301 +0,0 @@ -From: Bernhard Reutner-Fischer -Date: Tue, 17 Apr 2012 09:30:15 +0200 -Subject: [PATCH] libc: add posix_fallocate() - -Signed-off-by: Bernhard Reutner-Fischer ---- - create mode 100644 libc/sysdeps/linux/common/posix_fallocate.c - create mode 100644 libc/sysdeps/linux/common/posix_fallocate64.c - create mode 100644 test/unistd/tst-posix_fallocate.c - create mode 100644 test/unistd/tst-posix_fallocate64.c - ---- a/include/fcntl.h -+++ b/include/fcntl.h -@@ -210,9 +210,7 @@ extern int posix_fadvise64 (int __fd, __ - - #endif - --#if 0 /* && defined __UCLIBC_HAS_ADVANCED_REALTIME__ */ -- --/* FIXME -- uClibc should probably implement these... */ -+#if defined __UCLIBC_HAS_ADVANCED_REALTIME__ - - /* Reserve storage for the data of the file associated with FD. - ---- a/libc/sysdeps/linux/common/Makefile.in -+++ b/libc/sysdeps/linux/common/Makefile.in -@@ -81,7 +81,8 @@ CSRC-$(UCLIBC_HAS_REALTIME) += clock_get - sched_get_priority_max.c sched_get_priority_min.c sched_getscheduler.c \ - sched_rr_get_interval.c sched_setparam.c sched_setscheduler.c sigqueue.c - # clock_getcpuclockid|clock_nanosleep|mq_timedreceive|mq_timedsend|posix_fadvise|posix_fallocate|posix_madvise|posix_memalign|posix_mem_offset|posix_spawnattr_destroy|posix_spawnattr_init|posix_spawnattr_getflags|posix_spawnattr_setflags|posix_spawnattr_getpgroup|posix_spawnattr_setpgroup|posix_spawnattr_getschedparam|posix_spawnattr_setschedparam|posix_spawnattr_getschedpolicy|posix_spawnattr_setschedpolicy|posix_spawnattr_getsigdefault|posix_spawnattr_setsigdefault|posix_spawnattr_getsigmask|posix_spawnattr_setsigmask|posix_spawnattr_init|posix_spawnattr_setflags|posix_spawnattr_setpgroup|posix_spawnattr_setschedparam|posix_spawnattr_setschedpolicy|posix_spawnattr_setsigdefault|posix_spawnattr_setsigmask|posix_spawn_file_actions_addclose|posix_spawn_file_actions_addopen|posix_spawn_file_actions_adddup2|posix_spawn_file_actions_addopen|posix_spawn_file_actions_destroy|posix_spawn_file_actions_init|posix_spawn_file_actions_init|posix_spawn|posix_spawnp|posix_spawnp|posix_typed_mem_get_info|pthread_mutex_timedlock|sem_timedwait --CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c posix_madvise.c -+CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c posix_madvise.c \ -+ posix_fallocate.c posix_fallocate64.c - CSRC-$(UCLIBC_SUSV4_LEGACY) += utime.c - CSRC-$(UCLIBC_HAS_EPOLL) += epoll.c - CSRC-$(UCLIBC_HAS_XATTR) += xattr.c ---- a/libc/sysdeps/linux/common/bits/kernel-features.h -+++ b/libc/sysdeps/linux/common/bits/kernel-features.h -@@ -494,6 +494,14 @@ - # define __ASSUME_PRIVATE_FUTEX 1 - #endif - -+/* Support for fallocate was added in 2.6.23, -+ on s390 only after 2.6.23-rc1, on alpha only after 2.6.33-rc1. */ -+#if __LINUX_KERNEL_VERSION >= 0x020617 \ -+ && (!defined __s390__ || __LINUX_KERNEL_VERSION >= 0x020618) \ -+ && (!defined __alpha__ || __LINUX_KERNEL_VERSION >= 0x020621) -+# define __ASSUME_FALLOCATE 1 -+#endif -+ - /* getcpu is a syscall for x86-64 since 3.1. */ - #if defined __x86_64__ && __LINUX_KERNEL_VERSION >= 0x030100 - # define __ASSUME_GETCPU_SYSCALL 1 ---- /dev/null -+++ b/libc/sysdeps/linux/common/posix_fallocate.c -@@ -0,0 +1,43 @@ -+/* vi: set sw=4 ts=4: */ -+/* -+ * posix_fallocate() for uClibc -+ * http://www.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html -+ * -+ * Copyright (C) 2000-2006 Erik Andersen -+ * -+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball. -+ */ -+ -+#include -+#include -+#include -+#include -+ -+#if defined __NR_fallocate -+int posix_fallocate(int fd, __off_t offset, __off_t len) -+{ -+ int ret; -+ -+# if __WORDSIZE == 32 -+ uint32_t off_low = offset; -+ uint32_t len_low = len; -+ /* may assert that these >>31 are 0 */ -+ uint32_t zero = 0; -+ INTERNAL_SYSCALL_DECL(err); -+ ret = (int) (INTERNAL_SYSCALL(fallocate, err, 6, fd, 0, -+ __LONG_LONG_PAIR (zero, off_low), -+ __LONG_LONG_PAIR (zero, len_low))); -+# elif __WORDSIZE == 64 -+ INTERNAL_SYSCALL_DECL(err); -+ ret = (int) (INTERNAL_SYSCALL(fallocate, err, 4, fd, 0, offset, len)); -+# else -+# error your machine is neither 32 bit or 64 bit ... it must be magical -+#endif -+ if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err))) -+ return INTERNAL_SYSCALL_ERRNO (ret, err); -+ return 0; -+} -+# if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64 -+strong_alias(posix_fallocate,posix_fallocate64) -+# endif -+#endif ---- /dev/null -+++ b/libc/sysdeps/linux/common/posix_fallocate64.c -@@ -0,0 +1,39 @@ -+/* vi: set sw=4 ts=4: */ -+/* -+ * posix_fallocate() for uClibc -+ * http://www.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html -+ * -+ * Copyright (C) 2000-2006 Erik Andersen -+ * -+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball. -+ */ -+ -+#include -+#include -+#include -+#include -+ -+#if defined __NR_fallocate -+ -+# if __WORDSIZE == 64 -+/* Can use normal posix_fallocate() */ -+# elif __WORDSIZE == 32 -+int posix_fallocate64(int fd, __off64_t offset, __off64_t len) -+{ -+ int ret; -+ uint32_t off_low = offset & 0xffffffff; -+ uint32_t off_high = offset >> 32; -+ uint32_t len_low = len & 0xffffffff; -+ uint32_t len_high = len >> 32; -+ INTERNAL_SYSCALL_DECL(err); -+ ret = (int) (INTERNAL_SYSCALL(fallocate, err, 6, fd, 0, -+ __LONG_LONG_PAIR (off_high, off_low), -+ __LONG_LONG_PAIR (len_high, len_low))); -+ if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err))) -+ return INTERNAL_SYSCALL_ERRNO (ret, err); -+ return 0; -+} -+# else -+# error your machine is neither 32 bit or 64 bit ... it must be magical -+# endif -+#endif ---- a/test/.gitignore -+++ b/test/.gitignore -@@ -302,6 +302,8 @@ unistd/getcwd - unistd/getopt - unistd/getopt_long - unistd/tstgetopt -+unistd/tst-posix_fallocate -+unistd/tst-posix_fallocate64 - unistd/tst-preadwrite - unistd/tst-preadwrite64 - unistd/vfork ---- a/test/unistd/Makefile.in -+++ b/test/unistd/Makefile.in -@@ -2,7 +2,10 @@ - # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. - - ifeq ($(UCLIBC_HAS_LFS),) --TESTS_DISABLED := tst-preadwrite64 -+TESTS_DISABLED := tst-preadwrite64 tst-posix_fallocate64 -+endif -+ifeq ($(UCLIBC_HAS_ADVANCED_REALTIME),) -+TESTS_DISABLED := tst-posix_fallocate - endif - OPTS_getopt := -abcXXX -9 - OPTS_getopt_long := --add XXX --delete YYY --verbose ---- /dev/null -+++ b/test/unistd/tst-posix_fallocate.c -@@ -0,0 +1,127 @@ -+#include -+#include -+ -+#ifndef TST_POSIX_FALLOCATE64 -+# define stat64 stat -+# define fstat64 fstat -+# else -+# ifndef O_LARGEFILE -+# error no O_LARGEFILE but you want to test with LFS enabled -+# endif -+#endif -+ -+static void do_prepare (void); -+#define PREPARE(argc, argv) do_prepare () -+static int do_test (void); -+#define TEST_FUNCTION do_test () -+#include -+ -+static int fd; -+static void -+do_prepare (void) -+{ -+ fd = create_temp_file ("tst-posix_fallocate.", NULL); -+ if (fd == -1) -+ { -+ printf ("cannot create temporary file: %m\n"); -+ exit (1); -+ } -+} -+ -+ -+static int -+do_test (void) -+{ -+ struct stat64 st; -+ -+ if (fstat64 (fd, &st) != 0) -+ { -+ puts ("1st fstat failed"); -+ return 1; -+ } -+ -+ if (st.st_size != 0) -+ { -+ puts ("file not created with size 0"); -+ return 1; -+ } -+ -+ if (posix_fallocate (fd, 512, 768) != 0) -+ { -+ puts ("1st posix_fallocate call failed"); -+ return 1; -+ } -+ -+ if (fstat64 (fd, &st) != 0) -+ { -+ puts ("2nd fstat failed"); -+ return 1; -+ } -+ -+ if (st.st_size != 512 + 768) -+ { -+ printf ("file size after 1st posix_fallocate call is %llu, expected %u\n", -+ (unsigned long long int) st.st_size, 512u + 768u); -+ return 1; -+ } -+ -+ if (posix_fallocate (fd, 0, 1024) != 0) -+ { -+ puts ("2nd posix_fallocate call failed"); -+ return 1; -+ } -+ -+ if (fstat64 (fd, &st) != 0) -+ { -+ puts ("3rd fstat failed"); -+ return 1; -+ } -+ -+ if (st.st_size != 512 + 768) -+ { -+ puts ("file size changed in 2nd posix_fallocate"); -+ return 1; -+ } -+ -+ if (posix_fallocate (fd, 2048, 64) != 0) -+ { -+ puts ("3rd posix_fallocate call failed"); -+ return 1; -+ } -+ -+ if (fstat64 (fd, &st) != 0) -+ { -+ puts ("4th fstat failed"); -+ return 1; -+ } -+ -+ if (st.st_size != 2048 + 64) -+ { -+ printf ("file size after 3rd posix_fallocate call is %llu, expected %u\n", -+ (unsigned long long int) st.st_size, 2048u + 64u); -+ return 1; -+ } -+#ifdef TST_POSIX_FALLOCATE64 -+ if (posix_fallocate64 (fd, 4097ULL, 4294967295ULL + 2ULL) != 0) -+ { -+ puts ("4th posix_fallocate call failed"); -+ return 1; -+ } -+ -+ if (fstat64 (fd, &st) != 0) -+ { -+ puts ("5th fstat failed"); -+ return 1; -+ } -+ -+ if (st.st_size != 4097ULL + 4294967295ULL + 2ULL) -+ { -+ printf ("file size after 4th posix_fallocate call is %llu, expected %llu\n", -+ (unsigned long long int) st.st_size, 4097ULL + 4294967295ULL + 2ULL); -+ return 1; -+ } -+#endif -+ close (fd); -+ -+ return 0; -+} ---- /dev/null -+++ b/test/unistd/tst-posix_fallocate64.c -@@ -0,0 +1,2 @@ -+#define TST_POSIX_FALLOCATE64 -+#include "tst-posix_fallocate.c" diff --git a/toolchain/uClibc/patches-0.9.33.2/023-libc-add-fallocate-and-fallocate64.patch b/toolchain/uClibc/patches-0.9.33.2/023-libc-add-fallocate-and-fallocate64.patch deleted file mode 100644 index 282b64f52e5..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/023-libc-add-fallocate-and-fallocate64.patch +++ /dev/null @@ -1,447 +0,0 @@ -From: "Anthony G. Basile" -Date: Sun, 7 Sep 2014 15:33:46 -0400 -Subject: [PATCH] libc: add fallocate() and fallocate64() - -We add the Linux-specific function fallocate() which allows the user to -directly manipulate allocate space for a file. fallocate() can operate -in different modes, but the default mode is equivalent to posix_fallocate() -which is specified in POSIX.1. - -Recent releases of e2fsprogs 1.42.11 and above expect fallocate64() to be -available. - -Signed-off-by: Anthony G. Basile -Signed-off-by: Bernhard Reutner-Fischer ---- - create mode 100644 libc/sysdeps/linux/common/fallocate.c - create mode 100644 libc/sysdeps/linux/common/fallocate64.c - create mode 100644 test/unistd/tst-fallocate.c - create mode 100644 test/unistd/tst-fallocate64.c - ---- a/extra/Configs/Config.in -+++ b/extra/Configs/Config.in -@@ -952,8 +952,8 @@ config UCLIBC_LINUX_SPECIFIC - default y - help - accept4(), bdflush(), -- capget(), capset(), eventfd(), fstatfs(), -- inotify_*(), ioperm(), iopl(), -+ capget(), capset(), eventfd(), fallocate(), -+ fstatfs(), inotify_*(), ioperm(), iopl(), - madvise(), modify_ldt(), pipe2(), personality(), - prctl()/arch_prctl(), pivot_root(), modify_ldt(), - ppoll(), readahead(), reboot(), remap_file_pages(), ---- a/include/fcntl.h -+++ b/include/fcntl.h -@@ -237,6 +237,38 @@ extern int __fcntl_nocancel (int fd, int - libc_hidden_proto(__fcntl_nocancel) - #endif - -+#if (defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU) || defined _LIBC -+/* Reserve storage for the data of a file associated with FD. This function -+ is Linux-specific. For the portable version, use posix_fallocate(). -+ Unlike the latter, fallocate can operate in different modes. The default -+ mode = 0 is equivalent to posix_fallocate(). -+ -+ Note: These declarations are used in posix_fallocate.c and -+ posix_fallocate64.c, so we expose them internally. -+ */ -+ -+/* Flags for fallocate's mode. */ -+# define FALLOC_FL_KEEP_SIZE 1 /* Don't extend size of file -+ even if offset + len is -+ greater than file size. */ -+# define FALLOC_FL_PUNCH_HOLE 2 /* Create a hole in the file. */ -+ -+# ifndef __USE_FILE_OFFSET64 -+extern int fallocate (int __fd, int __mode, __off_t __offset, __off_t __len); -+# else -+# ifdef __REDIRECT -+extern int __REDIRECT (fallocate, (int __fd, int __mode, __off64_t __offset, -+ __off64_t __len), -+ fallocate64); -+# else -+# define fallocate fallocate64 -+# endif -+# endif -+# ifdef __USE_LARGEFILE64 -+extern int fallocate64 (int __fd, int __mode, __off64_t __offset, __off64_t __len); -+# endif -+#endif -+ - __END_DECLS - - #endif /* fcntl.h */ ---- a/libc/sysdeps/linux/common/Makefile.in -+++ b/libc/sysdeps/linux/common/Makefile.in -@@ -61,6 +61,10 @@ CSRC-$(UCLIBC_LINUX_SPECIFIC) += \ - vmsplice.c - CSRC-$(if $(findstring yy,$(UCLIBC_LINUX_SPECIFIC)$(UCLIBC_HAS_LFS)),y) += \ - sendfile64.c -+# posix_fallocate() needs __libc_fallocate() from fallocate.c -+# posix_fallocate64() needs __libc_fallocate64() from fallocate64.c -+CSRC-$(if $(UCLIBC_LINUX_SPECIFIC)$(UCLIBC_HAS_ADVANCED_REALTIME),y,) += \ -+ fallocate.c $(filter fallocate64.c,$(CSRC-y)) - # NPTL needs these internally: madvise.c - CSRC-$(findstring y,$(UCLIBC_LINUX_SPECIFIC)$(UCLIBC_HAS_THREADS_NATIVE)) += madvise.c - ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y) ---- /dev/null -+++ b/libc/sysdeps/linux/common/fallocate.c -@@ -0,0 +1,48 @@ -+/* vi: set sw=4 ts=4: */ -+/* -+ * fallocate() for uClibc - Based off of posix_fallocate() by Erik Andersen -+ * http://www.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html -+ * -+ * Copyright (C) 2000-2006 Erik Andersen -+ * -+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball. -+ */ -+ -+#include -+#include -+#include -+#include -+ -+#if defined __NR_fallocate -+extern __typeof(fallocate) __libc_fallocate attribute_hidden; -+int attribute_hidden __libc_fallocate(int fd, int mode, __off_t offset, __off_t len) -+{ -+ int ret; -+ -+# if __WORDSIZE == 32 -+ uint32_t off_low = offset; -+ uint32_t len_low = len; -+ /* may assert that these >>31 are 0 */ -+ uint32_t zero = 0; -+ INTERNAL_SYSCALL_DECL(err); -+ ret = (int) (INTERNAL_SYSCALL(fallocate, err, 6, fd, mode, -+ __LONG_LONG_PAIR (zero, off_low), -+ __LONG_LONG_PAIR (zero, len_low))); -+# elif __WORDSIZE == 64 -+ INTERNAL_SYSCALL_DECL(err); -+ ret = (int) (INTERNAL_SYSCALL(fallocate, err, 4, fd, mode, offset, len)); -+# else -+# error your machine is neither 32 bit or 64 bit ... it must be magical -+# endif -+ if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err))) -+ return INTERNAL_SYSCALL_ERRNO (ret, err); -+ return 0; -+} -+ -+# if defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU -+strong_alias(__libc_fallocate,fallocate) -+# if __WORDSIZE == 64 -+strong_alias(__libc_fallocate,fallocate64) -+# endif -+# endif -+#endif ---- /dev/null -+++ b/libc/sysdeps/linux/common/fallocate64.c -@@ -0,0 +1,42 @@ -+/* vi: set sw=4 ts=4: */ -+/* -+ * fallocate() for uClibc - based off posix_fallocate() by Erik Andersen -+ * http://www.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html -+ * -+ * Copyright (C) 2000-2006 Erik Andersen -+ * -+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball. -+ */ -+ -+#include -+ -+#include -+#include -+#include -+ -+#if defined __NR_fallocate -+ -+# if __WORDSIZE == 64 -+/* Can use normal fallocate() */ -+# elif __WORDSIZE == 32 -+extern __typeof(fallocate64) __libc_fallocate64 attribute_hidden; -+int attribute_hidden __libc_fallocate64(int fd, int mode, __off64_t offset, -+ __off64_t len) -+{ -+ int ret; -+ INTERNAL_SYSCALL_DECL(err); -+ ret = (int) (INTERNAL_SYSCALL(fallocate, err, 6, fd, mode, -+ OFF64_HI_LO (offset), OFF64_HI_LO (len))); -+ if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err))) -+ return INTERNAL_SYSCALL_ERRNO (ret, err); -+ return 0; -+} -+ -+# if defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU -+strong_alias(__libc_fallocate64,fallocate64) -+# endif -+ -+# else -+# error your machine is neither 32 bit or 64 bit ... it must be magical -+# endif -+#endif ---- a/libc/sysdeps/linux/common/posix_fallocate.c -+++ b/libc/sysdeps/linux/common/posix_fallocate.c -@@ -14,28 +14,10 @@ - #include - - #if defined __NR_fallocate -+extern __typeof(fallocate) __libc_fallocate attribute_hidden; - int posix_fallocate(int fd, __off_t offset, __off_t len) - { -- int ret; -- --# if __WORDSIZE == 32 -- uint32_t off_low = offset; -- uint32_t len_low = len; -- /* may assert that these >>31 are 0 */ -- uint32_t zero = 0; -- INTERNAL_SYSCALL_DECL(err); -- ret = (int) (INTERNAL_SYSCALL(fallocate, err, 6, fd, 0, -- __LONG_LONG_PAIR (zero, off_low), -- __LONG_LONG_PAIR (zero, len_low))); --# elif __WORDSIZE == 64 -- INTERNAL_SYSCALL_DECL(err); -- ret = (int) (INTERNAL_SYSCALL(fallocate, err, 4, fd, 0, offset, len)); --# else --# error your machine is neither 32 bit or 64 bit ... it must be magical --#endif -- if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err))) -- return INTERNAL_SYSCALL_ERRNO (ret, err); -- return 0; -+ return __libc_fallocate(fd, 0, offset, len); - } - # if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64 - strong_alias(posix_fallocate,posix_fallocate64) ---- a/libc/sysdeps/linux/common/posix_fallocate64.c -+++ b/libc/sysdeps/linux/common/posix_fallocate64.c -@@ -18,22 +18,12 @@ - # if __WORDSIZE == 64 - /* Can use normal posix_fallocate() */ - # elif __WORDSIZE == 32 -+extern __typeof(fallocate64) __libc_fallocate64 attribute_hidden; - int posix_fallocate64(int fd, __off64_t offset, __off64_t len) - { -- int ret; -- uint32_t off_low = offset & 0xffffffff; -- uint32_t off_high = offset >> 32; -- uint32_t len_low = len & 0xffffffff; -- uint32_t len_high = len >> 32; -- INTERNAL_SYSCALL_DECL(err); -- ret = (int) (INTERNAL_SYSCALL(fallocate, err, 6, fd, 0, -- __LONG_LONG_PAIR (off_high, off_low), -- __LONG_LONG_PAIR (len_high, len_low))); -- if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err))) -- return INTERNAL_SYSCALL_ERRNO (ret, err); -- return 0; -+ return __libc_fallocate64(fd, 0, offset, len); - } - # else --# error your machine is neither 32 bit or 64 bit ... it must be magical -+# error your machine is neither 32 bit or 64 bit ... it must be magical - # endif - #endif ---- a/test/.gitignore -+++ b/test/.gitignore -@@ -302,6 +302,8 @@ unistd/getcwd - unistd/getopt - unistd/getopt_long - unistd/tstgetopt -+unistd/tst-fallocate -+unistd/tst-fallocate64 - unistd/tst-posix_fallocate - unistd/tst-posix_fallocate64 - unistd/tst-preadwrite ---- /dev/null -+++ b/test/unistd/tst-fallocate.c -@@ -0,0 +1,166 @@ -+#include -+#include -+ -+#ifndef TST_FALLOCATE64 -+# define stat64 stat -+# define fstat64 fstat -+# else -+# ifndef O_LARGEFILE -+# error no O_LARGEFILE but you want to test with LFS enabled -+# endif -+#endif -+ -+static void do_prepare(void); -+static int do_test(void); -+#define PREPARE(argc, argv) do_prepare () -+#define TEST_FUNCTION do_test () -+#include -+ -+static int fd; -+static void -+do_prepare (void) -+{ -+ fd = create_temp_file ("tst-fallocate.", NULL); -+ if (fd == -1) -+ { -+ printf ("cannot create temporary file: %m\n"); -+ exit (1); -+ } -+} -+ -+ -+static int -+do_test (void) -+{ -+ struct stat64 st; -+ int c; -+ char garbage[4096]; -+ blkcnt_t blksb4; -+ -+ if (fstat64 (fd, &st) != 0) -+ { -+ puts ("1st fstat failed"); -+ return 1; -+ } -+ -+ if (st.st_size != 0) -+ { -+ puts ("file not created with size 0"); -+ return 1; -+ } -+ -+ /* This is the default mode which is identical to posix_fallocate(). -+ Note: we need a few extra blocks for FALLOC_FL_PUNCH_HOLE below. -+ While block sizes vary, we'll assume eight 4K blocks for good measure. */ -+ if (fallocate (fd, 0, 8 * 4096, 128) != 0) -+ { -+ puts ("1st fallocate call failed"); -+ return 1; -+ } -+ -+ if (fstat64 (fd, &st) != 0) -+ { -+ puts ("2nd fstat failed"); -+ return 1; -+ } -+ -+ if (st.st_size != 8 * 4096 + 128) -+ { -+ printf ("file size after 1st fallocate call is %llu, expected %u\n", -+ (unsigned long long int) st.st_size, 8u * 4096u + 128u); -+ return 1; -+ } -+ -+ /* Without FALLOC_FL_KEEP_SIZE, this would increaste the size of the file. */ -+ if (fallocate (fd, FALLOC_FL_KEEP_SIZE, 0, 16 * 4096) != 0) -+ { -+ puts ("2nd fallocate call failed"); -+ return 1; -+ } -+ -+ if (fstat64 (fd, &st) != 0) -+ { -+ puts ("3rd fstat failed"); -+ return 1; -+ } -+ -+ if (st.st_size != 8 * 4096 + 128) -+ { -+ printf ("file size changed in 2nd fallocate call to %llu, expected %u\n", -+ (unsigned long long int) st.st_size, 8u * 4096u + 128u); -+ return 1; -+ } -+ -+ /* Let's fill up the first eight 4k blocks with 'x' to force some allocations. */ -+ -+ memset(garbage, 'x', 4096); -+ for(c=0; c < 8; c++) -+ if(write(fd, garbage, 4096) == -1) -+ { -+ puts ("write failed"); -+ return 1; -+ } -+ -+ if (fstat64 (fd, &st) != 0) -+ { -+ puts ("4th fstat failed"); -+ return 1; -+ } -+ -+ blksb4 = st.st_blocks; -+ -+ /* Let's punch a hole in the entire file, turning it effectively into a sparse file. */ -+ if (fallocate (fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 8 * 4096 + 128) != 0) -+ { -+ puts ("3rd fallocate call failed"); -+ return 1; -+ } -+ -+ if (fstat64 (fd, &st) != 0) -+ { -+ puts ("5th fstat failed"); -+ return 1; -+ } -+ -+ if (st.st_size != 8 * 4096 + 128) -+ { -+ printf ("file size after 3rd fallocate call is %llu, expected %u\n", -+ (unsigned long long int) st.st_size, 8u * 4096u + 128u); -+ return 1; -+ } -+ -+ /* The number of allocated blocks should decrease. I hope this works on -+ all filesystems! */ -+ if (st.st_blocks >= blksb4) -+ { -+ printf ("number of blocks after 3rd fallocate call is %lu, expected less than %lu\n", -+ (unsigned long int) st.st_blocks, blksb4); -+ return 1; -+ } -+ -+#ifdef TST_FALLOCATE64 -+ /* We'll just do a mode = 0 test for fallocate64() */ -+ if (fallocate64 (fd, 0, 4097ULL, 4294967295ULL + 2ULL) != 0) -+ { -+ puts ("1st fallocate64 call failed"); -+ return 1; -+ } -+ -+ if (fstat64 (fd, &st) != 0) -+ { -+ puts ("6th fstat failed"); -+ return 1; -+ } -+ -+ if (st.st_size != 4097ULL + 4294967295ULL + 2ULL) -+ { -+ printf ("file size after 1st fallocate64 call is %llu, expected %llu\n", -+ (unsigned long long int) st.st_size, 4097ULL + 4294967295ULL + 2ULL); -+ return 1; -+ } -+#endif -+ close (fd); -+ -+ return 0; -+} -+ ---- /dev/null -+++ b/test/unistd/tst-fallocate64.c -@@ -0,0 +1,2 @@ -+#define TST_FALLOCATE64 -+#include "tst-fallocate.c" ---- a/test/unistd/Makefile.in -+++ b/test/unistd/Makefile.in -@@ -2,10 +2,13 @@ - # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. - - ifeq ($(UCLIBC_HAS_LFS),) --TESTS_DISABLED := tst-preadwrite64 tst-posix_fallocate64 -+TESTS_DISABLED := tst-preadwrite64 tst-posix_fallocate64 tst-fallocate64 - endif - ifeq ($(UCLIBC_HAS_ADVANCED_REALTIME),) --TESTS_DISABLED := tst-posix_fallocate -+TESTS_DISABLED := tst-posix_fallocate tst-fallocate64 -+endif -+ifeq ($(UCLIBC_LINUX_SPECIFIC),) -+TESTS_DISABLED += tst-fallocate - endif - OPTS_getopt := -abcXXX -9 - OPTS_getopt_long := --add XXX --delete YYY --verbose diff --git a/toolchain/uClibc/patches-0.9.33.2/024-i386-bits-syscalls.h-allow-immediate-values-as-6th-s.patch b/toolchain/uClibc/patches-0.9.33.2/024-i386-bits-syscalls.h-allow-immediate-values-as-6th-s.patch deleted file mode 100644 index 2f75fbe2a5c..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/024-i386-bits-syscalls.h-allow-immediate-values-as-6th-s.patch +++ /dev/null @@ -1,25 +0,0 @@ -From: Natanael Copa -Date: Thu, 5 Jul 2012 11:55:19 +0000 -Subject: [PATCH] i386/bits/syscalls.h: allow immediate values as 6th syscall - arg - -Allow use of immedate values as the 6th syscall argument. Otherwise we must -store the arg on memory. This gives gcc more options to optimize better. - -This also works around an issue with posix_fallocate. - -Signed-off-by: Natanael Copa -Signed-off-by: Bernhard Reutner-Fischer ---- - ---- a/libc/sysdeps/linux/i386/bits/syscalls.h -+++ b/libc/sysdeps/linux/i386/bits/syscalls.h -@@ -136,7 +136,7 @@ __asm__ ( - #define ASMFMT_5(arg1, arg2, arg3, arg4, arg5) \ - , "a" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5) - #define ASMFMT_6(arg1, arg2, arg3, arg4, arg5, arg6) \ -- , "a" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5), "m" (arg6) -+ , "a" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5), "g" (arg6) - - #else /* !PIC */ - diff --git a/toolchain/uClibc/patches-0.9.33.2/025-libc-sync_file_range.patch b/toolchain/uClibc/patches-0.9.33.2/025-libc-sync_file_range.patch deleted file mode 100644 index e7efb93689a..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/025-libc-sync_file_range.patch +++ /dev/null @@ -1,57 +0,0 @@ -Index: uClibc-0.9.33.2/libc/sysdeps/linux/common/sync_file_range.c -=================================================================== ---- uClibc-0.9.33.2.orig/libc/sysdeps/linux/common/sync_file_range.c 2012-05-15 09:20:09.000000000 +0200 -+++ uClibc-0.9.33.2/libc/sysdeps/linux/common/sync_file_range.c 2015-04-03 00:27:47.701221722 +0200 -@@ -4,24 +4,39 @@ - * - * Copyright (C) 2008 Bernhard Reutner-Fischer - * -- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. -+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball. - */ - - #include --#if defined __USE_GNU --#include -+#if defined __UCLIBC_HAS_LFS__ && defined __USE_GNU -+# include -+# include -+# include - --#if defined __NR_sync_file_range && defined __UCLIBC_HAS_LFS__ --#define __NR___syscall_sync_file_range __NR_sync_file_range --static __inline__ _syscall6(int, __syscall_sync_file_range, int, fd, -- off_t, offset_hi, off_t, offset_lo, -- off_t, nbytes_hi, off_t, nbytes_lo, unsigned int, flags) -+# ifdef __NR_sync_file_range2 -+# undef __NR_sync_file_range -+# define __NR_sync_file_range __NR_sync_file_range2 -+# endif -+ -+# ifdef __NR_sync_file_range - int sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags) - { -- return __syscall_sync_file_range(fd, -- __LONG_LONG_PAIR((long)(offset >> 32), (long)(offset & 0xffffffff)), -- __LONG_LONG_PAIR((long)(nbytes >> 32), (long)(nbytes & 0xffffffff)), -- flags); -+# if defined __powerpc__ && __WORDSIZE == 64 -+ return INLINE_SYSCALL(sync_file_range, 4, fd, flags, offset, nbytes); -+# elif (defined __mips__ && _MIPS_SIM == _ABIO32) || \ -+ (defined(__UCLIBC_SYSCALL_ALIGN_64BIT__) && !(defined(__powerpc__) || defined(__xtensa__))) -+ /* arch with 64-bit data in even reg alignment #2: [arcv2/others-in-future] -+ * stock syscall handler in kernel (reg hole punched) -+ * see libc/sysdeps/linux/common/posix_fadvise.c for more details */ -+ return INLINE_SYSCALL(sync_file_range, 7, fd, 0, -+ OFF64_HI_LO(offset), OFF64_HI_LO(nbytes), flags); -+# elif defined __NR_sync_file_range2 -+ return INLINE_SYSCALL(sync_file_range, 6, fd, flags, -+ OFF64_HI_LO(offset), OFF64_HI_LO(nbytes)); -+# else -+ return INLINE_SYSCALL(sync_file_range, 6, fd, -+ OFF64_HI_LO(offset), OFF64_HI_LO(nbytes), flags); -+# endif - } --#endif -+# endif - #endif diff --git a/toolchain/uClibc/patches-0.9.33.2/100-fix_unifdef.patch b/toolchain/uClibc/patches-0.9.33.2/100-fix_unifdef.patch deleted file mode 100644 index 3d75b6e79fe..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/100-fix_unifdef.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/extra/scripts/unifdef.c -+++ b/extra/scripts/unifdef.c -@@ -78,8 +78,6 @@ __FBSDID("$FreeBSD: /repoman/r/ncvs/src/ - #define errx(exit_code, fmt, args...) ({ warnx(fmt, ## args); exit(exit_code); }) - #define err(exit_code, fmt, args...) errx(exit_code, fmt ": %s", ## args, strerror(errno)) - --size_t strlcpy(char *dst, const char *src, size_t siz); -- - /* types of input lines: */ - typedef enum { - LT_TRUEI, /* a true #if with ignore flag */ diff --git a/toolchain/uClibc/patches-0.9.33.2/110-compat_macros.patch b/toolchain/uClibc/patches-0.9.33.2/110-compat_macros.patch deleted file mode 100644 index a7538b16f8d..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/110-compat_macros.patch +++ /dev/null @@ -1,51 +0,0 @@ ---- a/include/string.h -+++ b/include/string.h -@@ -355,18 +355,40 @@ extern char *index (__const char *__s, i - /* Find the last occurrence of C in S (same as strrchr). */ - extern char *rindex (__const char *__s, int __c) - __THROW __attribute_pure__ __nonnull ((1)); --# else --# ifdef __UCLIBC_SUSV3_LEGACY_MACROS__ -+# elif defined(__UCLIBC_SUSV3_LEGACY_MACROS__) && !defined(_STRINGS_H) - /* bcopy/bzero/bcmp/index/rindex are marked LEGACY in SuSv3. - * They are replaced as proposed by SuSv3. Don't sync this part - * with glibc and keep it in sync with strings.h. */ - --# define bcopy(src,dest,n) (memmove((dest), (src), (n)), (void) 0) --# define bzero(s,n) (memset((s), '\0', (n)), (void) 0) --# define bcmp(s1,s2,n) memcmp((s1), (s2), (size_t)(n)) --# define index(s,c) strchr((s), (c)) --# define rindex(s,c) strrchr((s), (c)) --# endif -+/* Copy N bytes of SRC to DEST (like memmove, but args reversed). */ -+static __inline__ void bcopy (__const void *__src, void *__dest, size_t __n) -+{ -+ memmove(__dest, __src, __n); -+} -+ -+/* Set N bytes of S to 0. */ -+static __inline__ void bzero (void *__s, size_t __n) -+{ -+ memset(__s, 0, __n); -+} -+ -+/* Compare N bytes of S1 and S2 (same as memcmp). */ -+static __inline__ int bcmp (__const void *__s1, __const void *__s2, size_t __n) -+{ -+ return memcmp(__s1, __s2, __n); -+} -+ -+/* Find the first occurrence of C in S (same as strchr). */ -+static __inline__ char *index (__const char *__s, int __c) -+{ -+ return strchr(__s, __c); -+} -+ -+/* Find the last occurrence of C in S (same as strrchr). */ -+static __inline__ char *rindex (__const char *__s, int __c) -+{ -+ return strrchr(__s, __c); -+} - # endif - - /* Return the position of the first bit set in I, or 0 if none are set. diff --git a/toolchain/uClibc/patches-0.9.33.2/120-adjtimex.patch b/toolchain/uClibc/patches-0.9.33.2/120-adjtimex.patch deleted file mode 100644 index dcf9c9b5aa2..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/120-adjtimex.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/include/sys/timex.h -+++ b/include/sys/timex.h -@@ -116,9 +116,8 @@ struct timex - - __BEGIN_DECLS - --#if 0 --extern int __adjtimex (struct timex *__ntx) __THROW; --#endif -+#undef __adjtimex -+#define __adjtimex adjtimex - extern int adjtimex (struct timex *__ntx) __THROW; - libc_hidden_proto(adjtimex) - diff --git a/toolchain/uClibc/patches-0.9.33.2/131-inet-fix-__read_etc_hosts_r-segfault.patch b/toolchain/uClibc/patches-0.9.33.2/131-inet-fix-__read_etc_hosts_r-segfault.patch deleted file mode 100644 index bd9ed380a60..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/131-inet-fix-__read_etc_hosts_r-segfault.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/libc/inet/resolv.c -+++ b/libc/inet/resolv.c -@@ -1631,6 +1631,7 @@ int attribute_hidden __read_etc_hosts_r( - * struct in[6]_addr - * char line_buffer[BUFSZ+]; - */ -+ memset(buf, 0, buflen); - parser->data = buf; - parser->data_len = aliaslen; - parser->line_len = buflen - aliaslen; diff --git a/toolchain/uClibc/patches-0.9.33.2/132-inet_fix_res_init.patch b/toolchain/uClibc/patches-0.9.33.2/132-inet_fix_res_init.patch deleted file mode 100644 index c935821b221..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/132-inet_fix_res_init.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/libc/inet/resolv.c -+++ b/libc/inet/resolv.c -@@ -3654,11 +3654,11 @@ res_init(void) - */ - if (!_res.id) - _res.id = res_randomid(); -- __res_sync = res_sync_func; - - __UCLIBC_MUTEX_UNLOCK(__resolv_lock); - - __res_vinit(&_res, 1); -+ __res_sync = res_sync_func; - - return 0; - } diff --git a/toolchain/uClibc/patches-0.9.33.2/133-inet6-scoped-getnameinfo.patch b/toolchain/uClibc/patches-0.9.33.2/133-inet6-scoped-getnameinfo.patch deleted file mode 100644 index 390e06ddb75..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/133-inet6-scoped-getnameinfo.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/libc/inet/resolv.c -+++ b/libc/inet/resolv.c -@@ -317,6 +317,7 @@ Domain name in a message can be represen - #include - #include - #include -+#include - #include - #include "internal/parse_config.h" - -@@ -1861,7 +1862,6 @@ int getnameinfo(const struct sockaddr *s - c = inet_ntop(AF_INET6, - (const void *) &sin6p->sin6_addr, - host, hostlen); --#if 0 - /* Does scope id need to be supported? */ - uint32_t scopeid; - scopeid = sin6p->sin6_scope_id; -@@ -1898,7 +1898,6 @@ int getnameinfo(const struct sockaddr *s - return EAI_SYSTEM; - memcpy(host + real_hostlen, scopebuf, scopelen + 1); - } --#endif - } - #endif /* __UCLIBC_HAS_IPV6__ */ - #if defined __UCLIBC_HAS_IPV4__ diff --git a/toolchain/uClibc/patches-0.9.33.2/135-inet_fix_threaded_use_of_res_functions.patch b/toolchain/uClibc/patches-0.9.33.2/135-inet_fix_threaded_use_of_res_functions.patch deleted file mode 100644 index 6732d54d3e4..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/135-inet_fix_threaded_use_of_res_functions.patch +++ /dev/null @@ -1,126 +0,0 @@ ---- a/libc/inet/resolv.c -+++ b/libc/inet/resolv.c -@@ -3536,6 +3536,61 @@ __res_vinit(res_state rp, int preinit) - return 0; - } - -+static unsigned int -+res_randomid(void) -+{ -+ return 0xffff & getpid(); -+} -+ -+/* Our res_init never fails (always returns 0) */ -+int -+res_init(void) -+{ -+ /* -+ * These three fields used to be statically initialized. This made -+ * it hard to use this code in a shared library. It is necessary, -+ * now that we're doing dynamic initialization here, that we preserve -+ * the old semantics: if an application modifies one of these three -+ * fields of _res before res_init() is called, res_init() will not -+ * alter them. Of course, if an application is setting them to -+ * _zero_ before calling res_init(), hoping to override what used -+ * to be the static default, we can't detect it and unexpected results -+ * will follow. Zero for any of these fields would make no sense, -+ * so one can safely assume that the applications were already getting -+ * unexpected results. -+ * -+ * _res.options is tricky since some apps were known to diddle the bits -+ * before res_init() was first called. We can't replicate that semantic -+ * with dynamic initialization (they may have turned bits off that are -+ * set in RES_DEFAULT). Our solution is to declare such applications -+ * "broken". They could fool us by setting RES_INIT but none do (yet). -+ */ -+ -+ __UCLIBC_MUTEX_LOCK(__resolv_lock); -+ -+ if (!_res.retrans) -+ _res.retrans = RES_TIMEOUT; -+ if (!_res.retry) -+ _res.retry = 4; -+ if (!(_res.options & RES_INIT)) -+ _res.options = RES_DEFAULT; -+ -+ /* -+ * This one used to initialize implicitly to zero, so unless the app -+ * has set it to something in particular, we can randomize it now. -+ */ -+ if (!_res.id) -+ _res.id = res_randomid(); -+ -+ __UCLIBC_MUTEX_UNLOCK(__resolv_lock); -+ -+ __res_vinit(&_res, 1); -+ __res_sync = res_sync_func; -+ -+ return 0; -+} -+libc_hidden_def(res_init) -+ - static void - __res_iclose(void) - { -@@ -3608,61 +3663,6 @@ struct __res_state *__resp = &_res; - # endif - #endif /* !__UCLIBC_HAS_THREADS__ */ - --static unsigned int --res_randomid(void) --{ -- return 0xffff & getpid(); --} -- --/* Our res_init never fails (always returns 0) */ --int --res_init(void) --{ -- /* -- * These three fields used to be statically initialized. This made -- * it hard to use this code in a shared library. It is necessary, -- * now that we're doing dynamic initialization here, that we preserve -- * the old semantics: if an application modifies one of these three -- * fields of _res before res_init() is called, res_init() will not -- * alter them. Of course, if an application is setting them to -- * _zero_ before calling res_init(), hoping to override what used -- * to be the static default, we can't detect it and unexpected results -- * will follow. Zero for any of these fields would make no sense, -- * so one can safely assume that the applications were already getting -- * unexpected results. -- * -- * _res.options is tricky since some apps were known to diddle the bits -- * before res_init() was first called. We can't replicate that semantic -- * with dynamic initialization (they may have turned bits off that are -- * set in RES_DEFAULT). Our solution is to declare such applications -- * "broken". They could fool us by setting RES_INIT but none do (yet). -- */ -- -- __UCLIBC_MUTEX_LOCK(__resolv_lock); -- -- if (!_res.retrans) -- _res.retrans = RES_TIMEOUT; -- if (!_res.retry) -- _res.retry = 4; -- if (!(_res.options & RES_INIT)) -- _res.options = RES_DEFAULT; -- -- /* -- * This one used to initialize implicitly to zero, so unless the app -- * has set it to something in particular, we can randomize it now. -- */ -- if (!_res.id) -- _res.id = res_randomid(); -- -- __UCLIBC_MUTEX_UNLOCK(__resolv_lock); -- -- __res_vinit(&_res, 1); -- __res_sync = res_sync_func; -- -- return 0; --} --libc_hidden_def(res_init) -- - /* - * Set up default settings. If the configuration file exist, the values - * there will have precedence. Otherwise, the server address is set to diff --git a/toolchain/uClibc/patches-0.9.33.2/136-inet_make_res_init_thread_safe.patch b/toolchain/uClibc/patches-0.9.33.2/136-inet_make_res_init_thread_safe.patch deleted file mode 100644 index 06278898f9b..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/136-inet_make_res_init_thread_safe.patch +++ /dev/null @@ -1,53 +0,0 @@ ---- a/libc/inet/resolv.c -+++ b/libc/inet/resolv.c -@@ -3432,6 +3432,7 @@ static void res_sync_func(void) - */ - } - -+/* has to be called under __resolv_lock */ - static int - __res_vinit(res_state rp, int preinit) - { -@@ -3440,7 +3441,6 @@ __res_vinit(res_state rp, int preinit) - int m = 0; - #endif - -- __UCLIBC_MUTEX_LOCK(__resolv_lock); - __close_nameservers(); - __open_nameservers(); - -@@ -3532,7 +3532,6 @@ __res_vinit(res_state rp, int preinit) - - rp->options |= RES_INIT; - -- __UCLIBC_MUTEX_UNLOCK(__resolv_lock); - return 0; - } - -@@ -3582,11 +3581,11 @@ res_init(void) - if (!_res.id) - _res.id = res_randomid(); - -- __UCLIBC_MUTEX_UNLOCK(__resolv_lock); -- - __res_vinit(&_res, 1); - __res_sync = res_sync_func; - -+ __UCLIBC_MUTEX_UNLOCK(__resolv_lock); -+ - return 0; - } - libc_hidden_def(res_init) -@@ -3687,7 +3686,11 @@ struct __res_state *__resp = &_res; - int - res_ninit(res_state statp) - { -- return __res_vinit(statp, 0); -+ int ret; -+ __UCLIBC_MUTEX_LOCK(__resolv_lock); -+ ret = __res_vinit(statp, 0); -+ __UCLIBC_MUTEX_UNLOCK(__resolv_lock); -+ return ret; - } - - #endif /* L_res_init */ diff --git a/toolchain/uClibc/patches-0.9.33.2/137-inet_fix_threaded_res_init.patch b/toolchain/uClibc/patches-0.9.33.2/137-inet_fix_threaded_res_init.patch deleted file mode 100644 index ce8448ab49e..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/137-inet_fix_threaded_res_init.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/libc/inet/resolv.c -+++ b/libc/inet/resolv.c -@@ -3581,6 +3581,7 @@ res_init(void) - if (!_res.id) - _res.id = res_randomid(); - -+ __res_sync = NULL; - __res_vinit(&_res, 1); - __res_sync = res_sync_func; - diff --git a/toolchain/uClibc/patches-0.9.33.2/150-vasprintf_size_reduce.patch b/toolchain/uClibc/patches-0.9.33.2/150-vasprintf_size_reduce.patch deleted file mode 100644 index 7853c1afa03..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/150-vasprintf_size_reduce.patch +++ /dev/null @@ -1,37 +0,0 @@ -Reduce the initial buffer size for open_memstream (used by vasprintf), -as most strings are usually smaller than that. -Realloc the buffer after finishing the string to further reduce size. - -Signed-off-by: Felix Fietkau - ---- a/libc/stdio/vasprintf.c -+++ b/libc/stdio/vasprintf.c -@@ -39,6 +39,8 @@ int vasprintf(char **__restrict buf, con - if (rv < 0) { - free(*buf); - *buf = NULL; -+ } else { -+ *buf = realloc(*buf, rv + 1); - } - } - ---- a/libc/stdio/open_memstream.c -+++ b/libc/stdio/open_memstream.c -@@ -17,6 +17,8 @@ - - #define COOKIE ((__oms_cookie *) cookie) - -+#define MEMSTREAM_BUFSIZ 256 -+ - typedef struct { - char *buf; - size_t len; -@@ -134,7 +136,7 @@ FILE *open_memstream(char **__restrict b - register FILE *fp; - - if ((cookie = malloc(sizeof(__oms_cookie))) != NULL) { -- if ((cookie->buf = malloc(cookie->len = BUFSIZ)) == NULL) { -+ if ((cookie->buf = malloc(cookie->len = MEMSTREAM_BUFSIZ)) == NULL) { - goto EXIT_cookie; - } - *cookie->buf = 0; /* Set nul terminator for buffer. */ diff --git a/toolchain/uClibc/patches-0.9.33.2/170-math_finite.patch b/toolchain/uClibc/patches-0.9.33.2/170-math_finite.patch deleted file mode 100644 index b0ae3337b98..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/170-math_finite.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/include/math.h -+++ b/include/math.h -@@ -195,7 +195,7 @@ extern int signgam; - - - /* ISO C99 defines some generic macros which work on any data type. */ --#ifdef __USE_ISOC99 -+#if defined(__USE_ISOC99) || defined(__USE_BSD) - - /* Get the architecture specific values describing the floating-point - evaluation. The following symbols will get defined: -@@ -315,6 +315,11 @@ enum - - #endif /* Use ISO C99. */ - -+/* BSD compat */ -+#define finite(x) __finite(x) -+#define finitef(x) __finitef(x) -+#define finitel(x) __finitel(x) -+ - #ifdef __USE_MISC - /* Support for various different standard error handling behaviors. */ - typedef enum diff --git a/toolchain/uClibc/patches-0.9.33.2/180-pthread_cleanup_fix.patch b/toolchain/uClibc/patches-0.9.33.2/180-pthread_cleanup_fix.patch deleted file mode 100644 index ae36018792b..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/180-pthread_cleanup_fix.patch +++ /dev/null @@ -1,45 +0,0 @@ ---- a/libpthread/nptl/cleanup_defer_compat.c -+++ b/libpthread/nptl/cleanup_defer_compat.c -@@ -22,7 +22,7 @@ - - void - attribute_protected --_pthread_cleanup_push_defer ( -+__pthread_cleanup_push_defer ( - struct _pthread_cleanup_buffer *buffer, - void (*routine) (void *), - void *arg) -@@ -57,12 +57,12 @@ _pthread_cleanup_push_defer ( - - THREAD_SETMEM (self, cleanup, buffer); - } --strong_alias (_pthread_cleanup_push_defer, __pthread_cleanup_push_defer) -+strong_alias (__pthread_cleanup_push_defer, _pthread_cleanup_push_defer) - - - void - attribute_protected --_pthread_cleanup_pop_restore ( -+__pthread_cleanup_pop_restore ( - struct _pthread_cleanup_buffer *buffer, - int execute) - { -@@ -97,4 +97,4 @@ _pthread_cleanup_pop_restore ( - if (execute) - buffer->__routine (buffer->__arg); - } --strong_alias (_pthread_cleanup_pop_restore, __pthread_cleanup_pop_restore) -+strong_alias (__pthread_cleanup_pop_restore, _pthread_cleanup_pop_restore) ---- a/libpthread/nptl/init.c -+++ b/libpthread/nptl/init.c -@@ -112,8 +112,8 @@ static const struct pthread_functions pt - .ptr___pthread_key_create = __pthread_key_create_internal, - .ptr___pthread_getspecific = __pthread_getspecific_internal, - .ptr___pthread_setspecific = __pthread_setspecific_internal, -- .ptr__pthread_cleanup_push_defer = _pthread_cleanup_push_defer, -- .ptr__pthread_cleanup_pop_restore = _pthread_cleanup_pop_restore, -+ .ptr__pthread_cleanup_push_defer = __pthread_cleanup_push_defer, -+ .ptr__pthread_cleanup_pop_restore = __pthread_cleanup_pop_restore, - .ptr_nthreads = &__nptl_nthreads, - .ptr___pthread_unwind = &__pthread_unwind, - .ptr__nptl_deallocate_tsd = __nptl_deallocate_tsd, diff --git a/toolchain/uClibc/patches-0.9.33.2/190-nptl_use_arch_default_stack_limit.patch b/toolchain/uClibc/patches-0.9.33.2/190-nptl_use_arch_default_stack_limit.patch deleted file mode 100644 index b7f5c82e057..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/190-nptl_use_arch_default_stack_limit.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/libpthread/nptl/init.c -+++ b/libpthread/nptl/init.c -@@ -402,6 +402,10 @@ __pthread_initialize_minimal_internal (v - Use the minimal size acceptable. */ - limit.rlim_cur = PTHREAD_STACK_MIN; - -+ /* Do not exceed architecture specific default */ -+ if (limit.rlim_cur > ARCH_STACK_DEFAULT_SIZE) -+ limit.rlim_cur = ARCH_STACK_DEFAULT_SIZE; -+ - /* Make sure it meets the minimum size that allocate_stack - (allocatestack.c) will demand, which depends on the page size. */ - const uintptr_t pagesz = sysconf (_SC_PAGESIZE); diff --git a/toolchain/uClibc/patches-0.9.33.2/200-no_forced_unwind.patch b/toolchain/uClibc/patches-0.9.33.2/200-no_forced_unwind.patch deleted file mode 100644 index d6869e2de63..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/200-no_forced_unwind.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/Rules.mak -+++ b/Rules.mak -@@ -707,7 +707,6 @@ endif - ifeq ($(UCLIBC_HAS_THREADS),y) - ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y) - PTNAME := nptl -- CFLAGS += -DHAVE_FORCED_UNWIND - else - ifeq ($(LINUXTHREADS_OLD),y) - PTNAME := linuxthreads.old diff --git a/toolchain/uClibc/patches-0.9.33.2/210-mips_use_pic_crt1.patch b/toolchain/uClibc/patches-0.9.33.2/210-mips_use_pic_crt1.patch deleted file mode 100644 index 2ca10d47cc3..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/210-mips_use_pic_crt1.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/libc/sysdeps/linux/mips/Makefile.arch -+++ b/libc/sysdeps/linux/mips/Makefile.arch -@@ -20,6 +20,8 @@ ifneq ($(UCLIBC_HAS_THREADS_NATIVE),y) - SSRC += vfork.S clone.S - endif - -+CFLAGS-crt1.S += $(PICFLAG) -+ - ASFLAGS-syscall_error.S += -D_LIBC_REENTRANT - - ARCH_HEADERS := sgidefs.h diff --git a/toolchain/uClibc/patches-0.9.33.2/350-use-fputs_unlocked.patch b/toolchain/uClibc/patches-0.9.33.2/350-use-fputs_unlocked.patch deleted file mode 100644 index 58b03ec7d96..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/350-use-fputs_unlocked.patch +++ /dev/null @@ -1,19 +0,0 @@ -commit 3e3ae40f053b22fbb9bef50067d6edad4c358c4c -Author: Mirko Vogt -Date: Tue May 24 14:36:42 2011 +0200 - - use 'fputws_unlocked(S,F)' instead of 'fputws(S,F)' - - this eliminates a source of reproduceable freezes - ---- a/libc/stdio/_vfprintf.c -+++ b/libc/stdio/_vfprintf.c -@@ -1229,7 +1229,7 @@ static size_t _fp_out_narrow(FILE *fp, i - #define STRLEN wcslen - #define _PPFS_init _ppwfs_init - /* Pulls in fseek: */ --#define OUTPUT(F,S) fputws(S,F) -+#define OUTPUT(F,S) fputws_unlocked(S,F) - /* TODO: #define OUTPUT(F,S) _wstdio_fwrite((S),wcslen(S),(F)) */ - #define _outnwcs(stream, wstring, len) _wstdio_fwrite((const wchar_t *)(wstring), len, stream) - #define FP_OUT _fp_out_wide diff --git a/toolchain/uClibc/patches-0.9.33.2/410-llvm_workaround.patch b/toolchain/uClibc/patches-0.9.33.2/410-llvm_workaround.patch deleted file mode 100644 index 7ae394325bc..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/410-llvm_workaround.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/libc/stdio/_stdio.c -+++ b/libc/stdio/_stdio.c -@@ -124,7 +124,7 @@ static FILE _stdio_streams[] = { - __FLAG_NBF|__FLAG_WRITEONLY, \ - 2, \ - NULL, \ -- NULL, \ -+ 0, \ - 0 ) - }; - diff --git a/toolchain/uClibc/patches-0.9.33.2/450-powerpc_copysignl.patch b/toolchain/uClibc/patches-0.9.33.2/450-powerpc_copysignl.patch deleted file mode 100644 index ad8d6824bb3..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/450-powerpc_copysignl.patch +++ /dev/null @@ -1,103 +0,0 @@ ---- a/libc/sysdeps/linux/powerpc/Makefile.arch -+++ b/libc/sysdeps/linux/powerpc/Makefile.arch -@@ -5,7 +5,7 @@ - # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. - # - --CSRC := __syscall_error.c pread_write.c ioctl.c -+CSRC := __syscall_error.c pread_write.c ioctl.c copysignl.c - - ifeq ($(UCLIBC_HAS_ADVANCED_REALTIME),y) - CSRC += posix_fadvise.c posix_fadvise64.c ---- /dev/null -+++ b/libc/sysdeps/linux/powerpc/copysignl.c -@@ -0,0 +1,89 @@ -+/* s_copysignl.c -- long double version of s_copysign.c. -+ * Conversion to long double by Ulrich Drepper, -+ * Cygnus Support, drepper@cygnus.com. -+ */ -+ -+/* -+ * ==================================================== -+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. -+ * -+ * Developed at SunPro, a Sun Microsystems, Inc. business. -+ * Permission to use, copy, modify, and distribute this -+ * software is freely granted, provided that this notice -+ * is preserved. -+ * ==================================================== -+ */ -+ -+/* -+ * copysignl(long double x, long double y) -+ * copysignl(x,y) returns a value with the magnitude of x and -+ * with the sign bit of y. -+ */ -+ -+#include -+#include -+ -+#if __FLOAT_WORD_ORDER == BIG_ENDIAN -+ -+typedef union -+{ -+ long double value; -+ struct -+ { -+ int sign_exponent:16; -+ unsigned int empty:16; -+ uint32_t msw; -+ uint32_t lsw; -+ } parts; -+} ieee_long_double_shape_type; -+ -+#endif -+ -+#if __FLOAT_WORD_ORDER == LITTLE_ENDIAN -+ -+typedef union -+{ -+ long double value; -+ struct -+ { -+ uint32_t lsw; -+ uint32_t msw; -+ int sign_exponent:16; -+ unsigned int empty:16; -+ } parts; -+} ieee_long_double_shape_type; -+ -+#endif -+ -+/* Get int from the exponent of a long double. */ -+ -+#define GET_LDOUBLE_EXP(exp,d) \ -+do { \ -+ ieee_long_double_shape_type ge_u; \ -+ ge_u.value = (d); \ -+ (exp) = ge_u.parts.sign_exponent; \ -+} while (0) -+ -+/* Set exponent of a long double from an int. */ -+ -+#define SET_LDOUBLE_EXP(d,exp) \ -+do { \ -+ ieee_long_double_shape_type se_u; \ -+ se_u.value = (d); \ -+ se_u.parts.sign_exponent = (exp); \ -+ (d) = se_u.value; \ -+} while (0) -+ -+long double copysignl(long double x, long double y); -+libc_hidden_proto(copysignl); -+ -+long double copysignl(long double x, long double y) -+{ -+ uint32_t es1,es2; -+ GET_LDOUBLE_EXP(es1,x); -+ GET_LDOUBLE_EXP(es2,y); -+ SET_LDOUBLE_EXP(x,(es1&0x7fff)|(es2&0x8000)); -+ return x; -+} -+ -+libc_hidden_def(copysignl); diff --git a/toolchain/uClibc/patches-0.9.33.2/460-powerpc_ptrace_h.patch b/toolchain/uClibc/patches-0.9.33.2/460-powerpc_ptrace_h.patch deleted file mode 100644 index c48b68244bb..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/460-powerpc_ptrace_h.patch +++ /dev/null @@ -1,96 +0,0 @@ ---- a/libc/sysdeps/linux/powerpc/sys/ptrace.h -+++ b/libc/sysdeps/linux/powerpc/sys/ptrace.h -@@ -1,5 +1,5 @@ - /* `ptrace' debugger support interface. Linux version. -- Copyright (C) 2001 Free Software Foundation, Inc. -+ Copyright (C) 2001, 2006, 2007, 2011 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or -@@ -13,9 +13,8 @@ - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public -- License along with the GNU C Library; if not, write to the Free -- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -- 02111-1307 USA. */ -+ License along with the GNU C Library; if not, see -+ . */ - - #ifndef _SYS_PTRACE_H - #define _SYS_PTRACE_H 1 -@@ -79,8 +78,73 @@ enum __ptrace_request - #define PT_DETACH PTRACE_DETACH - - /* Continue and stop at the next (return from) syscall. */ -- PTRACE_SYSCALL = 24 -+ PTRACE_SYSCALL = 24, - #define PT_SYSCALL PTRACE_SYSCALL -+ -+ /* Set ptrace filter options. */ -+ PTRACE_SETOPTIONS = 0x4200, -+#define PT_SETOPTIONS PTRACE_SETOPTIONS -+ -+ /* Get last ptrace message. */ -+ PTRACE_GETEVENTMSG = 0x4201, -+#define PT_GETEVENTMSG PTRACE_GETEVENTMSG -+ -+ /* Get siginfo for process. */ -+ PTRACE_GETSIGINFO = 0x4202, -+#define PT_GETSIGINFO PTRACE_GETSIGINFO -+ -+ /* Set new siginfo for process. */ -+ PTRACE_SETSIGINFO = 0x4203, -+#define PT_SETSIGINFO PTRACE_SETSIGINFO -+ -+ /* Get register content. */ -+ PTRACE_GETREGSET = 0x4204, -+#define PTRACE_GETREGSET PTRACE_GETREGSET -+ -+ /* Set register content. */ -+ PTRACE_SETREGSET = 0x4205, -+#define PTRACE_SETREGSET PTRACE_SETREGSET -+ -+ /* Like PTRACE_ATTACH, but do not force tracee to trap and do not affect -+ signal or group stop state. */ -+ PTRACE_SEIZE = 0x4206, -+#define PTRACE_SEIZE PTRACE_SEIZE -+ -+ /* Trap seized tracee. */ -+ PTRACE_INTERRUPT = 0x4207, -+#define PTRACE_INTERRUPT PTRACE_INTERRUPT -+ -+ /* Wait for next group event. */ -+ PTRACE_LISTEN = 0x4208 -+}; -+ -+ -+/* Flag for PTRACE_LISTEN. */ -+enum __ptrace_flags -+{ -+ PTRACE_SEIZE_DEVEL = 0x80000000 -+}; -+ -+/* Options set using PTRACE_SETOPTIONS. */ -+enum __ptrace_setoptions { -+ PTRACE_O_TRACESYSGOOD = 0x00000001, -+ PTRACE_O_TRACEFORK = 0x00000002, -+ PTRACE_O_TRACEVFORK = 0x00000004, -+ PTRACE_O_TRACECLONE = 0x00000008, -+ PTRACE_O_TRACEEXEC = 0x00000010, -+ PTRACE_O_TRACEVFORKDONE = 0x00000020, -+ PTRACE_O_TRACEEXIT = 0x00000040, -+ PTRACE_O_MASK = 0x0000007f -+}; -+ -+/* Wait extended result codes for the above trace options. */ -+enum __ptrace_eventcodes { -+ PTRACE_EVENT_FORK = 1, -+ PTRACE_EVENT_VFORK = 2, -+ PTRACE_EVENT_CLONE = 3, -+ PTRACE_EVENT_EXEC = 4, -+ PTRACE_EVENT_VFORK_DONE = 5, -+ PTRACE_EVENT_EXIT = 6 - }; - - /* Perform process tracing functions. REQUEST is one of the values diff --git a/toolchain/uClibc/patches-0.9.33.2/470-powerpc_syscall6.patch b/toolchain/uClibc/patches-0.9.33.2/470-powerpc_syscall6.patch deleted file mode 100644 index 9511dcc1995..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/470-powerpc_syscall6.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/libc/sysdeps/linux/powerpc/syscall.S -+++ b/libc/sysdeps/linux/powerpc/syscall.S -@@ -30,6 +30,7 @@ syscall: - mr 5,6 - mr 6,7 - mr 7,8 -+ mr 8,9 - sc - bnslr; - diff --git a/toolchain/uClibc/patches-0.9.33.2/480-powerpc_rel24_support.patch b/toolchain/uClibc/patches-0.9.33.2/480-powerpc_rel24_support.patch deleted file mode 100644 index 19c2b2c8a26..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/480-powerpc_rel24_support.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/ldso/ldso/powerpc/elfinterp.c -+++ b/ldso/ldso/powerpc/elfinterp.c -@@ -297,22 +297,17 @@ _dl_do_reloc (struct elf_resolve *tpnt,s - break; - #endif - case R_PPC_REL24: --#if 0 - { - Elf32_Sword delta = finaladdr - (Elf32_Word)reloc_addr; - if (unlikely(delta<<6>>6 != delta)) { - _dl_dprintf(2, "%s: symbol '%s' R_PPC_REL24 is out of range.\n\t" - "Compile shared libraries with -fPIC!\n", - _dl_progname, symname); -- _dl_exit(1); -+ return -1; - } - *reloc_addr = (*reloc_addr & 0xfc000003) | (delta & 0x3fffffc); - break; - } --#else -- _dl_dprintf(2,"R_PPC_REL24: Compile shared libraries with -fPIC!\n"); -- return -1; --#endif - case R_PPC_NONE: - goto out_nocode; /* No code code modified */ - default: diff --git a/toolchain/uClibc/patches-0.9.33.2/500-eventfd.patch b/toolchain/uClibc/patches-0.9.33.2/500-eventfd.patch deleted file mode 100644 index 374052c5b59..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/500-eventfd.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 7810e4f8027b5c4c8ceec6fefec4eb779362ebb5 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Sun, 10 Jun 2012 16:36:23 +0000 -Subject: eventfd: Implement eventfd2 and fix eventfd - -eventfd: evntfd assumes to take two arguments instead it -should be one evntfd expects two therefore implement both syscalls with -correct parameters - -Thanks Eugene Rudoy for reporting it and also providing the patch - -Signed-off-by: Khem Raj ---- ---- a/libc/sysdeps/linux/common/eventfd.c -+++ b/libc/sysdeps/linux/common/eventfd.c -@@ -7,12 +7,24 @@ - * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. - */ - -+#include - #include - #include - - /* - * eventfd() - */ --#ifdef __NR_eventfd --_syscall2(int, eventfd, int, count, int, flags) -+#if defined __NR_eventfd || defined __NR_eventfd2 -+int eventfd (int count, int flags) -+{ -+#if defined __NR_eventfd2 -+ return INLINE_SYSCALL (eventfd2, 2, count, flags); -+#elif defined __NR_eventfd -+ if (flags != 0) { -+ __set_errno (EINVAL); -+ return -1; -+ } -+ return INLINE_SYSCALL (eventfd, 1, count); -+#endif -+} - #endif ---- a/libc/sysdeps/linux/common/stubs.c -+++ b/libc/sysdeps/linux/common/stubs.c -@@ -93,7 +93,7 @@ make_stub(epoll_ctl) - make_stub(epoll_wait) - #endif - --#if !defined __NR_eventfd && defined __UCLIBC_LINUX_SPECIFIC__ -+#if !defined __NR_eventfd && !defined __NR_eventfd2 && defined __UCLIBC_LINUX_SPECIFIC__ - make_stub(eventfd) - #endif - diff --git a/toolchain/uClibc/patches-0.9.33.2/600-mips64_abi_selection.patch b/toolchain/uClibc/patches-0.9.33.2/600-mips64_abi_selection.patch deleted file mode 100644 index beca17ca473..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/600-mips64_abi_selection.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 603af30d6992e94ac30a66b953264076f4f2fd71 Mon Sep 17 00:00:00 2001 -From: Markos Chandras -Date: Thu, 11 Jul 2013 16:59:16 +0000 -Subject: Rules.mak: MIPS64: Select correct interpreter - -gcc (eg 4.7.3) hardcodes the MIPS64 interpreters like this: -(see gcc/config/linux.h and gcc/config/mips/linux64.h) - -o32: UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0" -n32: UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0" -n64: UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0" - -The existing check for MIPS64 in uClibc is wrong because it does -not respect the selected ABI - -We fix this by explicitely checking the selected ABI instead of the -selected MIPS variant. - -Signed-off-by: Markos Chandras -Cc: Anthony G. Basile -Signed-off-by: Bernhard Reutner-Fischer ---- - ---- a/Rules.mak -+++ b/Rules.mak -@@ -118,13 +118,19 @@ export MAJOR_VERSION MINOR_VERSION SUBLE - LIBC := libc - SHARED_LIBNAME := $(LIBC).so.$(ABI_VERSION) - UBACKTRACE_DSO := libubacktrace.so.$(ABI_VERSION) --ifneq ($(findstring $(TARGET_ARCH) , hppa64 ia64 mips64 powerpc64 s390x sparc64 x86_64 ),) -+ -+UCLIBC_LDSO_NAME := ld-uClibc -+ARCH_NATIVE_BIT := 32 -+ifneq ($(findstring $(TARGET_ARCH),hppa64 ia64 powerpc64 s390x sparc64 x86_64),) - UCLIBC_LDSO_NAME := ld64-uClibc - ARCH_NATIVE_BIT := 64 - else --UCLIBC_LDSO_NAME := ld-uClibc --ARCH_NATIVE_BIT := 32 -+ifeq ($(CONFIG_MIPS_N64_ABI),y) -+UCLIBC_LDSO_NAME := ld64-uClibc -+ARCH_NATIVE_BIT := 64 - endif -+endif -+ - UCLIBC_LDSO := $(UCLIBC_LDSO_NAME).so.$(ABI_VERSION) - NONSHARED_LIBNAME := uclibc_nonshared.a - libc := $(top_builddir)lib/$(SHARED_LIBNAME) diff --git a/toolchain/uClibc/patches-0.9.33.2/610-mips64_syscall_fix.patch b/toolchain/uClibc/patches-0.9.33.2/610-mips64_syscall_fix.patch deleted file mode 100644 index 46d1f5cd187..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/610-mips64_syscall_fix.patch +++ /dev/null @@ -1,285 +0,0 @@ -commit e5cde2eb0ed7df9416fdd6070af07c8448c72a30 -Author: Steve Ellcey -Date: Wed Feb 12 11:01:35 2014 -0800 - - mips: Remove duplicate macro definitions - - The INLINE_SYSCALL, INTERNAL_SYSCALL*, and internal_syscall* macros - are defined for MIPS in both libc/sysdeps/linux/mips/sysdep.h and - libc/sysdeps/linux/mips/bits/syscalls.h. The macros are the same - in both cases except that syscalls.h defines internal_syscalls[567] - the same for N32 and N64 ABIs and has a different definition for O32. - I believe that is correct. The sysdep.h header uses the O32 versions - for N32 and has different definitions for N64. I think that is wrong - and that N32 and N64 should share the same definition (modulo the - type 'long' vs. 'long long' for the arguments. This setup (from - sysdep.h) now agrees with what glibc has. - - I am not positive about which header (sysdep.h vs syscalls.h) is - really the right one to have these definitions in but using sysdep.h - seems to work for all my builds. - - Signed-off-by: Steve Ellcey - Signed-off-by: Bernhard Reutner-Fischer - ---- a/libc/sysdeps/linux/mips/sysdep.h -+++ b/libc/sysdeps/linux/mips/sysdep.h -@@ -133,258 +133,6 @@ L(syse1): - - #else /* ! __ASSEMBLER__ */ - --/* Define a macro which expands into the inline wrapper code for a system -- call. */ --#undef INLINE_SYSCALL --#define INLINE_SYSCALL(name, nr, args...) \ -- ({ INTERNAL_SYSCALL_DECL(err); \ -- long result_var = INTERNAL_SYSCALL (name, err, nr, args); \ -- if ( INTERNAL_SYSCALL_ERROR_P (result_var, err) ) \ -- { \ -- __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, err)); \ -- result_var = -1L; \ -- } \ -- result_var; }) -- --#undef INTERNAL_SYSCALL_DECL --#define INTERNAL_SYSCALL_DECL(err) long err -- --#undef INTERNAL_SYSCALL_ERROR_P --#define INTERNAL_SYSCALL_ERROR_P(val, err) ((long) (err)) -- --#undef INTERNAL_SYSCALL_ERRNO --#define INTERNAL_SYSCALL_ERRNO(val, err) (val) -- --#undef INTERNAL_SYSCALL --#define INTERNAL_SYSCALL(name, err, nr, args...) \ -- internal_syscall##nr (, "li\t$2, %2\t\t\t# " #name "\n\t", \ -- "i" (SYS_ify (name)), err, args) -- --#undef INTERNAL_SYSCALL_NCS --#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \ -- internal_syscall##nr (= number, , "r" (__v0), err, args) --#undef internal_syscall0 --#define internal_syscall0(ncs_init, cs_init, input, err, dummy...) \ --({ \ -- long _sys_result; \ -- \ -- { \ -- register long __v0 __asm__("$2") ncs_init; \ -- register long __a3 __asm__("$7"); \ -- __asm__ __volatile__ ( \ -- ".set\tnoreorder\n\t" \ -- cs_init \ -- "syscall\n\t" \ -- ".set reorder" \ -- : "=r" (__v0), "=r" (__a3) \ -- : input \ -- : __SYSCALL_CLOBBERS); \ -- err = __a3; \ -- _sys_result = __v0; \ -- } \ -- _sys_result; \ --}) -- --#undef internal_syscall1 --#define internal_syscall1(ncs_init, cs_init, input, err, arg1) \ --({ \ -- long _sys_result; \ -- \ -- { \ -- register long __v0 __asm__("$2") ncs_init; \ -- register long __a0 __asm__("$4") = (long) arg1; \ -- register long __a3 __asm__("$7"); \ -- __asm__ __volatile__ ( \ -- ".set\tnoreorder\n\t" \ -- cs_init \ -- "syscall\n\t" \ -- ".set reorder" \ -- : "=r" (__v0), "=r" (__a3) \ -- : input, "r" (__a0) \ -- : __SYSCALL_CLOBBERS); \ -- err = __a3; \ -- _sys_result = __v0; \ -- } \ -- _sys_result; \ --}) -- --#undef internal_syscall2 --#define internal_syscall2(ncs_init, cs_init, input, err, arg1, arg2) \ --({ \ -- long _sys_result; \ -- \ -- { \ -- register long __v0 __asm__("$2") ncs_init; \ -- register long __a0 __asm__("$4") = (long) arg1; \ -- register long __a1 __asm__("$5") = (long) arg2; \ -- register long __a3 __asm__("$7"); \ -- __asm__ __volatile__ ( \ -- ".set\tnoreorder\n\t" \ -- cs_init \ -- "syscall\n\t" \ -- ".set\treorder" \ -- : "=r" (__v0), "=r" (__a3) \ -- : input, "r" (__a0), "r" (__a1) \ -- : __SYSCALL_CLOBBERS); \ -- err = __a3; \ -- _sys_result = __v0; \ -- } \ -- _sys_result; \ --}) -- --#undef internal_syscall3 --#define internal_syscall3(ncs_init, cs_init, input, err, arg1, arg2, arg3)\ --({ \ -- long _sys_result; \ -- \ -- { \ -- register long __v0 __asm__("$2") ncs_init; \ -- register long __a0 __asm__("$4") = (long) arg1; \ -- register long __a1 __asm__("$5") = (long) arg2; \ -- register long __a2 __asm__("$6") = (long) arg3; \ -- register long __a3 __asm__("$7"); \ -- __asm__ __volatile__ ( \ -- ".set\tnoreorder\n\t" \ -- cs_init \ -- "syscall\n\t" \ -- ".set\treorder" \ -- : "=r" (__v0), "=r" (__a3) \ -- : input, "r" (__a0), "r" (__a1), "r" (__a2) \ -- : __SYSCALL_CLOBBERS); \ -- err = __a3; \ -- _sys_result = __v0; \ -- } \ -- _sys_result; \ --}) -- --#undef internal_syscall4 --#define internal_syscall4(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4)\ --({ \ -- long _sys_result; \ -- \ -- { \ -- register long __v0 __asm__("$2") ncs_init; \ -- register long __a0 __asm__("$4") = (long) arg1; \ -- register long __a1 __asm__("$5") = (long) arg2; \ -- register long __a2 __asm__("$6") = (long) arg3; \ -- register long __a3 __asm__("$7") = (long) arg4; \ -- __asm__ __volatile__ ( \ -- ".set\tnoreorder\n\t" \ -- cs_init \ -- "syscall\n\t" \ -- ".set\treorder" \ -- : "=r" (__v0), "+r" (__a3) \ -- : input, "r" (__a0), "r" (__a1), "r" (__a2) \ -- : __SYSCALL_CLOBBERS); \ -- err = __a3; \ -- _sys_result = __v0; \ -- } \ -- _sys_result; \ --}) -- --/* We need to use a frame pointer for the functions in which we -- adjust $sp around the syscall, or debug information and unwind -- information will be $sp relative and thus wrong during the syscall. As -- of GCC 3.4.3, this is sufficient. */ --#define FORCE_FRAME_POINTER alloca (4) -- --#undef internal_syscall5 --#define internal_syscall5(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4, arg5)\ --({ \ -- long _sys_result; \ -- \ -- FORCE_FRAME_POINTER; \ -- { \ -- register long __v0 __asm__("$2") ncs_init; \ -- register long __a0 __asm__("$4") = (long) arg1; \ -- register long __a1 __asm__("$5") = (long) arg2; \ -- register long __a2 __asm__("$6") = (long) arg3; \ -- register long __a3 __asm__("$7") = (long) arg4; \ -- __asm__ __volatile__ ( \ -- ".set\tnoreorder\n\t" \ -- "subu\t$29, 32\n\t" \ -- "sw\t%6, 16($29)\n\t" \ -- cs_init \ -- "syscall\n\t" \ -- "addiu\t$29, 32\n\t" \ -- ".set\treorder" \ -- : "=r" (__v0), "+r" (__a3) \ -- : input, "r" (__a0), "r" (__a1), "r" (__a2), \ -- "r" ((long)arg5) \ -- : __SYSCALL_CLOBBERS); \ -- err = __a3; \ -- _sys_result = __v0; \ -- } \ -- _sys_result; \ --}) -- --#undef internal_syscall6 --#define internal_syscall6(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4, arg5, arg6)\ --({ \ -- long _sys_result; \ -- \ -- FORCE_FRAME_POINTER; \ -- { \ -- register long __v0 __asm__("$2") ncs_init; \ -- register long __a0 __asm__("$4") = (long) arg1; \ -- register long __a1 __asm__("$5") = (long) arg2; \ -- register long __a2 __asm__("$6") = (long) arg3; \ -- register long __a3 __asm__("$7") = (long) arg4; \ -- __asm__ __volatile__ ( \ -- ".set\tnoreorder\n\t" \ -- "subu\t$29, 32\n\t" \ -- "sw\t%6, 16($29)\n\t" \ -- "sw\t%7, 20($29)\n\t" \ -- cs_init \ -- "syscall\n\t" \ -- "addiu\t$29, 32\n\t" \ -- ".set\treorder" \ -- : "=r" (__v0), "+r" (__a3) \ -- : input, "r" (__a0), "r" (__a1), "r" (__a2), \ -- "r" ((long)arg5), "r" ((long)arg6) \ -- : __SYSCALL_CLOBBERS); \ -- err = __a3; \ -- _sys_result = __v0; \ -- } \ -- _sys_result; \ --}) -- --#undef internal_syscall7 --#define internal_syscall7(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4, arg5, arg6, arg7)\ --({ \ -- long _sys_result; \ -- \ -- FORCE_FRAME_POINTER; \ -- { \ -- register long __v0 __asm__("$2") ncs_init; \ -- register long __a0 __asm__("$4") = (long) arg1; \ -- register long __a1 __asm__("$5") = (long) arg2; \ -- register long __a2 __asm__("$6") = (long) arg3; \ -- register long __a3 __asm__("$7") = (long) arg4; \ -- __asm__ __volatile__ ( \ -- ".set\tnoreorder\n\t" \ -- "subu\t$29, 32\n\t" \ -- "sw\t%6, 16($29)\n\t" \ -- "sw\t%7, 20($29)\n\t" \ -- "sw\t%8, 24($29)\n\t" \ -- cs_init \ -- "syscall\n\t" \ -- "addiu\t$29, 32\n\t" \ -- ".set\treorder" \ -- : "=r" (__v0), "+r" (__a3) \ -- : input, "r" (__a0), "r" (__a1), "r" (__a2), \ -- "r" ((long)arg5), "r" ((long)arg6), "r" ((long)arg7) \ -- : __SYSCALL_CLOBBERS); \ -- err = __a3; \ -- _sys_result = __v0; \ -- } \ -- _sys_result; \ --}) -- --#undef __SYSCALL_CLOBBERS --#define __SYSCALL_CLOBBERS "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", \ -- "$14", "$15", "$24", "$25", "memory" -- - /* Pointer mangling is not yet supported for MIPS. */ - #define PTR_MANGLE(var) (void) (var) - #define PTR_DEMANGLE(var) (void) (var) diff --git a/toolchain/uClibc/patches-0.9.33.2/611-mips_syscall_error_argument.patch b/toolchain/uClibc/patches-0.9.33.2/611-mips_syscall_error_argument.patch deleted file mode 100644 index 87ef8bae879..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/611-mips_syscall_error_argument.patch +++ /dev/null @@ -1,99 +0,0 @@ -commit 2952c70804b48bb5c87eea21df5e401969dc4ec1 -Author: Kevin Cernekee -Date: Tue Jun 5 15:05:20 2012 -0700 - - MIPS: Use $a0 instead of $v0 for __syscall_error() argument - - $a0 is saved across _dl_runtime_resolve(); $v0 is not. Unfortunately, - __syscall_error() uses $v0 for its argument, not $a0 as is the MIPS ABI - standard. This means that if lazy binding was used for __syscall_error(), - the errno value in $v0 could get corrupted. - - The problem can be easily seen in testcases where syscalls in librt fail; - when librt tries to call __syscall_error() in libc, the argument gets - lost and errno gets set to a bogus value: - - # ./tst-mqueue1 ; echo $? - mq_receive on O_WRONLY mqd_t did not fail with EBADF: Unknown error 2004684208 - 1 - # ./tst-mqueue2 ; echo $? - mq_timedreceive with too small msg_len did not fail with EMSGSIZE: Unknown error 1997360560 - 1 - # ./tst-mqueue4 ; echo $? - mq_timedsend did not fail with ETIMEDOUT: Unknown error 2008747440 - 1 - - When _dl_runtime_resolve() was taken out of the equation, the same test - cases passed: - - # LD_BIND_NOW=y ./tst-mqueue1 ; echo $? - 0 - # LD_BIND_NOW=y ./tst-mqueue2 ; echo $? - 0 - # LD_BIND_NOW=y ./tst-mqueue4 ; echo $? - 0 - - Changing __syscall_error() to look at $a0 instead of $v0 fixed the - problem. - - (Note that there is also a "__syscall_error.c" file which presumably - uses the standard C calling conventions, but I do not think it is used - on MIPS.) - - Signed-off-by: Kevin Cernekee - Signed-off-by: Bernhard Reutner-Fischer - -commit 3c58d95d918c7e2fda374c37a52f81b34b81e4ca -Author: Kevin Cernekee -Date: Tue Jun 5 15:05:19 2012 -0700 - - MIPS: Convert __syscall_error() callers to use $a0 for argument - - Some callers passed the first argument in $v0, while others used $a0. - Change the callers to use $a0 consistently. - - Signed-off-by: Kevin Cernekee - Signed-off-by: Bernhard Reutner-Fischer - ---- a/libc/sysdeps/linux/mips/vfork.S -+++ b/libc/sysdeps/linux/mips/vfork.S -@@ -84,6 +84,7 @@ NESTED(__vfork,FRAMESZ,sp) - - /* Something bad happened -- no child created. */ - L(error): -+ move a0, v0 - #ifdef __PIC__ - PTR_LA t9, __syscall_error - RESTORE_GP64 ---- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h -+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h -@@ -31,7 +31,7 @@ - # undef PSEUDO - # define PSEUDO(name, syscall_name, args) \ - .align 2; \ -- 99: \ -+ 99: move a0, v0; \ - PTR_LA t9,__syscall_error; \ - /* manual cpreturn. */ \ - REG_L gp, STKOFF_GP(sp); \ ---- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/vfork.S -+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/vfork.S -@@ -80,6 +80,7 @@ NESTED(__vfork,FRAMESZ,sp) - - /* Something bad happened -- no child created. */ - L(error): -+ move a0, v0 - #ifdef __PIC__ - PTR_LA t9, __syscall_error - RESTORE_GP64 ---- a/libc/sysdeps/linux/mips/syscall_error.S -+++ b/libc/sysdeps/linux/mips/syscall_error.S -@@ -43,7 +43,7 @@ ENTRY(__syscall_error) - #ifdef __PIC__ - SAVE_GP(GPOFF) - #endif -- REG_S v0, V0OFF(sp) -+ REG_S a0, V0OFF(sp) - REG_S ra, RAOFF(sp) - - /* Find our per-thread errno address */ diff --git a/toolchain/uClibc/patches-0.9.33.2/612-mips64_relocation_fix.patch b/toolchain/uClibc/patches-0.9.33.2/612-mips64_relocation_fix.patch deleted file mode 100644 index 7edeee17d05..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/612-mips64_relocation_fix.patch +++ /dev/null @@ -1,29 +0,0 @@ -commit 052bcf13afb067cafac5e7f4fc21fbad2b34b11f -Author: Waldemar Brodkorb -Date: Wed Nov 27 09:55:51 2013 +0100 - - Fix for SIGBUS error on MIPS64 with N64 ABI - - When accessing errno, a per thread variable, from _stdio_init - a SIGBUS error happens. This change fixes the wrong relocation - and debug output. - - Signed-off-by: Waldemar Brodkorb - Signed-off-by: Bernhard Reutner-Fischer - ---- a/ldso/ldso/mips/elfinterp.c -+++ b/ldso/ldso/mips/elfinterp.c -@@ -259,11 +259,11 @@ int _dl_parse_relocation_information(str - case R_MIPS_TLS_TPREL32: - case R_MIPS_TLS_TPREL64: - CHECK_STATIC_TLS((struct link_map *)tls_tpnt); -- *(ElfW(Word) *)reloc_addr += -+ *(ElfW(Addr) *)reloc_addr += - TLS_TPREL_VALUE (tls_tpnt, symbol_addr); - #ifdef __SUPPORT_LD_DEBUG__ - _dl_dprintf(2, "TLS_TPREL : %s, %x, %x\n", -- symname, old_val, *((unsigned int *)reloc_addr)); -+ symname, old_val, *((unsigned long *)reloc_addr)); - #endif - break; - } diff --git a/toolchain/uClibc/patches-0.9.33.2/613-mips64_more_relocation_fixes.patch b/toolchain/uClibc/patches-0.9.33.2/613-mips64_more_relocation_fixes.patch deleted file mode 100644 index e2efa23823f..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/613-mips64_more_relocation_fixes.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/ldso/ldso/mips/elfinterp.c -+++ b/ldso/ldso/mips/elfinterp.c -@@ -239,7 +239,7 @@ int _dl_parse_relocation_information(str - case R_MIPS_TLS_DTPMOD64: - case R_MIPS_TLS_DTPMOD32: - if (tls_tpnt) -- *(ElfW(Word) *)reloc_addr = tls_tpnt->l_tls_modid; -+ *(ElfW(Addr) *)reloc_addr = tls_tpnt->l_tls_modid; - #ifdef __SUPPORT_LD_DEBUG__ - _dl_dprintf(2, "TLS_DTPMOD : %s, %d, %d\n", - symname, old_val, *((unsigned int *)reloc_addr)); -@@ -248,7 +248,7 @@ int _dl_parse_relocation_information(str - - case R_MIPS_TLS_DTPREL64: - case R_MIPS_TLS_DTPREL32: -- *(ElfW(Word) *)reloc_addr += -+ *(ElfW(Addr) *)reloc_addr += - TLS_DTPREL_VALUE (symbol_addr); - #ifdef __SUPPORT_LD_DEBUG__ - _dl_dprintf(2, "TLS_DTPREL : %s, %x, %x\n", diff --git a/toolchain/uClibc/patches-0.9.33.2/614-mips64_fix_setjmp_longjmp.patch b/toolchain/uClibc/patches-0.9.33.2/614-mips64_fix_setjmp_longjmp.patch deleted file mode 100644 index 170613091b7..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/614-mips64_fix_setjmp_longjmp.patch +++ /dev/null @@ -1,99 +0,0 @@ -commit 70a04a287a2875c82e6822c36e071afba5b63a62 -Author: Waldemar Brodkorb -Date: Wed Jan 29 18:58:56 2014 +0100 - - libc: mips: Fix setjmp/longjmp for MIPS64 N64 ABI - - When booting a Linux system with qemu-system-mips64 the execution - of $(pwd) in the ash shell triggers a segmentation fault. Ash uses - setjmp/longjmp for exception handling. - - After looking at the glibc implementation, - I found some differences, with this patch tries to resolve. - Now the system boots up fine and no segmentation faults occur. - - The global pointer should be restored and the types for the - register values should be wide enough. - - See: - http://www.cygwin.com/ml/libc-alpha/2003-03/msg00363.html - - Signed-off-by: Waldemar Brodkorb - Signed-off-by: Bernhard Reutner-Fischer - ---- a/libc/sysdeps/linux/mips/bits/setjmp.h -+++ b/libc/sysdeps/linux/mips/bits/setjmp.h -@@ -26,13 +26,19 @@ - - #include - -+#if _MIPS_SIM == _MIPS_SIM_ABI32 -+#define ptrsize void * -+#else -+#define ptrsize long long -+#endif -+ - typedef struct - { - /* Program counter. */ -- void * __pc; -+ ptrsize __pc; - - /* Stack pointer. */ -- void * __sp; -+ ptrsize __sp; - - /* Callee-saved registers s0 through s7. */ - #if _MIPS_SIM == _MIPS_SIM_ABI32 -@@ -42,10 +48,10 @@ typedef struct - #endif - - /* The frame pointer. */ -- void * __fp; -+ ptrsize __fp; - - /* The global pointer. */ -- void * __gp; -+ ptrsize __gp; - - /* Floating point status register. */ - int __fpc_csr; ---- a/libc/sysdeps/linux/mips/setjmp.S -+++ b/libc/sysdeps/linux/mips/setjmp.S -@@ -53,6 +53,7 @@ __sigsetjmp: - PTR_LA t9, __sigsetjmp_aux - #if _MIPS_SIM != _MIPS_SIM_ABI32 - .cpreturn -+ move a4, gp - #endif - jr t9 - #else ---- a/libc/sysdeps/linux/mips/setjmp_aux.c -+++ b/libc/sysdeps/linux/mips/setjmp_aux.c -@@ -31,7 +31,7 @@ extern int __sigjmp_save (sigjmp_buf, in - - int - #if _MIPS_SIM == _MIPS_SIM_ABI64 --__sigsetjmp_aux (jmp_buf env, int savemask, long sp, long fp) -+__sigsetjmp_aux (jmp_buf env, int savemask, long long sp, long long fp, long long gp) - #else /* O32 || N32 */ - __sigsetjmp_aux (jmp_buf env, int savemask, int sp, int fp) - #endif /* O32 || N32 */ -@@ -65,14 +65,14 @@ __sigsetjmp_aux (jmp_buf env, int savema - #endif - - /* .. and the stack pointer; */ -- env[0].__jmpbuf[0].__sp = (void *) sp; -+ env[0].__jmpbuf[0].__sp = (ptrsize) sp; - - /* .. and the FP; it'll be in s8. */ -- env[0].__jmpbuf[0].__fp = (void *) fp; -+ env[0].__jmpbuf[0].__fp = (ptrsize) fp; - - /* .. and the GP; */ - #if _MIPS_SIM == _MIPS_SIM_ABI64 -- __asm__ __volatile__ ("sd $gp, %0" : : "m" (env[0].__jmpbuf[0].__gp)); -+ env[0].__jmpbuf[0].__gp = (ptrsize) gp; - #else - __asm__ __volatile__ ("sw $gp, %0" : : "m" (env[0].__jmpbuf[0].__gp)); - #endif diff --git a/toolchain/uClibc/patches-0.9.33.2/615-mips_fix_sigev_pad_size.patch b/toolchain/uClibc/patches-0.9.33.2/615-mips_fix_sigev_pad_size.patch deleted file mode 100644 index f75092f3432..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/615-mips_fix_sigev_pad_size.patch +++ /dev/null @@ -1,58 +0,0 @@ -commit b97b4b698b023f75b54f987859c856ab4861ea00 -Author: Vicente Olivert Riera -Date: Thu Jan 2 15:02:12 2014 +0000 - - siginfo.h: __SIGEV_PAD_SIZE takes __WORDSIZE into account - - Make __SIGEV_PAD_SIZE to take __WORDSIZE into account for alpha, mips - and ia64 arches. - - Signed-off-by: Vicente Olivert Riera - Signed-off-by: Bernhard Reutner-Fischer - ---- a/libc/sysdeps/linux/alpha/bits/siginfo.h -+++ b/libc/sysdeps/linux/alpha/bits/siginfo.h -@@ -258,7 +258,11 @@ enum - - /* Structure to transport application-defined values with signals. */ - # define __SIGEV_MAX_SIZE 64 --# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 4) -+# if __WORDSIZE == 64 -+# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 4) -+# else -+# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 3) -+# endif - - typedef struct sigevent - { ---- a/libc/sysdeps/linux/ia64/bits/siginfo.h -+++ b/libc/sysdeps/linux/ia64/bits/siginfo.h -@@ -298,7 +298,11 @@ enum - - /* Structure to transport application-defined values with signals. */ - # define __SIGEV_MAX_SIZE 64 --# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 4) -+# if __WORDSIZE == 64 -+# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 4) -+# else -+# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 3) -+# endif - - typedef struct sigevent - { ---- a/libc/sysdeps/linux/mips/bits/siginfo.h -+++ b/libc/sysdeps/linux/mips/bits/siginfo.h -@@ -265,8 +265,11 @@ enum - - /* Structure to transport application-defined values with signals. */ - # define __SIGEV_MAX_SIZE 64 --# define __SIGEV_HEAD_SIZE (sizeof(long) + 2*sizeof(int)) --# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE - __SIGEV_HEAD_SIZE) / sizeof (int)) -+# if __WORDSIZE == 64 -+# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 4) -+# else -+# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 3) -+# endif - - /* Forward declaration of the `pthread_attr_t' type. */ - struct __pthread_attr_s; diff --git a/toolchain/uClibc/patches-0.9.33.2/616-mips_fix_stat_time.patch b/toolchain/uClibc/patches-0.9.33.2/616-mips_fix_stat_time.patch deleted file mode 100644 index 1559857a44d..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/616-mips_fix_stat_time.patch +++ /dev/null @@ -1,123 +0,0 @@ ---- a/libc/sysdeps/linux/common/xstatconv.c -+++ b/libc/sysdeps/linux/common/xstatconv.c -@@ -39,9 +39,12 @@ void __xstat_conv(struct kernel_stat *kb - buf->st_size = kbuf->st_size; - buf->st_blksize = kbuf->st_blksize; - buf->st_blocks = kbuf->st_blocks; -- buf->st_atim = kbuf->st_atim; -- buf->st_mtim = kbuf->st_mtim; -- buf->st_ctim = kbuf->st_ctim; -+ buf->st_atim.tv_sec = kbuf->st_atim.tv_sec; -+ buf->st_atim.tv_nsec = kbuf->st_atim.tv_nsec; -+ buf->st_mtim.tv_sec = kbuf->st_mtim.tv_sec; -+ buf->st_mtim.tv_nsec = kbuf->st_mtim.tv_nsec; -+ buf->st_ctim.tv_sec = kbuf->st_ctim.tv_sec; -+ buf->st_ctim.tv_nsec = kbuf->st_ctim.tv_nsec; - } - - void __xstat32_conv(struct kernel_stat64 *kbuf, struct stat *buf) -@@ -58,9 +61,12 @@ void __xstat32_conv(struct kernel_stat64 - buf->st_size = kbuf->st_size; - buf->st_blksize = kbuf->st_blksize; - buf->st_blocks = kbuf->st_blocks; -- buf->st_atim = kbuf->st_atim; -- buf->st_mtim = kbuf->st_mtim; -- buf->st_ctim = kbuf->st_ctim; -+ buf->st_atim.tv_sec = kbuf->st_atim.tv_sec; -+ buf->st_atim.tv_nsec = kbuf->st_atim.tv_nsec; -+ buf->st_mtim.tv_sec = kbuf->st_mtim.tv_sec; -+ buf->st_mtim.tv_nsec = kbuf->st_mtim.tv_nsec; -+ buf->st_ctim.tv_sec = kbuf->st_ctim.tv_sec; -+ buf->st_ctim.tv_nsec = kbuf->st_ctim.tv_nsec; - } - - #ifdef __UCLIBC_HAS_LFS__ -@@ -82,9 +88,12 @@ void __xstat64_conv(struct kernel_stat64 - buf->st_size = kbuf->st_size; - buf->st_blksize = kbuf->st_blksize; - buf->st_blocks = kbuf->st_blocks; -- buf->st_atim = kbuf->st_atim; -- buf->st_mtim = kbuf->st_mtim; -- buf->st_ctim = kbuf->st_ctim; -+ buf->st_atim.tv_sec = kbuf->st_atim.tv_sec; -+ buf->st_atim.tv_nsec = kbuf->st_atim.tv_nsec; -+ buf->st_mtim.tv_sec = kbuf->st_mtim.tv_sec; -+ buf->st_mtim.tv_nsec = kbuf->st_mtim.tv_nsec; -+ buf->st_ctim.tv_sec = kbuf->st_ctim.tv_sec; -+ buf->st_ctim.tv_nsec = kbuf->st_ctim.tv_nsec; - } - - #endif /* __UCLIBC_HAS_LFS__ */ ---- a/libc/sysdeps/linux/mips/bits/kernel_stat.h -+++ b/libc/sysdeps/linux/mips/bits/kernel_stat.h -@@ -8,6 +8,18 @@ - #include - - #if _MIPS_SIM == _MIPS_SIM_ABI64 -+typedef struct { -+ unsigned int tv_sec; -+ unsigned int tv_nsec; -+} __ktimespec_t; -+#else -+typedef struct { -+ time_t tv_sec; -+ unsigned long tv_nsec; -+} __ktimespec_t; -+#endif -+ -+#if _MIPS_SIM == _MIPS_SIM_ABI64 - /* The memory layout is the same as of struct stat64 of the 32-bit kernel. */ - struct kernel_stat { - __kernel_dev_t st_dev; -@@ -20,9 +32,9 @@ struct kernel_stat { - __kernel_dev_t st_rdev; - unsigned int st_pad2[3]; - __kernel_off_t st_size; -- struct timespec st_atim; -- struct timespec st_mtim; -- struct timespec st_ctim; -+ __ktimespec_t st_atim; -+ __ktimespec_t st_mtim; -+ __ktimespec_t st_ctim; - unsigned int st_blksize; - unsigned int reserved3; - unsigned long st_blocks; -@@ -41,9 +53,9 @@ struct kernel_stat { - unsigned int st_rdev; - unsigned int st_pad2[3]; - unsigned long long st_size; -- struct timespec st_atim; -- struct timespec st_mtim; -- struct timespec st_ctim; -+ __ktimespec_t st_atim; -+ __ktimespec_t st_mtim; -+ __ktimespec_t st_ctim; - unsigned int st_blksize; - unsigned int reserved3; - unsigned long long st_blocks; -@@ -62,9 +74,9 @@ struct kernel_stat { - long st_pad2[2]; - __kernel_off_t st_size; - long st_pad3; -- struct timespec st_atim; -- struct timespec st_mtim; -- struct timespec st_ctim; -+ __ktimespec_t st_atim; -+ __ktimespec_t st_mtim; -+ __ktimespec_t st_ctim; - long st_blksize; - long st_blocks; - long st_pad4[14]; -@@ -81,9 +93,9 @@ struct kernel_stat64 { - unsigned long st_rdev; - unsigned long st_pad1[3]; /* Reserved for st_rdev expansion */ - long long st_size; -- struct timespec st_atim; -- struct timespec st_mtim; -- struct timespec st_ctim; -+ __ktimespec_t st_atim; -+ __ktimespec_t st_mtim; -+ __ktimespec_t st_ctim; - unsigned long st_blksize; - unsigned long st_pad2; - long long st_blocks; diff --git a/toolchain/uClibc/patches-0.9.33.2/617-mips_fix_setjmp_ptrsize.patch b/toolchain/uClibc/patches-0.9.33.2/617-mips_fix_setjmp_ptrsize.patch deleted file mode 100644 index 628d4b02d58..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/617-mips_fix_setjmp_ptrsize.patch +++ /dev/null @@ -1,58 +0,0 @@ ---- a/libc/sysdeps/linux/mips/bits/setjmp.h -+++ b/libc/sysdeps/linux/mips/bits/setjmp.h -@@ -27,18 +27,18 @@ - #include - - #if _MIPS_SIM == _MIPS_SIM_ABI32 --#define ptrsize void * -+#define __setjmp_ptr void * - #else --#define ptrsize long long -+#define __setjmp_ptr long long - #endif - - typedef struct - { - /* Program counter. */ -- ptrsize __pc; -+ __setjmp_ptr __pc; - - /* Stack pointer. */ -- ptrsize __sp; -+ __setjmp_ptr __sp; - - /* Callee-saved registers s0 through s7. */ - #if _MIPS_SIM == _MIPS_SIM_ABI32 -@@ -48,10 +48,10 @@ typedef struct - #endif - - /* The frame pointer. */ -- ptrsize __fp; -+ __setjmp_ptr __fp; - - /* The global pointer. */ -- ptrsize __gp; -+ __setjmp_ptr __gp; - - /* Floating point status register. */ - int __fpc_csr; ---- a/libc/sysdeps/linux/mips/setjmp_aux.c -+++ b/libc/sysdeps/linux/mips/setjmp_aux.c -@@ -65,14 +65,14 @@ __sigsetjmp_aux (jmp_buf env, int savema - #endif - - /* .. and the stack pointer; */ -- env[0].__jmpbuf[0].__sp = (ptrsize) sp; -+ env[0].__jmpbuf[0].__sp = (__setjmp_ptr) sp; - - /* .. and the FP; it'll be in s8. */ -- env[0].__jmpbuf[0].__fp = (ptrsize) fp; -+ env[0].__jmpbuf[0].__fp = (__setjmp_ptr) fp; - - /* .. and the GP; */ - #if _MIPS_SIM == _MIPS_SIM_ABI64 -- env[0].__jmpbuf[0].__gp = (ptrsize) gp; -+ env[0].__jmpbuf[0].__gp = (__setjmp_ptr) gp; - #else - __asm__ __volatile__ ("sw $gp, %0" : : "m" (env[0].__jmpbuf[0].__gp)); - #endif diff --git a/toolchain/uClibc/patches-0.9.33.2/618-mips64_fix_syscall_error.patch b/toolchain/uClibc/patches-0.9.33.2/618-mips64_fix_syscall_error.patch deleted file mode 100644 index 67611fdebce..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/618-mips64_fix_syscall_error.patch +++ /dev/null @@ -1,36 +0,0 @@ ---- a/libc/sysdeps/linux/mips/sysdep.h -+++ b/libc/sysdeps/linux/mips/sysdep.h -@@ -96,7 +96,8 @@ - backwards into the previous fn. */ - - #ifdef __PIC__ --#define PSEUDO(name, syscall_name, args) \ -+# if _MIPS_SIM == _ABIO32 -+# define PSEUDO(name, syscall_name, args) \ - .align 2; \ - 99: move a0, v0; \ - la t9,__syscall_error; \ -@@ -109,6 +110,23 @@ - .set reorder; \ - bne a3, zero, 99b; \ - L(syse1): -+# else -+# define PSEUDO(name, syscall_name, args) \ -+ .align 2; \ -+ 99: \ -+ .set noat; \ -+ .cpsetup t9, $1, name; \ -+ .set at; \ -+ move a0, v0; \ -+ dla t9,__syscall_error; \ -+ .cpreturn; \ -+ jr t9; \ -+ ENTRY(name) \ -+ li v0, SYS_ify(syscall_name); \ -+ syscall; \ -+ bne a3, zero, 99b; \ -+L(syse1): -+# endif - #else - #define PSEUDO(name, syscall_name, args) \ - .set noreorder; \ diff --git a/toolchain/uClibc/patches-0.9.33.2/619-mips64_fix_sysdep_cancel.patch b/toolchain/uClibc/patches-0.9.33.2/619-mips64_fix_sysdep_cancel.patch deleted file mode 100644 index d590359a488..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/619-mips64_fix_sysdep_cancel.patch +++ /dev/null @@ -1,195 +0,0 @@ ---- a/extra/Configs/Config.in -+++ b/extra/Configs/Config.in -@@ -235,6 +235,7 @@ config TARGET_SUBARCH - default "i486" if CONFIG_486 - default "i586" if CONFIG_586 || CONFIG_586MMX - default "i686" if TARGET_ARCH = "i386" -+ default "mips64" if CONFIG_MIPS_N64_ABI - default "" - - source "extra/Configs/Config.in.arch" ---- /dev/null -+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h -@@ -0,0 +1,182 @@ -+/* Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library 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 -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library. If not, see -+ . */ -+ -+#include -+#include -+#ifndef __ASSEMBLER__ -+# include -+#endif -+#include -+ -+/* Gas will put the initial save of $gp into the CIE, because it appears to -+ happen before any instructions. So we use cfi_same_value instead of -+ cfi_restore. */ -+ -+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt -+ -+#ifdef __PIC__ -+# undef PSEUDO -+# define PSEUDO(name, syscall_name, args) \ -+ .align 2; \ -+ L(pseudo_start): \ -+ cfi_startproc; \ -+ cfi_adjust_cfa_offset (STKSPACE); \ -+ cfi_rel_offset (gp, STKOFF_GP); \ -+ 99: move a0, v0; \ -+ PTR_LA t9,__syscall_error; \ -+ /* manual cpreturn */ \ -+ REG_L gp, STKOFF_GP(sp); \ -+ cfi_same_value (gp); \ -+ RESTORESTK; \ -+ jr t9; \ -+ .type __##syscall_name##_nocancel, @function; \ -+ .globl __##syscall_name##_nocancel; \ -+ __##syscall_name##_nocancel: \ -+ SAVESTK; \ -+ .cpsetup t9, STKOFF_GP, name; \ -+ cfi_rel_offset (gp, STKOFF_GP); \ -+ li v0, SYS_ify(syscall_name); \ -+ syscall; \ -+ bne a3, zero, SYSCALL_ERROR_LABEL; \ -+ /* manual cpreturn */ \ -+ REG_L gp, STKOFF_GP(sp); \ -+ cfi_same_value (gp); \ -+ RESTORESTK; \ -+ ret; \ -+ .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \ -+ ENTRY (name) \ -+ SAVESTK; \ -+ .cpsetup t9, STKOFF_GP, name; \ -+ cfi_rel_offset (gp, STKOFF_GP); \ -+ SINGLE_THREAD_P(v1); \ -+ bne zero, v1, L(pseudo_cancel); \ -+ .set noreorder; \ -+ li v0, SYS_ify(syscall_name); \ -+ syscall; \ -+ .set reorder; \ -+ bne a3, zero, SYSCALL_ERROR_LABEL; \ -+ /* manual cpreturn */ \ -+ REG_L gp, STKOFF_GP(sp); \ -+ cfi_same_value (gp); \ -+ RESTORESTK; \ -+ ret; \ -+ L(pseudo_cancel): \ -+ cfi_adjust_cfa_offset (STKSPACE); \ -+ cfi_rel_offset (gp, STKOFF_GP); \ -+ REG_S ra, STKOFF_RA(sp); \ -+ cfi_rel_offset (ra, STKOFF_RA); \ -+ PUSHARGS_##args; /* save syscall args */ \ -+ CENABLE; \ -+ REG_S v0, STKOFF_SVMSK(sp); /* save mask */ \ -+ POPARGS_##args; /* restore syscall args */ \ -+ .set noreorder; \ -+ li v0, SYS_ify (syscall_name); \ -+ syscall; \ -+ .set reorder; \ -+ REG_S v0, STKOFF_SC_V0(sp); /* save syscall result */ \ -+ REG_S a3, STKOFF_SC_ERR(sp); /* save syscall error flag */ \ -+ REG_L a0, STKOFF_SVMSK(sp); /* pass mask as arg1 */ \ -+ CDISABLE; \ -+ REG_L a3, STKOFF_SC_ERR(sp); /* restore syscall error flag */ \ -+ REG_L ra, STKOFF_RA(sp); /* restore return address */ \ -+ REG_L v0, STKOFF_SC_V0(sp); /* restore syscall result */ \ -+ bne a3, zero, SYSCALL_ERROR_LABEL; \ -+ /* manual cpreturn */ \ -+ REG_L gp, STKOFF_GP(sp); \ -+ cfi_same_value (gp); \ -+ RESTORESTK; \ -+ L(pseudo_end): -+ -+ -+# undef PSEUDO_END -+# define PSEUDO_END(sym) cfi_endproc; .end sym; .size sym,.-sym -+ -+#endif -+ -+# define PUSHARGS_0 /* nothing to do */ -+# define PUSHARGS_1 PUSHARGS_0 REG_S a0, STKOFF_A0(sp); cfi_rel_offset (a0, STKOFF_A0); -+# define PUSHARGS_2 PUSHARGS_1 REG_S a1, STKOFF_A1(sp); cfi_rel_offset (a1, STKOFF_A1); -+# define PUSHARGS_3 PUSHARGS_2 REG_S a2, STKOFF_A2(sp); cfi_rel_offset (a2, STKOFF_A2); -+# define PUSHARGS_4 PUSHARGS_3 REG_S a3, STKOFF_A3(sp); cfi_rel_offset (a3, STKOFF_A3); -+# define PUSHARGS_5 PUSHARGS_4 REG_S a4, STKOFF_A4(sp); cfi_rel_offset (a3, STKOFF_A4); -+# define PUSHARGS_6 PUSHARGS_5 REG_S a5, STKOFF_A5(sp); cfi_rel_offset (a3, STKOFF_A5); -+ -+# define POPARGS_0 /* nothing to do */ -+# define POPARGS_1 POPARGS_0 REG_L a0, STKOFF_A0(sp); -+# define POPARGS_2 POPARGS_1 REG_L a1, STKOFF_A1(sp); -+# define POPARGS_3 POPARGS_2 REG_L a2, STKOFF_A2(sp); -+# define POPARGS_4 POPARGS_3 REG_L a3, STKOFF_A3(sp); -+# define POPARGS_5 POPARGS_4 REG_L a4, STKOFF_A4(sp); -+# define POPARGS_6 POPARGS_5 REG_L a5, STKOFF_A5(sp); -+ -+/* Save an even number of slots. Should be 0 if an even number of slots -+ are used below, or SZREG if an odd number are used. */ -+# define STK_PAD SZREG -+ -+/* Place values that we are more likely to use later in this sequence, i.e. -+ closer to the SP at function entry. If you do that, the are more -+ likely to already be in your d-cache. */ -+# define STKOFF_A5 (STK_PAD) -+# define STKOFF_A4 (STKOFF_A5 + SZREG) -+# define STKOFF_A3 (STKOFF_A4 + SZREG) -+# define STKOFF_A2 (STKOFF_A3 + SZREG) /* MT and more args. */ -+# define STKOFF_A1 (STKOFF_A2 + SZREG) /* MT and 2 args. */ -+# define STKOFF_A0 (STKOFF_A1 + SZREG) /* MT and 1 arg. */ -+# define STKOFF_RA (STKOFF_A0 + SZREG) /* Used if MT. */ -+# define STKOFF_SC_V0 (STKOFF_RA + SZREG) /* Used if MT. */ -+# define STKOFF_SC_ERR (STKOFF_SC_V0 + SZREG) /* Used if MT. */ -+# define STKOFF_SVMSK (STKOFF_SC_ERR + SZREG) /* Used if MT. */ -+# define STKOFF_GP (STKOFF_SVMSK + SZREG) /* Always used. */ -+ -+# define STKSPACE (STKOFF_GP + SZREG) -+# define SAVESTK PTR_SUBU sp, STKSPACE; cfi_adjust_cfa_offset(STKSPACE) -+# define RESTORESTK PTR_ADDU sp, STKSPACE; cfi_adjust_cfa_offset(-STKSPACE) -+ -+# ifdef IS_IN_libpthread -+# define CENABLE PTR_LA t9, __pthread_enable_asynccancel; jalr t9 -+# define CDISABLE PTR_LA t9, __pthread_disable_asynccancel; jalr t9 -+# elif defined IS_IN_librt -+# define CENABLE PTR_LA t9, __librt_enable_asynccancel; jalr t9 -+# define CDISABLE PTR_LA t9, __librt_disable_asynccancel; jalr t9 -+# else -+# define CENABLE PTR_LA t9, __libc_enable_asynccancel; jalr t9 -+# define CDISABLE PTR_LA t9, __libc_disable_asynccancel; jalr t9 -+# endif -+ -+# ifndef __ASSEMBLER__ -+# define SINGLE_THREAD_P \ -+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ -+ header.multiple_threads) \ -+ == 0, 1) -+# else -+# define SINGLE_THREAD_P(reg) \ -+ READ_THREAD_POINTER(reg); \ -+ lw reg, MULTIPLE_THREADS_OFFSET(reg) -+#endif -+ -+#elif !defined __ASSEMBLER__ -+ -+# define SINGLE_THREAD_P 1 -+# define NO_CANCELLATION 1 -+ -+#endif -+ -+#ifndef __ASSEMBLER__ -+# define RTLD_SINGLE_THREAD_P \ -+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ -+ header.multiple_threads) == 0, 1) -+#endif diff --git a/toolchain/uClibc/patches-0.9.33.2/960-remove_eabi_oabi_selection.patch b/toolchain/uClibc/patches-0.9.33.2/960-remove_eabi_oabi_selection.patch deleted file mode 100644 index 19ac24695b5..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/960-remove_eabi_oabi_selection.patch +++ /dev/null @@ -1,32 +0,0 @@ -Rely on the compiler to be properly setup for the default ABI. - -When installing-headers, there are two cases: -- NPTL: no issue, a cross-compiler is already expected -- LinuxThreads: no issue, EABI/OABI has no impact on installed headers. - -Signed-off-by: "Yann E. MORIN" -Cc: Khem Raj -Cc: Bernhard Reutner-Fischer -Cc: Carmelo AMOROSO ---- - ---- a/extra/Configs/Config.arm -+++ b/extra/Configs/Config.arm -@@ -12,17 +12,6 @@ config FORCE_OPTIONS_FOR_ARCH - default y - select ARCH_ANY_ENDIAN - --config CONFIG_ARM_EABI -- bool "Build for EABI" -- help -- If you say 'y' here, functions and constants required by the -- ARM EABI will be built into the library. You should say 'y' -- if your compiler uses the ARM EABI, in which case you will also -- need a kernel supporting the EABI system call interface. -- -- If you say 'n' here, then the library will be built for the -- old Linux ABI. -- - config COMPILE_IN_THUMB_MODE - bool "Build using Thumb mode" - select USE_BX diff --git a/toolchain/uClibc/patches-0.9.33.2/970-add___kernel_long_and___kernel_ulong.patch b/toolchain/uClibc/patches-0.9.33.2/970-add___kernel_long_and___kernel_ulong.patch deleted file mode 100644 index d790664ba46..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/970-add___kernel_long_and___kernel_ulong.patch +++ /dev/null @@ -1,320 +0,0 @@ -From 6a76edddaa62ff06f178143b582167734cb55c18 Mon Sep 17 00:00:00 2001 -From: Chris Packham -Date: Mon, 01 Oct 2012 05:12:54 +0000 -Subject: libc/sysdeps: add __kernel_long and __kernel_ulong - -Linux 3.4 added __kernel_long_t and __kernel_ulong_t and various -exported header files were updated to use these new types. Add the -definitions for __kernel_long_t and __kernel_ulong_t to the relevant -kernel_types.h headers. - -This change was automated with the following scriptlet - - git grep --name-only 'typedef.*__kernel_old_dev_t' \ - | xargs sed -i '/typedef.*__kernel_old_dev_t/ a\ - typedef long\t\t__kernel_long_t;\ - typedef unsigned long\t__kernel_ulong_t;' - -Whitespace in arm, avr32, hppa, sparc was then manually fixed up. - -Signed-off-by: Chris Packham --- -Here's a cleaned up patch which should get the whitespace right. I'm a -bit iffy about the sparc changes they make sense to me but it's not a -platform I have access to. - -I can break this up per arch or per maintainer if requested. - - libc/sysdeps/linux/alpha/bits/kernel_types.h | 2 ++ - libc/sysdeps/linux/arm/bits/kernel_types.h | 2 ++ - libc/sysdeps/linux/avr32/bits/kernel_types.h | 2 ++ - libc/sysdeps/linux/bfin/bits/kernel_types.h | 2 ++ - libc/sysdeps/linux/c6x/bits/kernel_types.h | 2 ++ - libc/sysdeps/linux/cris/bits/kernel_types.h | 2 ++ - libc/sysdeps/linux/e1/bits/kernel_types.h | 2 ++ - libc/sysdeps/linux/h8300/bits/kernel_types.h | 2 ++ - libc/sysdeps/linux/hppa/bits/kernel_types.h | 2 ++ - libc/sysdeps/linux/i386/bits/kernel_types.h | 2 ++ - libc/sysdeps/linux/ia64/bits/kernel_types.h | 2 ++ - libc/sysdeps/linux/m68k/bits/kernel_types.h | 2 ++ - libc/sysdeps/linux/microblaze/bits/kernel_types.h | 2 ++ - libc/sysdeps/linux/mips/bits/kernel_types.h | 4 ++++ - libc/sysdeps/linux/nios2/bits/kernel_types.h | 2 ++ - libc/sysdeps/linux/powerpc/bits/kernel_types.h | 4 ++++ - libc/sysdeps/linux/sh/bits/kernel_types.h | 2 ++ - libc/sysdeps/linux/sh64/bits/kernel_types.h | 2 ++ - libc/sysdeps/linux/sparc/bits/kernel_types.h | 4 ++++ - libc/sysdeps/linux/v850/bits/kernel_types.h | 2 ++ - libc/sysdeps/linux/x86_64/bits/kernel_types.h | 2 ++ - libc/sysdeps/linux/xtensa/bits/kernel_types.h | 2 ++ - 22 files changed, 50 insertions(+) -Signed-off-by: Bernhard Reutner-Fischer ---- ---- a/libc/sysdeps/linux/alpha/bits/kernel_types.h -+++ b/libc/sysdeps/linux/alpha/bits/kernel_types.h -@@ -33,6 +33,8 @@ typedef __kernel_gid_t __kernel_old_gid_ - typedef __kernel_uid_t __kernel_uid32_t; - typedef __kernel_gid_t __kernel_gid32_t; - typedef __kernel_dev_t __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - - typedef struct { - int val[2]; ---- a/libc/sysdeps/linux/arm/bits/kernel_types.h -+++ b/libc/sysdeps/linux/arm/bits/kernel_types.h -@@ -32,6 +32,8 @@ typedef unsigned short __kernel_old_uid - typedef unsigned short __kernel_old_gid_t; - typedef long long __kernel_loff_t; - typedef __kernel_dev_t __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - - typedef struct { - #ifdef __USE_ALL ---- a/libc/sysdeps/linux/avr32/bits/kernel_types.h -+++ b/libc/sysdeps/linux/avr32/bits/kernel_types.h -@@ -39,6 +39,8 @@ typedef unsigned int __kernel_gid32_t; - typedef unsigned short __kernel_old_uid_t; - typedef unsigned short __kernel_old_gid_t; - typedef unsigned short __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - - #ifdef __GNUC__ - typedef long long __kernel_loff_t; ---- a/libc/sysdeps/linux/bfin/bits/kernel_types.h -+++ b/libc/sysdeps/linux/bfin/bits/kernel_types.h -@@ -32,6 +32,8 @@ typedef unsigned short __kernel_old_uid_ - typedef unsigned short __kernel_old_gid_t; - typedef long long __kernel_loff_t; - typedef __kernel_dev_t __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - - typedef struct { - #ifdef __USE_ALL ---- a/libc/sysdeps/linux/c6x/bits/kernel_types.h -+++ b/libc/sysdeps/linux/c6x/bits/kernel_types.h -@@ -22,6 +22,8 @@ typedef unsigned int __kernel_gid32_t; - typedef unsigned int __kernel_old_uid_t; - typedef unsigned int __kernel_old_gid_t; - typedef unsigned int __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - typedef unsigned int __kernel_size_t; - typedef int __kernel_ssize_t; - typedef int __kernel_ptrdiff_t; ---- a/libc/sysdeps/linux/cris/bits/kernel_types.h -+++ b/libc/sysdeps/linux/cris/bits/kernel_types.h -@@ -28,6 +28,8 @@ typedef unsigned int __kernel_gid32_t - typedef unsigned short __kernel_old_uid_t; - typedef unsigned short __kernel_old_gid_t; - typedef __kernel_dev_t __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - - #ifdef __GNUC__ - typedef long long __kernel_loff_t; ---- a/libc/sysdeps/linux/e1/bits/kernel_types.h -+++ b/libc/sysdeps/linux/e1/bits/kernel_types.h -@@ -31,6 +31,8 @@ typedef unsigned int __kernel_gid32_t; - typedef unsigned short __kernel_old_uid_t; - typedef unsigned short __kernel_old_gid_t; - typedef __kernel_dev_t __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - typedef long long __kernel_loff_t; - - /* ---- a/libc/sysdeps/linux/h8300/bits/kernel_types.h -+++ b/libc/sysdeps/linux/h8300/bits/kernel_types.h -@@ -32,6 +32,8 @@ typedef unsigned short __kernel_old_uid_ - typedef unsigned short __kernel_old_gid_t; - typedef long long __kernel_loff_t; - typedef __kernel_dev_t __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - - typedef struct { - #ifdef __USE_ALL ---- a/libc/sysdeps/linux/hppa/bits/kernel_types.h -+++ b/libc/sysdeps/linux/hppa/bits/kernel_types.h -@@ -45,6 +45,8 @@ typedef long long __kernel_off64_t; - typedef unsigned long long __kernel_ino64_t; - - typedef unsigned int __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - - typedef struct { - #ifdef __USE_ALL ---- a/libc/sysdeps/linux/i386/bits/kernel_types.h -+++ b/libc/sysdeps/linux/i386/bits/kernel_types.h -@@ -40,6 +40,8 @@ typedef unsigned int __kernel_gid32_t; - typedef unsigned short __kernel_old_uid_t; - typedef unsigned short __kernel_old_gid_t; - typedef __kernel_dev_t __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - typedef long long __kernel_loff_t; - - typedef struct { ---- a/libc/sysdeps/linux/ia64/bits/kernel_types.h -+++ b/libc/sysdeps/linux/ia64/bits/kernel_types.h -@@ -52,5 +52,7 @@ typedef __kernel_gid_t __kernel_gid32_t; - - typedef unsigned int __kernel_dev_t; - typedef unsigned int __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - - #endif /* _ASM_IA64_POSIX_TYPES_H */ ---- a/libc/sysdeps/linux/m68k/bits/kernel_types.h -+++ b/libc/sysdeps/linux/m68k/bits/kernel_types.h -@@ -32,6 +32,8 @@ typedef unsigned short __kernel_old_uid_ - typedef unsigned short __kernel_old_gid_t; - typedef long long __kernel_loff_t; - typedef __kernel_dev_t __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - - typedef struct { - #ifdef __USE_ALL ---- a/libc/sysdeps/linux/microblaze/bits/kernel_types.h -+++ b/libc/sysdeps/linux/microblaze/bits/kernel_types.h -@@ -44,6 +44,8 @@ typedef unsigned int __kernel_gid32_t; - typedef unsigned int __kernel_old_uid_t; - typedef unsigned int __kernel_old_gid_t; - typedef unsigned int __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - - #ifdef __GNUC__ - typedef long long __kernel_loff_t; ---- a/libc/sysdeps/linux/mips/bits/kernel_types.h -+++ b/libc/sysdeps/linux/mips/bits/kernel_types.h -@@ -32,6 +32,8 @@ typedef int __kernel_gid32_t; - typedef __kernel_uid_t __kernel_old_uid_t; - typedef __kernel_gid_t __kernel_old_gid_t; - typedef __kernel_dev_t __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - typedef long long __kernel_loff_t; - #else - typedef unsigned int __kernel_dev_t; -@@ -68,6 +70,8 @@ typedef int __kernel_gid32_t; - typedef __kernel_uid_t __kernel_old_uid_t; - typedef __kernel_gid_t __kernel_old_gid_t; - typedef __kernel_dev_t __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - typedef long long __kernel_loff_t; - #endif - ---- a/libc/sysdeps/linux/nios2/bits/kernel_types.h -+++ b/libc/sysdeps/linux/nios2/bits/kernel_types.h -@@ -31,6 +31,8 @@ typedef unsigned int __kernel_gid32_t; - typedef unsigned short __kernel_old_uid_t; - typedef unsigned short __kernel_old_gid_t; - typedef unsigned short __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - typedef long long __kernel_loff_t; - - typedef struct { ---- a/libc/sysdeps/linux/powerpc/bits/kernel_types.h -+++ b/libc/sysdeps/linux/powerpc/bits/kernel_types.h -@@ -36,6 +36,8 @@ typedef unsigned int __kernel_gid32_t; - typedef unsigned int __kernel_old_uid_t; - typedef unsigned int __kernel_old_gid_t; - typedef __kernel_dev_t __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - #else - typedef unsigned int __kernel_dev_t; - typedef unsigned int __kernel_ino_t; -@@ -61,6 +63,8 @@ typedef unsigned int __kernel_gid32_t; - typedef unsigned int __kernel_old_uid_t; - typedef unsigned int __kernel_old_gid_t; - typedef __kernel_dev_t __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - typedef long long __kernel_loff_t; - #endif - ---- a/libc/sysdeps/linux/sh/bits/kernel_types.h -+++ b/libc/sysdeps/linux/sh/bits/kernel_types.h -@@ -32,6 +32,8 @@ typedef unsigned int __kernel_gid32_t; - typedef unsigned short __kernel_old_uid_t; - typedef unsigned short __kernel_old_gid_t; - typedef __kernel_dev_t __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - typedef long long __kernel_loff_t; - - typedef struct { ---- a/libc/sysdeps/linux/sh64/bits/kernel_types.h -+++ b/libc/sysdeps/linux/sh64/bits/kernel_types.h -@@ -43,6 +43,8 @@ typedef unsigned int __kernel_gid32_t - typedef unsigned short __kernel_old_uid_t; - typedef unsigned short __kernel_old_gid_t; - typedef __kernel_dev_t __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - typedef long long __kernel_loff_t; - - typedef struct { ---- a/libc/sysdeps/linux/sparc/bits/kernel_types.h -+++ b/libc/sysdeps/linux/sparc/bits/kernel_types.h -@@ -32,6 +32,8 @@ typedef unsigned short __kernel_g - typedef __kernel_uid_t __kernel_old_uid_t; - typedef __kernel_gid_t __kernel_old_gid_t; - typedef __kernel_dev_t __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - typedef __kernel_uid_t __kernel_uid32_t; - typedef __kernel_gid_t __kernel_gid32_t; - typedef int __kernel_suseconds_t; -@@ -62,6 +64,8 @@ typedef unsigned int __kernel_gid - typedef unsigned short __kernel_old_uid_t; - typedef unsigned short __kernel_old_gid_t; - typedef __kernel_dev_t __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - typedef long long __kernel_loff_t; - #endif - ---- a/libc/sysdeps/linux/v850/bits/kernel_types.h -+++ b/libc/sysdeps/linux/v850/bits/kernel_types.h -@@ -41,6 +41,8 @@ typedef unsigned int __kernel_gid32_t; - typedef unsigned short __kernel_old_uid_t; - typedef unsigned short __kernel_old_gid_t; - typedef __kernel_dev_t __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - - typedef struct { - #ifdef __USE_ALL ---- a/libc/sysdeps/linux/x86_64/bits/kernel_types.h -+++ b/libc/sysdeps/linux/x86_64/bits/kernel_types.h -@@ -40,6 +40,8 @@ typedef unsigned int __kernel_gid32_t; - typedef unsigned short __kernel_old_uid_t; - typedef unsigned short __kernel_old_gid_t; - typedef __kernel_dev_t __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - typedef long long __kernel_loff_t; - - typedef struct { ---- a/libc/sysdeps/linux/xtensa/bits/kernel_types.h -+++ b/libc/sysdeps/linux/xtensa/bits/kernel_types.h -@@ -33,6 +33,8 @@ typedef unsigned int __kernel_gid32_t; - typedef unsigned short __kernel_old_uid_t; - typedef unsigned short __kernel_old_gid_t; - typedef unsigned short __kernel_old_dev_t; -+typedef long __kernel_long_t; -+typedef unsigned long __kernel_ulong_t; - typedef long long __kernel_loff_t; - - /* Beginning in 2.6 kernels, which is the first version that includes the diff --git a/toolchain/uClibc/patches-0.9.33.2/981-fix_setting_arch_native_bit.patch b/toolchain/uClibc/patches-0.9.33.2/981-fix_setting_arch_native_bit.patch deleted file mode 100644 index 4c7dd46891c..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/981-fix_setting_arch_native_bit.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 7e509aae23665b9a79f6c9b4c24d1d8a55bd3582 Mon Sep 17 00:00:00 2001 -From: Gustavo Zacarias -Date: Wed, 24 Jul 2013 15:30:35 +0000 -Subject: Rules.mak: Fix setting arch native bit - -fix breakage from 603af30d - -Removing the whitespace from findstring for 64 bit architectures has -bad consequences since powerpc would be a match in powerpc64 and sparc -would also be a match in sparc64. -That doesn't make them 64 bits in reality causing general breakage. - -Signed-off-by: Gustavo Zacarias -Reviewed-by: Markos Chandras -Signed-off-by: Bernhard Reutner-Fischer ---- - ---- a/Rules.mak -+++ b/Rules.mak -@@ -121,7 +121,7 @@ UBACKTRACE_DSO := libubacktrace.so.$(ABI - - UCLIBC_LDSO_NAME := ld-uClibc - ARCH_NATIVE_BIT := 32 --ifneq ($(findstring $(TARGET_ARCH),hppa64 ia64 powerpc64 s390x sparc64 x86_64),) -+ifneq ($(findstring $(TARGET_ARCH) , hppa64 ia64 powerpc64 s390x sparc64 x86_64 ),) - UCLIBC_LDSO_NAME := ld64-uClibc - ARCH_NATIVE_BIT := 64 - else diff --git a/toolchain/uClibc/patches-0.9.33.2/990-no-stack-cache.patch b/toolchain/uClibc/patches-0.9.33.2/990-no-stack-cache.patch deleted file mode 100644 index 8f0b511ea6f..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/990-no-stack-cache.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/libpthread/nptl/allocatestack.c -+++ b/libpthread/nptl/allocatestack.c -@@ -100,7 +100,7 @@ - /* Cache handling for not-yet free stacks. */ - - /* Maximum size in kB of cache. */ --static size_t stack_cache_maxsize = 40 * 1024 * 1024; /* 40MiBi by default. */ -+static size_t stack_cache_maxsize = 0; /* embedded systems don't have enough ram for dirty stack caches */ - static size_t stack_cache_actsize; - - /* Mutex protecting this variable. */ diff --git a/toolchain/uClibc/patches-0.9.33.2/991-gen_wctype.patch b/toolchain/uClibc/patches-0.9.33.2/991-gen_wctype.patch deleted file mode 100644 index e85d6d45228..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/991-gen_wctype.patch +++ /dev/null @@ -1,183 +0,0 @@ ---- a/extra/locale/gen_wctype.c -+++ b/extra/locale/gen_wctype.c -@@ -227,11 +227,12 @@ int main(int argc, char **argv) - ++verbose; - continue; - } -- if (!setlocale(LC_CTYPE, *argv)) { -+ /* setlocale might be just a stub */ -+ /* if (!setlocale(LC_CTYPE, *argv)) { - verbose_msg("setlocale(LC_CTYPE,%s) failed! Skipping this locale...\n", *argv); - continue; - } -- -+ */ - if (!(totitle = wctrans("totitle"))) { - verbose_msg("no totitle transformation.\n"); - } -@@ -306,43 +307,43 @@ int main(int argc, char **argv) - #endif - #if 0 - if (c < 256) { -- unsigned int glibc; -+ unsigned int curr_stdclib; - -- glibc = 0; -- if (isalnum(c)) ++glibc; glibc <<= 1; -- if (isalpha(c)) ++glibc; glibc <<= 1; -- if (isblank(c)) ++glibc; glibc <<= 1; -- if (iscntrl(c)) ++glibc; glibc <<= 1; -- if (isdigit(c)) ++glibc; glibc <<= 1; -- if (isgraph(c)) ++glibc; glibc <<= 1; -- if (islower(c)) ++glibc; glibc <<= 1; -- if (isprint(c)) ++glibc; glibc <<= 1; -- if (ispunct(c)) ++glibc; glibc <<= 1; -- if (isspace(c)) ++glibc; glibc <<= 1; -- if (isupper(c)) ++glibc; glibc <<= 1; -- if (isxdigit(c)) ++glibc; -- verbose_msg("%#8x : ctype %#4x\n", c, glibc); -+ curr_stdclib = 0; -+ if (isalnum(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (isalpha(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (isblank(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iscntrl(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (isdigit(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (isgraph(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (islower(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (isprint(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (ispunct(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (isspace(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (isupper(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (isxdigit(c)) ++curr_stdclib; -+ verbose_msg("%#8x : ctype %#4x\n", c, curr_stdclib); - } - #endif - #if 1 - /* Paranoid checking... */ - { -- unsigned int glibc; -+ unsigned int curr_stdclib; - unsigned int mine; - -- glibc = 0; -- if (iswalnum(c)) ++glibc; glibc <<= 1; -- if (iswalpha(c)) ++glibc; glibc <<= 1; -- if (iswblank(c)) ++glibc; glibc <<= 1; -- if (iswcntrl(c)) ++glibc; glibc <<= 1; -- if (iswdigit(c)) ++glibc; glibc <<= 1; -- if (iswgraph(c)) ++glibc; glibc <<= 1; -- if (iswlower(c)) ++glibc; glibc <<= 1; -- if (iswprint(c)) ++glibc; glibc <<= 1; -- if (iswpunct(c)) ++glibc; glibc <<= 1; -- if (iswspace(c)) ++glibc; glibc <<= 1; -- if (iswupper(c)) ++glibc; glibc <<= 1; -- if (iswxdigit(c)) ++glibc; -+ curr_stdclib = 0; -+ if (iswalnum(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswalpha(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswblank(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswcntrl(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswdigit(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswgraph(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswlower(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswprint(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswpunct(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswspace(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswupper(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswxdigit(c)) ++curr_stdclib; - - mine = 0; - if (mywalnum(d,c)) ++mine; mine <<= 1; -@@ -358,15 +359,15 @@ int main(int argc, char **argv) - if (mywupper(d,c)) ++mine; mine <<= 1; - if (mywxdigit(d,c)) ++mine; - -- if (glibc != mine) { -- verbose_msg("%#8x : glibc %#4x != %#4x mine %u\n", c, glibc, mine, d); -+ if (curr_stdclib != mine) { -+ verbose_msg("%#8x : curr_stdclib %#4x != %#4x mine %u\n", c, curr_stdclib, mine, d); - return EXIT_FAILURE; - } - #if 0 - if (iswctype(c,is_comb) || iswctype(c,is_comb3)) { - /* if (!iswpunct(c)) { */ - verbose_msg("%#8x : %d %d %#4x\n", -- c, iswctype(c,is_comb),iswctype(c,is_comb3), glibc); -+ c, iswctype(c,is_comb),iswctype(c,is_comb3), curr_stdclib); - /* } */ - } - #endif -@@ -553,7 +554,7 @@ int main(int argc, char **argv) - for (c = 0; c <= 0x10ffffUL; c++) - #endif - { -- unsigned int glibc; -+ unsigned int curr_stdclib; - unsigned int mine; - unsigned int upper, lower; - -@@ -568,19 +569,19 @@ int main(int argc, char **argv) - } - #endif - #endif -- glibc = 0; -- if (iswalnum(c)) ++glibc; glibc <<= 1; -- if (iswalpha(c)) ++glibc; glibc <<= 1; -- if (iswblank(c)) ++glibc; glibc <<= 1; -- if (iswcntrl(c)) ++glibc; glibc <<= 1; -- if (iswdigit(c)) ++glibc; glibc <<= 1; -- if (iswgraph(c)) ++glibc; glibc <<= 1; -- if (iswlower(c)) ++glibc; glibc <<= 1; -- if (iswprint(c)) ++glibc; glibc <<= 1; -- if (iswpunct(c)) ++glibc; glibc <<= 1; -- if (iswspace(c)) ++glibc; glibc <<= 1; -- if (iswupper(c)) ++glibc; glibc <<= 1; -- if (iswxdigit(c)) ++glibc; -+ curr_stdclib = 0; -+ if (iswalnum(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswalpha(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswblank(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswcntrl(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswdigit(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswgraph(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswlower(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswprint(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswpunct(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswspace(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswupper(c)) ++curr_stdclib; curr_stdclib <<= 1; -+ if (iswxdigit(c)) ++curr_stdclib; - - { - unsigned int u; -@@ -630,8 +631,8 @@ int main(int argc, char **argv) - if (mywupper(d,c)) ++mine; mine <<= 1; - if (mywxdigit(d,c)) ++mine; - -- if (glibc != mine) { -- verbose_msg("%#8x : glibc %#4x != %#4x mine %d\n", c, glibc, mine, d); -+ if (curr_stdclib != mine) { -+ verbose_msg("%#8x : curr_stdclib %#4x != %#4x mine %d\n", c, curr_stdclib, mine, d); - if (c < 0x30000UL) { - verbose_msg("sc=%#x u=%#x n=%#x i0=%#x i1=%#x\n", sc, u, n, i0, i1); - } -@@ -655,17 +656,17 @@ int main(int argc, char **argv) - } - - if (towupper(c) != upper) { -- verbose_msg("%#8x : towupper glibc %#4x != %#4x mine\n", -+ verbose_msg("%#8x : towupper curr_stdclib %#4x != %#4x mine\n", - c, towupper(c), upper); - } - - if (towlower(c) != lower) { -- verbose_msg("%#8x : towlower glibc %#4x != %#4x mine i0 = %d\n", -+ verbose_msg("%#8x : towlower curr_stdclib %#4x != %#4x mine i0 = %d\n", - c, towlower(c), lower, i0); - } - - if (totitle && ((tt = towctrans(c, totitle)) != upper)) { -- verbose_msg("%#8x : totitle glibc %#4lx != %#4x mine i0 = %d\n", -+ verbose_msg("%#8x : totitle curr_stdclib %#4lx != %#4x mine i0 = %d\n", - c, tt, upper, i0); - } - } diff --git a/toolchain/uClibc/patches-0.9.33.2/995-add-sigsys-to-siginfo_t-union.patch b/toolchain/uClibc/patches-0.9.33.2/995-add-sigsys-to-siginfo_t-union.patch deleted file mode 100644 index 4894a56138e..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/995-add-sigsys-to-siginfo_t-union.patch +++ /dev/null @@ -1,145 +0,0 @@ -Index: uClibc/libc/sysdeps/linux/common/bits/siginfo.h -=================================================================== ---- uClibc.orig/libc/sysdeps/linux/common/bits/siginfo.h -+++ uClibc/libc/sysdeps/linux/common/bits/siginfo.h -@@ -104,6 +104,14 @@ typedef struct siginfo - long int si_band; /* Band event for SIGPOLL. */ - int si_fd; - } _sigpoll; -+ -+ /* SIGSYS. */ -+ struct -+ { -+ void *_call_addr; /* Calling user insn. */ -+ int _syscall; /* Triggering system call number. */ -+ unsigned int _arch; /* AUDIT_ARCH_* of syscall. */ -+ } _sigsys; - } _sifields; - } siginfo_t; - -@@ -122,6 +130,9 @@ typedef struct siginfo - # define si_addr _sifields._sigfault.si_addr - # define si_band _sifields._sigpoll.si_band - # define si_fd _sifields._sigpoll.si_fd -+# define si_call_addr _sifields._sigsys._call_addr -+# define si_syscall _sifields._sigsys._syscall -+# define si_arch _sifields._sigsys._arch - - - /* Values for `si_code'. Positive values are reserved for kernel-generated -Index: uClibc/libc/sysdeps/linux/alpha/bits/siginfo.h -=================================================================== ---- uClibc.orig/libc/sysdeps/linux/alpha/bits/siginfo.h -+++ uClibc/libc/sysdeps/linux/alpha/bits/siginfo.h -@@ -98,6 +98,14 @@ typedef struct siginfo - int si_band; /* Band event for SIGPOLL. */ - int si_fd; - } _sigpoll; -+ -+ /* SIGSYS. */ -+ struct -+ { -+ void *_call_addr; /* Calling user insn. */ -+ int _syscall; /* Triggering system call number. */ -+ unsigned int _arch; /* AUDIT_ARCH_* of syscall. */ -+ } _sigsys; - } _sifields; - } siginfo_t; - -@@ -116,6 +124,9 @@ typedef struct siginfo - # define si_addr _sifields._sigfault.si_addr - # define si_band _sifields._sigpoll.si_band - # define si_fd _sifields._sigpoll.si_fd -+# define si_call_addr _sifields._sigsys._call_addr -+# define si_syscall _sifields._sigsys._syscall -+# define si_arch _sifields._sigsys._arch - - - /* Values for `si_code'. Positive values are reserved for kernel-generated -Index: uClibc/libc/sysdeps/linux/ia64/bits/siginfo.h -=================================================================== ---- uClibc.orig/libc/sysdeps/linux/ia64/bits/siginfo.h -+++ uClibc/libc/sysdeps/linux/ia64/bits/siginfo.h -@@ -103,6 +103,14 @@ typedef struct siginfo - long int si_band; /* Band event for SIGPOLL. */ - int si_fd; - } _sigpoll; -+ -+ /* SIGSYS. */ -+ struct -+ { -+ void *_call_addr; /* Calling user insn. */ -+ int _syscall; /* Triggering system call number. */ -+ unsigned int _arch; /* AUDIT_ARCH_* of syscall. */ -+ } _sigsys; - } _sifields; - } siginfo_t; - -@@ -121,6 +129,9 @@ typedef struct siginfo - # define si_addr _sifields._sigfault.si_addr - # define si_band _sifields._sigpoll.si_band - # define si_fd _sifields._sigpoll.si_fd -+# define si_call_addr _sifields._sigsys._call_addr -+# define si_syscall _sifields._sigsys._syscall -+# define si_arch _sifields._sigsys._arch - - # ifdef __USE_GNU - # define si_imm _sifields._sigfault._si_imm -Index: uClibc/libc/sysdeps/linux/mips/bits/siginfo.h -=================================================================== ---- uClibc.orig/libc/sysdeps/linux/mips/bits/siginfo.h -+++ uClibc/libc/sysdeps/linux/mips/bits/siginfo.h -@@ -107,6 +107,14 @@ typedef struct siginfo - __uid_t si_uid; /* Real user ID of sending process. */ - sigval_t si_sigval; /* Signal value. */ - } _rt; -+ -+ /* SIGSYS. */ -+ struct -+ { -+ void *_call_addr; /* Calling user insn. */ -+ int _syscall; /* Triggering system call number. */ -+ unsigned int _arch; /* AUDIT_ARCH_* of syscall. */ -+ } _sigsys; - } _sifields; - } siginfo_t; - -@@ -123,6 +131,9 @@ typedef struct siginfo - # define si_addr _sifields._sigfault.si_addr - # define si_band _sifields._sigpoll.si_band - # define si_fd _sifields._sigpoll.si_fd -+# define si_call_addr _sifields._sigsys._call_addr -+# define si_syscall _sifields._sigsys._syscall -+# define si_arch _sifields._sigsys._arch - - - /* Values for `si_code'. Positive values are reserved for kernel-generated -Index: uClibc/libc/sysdeps/linux/sparc/bits/siginfo.h -=================================================================== ---- uClibc.orig/libc/sysdeps/linux/sparc/bits/siginfo.h -+++ uClibc/libc/sysdeps/linux/sparc/bits/siginfo.h -@@ -105,6 +105,14 @@ typedef struct siginfo - int si_band; /* Band event for SIGPOLL. */ - int si_fd; - } _sigpoll; -+ -+ /* SIGSYS. */ -+ struct -+ { -+ void *_call_addr; /* Calling user insn. */ -+ int _syscall; /* Triggering system call number. */ -+ unsigned int _arch; /* AUDIT_ARCH_* of syscall. */ -+ } _sigsys; - } _sifields; - } siginfo_t; - -@@ -124,6 +132,9 @@ typedef struct siginfo - # define si_trapno _sifields._sigfault.si_trapno - # define si_band _sifields._sigpoll.si_band - # define si_fd _sifields._sigpoll.si_fd -+# define si_call_addr _sifields._sigsys._call_addr -+# define si_syscall _sifields._sigsys._syscall -+# define si_arch _sifields._sigsys._arch - - - /* Values for `si_code'. Positive values are reserved for kernel-generated diff --git a/toolchain/uClibc/patches-0.9.33.2/999-eventfd_use_bits_scheme.patch b/toolchain/uClibc/patches-0.9.33.2/999-eventfd_use_bits_scheme.patch deleted file mode 100644 index 05512907104..00000000000 --- a/toolchain/uClibc/patches-0.9.33.2/999-eventfd_use_bits_scheme.patch +++ /dev/null @@ -1,248 +0,0 @@ -From fd355bc1dbcb794ae1abf0fad1459e28d8567ba0 Mon Sep 17 00:00:00 2001 -From: Hiroaki KAWAI -Date: Fri, 19 Apr 2013 01:09:35 +0000 -Subject: eventfd.h: Use new "bits/" scheme for arch-specific flags - -As in timerfd.h, eventfd.h needs arch-specific definition files. -alpha, mips and sparc needs separate file, all the other arch -will use common definition. - -This problem is already fixed in glibc. - -Also sanitize and provide bits for hppa. -Make sure not to install the new bits/eventfd unless eventfd support is -enabled. - -Signed-off-by: Hiroaki KAWAI -Signed-off-by: Bernhard Reutner-Fischer ---- ---- a/Makefile.in -+++ b/Makefile.in -@@ -272,6 +272,7 @@ HEADERS_RM-$(UCLIBC_HAS_XATTR) - HEADERS_RM-$(UCLIBC_HAS_XLOCALE) += xlocale.h - HEADERS_RM-$(UCLIBC_LINUX_SPECIFIC) += sys/eventfd.h sys/fsuid.h \ - bits/inotify.h \ -+ bits/eventfd.h \ - sys/inotify.h \ - sys/kdaemon.h \ - sys/perm.h \ ---- /dev/null -+++ b/libc/sysdeps/linux/alpha/bits/eventfd.h -@@ -0,0 +1,31 @@ -+/* Copyright (C) 2007-2013 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library 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 -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ . */ -+ -+#ifndef _SYS_EVENTFD_H -+# error "Never use directly; include instead." -+#endif -+ -+/* Flags for eventfd. */ -+enum -+ { -+ EFD_SEMAPHORE = 000000001, -+#define EFD_SEMAPHORE EFD_SEMAPHORE -+ EFD_CLOEXEC = 010000000, -+#define EFD_CLOEXEC EFD_CLOEXEC -+ EFD_NONBLOCK = 000000004 -+#define EFD_NONBLOCK EFD_NONBLOCK -+ }; ---- /dev/null -+++ b/libc/sysdeps/linux/common/bits/eventfd.h -@@ -0,0 +1,31 @@ -+/* Copyright (C) 2007-2013 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library 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 -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ . */ -+ -+#ifndef _SYS_EVENTFD_H -+# error "Never use directly; include instead." -+#endif -+ -+/* Flags for eventfd. */ -+enum -+ { -+ EFD_SEMAPHORE = 00000001, -+#define EFD_SEMAPHORE EFD_SEMAPHORE -+ EFD_CLOEXEC = 02000000, -+#define EFD_CLOEXEC EFD_CLOEXEC -+ EFD_NONBLOCK = 00004000 -+#define EFD_NONBLOCK EFD_NONBLOCK -+ }; ---- a/libc/sysdeps/linux/common/sys/eventfd.h -+++ b/libc/sysdeps/linux/common/sys/eventfd.h -@@ -1,4 +1,4 @@ --/* Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. -+/* Copyright (C) 2007-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or -@@ -21,21 +21,12 @@ - - #include - -+/* Get the platform-dependent flags. */ -+#include - - /* Type for event counter. */ - typedef uint64_t eventfd_t; - --/* Flags for signalfd. */ --enum -- { -- EFD_SEMAPHORE = 1, --#define EFD_SEMAPHORE EFD_SEMAPHORE -- EFD_CLOEXEC = 02000000, --#define EFD_CLOEXEC EFD_CLOEXEC -- EFD_NONBLOCK = 04000 --#define EFD_NONBLOCK EFD_NONBLOCK -- }; -- - - __BEGIN_DECLS - -@@ -43,6 +34,16 @@ __BEGIN_DECLS - value to COUNT. */ - extern int eventfd (int __count, int __flags) __THROW; - -+#if 0 /* not (yet) implemented in uClibc */ -+ -+/* Read event counter and possibly wait for events. */ -+extern int eventfd_read (int __fd, eventfd_t *__value); -+ -+/* Increment event counter. */ -+extern int eventfd_write (int __fd, eventfd_t __value); -+ -+#endif -+ - __END_DECLS - - #endif /* sys/eventfd.h */ ---- /dev/null -+++ b/libc/sysdeps/linux/hppa/bits/eventfd.h -@@ -0,0 +1,32 @@ -+/* Copyright (C) 2007-2013 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library 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 -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library. If not, see -+ . */ -+ -+#ifndef _SYS_EVENTFD_H -+# error "Never use directly; include instead." -+#endif -+ -+/* Flags for signalfd. */ -+enum -+ { -+ EFD_SEMAPHORE = 000000001, -+#define EFD_SEMAPHORE EFD_SEMAPHORE -+ EFD_CLOEXEC = 010000000, -+#define EFD_CLOEXEC EFD_CLOEXEC -+/* the below value looks suspicious, should be 000200004 for consistency */ -+ EFD_NONBLOCK = 00200004 /* HPUX has separate NDELAY & NONBLOCK */ -+#define EFD_NONBLOCK EFD_NONBLOCK -+ }; ---- /dev/null -+++ b/libc/sysdeps/linux/mips/bits/eventfd.h -@@ -0,0 +1,31 @@ -+/* Copyright (C) 2007-2013 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library 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 -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ . */ -+ -+#ifndef _SYS_EVENTFD_H -+# error "Never use directly; include instead." -+#endif -+ -+/* Flags for eventfd. */ -+enum -+ { -+ EFD_SEMAPHORE = 00000001, -+#define EFD_SEMAPHORE EFD_SEMAPHORE -+ EFD_CLOEXEC = 02000000, -+#define EFD_CLOEXEC EFD_CLOEXEC -+ EFD_NONBLOCK = 00000200 -+#define EFD_NONBLOCK EFD_NONBLOCK -+ }; ---- /dev/null -+++ b/libc/sysdeps/linux/sparc/bits/eventfd.h -@@ -0,0 +1,31 @@ -+/* Copyright (C) 2007-2013 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library 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 -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ . */ -+ -+#ifndef _SYS_EVENTFD_H -+# error "Never use directly; include instead." -+#endif -+ -+/* Flags for eventfd. */ -+enum -+ { -+ EFD_SEMAPHORE = 1, -+#define EFD_SEMAPHORE EFD_SEMAPHORE -+ EFD_CLOEXEC = 0x400000, -+#define EFD_CLOEXEC EFD_CLOEXEC -+ EFD_NONBLOCK = 0x004000 -+#define EFD_NONBLOCK EFD_NONBLOCK -+ }; diff --git a/toolchain/uClibc/patches/01-allow-to-disable-prefetch-support-in-memcpy-memset.patch b/toolchain/uClibc/patches/01-allow-to-disable-prefetch-support-in-memcpy-memset.patch deleted file mode 100644 index 7060cf0fdf4..00000000000 --- a/toolchain/uClibc/patches/01-allow-to-disable-prefetch-support-in-memcpy-memset.patch +++ /dev/null @@ -1,44 +0,0 @@ -diff --git a/extra/Configs/Config.mips b/extra/Configs/Config.mips -index e0b62dd..919e80c 100644 ---- a/extra/Configs/Config.mips -+++ b/extra/Configs/Config.mips -@@ -31,3 +31,10 @@ config CONFIG_MIPS_N64_ABI - bool "N64 ABI" - - endchoice -+ -+config UCLIBC_USE_MIPS_PREFETCH -+ bool "Use MIPS prefetch optimization for memcpy/memset" -+ default y -+ help -+ You get better performance when you use Prefetch. -+ https://gcc.gnu.org/projects/prefetch.html#mips -diff --git a/libc/string/mips/memcpy.S b/libc/string/mips/memcpy.S -index 59f9f0a..3825875 100644 ---- a/libc/string/mips/memcpy.S -+++ b/libc/string/mips/memcpy.S -@@ -39,7 +39,7 @@ - - #if (_MIPS_ISA == _MIPS_ISA_MIPS4) || (_MIPS_ISA == _MIPS_ISA_MIPS5) || \ - (_MIPS_ISA == _MIPS_ISA_MIPS32) || (_MIPS_ISA == _MIPS_ISA_MIPS64) --# ifndef DISABLE_PREFETCH -+# ifdef __UCLIBC_USE_MIPS_PREFETCH__ - # define USE_PREFETCH - # endif - #endif -diff --git a/libc/string/mips/memset.S b/libc/string/mips/memset.S -index 43034ce..1c9f14c 100644 ---- a/libc/string/mips/memset.S -+++ b/libc/string/mips/memset.S -@@ -37,7 +37,7 @@ - prefetching. */ - - #if (__mips == 4) || (__mips == 5) || (__mips == 32) || (__mips == 64) --# ifndef DISABLE_PREFETCH -+# ifdef __UCLIBC_USE_MIPS_PREFETCH__ - # define USE_PREFETCH - # endif - #endif --- -2.7.4.GIT - diff --git a/toolchain/yasm/Makefile b/toolchain/yasm/Makefile new file mode 100644 index 00000000000..e5cdac6fe98 --- /dev/null +++ b/toolchain/yasm/Makefile @@ -0,0 +1,63 @@ +# +# Copyright (C) 2016 Daniel Golle +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +include $(TOPDIR)/rules.mk + +PKG_NAME:=yasm +PKG_VERSION:=1.3.0 + +PKG_SOURCE_URL:=http://www.tortall.net/projects/yasm/releases/ +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz + +PKG_HASH:=3dce6601b495f5b3d45b59f7d2492a340ee7e84b5beca17e48f862502bd5603f + +HOST_BUILD_PARALLEL:=1 + +include $(INCLUDE_DIR)/toolchain-build.mk + +YASM_CONFIGURE:= \ + ./configure \ + --prefix=$(TOOLCHAIN_DIR) \ + --build=$(GNU_HOST_NAME) \ + --host=$(GNU_HOST_NAME) \ + --target=$(REAL_GNU_TARGET_NAME) \ + --with-sysroot=$(TOOLCHAIN_DIR) \ + --disable-multilib \ + --disable-werror \ + --disable-nls \ + --disable-sim \ + --disable-gdb \ + $(SOFT_FLOAT_CONFIG_OPTION) \ + +define Host/Prepare + $(call Host/Prepare/Default) + ln -snf $(notdir $(HOST_BUILD_DIR)) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) + $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/ +endef + +define Host/Configure + (cd $(HOST_BUILD_DIR); \ + $(YASM_CONFIGURE) \ + ); +endef + +define Host/Compile + +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) all +endef + +define Host/Install + $(MAKE) -C $(HOST_BUILD_DIR) \ + prefix=$(TOOLCHAIN_DIR) \ + install +endef + +define Host/Clean + rm -rf \ + $(HOST_BUILD_DIR) \ + $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) +endef + +$(eval $(call HostBuild)) diff --git a/tools/autoconf/Makefile b/tools/autoconf/Makefile index c45855c03d5..6eb64d77d51 100644 --- a/tools/autoconf/Makefile +++ b/tools/autoconf/Makefile @@ -11,7 +11,7 @@ PKG_VERSION:=2.69 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@GNU/autoconf -PKG_MD5SUM:=50f97f4159805e374639a73e2636f22e +PKG_HASH:=64ebcec9f8ac5b2487125a86a7760d2591ac9e1d3dbd59489633f9de62a57684 include $(INCLUDE_DIR)/host-build.mk diff --git a/tools/bison/Makefile b/tools/bison/Makefile index 256512116f9..68e06ae33b5 100644 --- a/tools/bison/Makefile +++ b/tools/bison/Makefile @@ -1,5 +1,5 @@ -# -# Copyright (C) 2008-2013 OpenWrt.org +# +# Copyright (C) 2008-2015 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -7,12 +7,11 @@ include $(TOPDIR)/rules.mk PKG_NAME:=bison -PKG_VERSION:=3.0.2 +PKG_VERSION:=3.0.5 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@GNU/$(PKG_NAME) -PKG_MD5SUM:=146be9ff9fbd27497f0bf2286a5a2082 -PKG_CAT:=xzcat +PKG_HASH:=075cef2e814642e30e10e8155e93022e4a91ca38a65aa1d5467d4e969f97f338 HOST_BUILD_PARALLEL:=1 diff --git a/tools/bison/patches/100-fix-gets-removal.patch b/tools/bison/patches/100-fix-gets-removal.patch index b9c878a2771..563c12040c5 100644 --- a/tools/bison/patches/100-fix-gets-removal.patch +++ b/tools/bison/patches/100-fix-gets-removal.patch @@ -1,6 +1,8 @@ +diff --git a/lib/stdio.in.h b/lib/stdio.in.h +index ff7c9c8..f391832 100644 --- a/lib/stdio.in.h +++ b/lib/stdio.in.h -@@ -714,13 +714,6 @@ +@@ -739,14 +739,6 @@ _GL_WARN_ON_USE (getline, "getline is unportable - " # endif #endif @@ -8,9 +10,10 @@ - so any use of gets warrants an unconditional warning; besides, C11 - removed it. */ -#undef gets --#if HAVE_RAW_DECL_GETS +-#if HAVE_RAW_DECL_GETS && !defined __cplusplus -_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); -#endif - - +- #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ + struct obstack; + /* Grow an obstack with formatted output. Return the number of diff --git a/tools/e2fsprogs/Makefile b/tools/e2fsprogs/Makefile index 5632e1949d3..676da26e751 100644 --- a/tools/e2fsprogs/Makefile +++ b/tools/e2fsprogs/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2010-2013 OpenWrt.org +# Copyright (C) 2010-2015 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=e2fsprogs -PKG_VERSION:=1.42.8 -PKG_MD5SUM:=8ef664b6eb698aa6b733df59b17b9ed4 +PKG_VERSION:=1.44.1 +PKG_HASH:=0ca164c1c87724df904c918b2d7051ef989b51de725db66c67514dbe6dd2b9ef PKG_RELEASE:=1 -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=@SF/e2fsprogs +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=@KERNEL/linux/kernel/people/tytso/e2fsprogs/v$(PKG_VERSION)/ HOST_BUILD_PARALLEL:=1 @@ -22,10 +22,8 @@ include $(INCLUDE_DIR)/host-build.mk HOST_CFLAGS += $(FPIC) HOST_CONFIGURE_ARGS += \ - --disable-shared \ --disable-elf-shlibs \ - --enable-static \ - --enable-dynamic-e2fsck \ + --enable-libuuid \ --disable-tls \ --disable-nls diff --git a/tools/e2fsprogs/patches/002-dont-build-e4defrag.patch b/tools/e2fsprogs/patches/002-dont-build-e4defrag.patch index 9f6e7b1cefc..2a7842f6554 100644 --- a/tools/e2fsprogs/patches/002-dont-build-e4defrag.patch +++ b/tools/e2fsprogs/patches/002-dont-build-e4defrag.patch @@ -8,4 +8,4 @@ +@DEFRAG_CMT@@LINUX_CMT@E4DEFRAG_PROG= @DEFRAG_CMT@@LINUX_CMT@E4DEFRAG_MAN= e4defrag.8 - @IMAGER_CMT@E2IMAGE_PROG= e2image + @LINUX_CMT@E4CRYPT_PROG = e4crypt diff --git a/tools/e2fsprogs/patches/003-openbsd-compat.patch b/tools/e2fsprogs/patches/003-openbsd-compat.patch index 1f7cdca0e56..492b8a88608 100644 --- a/tools/e2fsprogs/patches/003-openbsd-compat.patch +++ b/tools/e2fsprogs/patches/003-openbsd-compat.patch @@ -1,7 +1,6 @@ -diff -Nur e2fsprogs-1.42.7.orig/lib/blkid/getsize.c e2fsprogs-1.42.7/lib/blkid/getsize.c ---- e2fsprogs-1.42.7.orig/lib/blkid/getsize.c Fri Nov 30 03:40:18 2012 -+++ e2fsprogs-1.42.7/lib/blkid/getsize.c Thu Mar 7 14:21:59 2013 -@@ -26,6 +26,9 @@ +--- a/lib/blkid/getsize.c ++++ b/lib/blkid/getsize.c +@@ -29,6 +29,9 @@ #include #ifdef HAVE_SYS_IOCTL_H #include @@ -11,14 +10,3 @@ diff -Nur e2fsprogs-1.42.7.orig/lib/blkid/getsize.c e2fsprogs-1.42.7/lib/blkid/g #endif #ifdef HAVE_LINUX_FD_H #include -diff -Nur e2fsprogs-1.42.7.orig/lib/quota/mkquota.c e2fsprogs-1.42.7/lib/quota/mkquota.c ---- e2fsprogs-1.42.7.orig/lib/quota/mkquota.c Wed Jan 2 01:47:20 2013 -+++ e2fsprogs-1.42.7/lib/quota/mkquota.c Thu Mar 7 14:21:59 2013 -@@ -8,6 +8,7 @@ - #include - #include - #include -+#include - #include - #include - diff --git a/tools/e2fsprogs/patches/004-darwin-compat.patch b/tools/e2fsprogs/patches/004-darwin-compat.patch new file mode 100644 index 00000000000..d84aa121ca5 --- /dev/null +++ b/tools/e2fsprogs/patches/004-darwin-compat.patch @@ -0,0 +1,22 @@ +--- a/lib/blkid/blkid_types.h.in ++++ b/lib/blkid/blkid_types.h.in +@@ -9,6 +9,8 @@ + + @ASM_TYPES_HEADER@ + ++#include ++ + #ifndef HAVE___U8 + #define HAVE___U8 + #ifdef __U8_TYPEDEF +--- a/lib/ext2fs/ext2_types.h.in ++++ b/lib/ext2fs/ext2_types.h.in +@@ -9,6 +9,8 @@ + + @ASM_TYPES_HEADER@ + ++#include ++ + #ifndef HAVE___U8 + #define HAVE___U8 + #ifdef __U8_TYPEDEF diff --git a/tools/e2fsprogs/patches/004-freebsd-compat.patch b/tools/e2fsprogs/patches/004-freebsd-compat.patch deleted file mode 100644 index 5eff49999e2..00000000000 --- a/tools/e2fsprogs/patches/004-freebsd-compat.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff -Nur e2fsprogs-1.42.7.orig/lib/ext2fs/tdb.c e2fsprogs-1.42.7/lib/ext2fs/tdb.c ---- e2fsprogs-1.42.7.orig/lib/ext2fs/tdb.c 2012-07-06 15:37:27.000000000 +0200 -+++ e2fsprogs-1.42.7/lib/ext2fs/tdb.c 2013-03-07 14:54:59.000000000 +0100 -@@ -56,7 +56,9 @@ - #include - #endif - #include -+#ifndef __FreeBSD__ - #include -+#endif - #include - - #ifdef HAVE_SYS_MMAN_H diff --git a/tools/findutils/Makefile b/tools/findutils/Makefile index 970cff81464..b07c53d9f67 100644 --- a/tools/findutils/Makefile +++ b/tools/findutils/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2013 OpenWrt.org +# Copyright (C) 2006-2016 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -7,11 +7,11 @@ include $(TOPDIR)/rules.mk PKG_NAME:=findutils -PKG_VERSION:=4.4.2 +PKG_VERSION:=4.6.0 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@GNU/$(PKG_NAME) -PKG_MD5SUM:=351cc4adb07d54877fa15f75fb77d39f +PKG_HASH:=ded4c9f73731cd48fec3b6bdaccce896473b6d8e337e9612e16cf1431bb1169d HOST_BUILD_PARALLEL:=1 diff --git a/tools/findutils/patches/100-include_sysmacros.patch b/tools/findutils/patches/100-include_sysmacros.patch new file mode 100644 index 00000000000..82b1ee9a42b --- /dev/null +++ b/tools/findutils/patches/100-include_sysmacros.patch @@ -0,0 +1,13 @@ +--- a/gl/lib/mountlist.c ++++ b/gl/lib/mountlist.c +@@ -17,6 +17,10 @@ + + #include + ++#ifdef MAJOR_IN_SYSMACROS ++# include ++#endif ++ + #include "mountlist.h" + + #include diff --git a/tools/findutils/patches/110-glibc-change-work-around.patch b/tools/findutils/patches/110-glibc-change-work-around.patch new file mode 100644 index 00000000000..91b69274c8e --- /dev/null +++ b/tools/findutils/patches/110-glibc-change-work-around.patch @@ -0,0 +1,104 @@ +Subject: Workaround change in glibc + +Temporary workaround to compile with glibc 2.28, which +deprecated some constants + +Based on the workaround made for the tools/m4 package + +--- a/gl/lib/stdio-impl.h ++++ b/gl/lib/stdio-impl.h +@@ -18,6 +18,12 @@ + the same implementation of stdio extension API, except that some fields + have different naming conventions, or their access requires some casts. */ + ++/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around this ++ problem by defining it ourselves. FIXME: Do not rely on glibc ++ internals. */ ++#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN ++# define _IO_IN_BACKUP 0x100 ++#endif + + /* BSD stdio derived implementations. */ + +--- a/gl/lib/freadahead.c ++++ b/gl/lib/freadahead.c +@@ -25,7 +25,7 @@ + size_t + freadahead (FILE *fp) + { +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + if (fp->_IO_write_ptr > fp->_IO_write_base) + return 0; + return (fp->_IO_read_end - fp->_IO_read_ptr) +--- a/gl/lib/fseeko.c ++++ b/gl/lib/fseeko.c +@@ -47,7 +47,7 @@ fseeko (FILE *fp, off_t offset, int when + #endif + + /* These tests are based on fpurge.c. */ +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + if (fp->_IO_read_end == fp->_IO_read_ptr + && fp->_IO_write_ptr == fp->_IO_write_base + && fp->_IO_save_base == NULL) +@@ -123,7 +123,7 @@ fseeko (FILE *fp, off_t offset, int when + return -1; + } + +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + fp->_flags &= ~_IO_EOF_SEEN; + fp->_offset = pos; + #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ +--- a/gl/lib/fflush.c ++++ b/gl/lib/fflush.c +@@ -33,7 +33,7 @@ + #undef fflush + + +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + + /* Clear the stream's ungetc buffer, preserving the value of ftello (fp). */ + static void +@@ -72,7 +72,7 @@ clear_ungetc_buffer (FILE *fp) + + #endif + +-#if ! (defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */) ++#if ! (defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */) + + # if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */ +@@ -148,7 +148,7 @@ rpl_fflush (FILE *stream) + if (stream == NULL || ! freading (stream)) + return fflush (stream); + +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + + clear_ungetc_buffer_preserving_position (stream); + +--- a/gl/lib/freading.c ++++ b/gl/lib/freading.c +@@ -31,7 +31,7 @@ freading (FILE *fp) + /* Most systems provide FILE as a struct and the necessary bitmask in + , because they need it for implementing getc() and putc() as + fast macros. */ +-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + return ((fp->_flags & _IO_NO_WRITES) != 0 + || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0 + && fp->_IO_read_base != NULL)); +--- a/gl/lib/fpurge.c ++++ b/gl/lib/fpurge.c +@@ -62,7 +62,7 @@ fpurge (FILE *fp) + /* Most systems provide FILE as a struct and the necessary bitmask in + , because they need it for implementing getc() and putc() as + fast macros. */ +-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + fp->_IO_read_end = fp->_IO_read_ptr; + fp->_IO_write_ptr = fp->_IO_write_base; + /* Avoid memory leak when there is an active ungetc buffer. */ diff --git a/tools/findutils/patches/21-Fix-time_t-vs-long-int-mismatches.patch b/tools/findutils/patches/21-Fix-time_t-vs-long-int-mismatches.patch deleted file mode 100644 index f3ebb0520b8..00000000000 --- a/tools/findutils/patches/21-Fix-time_t-vs-long-int-mismatches.patch +++ /dev/null @@ -1,158 +0,0 @@ ->From 0078a6c784da339cc529b4f0bf1156ca52692e4c Mon Sep 17 00:00:00 2001 -From: Adam Borowski -Date: Thu, 6 Jun 2013 18:41:53 +0000 -Subject: [PATCH] Fix time_t vs long int mismatches. - -Old gnulibs used randomly either time_t or long int, with a compile-time -assert to ensure sizeof(time_t) <= sizeof(long int). This is not the -case on x32 where the machine word is 32 bit, yet time_t is 64 bit to -be able to handle dates after 2038. - -This is not relevant for modern versions of gnulib which has rewritten -this code, but, sadly, findutils 4.4.* uses an embedded copy of ancient -gnulib. ---- - gnulib/lib/getdate.y | 46 ++++++++++++++++++++++++---------------------- - 1 file changed, 24 insertions(+), 22 deletions(-) - -diff --git a/gnulib/lib/getdate.y b/gnulib/lib/getdate.y -index e292f5e..347cc77 100644 ---- a/gnulib/lib/getdate.y -+++ b/gnulib/lib/getdate.y -@@ -112,16 +112,18 @@ - /* Lots of this code assumes time_t and time_t-like values fit into - long int. It also assumes that signed integer overflow silently - wraps around, but there's no portable way to check for that at -- compile-time. */ -+ compile-time. -+ [1KB]: replaced suspicious uses of long_t by time_t. - verify (TYPE_IS_INTEGER (time_t)); - verify (LONG_MIN <= TYPE_MINIMUM (time_t) && TYPE_MAXIMUM (time_t) <= LONG_MAX); -+*/ - - /* An integer value, and the number of digits in its textual - representation. */ - typedef struct - { - bool negative; -- long int value; -+ time_t value; - size_t digits; - } textint; - -@@ -206,7 +208,7 @@ typedef struct - union YYSTYPE; - static int yylex (union YYSTYPE *, parser_control *); - static int yyerror (parser_control const *, char const *); --static long int time_zone_hhmm (textint, long int); -+static time_t time_zone_hhmm (textint, time_t); - - /* Extract into *PC any date and time info from a string of digits - of the form e.g., YYYYMMDD, YYMMDD, HHMM, HH (and sometimes YYY, -@@ -817,8 +819,8 @@ static table const military_table[] = - minutes. If MM is negative, then S is of the form HHMM and needs - to be picked apart; otherwise, S is of the form HH. */ - --static long int --time_zone_hhmm (textint s, long int mm) -+static time_t -+time_zone_hhmm (textint s, time_t mm) - { - if (mm < 0) - return (s.value / 100) * 60 + s.value % 100; -@@ -884,7 +886,7 @@ lookup_zone (parser_control const *pc, char const *name) - measured in seconds, ignoring leap seconds. - The body of this function is taken directly from the GNU C Library; - see src/strftime.c. */ --static long int -+static time_t - tm_diff (struct tm const *a, struct tm const *b) - { - /* Compute intervening leap days correctly even if year is negative. -@@ -896,9 +898,9 @@ tm_diff (struct tm const *a, struct tm const *b) - int a400 = SHR (a100, 2); - int b400 = SHR (b100, 2); - int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); -- long int ayear = a->tm_year; -- long int years = ayear - b->tm_year; -- long int days = (365 * years + intervening_leap_days -+ time_t ayear = a->tm_year; -+ time_t years = ayear - b->tm_year; -+ time_t int days = (365 * years + intervening_leap_days - + (a->tm_yday - b->tm_yday)); - return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour)) - + (a->tm_min - b->tm_min)) -@@ -1200,7 +1202,7 @@ bool - get_date (struct timespec *result, char const *p, struct timespec const *now) - { - time_t Start; -- long int Start_ns; -+ time_t Start_ns; - struct tm const *tmp; - struct tm tm; - struct tm tm0; -@@ -1407,16 +1409,16 @@ get_date (struct timespec *result, char const *p, struct timespec const *now) - problem, set the time zone to 1 hour behind UTC temporarily - by setting TZ="XXX1:00" and try mktime again. */ - -- long int time_zone = pc.time_zone; -- long int abs_time_zone = time_zone < 0 ? - time_zone : time_zone; -- long int abs_time_zone_hour = abs_time_zone / 60; -+ time_t time_zone = pc.time_zone; -+ time_t abs_time_zone = time_zone < 0 ? - time_zone : time_zone; -+ time_t abs_time_zone_hour = abs_time_zone / 60; - int abs_time_zone_min = abs_time_zone % 60; - char tz1buf[sizeof "XXX+0:00" - + sizeof pc.time_zone * CHAR_BIT / 3]; - if (!tz_was_altered) - tz0 = get_tz (tz0buf); - sprintf (tz1buf, "XXX%s%ld:%02d", "-" + (time_zone < 0), -- abs_time_zone_hour, abs_time_zone_min); -+ (long int)abs_time_zone_hour, abs_time_zone_min); - if (setenv ("TZ", tz1buf, 1) != 0) - goto fail; - tz_was_altered = true; -@@ -1439,7 +1441,7 @@ get_date (struct timespec *result, char const *p, struct timespec const *now) - - if (pc.zones_seen) - { -- long int delta = pc.time_zone * 60; -+ time_t delta = pc.time_zone * 60; - time_t t1; - #ifdef HAVE_TM_GMTOFF - delta -= tm.tm_gmtoff; -@@ -1486,16 +1488,16 @@ get_date (struct timespec *result, char const *p, struct timespec const *now) - must be applied before relative times, and if mktime is applied - again the time zone will be lost. */ - { -- long int sum_ns = pc.seconds.tv_nsec + pc.rel.ns; -- long int normalized_ns = (sum_ns % BILLION + BILLION) % BILLION; -+ time_t sum_ns = pc.seconds.tv_nsec + pc.rel.ns; -+ time_t normalized_ns = (sum_ns % BILLION + BILLION) % BILLION; - time_t t0 = Start; -- long int d1 = 60 * 60 * pc.rel.hour; -+ time_t d1 = 60 * 60 * pc.rel.hour; - time_t t1 = t0 + d1; -- long int d2 = 60 * pc.rel.minutes; -+ time_t d2 = 60 * pc.rel.minutes; - time_t t2 = t1 + d2; -- long int d3 = pc.rel.seconds; -+ time_t d3 = pc.rel.seconds; - time_t t3 = t2 + d3; -- long int d4 = (sum_ns - normalized_ns) / BILLION; -+ time_t d4 = (sum_ns - normalized_ns) / BILLION; - time_t t4 = t3 + d4; - - if ((d1 / (60 * 60) ^ pc.rel.hour) -@@ -1542,7 +1544,7 @@ main (int ac, char **av) - printf ("Bad format - couldn't convert.\n"); - else if (! (tm = localtime (&d.tv_sec))) - { -- long int sec = d.tv_sec; -+ time_t sec = d.tv_sec; - printf ("localtime (%ld) failed\n", sec); - } - else --- -1.8.3.rc3 - diff --git a/tools/m4/Makefile b/tools/m4/Makefile index 47c332123be..a6d931b0fd5 100644 --- a/tools/m4/Makefile +++ b/tools/m4/Makefile @@ -7,11 +7,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=m4 -PKG_VERSION:=1.4.17 +PKG_CPE_ID:=cpe:/a:gnu:m4 +PKG_VERSION:=1.4.18 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@GNU/$(PKG_NAME) -PKG_MD5SUM:=12a3c829301a4fd6586a57d3fcf196dc +PKG_HASH:=f2c1e86ca0a404ff281631bdc8377638992744b175afb806e25871a24a934e07 PKG_CAT:=xzcat HOST_BUILD_PARALLEL:=1 diff --git a/tools/m4/patches/0003-c-stack-stop-using-SIGSTKSZ.patch b/tools/m4/patches/0003-c-stack-stop-using-SIGSTKSZ.patch new file mode 100644 index 00000000000..a1cc9ae7723 --- /dev/null +++ b/tools/m4/patches/0003-c-stack-stop-using-SIGSTKSZ.patch @@ -0,0 +1,106 @@ +c-stack: stop using SIGSTKSZ + +It’s been proposed to stop making SIGSTKSZ an integer constant: +https://sourceware.org/pipermail/libc-alpha/2020-September/118028.html +Also, using SIGSTKSZ in #if did not conform to current POSIX. +Also, avoiding SIGSTKSZ makes the code simpler and easier to grok. +* lib/c-stack.c (SIGSTKSZ): Remove. +(alternate_signal_stack): Now a 64 KiB array, for simplicity. +All uses changed. + +[Retrieved (and backported) from: +https://git.savannah.gnu.org/cgit/gnulib.git/patch/?id=f9e2b20a12a230efa30f1d479563ae07d276a94b] +Signed-off-by: Fabrice Fontaine + +diff -Nura m4-1.4.18.orig/lib/c-stack.c m4-1.4.18/lib/c-stack.c +--- m4-1.4.18.orig/lib/c-stack.c 2021-04-11 19:12:14.086494029 +0200 ++++ m4-1.4.18/lib/c-stack.c 2021-04-11 19:48:46.316862760 +0200 +@@ -50,15 +50,16 @@ + #if ! HAVE_STACK_T && ! defined stack_t + typedef struct sigaltstack stack_t; + #endif +-#ifndef SIGSTKSZ +-# define SIGSTKSZ 16384 +-#elif HAVE_LIBSIGSEGV && SIGSTKSZ < 16384 +-/* libsigsegv 2.6 through 2.8 have a bug where some architectures use +- more than the Linux default of an 8k alternate stack when deciding +- if a fault was caused by stack overflow. */ +-# undef SIGSTKSZ +-# define SIGSTKSZ 16384 +-#endif ++ ++/* Storage for the alternate signal stack. ++ 64 KiB is not too large for Gnulib-using apps, and is large enough ++ for all known platforms. Smaller sizes may run into trouble. ++ For example, libsigsegv 2.6 through 2.8 have a bug where some ++ architectures use more than the Linux default of an 8 KiB alternate ++ stack when deciding if a fault was caused by stack overflow. */ ++static max_align_t alternate_signal_stack[(64 * 1024 ++ + sizeof (max_align_t) - 1) ++ / sizeof (max_align_t)]; + + #include + #include +@@ -128,19 +129,6 @@ + #if (HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK \ + && HAVE_STACK_OVERFLOW_HANDLING) || HAVE_LIBSIGSEGV + +-/* Storage for the alternate signal stack. */ +-static union +-{ +- char buffer[SIGSTKSZ]; +- +- /* These other members are for proper alignment. There's no +- standard way to guarantee stack alignment, but this seems enough +- in practice. */ +- long double ld; +- long l; +- void *p; +-} alternate_signal_stack; +- + static void + null_action (int signo __attribute__ ((unused))) + { +@@ -205,8 +193,8 @@ + + /* Always install the overflow handler. */ + if (stackoverflow_install_handler (overflow_handler, +- alternate_signal_stack.buffer, +- sizeof alternate_signal_stack.buffer)) ++ alternate_signal_stack, ++ sizeof alternate_signal_stack)) + { + errno = ENOTSUP; + return -1; +@@ -279,14 +267,14 @@ + stack_t st; + struct sigaction act; + st.ss_flags = 0; ++ st.ss_sp = alternate_signal_stack; ++ st.ss_size = sizeof alternate_signal_stack; + # if SIGALTSTACK_SS_REVERSED + /* Irix mistakenly treats ss_sp as the upper bound, rather than + lower bound, of the alternate stack. */ +- st.ss_sp = alternate_signal_stack.buffer + SIGSTKSZ - sizeof (void *); +- st.ss_size = sizeof alternate_signal_stack.buffer - sizeof (void *); +-# else +- st.ss_sp = alternate_signal_stack.buffer; +- st.ss_size = sizeof alternate_signal_stack.buffer; ++ st.ss_size -= sizeof (void *); ++ char *ss_sp = st.ss_sp; ++ st.ss_sp = ss_sp + st.ss_size; + # endif + r = sigaltstack (&st, NULL); + if (r != 0) +diff -Nura m4-1.4.18.orig/lib/c-stack.h m4-1.4.18/lib/c-stack.h +--- m4-1.4.18.orig/lib/c-stack.h 2021-04-11 19:12:14.098494042 +0200 ++++ m4-1.4.18/lib/c-stack.h 2021-04-11 19:17:42.138848378 +0200 +@@ -34,7 +34,7 @@ + A null ACTION acts like an action that does nothing. + + ACTION must be async-signal-safe. ACTION together with its callees +- must not require more than SIGSTKSZ bytes of stack space. Also, ++ must not require more than 64 KiB bytes of stack space. Also, + ACTION should not call longjmp, because this implementation does + not guarantee that it is safe to return to the original stack. + diff --git a/tools/m4/patches/001-fix-macos-vasnprintf.patch b/tools/m4/patches/001-fix-macos-vasnprintf.patch new file mode 100644 index 00000000000..e41315d34ec --- /dev/null +++ b/tools/m4/patches/001-fix-macos-vasnprintf.patch @@ -0,0 +1,25 @@ +--- a/lib/vasnprintf.c ++++ b/lib/vasnprintf.c +@@ -4858,7 +4858,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t * + #endif + *fbp = dp->conversion; + #if USE_SNPRINTF +-# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) ++# if ! (((__GLIBC__ > 2 \ ++ || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) \ ++ && !defined __UCLIBC__) \ ++ || (defined __APPLE__ && defined __MACH__) \ ++ || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) + fbp[1] = '%'; + fbp[2] = 'n'; + fbp[3] = '\0'; +@@ -4872,6 +4876,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t * + in format strings in writable memory may crash the program + (if compiled with _FORTIFY_SOURCE=2), so we should avoid it + in this situation. */ ++ /* macOS 10.13 High Sierra behaves like glibc with ++ _FORTIFY_SOURCE=2, and older macOS releases ++ presumably do not need %n. */ + /* On native Windows systems (such as mingw), we can avoid using + %n because: + - Although the gl_SNPRINTF_TRUNCATION_C99 test fails, diff --git a/tools/m4/patches/010-glibc-change-work-around.patch b/tools/m4/patches/010-glibc-change-work-around.patch new file mode 100644 index 00000000000..0ef6216965c --- /dev/null +++ b/tools/m4/patches/010-glibc-change-work-around.patch @@ -0,0 +1,118 @@ +Subject: Workaround change in glibc + +Temporary workaround to compile with glibc 2.28, which +deprecated some constants + +Taken from the rpms/m4 Fedora repository, commit 814d5921 +(Work around change in glibc) + +Original filename: m4-1.4.18-glibc-change-work-around.patch + +--- a/lib/stdio-impl.h ++++ b/lib/stdio-impl.h +@@ -18,6 +18,12 @@ + the same implementation of stdio extension API, except that some fields + have different naming conventions, or their access requires some casts. */ + ++/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around this ++ problem by defining it ourselves. FIXME: Do not rely on glibc ++ internals. */ ++#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN ++# define _IO_IN_BACKUP 0x100 ++#endif + + /* BSD stdio derived implementations. */ + +--- a/lib/fflush.c ++++ b/lib/fflush.c +@@ -33,7 +33,7 @@ + #undef fflush + + +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + + /* Clear the stream's ungetc buffer, preserving the value of ftello (fp). */ + static void +@@ -72,7 +72,7 @@ clear_ungetc_buffer (FILE *fp) + + #endif + +-#if ! (defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */) ++#if ! (defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */) + + # if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */ +@@ -148,7 +148,7 @@ rpl_fflush (FILE *stream) + if (stream == NULL || ! freading (stream)) + return fflush (stream); + +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + + clear_ungetc_buffer_preserving_position (stream); + +--- a/lib/fpending.c ++++ b/lib/fpending.c +@@ -32,7 +32,7 @@ __fpending (FILE *fp) + /* Most systems provide FILE as a struct and the necessary bitmask in + , because they need it for implementing getc() and putc() as + fast macros. */ +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + return fp->_IO_write_ptr - fp->_IO_write_base; + #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */ +--- a/lib/fpurge.c ++++ b/lib/fpurge.c +@@ -62,7 +62,7 @@ fpurge (FILE *fp) + /* Most systems provide FILE as a struct and the necessary bitmask in + , because they need it for implementing getc() and putc() as + fast macros. */ +-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + fp->_IO_read_end = fp->_IO_read_ptr; + fp->_IO_write_ptr = fp->_IO_write_base; + /* Avoid memory leak when there is an active ungetc buffer. */ +--- a/lib/freadahead.c ++++ b/lib/freadahead.c +@@ -25,7 +25,7 @@ + size_t + freadahead (FILE *fp) + { +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + if (fp->_IO_write_ptr > fp->_IO_write_base) + return 0; + return (fp->_IO_read_end - fp->_IO_read_ptr) +--- a/lib/freading.c ++++ b/lib/freading.c +@@ -31,7 +31,7 @@ freading (FILE *fp) + /* Most systems provide FILE as a struct and the necessary bitmask in + , because they need it for implementing getc() and putc() as + fast macros. */ +-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + return ((fp->_flags & _IO_NO_WRITES) != 0 + || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0 + && fp->_IO_read_base != NULL)); +--- a/lib/fseeko.c ++++ b/lib/fseeko.c +@@ -47,7 +47,7 @@ fseeko (FILE *fp, off_t offset, int when + #endif + + /* These tests are based on fpurge.c. */ +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + if (fp->_IO_read_end == fp->_IO_read_ptr + && fp->_IO_write_ptr == fp->_IO_write_base + && fp->_IO_save_base == NULL) +@@ -123,7 +123,7 @@ fseeko (FILE *fp, off_t offset, int when + return -1; + } + +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + fp->_flags &= ~_IO_EOF_SEEN; + fp->_offset = pos; + #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ diff --git a/tools/m4/patches/100-fix-gets-removal.patch b/tools/m4/patches/100-fix-gets-removal.patch deleted file mode 100644 index ecd110d934e..00000000000 --- a/tools/m4/patches/100-fix-gets-removal.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- a/lib/stdio.in.h -+++ b/lib/stdio.in.h -@@ -714,14 +714,6 @@ _GL_WARN_ON_USE (getline, "getline is un - # endif - #endif - --/* It is very rare that the developer ever has full control of stdin, -- so any use of gets warrants an unconditional warning; besides, C11 -- removed it. */ --#undef gets --#if HAVE_RAW_DECL_GETS --_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); --#endif -- - - #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ - struct obstack; diff --git a/tools/make-ext4fs/Makefile b/tools/make-ext4fs/Makefile index 7f09c36bacd..a886dc0a717 100644 --- a/tools/make-ext4fs/Makefile +++ b/tools/make-ext4fs/Makefile @@ -1,5 +1,6 @@ # # Copyright (C) 2015 OpenWrt.org +# Copyright (C) 2016 LEDE project # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -7,23 +8,21 @@ include $(TOPDIR)/rules.mk PKG_NAME:=make-ext4fs -PKG_VERSION:=2015-05-01 -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=http://git.openwrt.org/project/make_ext4fs.git -PKG_SOURCE_BRANCH:=openwrt/master +PKG_SOURCE_URL=$(LEDE_GIT)/project/make_ext4fs.git PKG_SOURCE_PROTO:=git -PKG_SOURCE_VERSION:=7c15bef6c732896d9ffb883fb1480fcd60c94a50 -PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) -PKG_MIRROR_MD5SUM:=d81eca37852cbf840108e1a8ad8fb22f -PKG_CAT:=zcat - -HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_DATE:=2016-08-14 +PKG_SOURCE_VERSION:=484903e4332be6c317f531b008cb2a841a18c506 +PKG_MIRROR_HASH:=d7ccd5e426b1d15331ff000a37dc15161f6eef594453e970fd584fcde5a25075 include $(INCLUDE_DIR)/host-build.mk +ifeq ($(HOST_OS),Linux) + MAKE_STATIC := STATIC=1 +endif + define Host/Compile - $(MAKE) -C $(HOST_BUILD_DIR) make_ext4fs + $(MAKE) -C $(HOST_BUILD_DIR) make_ext4fs $(MAKE_STATIC) endef define Host/Install diff --git a/tools/mkimage/Makefile b/tools/mkimage/Makefile index f73cc563184..bfe60993e27 100644 --- a/tools/mkimage/Makefile +++ b/tools/mkimage/Makefile @@ -13,7 +13,7 @@ PKG_SOURCE:=u-boot-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=\ http://mirror2.openwrt.org/sources \ ftp://ftp.denx.de/pub/u-boot -PKG_MD5SUM:=3ddcaee2f05b7c464778112ec83664b5 +PKG_HASH:=d3b132a7a9b3f3182b7aad71c2dfbd4fc15bea83e12c76134eb3ffefc07d1c71 PKG_CAT:=bzcat HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/u-boot-$(PKG_VERSION) @@ -31,8 +31,8 @@ define Host/Prepare endef define Host/Compile - $(MAKE) -C $(HOST_BUILD_DIR) defconfig HOSTCFLAGS="$(HOST_CPPFLAGS) $(HOST_CFLAGS)" HOSTLDFLAGS="$(HOST_LDFLAGS)" - $(MAKE) -C $(HOST_BUILD_DIR) tools-only HOSTCFLAGS="$(HOST_CPPFLAGS) $(HOST_CFLAGS)" HOSTLDFLAGS="$(HOST_LDFLAGS)" + $(MAKE) -C $(HOST_BUILD_DIR) defconfig HOSTCFLAGS="$(HOST_CPPFLAGS) $(HOST_CFLAGS)" HOSTLDFLAGS="$(HOST_LDFLAGS)" HOST_LOADLIBES="$$$$(pkg-config --static --libs libcrypto)" + $(MAKE) -C $(HOST_BUILD_DIR) tools-only HOSTCFLAGS="$(HOST_CPPFLAGS) $(HOST_CFLAGS)" HOSTLDFLAGS="$(HOST_LDFLAGS)" HOST_LOADLIBES="$$$$(pkg-config --static --libs libcrypto)" endef define Host/Install diff --git a/tools/mkimage/patches/010-freebsd-ulong-fix.patch b/tools/mkimage/patches/010-freebsd-ulong-fix.patch index 75b9e892ad0..1101e72d15b 100644 --- a/tools/mkimage/patches/010-freebsd-ulong-fix.patch +++ b/tools/mkimage/patches/010-freebsd-ulong-fix.patch @@ -1,6 +1,6 @@ --- a/include/image.h +++ b/include/image.h -@@ -44,6 +44,10 @@ +@@ -44,6 +44,10 @@ struct lmb; #endif /* USE_HOSTCC */ diff --git a/tools/mkimage/patches/030-allow-to-use-different-magic.patch b/tools/mkimage/patches/030-allow-to-use-different-magic.patch index d5afdd35b29..dcab48894c0 100644 --- a/tools/mkimage/patches/030-allow-to-use-different-magic.patch +++ b/tools/mkimage/patches/030-allow-to-use-different-magic.patch @@ -1,6 +1,6 @@ --- a/tools/mkimage.c +++ b/tools/mkimage.c -@@ -24,6 +24,7 @@ +@@ -24,6 +24,7 @@ struct image_tool_params params = { .arch = IH_ARCH_PPC, .type = IH_TYPE_KERNEL, .comp = IH_COMP_GZIP, @@ -8,7 +8,7 @@ .dtc = MKIMAGE_DEFAULT_DTC_OPTIONS, .imagename = "", .imagename2 = "", -@@ -168,6 +169,16 @@ +@@ -168,6 +169,16 @@ main (int argc, char **argv) genimg_get_comp_id (*++argv)) < 0) usage (); goto NXTARG; @@ -25,7 +25,7 @@ case 'D': if (--argc <= 0) usage (); -@@ -623,12 +634,13 @@ +@@ -623,12 +634,13 @@ static void usage(void) fprintf (stderr, "Usage: %s -l image\n" " -l ==> list image header information\n", params.cmdname); @@ -42,7 +42,7 @@ " -n ==> set image name to 'name'\n" --- a/tools/default_image.c +++ b/tools/default_image.c -@@ -98,7 +98,7 @@ +@@ -98,7 +98,7 @@ static void image_set_header(void *ptr, sbuf->st_size - sizeof(image_header_t)); /* Build new header */ @@ -53,7 +53,7 @@ image_set_load(hdr, params->addr); --- a/tools/imagetool.h +++ b/tools/imagetool.h -@@ -44,6 +44,7 @@ +@@ -44,6 +44,7 @@ struct image_tool_params { int arch; int type; int comp; diff --git a/tools/mkimage/patches/050-increase-path-and-filename-length.patch b/tools/mkimage/patches/050-increase-path-and-filename-length.patch deleted file mode 100644 index ec4f928c88a..00000000000 --- a/tools/mkimage/patches/050-increase-path-and-filename-length.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/tools/mkimage.h -+++ b/tools/mkimage.h -@@ -43,9 +43,9 @@ - #endif /* MKIMAGE_DEBUG */ - - #define MKIMAGE_TMPFILE_SUFFIX ".tmp" --#define MKIMAGE_MAX_TMPFILE_LEN 256 -+#define MKIMAGE_MAX_TMPFILE_LEN 2048 - #define MKIMAGE_DEFAULT_DTC_OPTIONS "-I dts -O dtb -p 500" --#define MKIMAGE_MAX_DTC_CMDLINE_LEN 512 -+#define MKIMAGE_MAX_DTC_CMDLINE_LEN 2048 - #define MKIMAGE_DTC "dtc" /* assume dtc is in $PATH */ - - /* diff --git a/tools/mkimage/patches/051-increase-dtb-file-size.patch b/tools/mkimage/patches/051-increase-dtb-file-size.patch deleted file mode 100644 index 7b2d5140d39..00000000000 --- a/tools/mkimage/patches/051-increase-dtb-file-size.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/tools/mkimage.h -+++ b/tools/mkimage.h -@@ -42,7 +42,7 @@ - - #define MKIMAGE_TMPFILE_SUFFIX ".tmp" - #define MKIMAGE_MAX_TMPFILE_LEN 2048 --#define MKIMAGE_DEFAULT_DTC_OPTIONS "-I dts -O dtb -p 500" -+#define MKIMAGE_DEFAULT_DTC_OPTIONS "-I dts -O dtb -p 2000" - #define MKIMAGE_MAX_DTC_CMDLINE_LEN 2048 - #define MKIMAGE_DTC "dtc" /* assume dtc is in $PATH */ - diff --git a/tools/mkimage/patches/090-reproducible-SOURCE_DATE_EPOCH.patch b/tools/mkimage/patches/090-reproducible-SOURCE_DATE_EPOCH.patch new file mode 100644 index 00000000000..c238fd62ed4 --- /dev/null +++ b/tools/mkimage/patches/090-reproducible-SOURCE_DATE_EPOCH.patch @@ -0,0 +1,82 @@ +From f3f431a712729a1af94d01bd1bfde17a252ff02c Mon Sep 17 00:00:00 2001 +From: Paul Kocialkowski +Date: Sun, 26 Jul 2015 18:48:15 +0200 +Subject: [PATCH] Reproducible U-Boot build support, using SOURCE_DATE_EPOCH + +In order to achieve reproducible builds in U-Boot, timestamps that are defined +at build-time have to be somewhat eliminated. The SOURCE_DATE_EPOCH environment +variable allows setting a fixed value for those timestamps. + +Simply by setting SOURCE_DATE_EPOCH to a fixed value, a number of targets can be +built reproducibly. This is the case for e.g. sunxi devices. + +However, some other devices might need some more tweaks, especially regarding +the image generation tools. + +Signed-off-by: Paul Kocialkowski +--- + Makefile | 7 ++++--- + README | 12 ++++++++++++ + tools/default_image.c | 21 ++++++++++++++++++++- + 3 files changed, 36 insertions(+), 4 deletions(-) + +--- a/README ++++ b/README +@@ -4928,6 +4928,18 @@ within that device. + normal addressable memory via the LBC. CONFIG_SYS_LS_MC_FW_ADDR is the + virtual address in NOR flash. + ++Reproducible builds ++------------------- ++ ++In order to achieve reproducible builds, timestamps used in the U-Boot build ++process have to be set to a fixed value. ++ ++This is done using the SOURCE_DATE_EPOCH environment variable. ++SOURCE_DATE_EPOCH is to be set on the build host's shell, not as a configuration ++option for U-Boot or an environment variable in U-Boot. ++ ++SOURCE_DATE_EPOCH should be set to a number of seconds since the epoch, in UTC. ++ + Building the Software: + ====================== + +--- a/tools/default_image.c ++++ b/tools/default_image.c +@@ -89,6 +89,9 @@ static void image_set_header(void *ptr, + struct image_tool_params *params) + { + uint32_t checksum; ++ char *source_date_epoch; ++ struct tm *time_universal; ++ time_t time; + + image_header_t * hdr = (image_header_t *)ptr; + +@@ -97,9 +100,25 @@ static void image_set_header(void *ptr, + sizeof(image_header_t)), + sbuf->st_size - sizeof(image_header_t)); + ++ source_date_epoch = getenv("SOURCE_DATE_EPOCH"); ++ if (source_date_epoch != NULL) { ++ time = (time_t) strtol(source_date_epoch, NULL, 10); ++ ++ time_universal = gmtime(&time); ++ if (time_universal == NULL) { ++ fprintf(stderr, "%s: SOURCE_DATE_EPOCH is not valid\n", ++ __func__); ++ time = 0; ++ } else { ++ time = mktime(time_universal); ++ } ++ } else { ++ time = sbuf->st_mtime; ++ } ++ + /* Build new header */ + image_set_magic(hdr, params->magic); +- image_set_time(hdr, sbuf->st_mtime); ++ image_set_time(hdr, time); + image_set_size(hdr, sbuf->st_size - sizeof(image_header_t)); + image_set_load(hdr, params->addr); + image_set_ep(hdr, params->ep); diff --git a/tools/mkimage/patches/200-gcc5_compat.patch b/tools/mkimage/patches/200-gcc5_compat.patch deleted file mode 100644 index 4d55f00a4e8..00000000000 --- a/tools/mkimage/patches/200-gcc5_compat.patch +++ /dev/null @@ -1,93 +0,0 @@ -From 478b02f1a7043b673565075ea5016376f3293b23 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Sat, 7 Feb 2015 22:52:40 +0100 -Subject: [PATCH] Add linux/compiler-gcc5.h to fix builds with gcc5 - -Add linux/compiler-gcc5/h from the kernel sources at: - -commit 5631b8fba640a4ab2f8a954f63a603fa34eda96b -Author: Steven Noonan -Date: Sat Oct 25 15:09:42 2014 -0700 - - compiler/gcc4+: Remove inaccurate comment about 'asm goto' miscompiles - -Signed-off-by: Hans de Goede ---- - include/linux/compiler-gcc5.h | 65 +++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 65 insertions(+) - create mode 100644 include/linux/compiler-gcc5.h - -diff --git a/include/linux/compiler-gcc5.h b/include/linux/compiler-gcc5.h -new file mode 100644 -index 0000000..c8c5659 ---- /dev/null -+++ b/include/linux/compiler-gcc5.h -@@ -0,0 +1,65 @@ -+#ifndef __LINUX_COMPILER_H -+#error "Please don't include directly, include instead." -+#endif -+ -+#define __used __attribute__((__used__)) -+#define __must_check __attribute__((warn_unused_result)) -+#define __compiler_offsetof(a, b) __builtin_offsetof(a, b) -+ -+/* Mark functions as cold. gcc will assume any path leading to a call -+ to them will be unlikely. This means a lot of manual unlikely()s -+ are unnecessary now for any paths leading to the usual suspects -+ like BUG(), printk(), panic() etc. [but let's keep them for now for -+ older compilers] -+ -+ Early snapshots of gcc 4.3 don't support this and we can't detect this -+ in the preprocessor, but we can live with this because they're unreleased. -+ Maketime probing would be overkill here. -+ -+ gcc also has a __attribute__((__hot__)) to move hot functions into -+ a special section, but I don't see any sense in this right now in -+ the kernel context */ -+#define __cold __attribute__((__cold__)) -+ -+#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) -+ -+#ifndef __CHECKER__ -+# define __compiletime_warning(message) __attribute__((warning(message))) -+# define __compiletime_error(message) __attribute__((error(message))) -+#endif /* __CHECKER__ */ -+ -+/* -+ * Mark a position in code as unreachable. This can be used to -+ * suppress control flow warnings after asm blocks that transfer -+ * control elsewhere. -+ * -+ * Early snapshots of gcc 4.5 don't support this and we can't detect -+ * this in the preprocessor, but we can live with this because they're -+ * unreleased. Really, we need to have autoconf for the kernel. -+ */ -+#define unreachable() __builtin_unreachable() -+ -+/* Mark a function definition as prohibited from being cloned. */ -+#define __noclone __attribute__((__noclone__)) -+ -+/* -+ * Tell the optimizer that something else uses this function or variable. -+ */ -+#define __visible __attribute__((externally_visible)) -+ -+/* -+ * GCC 'asm goto' miscompiles certain code sequences: -+ * -+ * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670 -+ * -+ * Work it around via a compiler barrier quirk suggested by Jakub Jelinek. -+ * -+ * (asm goto is automatically volatile - the naming reflects this.) -+ */ -+#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0) -+ -+#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP -+#define __HAVE_BUILTIN_BSWAP32__ -+#define __HAVE_BUILTIN_BSWAP64__ -+#define __HAVE_BUILTIN_BSWAP16__ -+#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */ --- -1.7.10.4 - diff --git a/tools/mkimage/patches/210-openssl-1.1.x-compat.patch b/tools/mkimage/patches/210-openssl-1.1.x-compat.patch new file mode 100644 index 00000000000..fa7c99f39b0 --- /dev/null +++ b/tools/mkimage/patches/210-openssl-1.1.x-compat.patch @@ -0,0 +1,97 @@ +--- a/lib/rsa/rsa-sign.c ++++ b/lib/rsa/rsa-sign.c +@@ -15,10 +15,25 @@ + #include + #include + +-#if OPENSSL_VERSION_NUMBER >= 0x10000000L ++#if OPENSSL_VERSION_NUMBER < 0x10000000L ++#define HAVE_ERR_REMOVE_STATE ++#elif OPENSSL_VERSION_NUMBER < 0x10100000L + #define HAVE_ERR_REMOVE_THREAD_STATE + #endif + ++#if OPENSSL_VERSION_NUMBER < 0x10100005L ++static void RSA_get0_key(const RSA *r, ++ const BIGNUM **n, const BIGNUM **e, const BIGNUM **d) ++{ ++ if (n != NULL) ++ *n = r->n; ++ if (e != NULL) ++ *e = r->e; ++ if (d != NULL) ++ *d = r->d; ++} ++#endif ++ + static int rsa_err(const char *msg) + { + unsigned long sslErr = ERR_get_error(); +@@ -154,7 +169,8 @@ static void rsa_remove(void) + ERR_free_strings(); + #ifdef HAVE_ERR_REMOVE_THREAD_STATE + ERR_remove_thread_state(NULL); +-#else ++#endif ++#ifdef HAVE_ERR_REMOVE_STATE + ERR_remove_state(0); + #endif + EVP_cleanup(); +@@ -210,7 +226,6 @@ static int rsa_sign_with_key(RSA *rsa, s + ret = rsa_err("Could not obtain signature"); + goto err_sign; + } +- EVP_MD_CTX_cleanup(context); + EVP_MD_CTX_destroy(context); + EVP_PKEY_free(key); + +@@ -270,23 +285,26 @@ static int rsa_get_exponent(RSA *key, ui + BIGNUM *bn_te; + uint64_t te; + ++ const BIGNUM *bn_e; ++ RSA_get0_key(key, NULL, &bn_e, NULL); ++ + ret = -EINVAL; + bn_te = NULL; + + if (!e) + goto cleanup; + +- if (BN_num_bits(key->e) > 64) ++ if (BN_num_bits(bn_e) > 64) + goto cleanup; + +- *e = BN_get_word(key->e); ++ *e = BN_get_word(bn_e); + +- if (BN_num_bits(key->e) < 33) { ++ if (BN_num_bits(bn_e) < 33) { + ret = 0; + goto cleanup; + } + +- bn_te = BN_dup(key->e); ++ bn_te = BN_dup(bn_e); + if (!bn_te) + goto cleanup; + +@@ -319,6 +337,9 @@ int rsa_get_params(RSA *key, uint64_t *e + BN_CTX *bn_ctx = BN_CTX_new(); + int ret = 0; + ++ const BIGNUM *bn_n; ++ RSA_get0_key(key, &bn_n, NULL, NULL); ++ + /* Initialize BIGNUMs */ + big1 = BN_new(); + big2 = BN_new(); +@@ -337,7 +358,7 @@ int rsa_get_params(RSA *key, uint64_t *e + if (0 != rsa_get_exponent(key, exponent)) + ret = -1; + +- if (!BN_copy(n, key->n) || !BN_set_word(big1, 1L) || ++ if (!BN_copy(n, bn_n) || !BN_set_word(big1, 1L) || + !BN_set_word(big2, 2L) || !BN_set_word(big32, 32L)) + ret = -1; + diff --git a/tools/mklibs/Makefile b/tools/mklibs/Makefile index 6bf1431b8c3..6df64f24b5b 100644 --- a/tools/mklibs/Makefile +++ b/tools/mklibs/Makefile @@ -7,17 +7,17 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mklibs -PKG_VERSION:=0.1.35 +PKG_VERSION:=0.1.45 -PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.gz +PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=http://ftp.de.debian.org/debian/pool/main/m/mklibs/ -PKG_MD5SUM:=3d2a4bd0bbf5ba964b0a1ecdafd1ea9a - +PKG_HASH:=dd92a904b3942566f713fe536cd77dd1a5cfc62243c0e0bc6bb5d866e37422f3 HOST_FIXUP:=autoreconf include $(INCLUDE_DIR)/host-build.mk HOST_CFLAGS += -I$(CURDIR)/include +HOST_CPPFLAGS += -std=gnu++98 define Host/Install $(INSTALL_BIN) \ diff --git a/tools/mklibs/patches/002-disable_symbol_checks.patch b/tools/mklibs/patches/002-disable_symbol_checks.patch index 44be637609d..96ca7a5f83f 100644 --- a/tools/mklibs/patches/002-disable_symbol_checks.patch +++ b/tools/mklibs/patches/002-disable_symbol_checks.patch @@ -1,20 +1,20 @@ --- a/src/mklibs +++ b/src/mklibs -@@ -524,7 +524,7 @@ while 1: +@@ -533,7 +533,7 @@ while 1: # No progress in last pass. Verify all remaining symbols are weak. for name in unresolved: if not needed_symbols[name].weak: - raise Exception("Unresolvable symbol %s" % name) -+ print "WARNING: Unresolvable symbol %s" % name ++ print("WARNING: Unresolvable symbol %s" % name) break previous_pass_unresolved = unresolved -@@ -559,7 +559,7 @@ while 1: +@@ -568,7 +568,7 @@ while 1: for name in needed_symbols: if not name in symbol_provider: if not needed_symbols[name].weak: - raise Exception("No library provides non-weak %s" % name) -+ print "WARNING: Unresolvable symbol %s" % name ++ print("WARNING: Unresolvable symbol %s" % name) else: lib = symbol_provider[name] library_symbols_used[lib].add(library_symbols[lib][name]) diff --git a/tools/mklibs/patches/003-no_copy.patch b/tools/mklibs/patches/003-no_copy.patch index e0ab2ac88d1..bc1ae8d73dd 100644 --- a/tools/mklibs/patches/003-no_copy.patch +++ b/tools/mklibs/patches/003-no_copy.patch @@ -1,6 +1,6 @@ --- a/src/mklibs +++ b/src/mklibs -@@ -463,7 +463,7 @@ while 1: +@@ -472,7 +472,7 @@ while 1: passnr = passnr + 1 # Gather all already reduced libraries and treat them as objects as well small_libs = [] @@ -9,7 +9,7 @@ obj = dest_path + "/" + lib small_libs.append(obj) inode = os.stat(obj)[ST_INO] -@@ -579,12 +579,7 @@ while 1: +@@ -588,12 +588,7 @@ while 1: if not so_file: sys.exit("File not found:" + library) pic_file = find_pic(library) @@ -23,7 +23,7 @@ # we have a pic file, recompile debug(DEBUG_SPAM, "extracting from:", pic_file, "so_file:", so_file) soname = extract_soname(so_file) -@@ -627,22 +622,14 @@ while 1: +@@ -636,22 +631,14 @@ while 1: cmd.append(library_depends_gcc_libnames(so_file)) command(target + "gcc", *cmd) @@ -32,11 +32,11 @@ - dest_path + "/" + so_file_name + "-so", - dest_path + "/" + so_file_name + "-so-stripped") ## DEBUG - debug(DEBUG_VERBOSE, so_file, "\t", `os.stat(so_file)[ST_SIZE]`) + debug(DEBUG_VERBOSE, so_file, "\t", str(os.stat(so_file)[ST_SIZE])) debug(DEBUG_VERBOSE, dest_path + "/" + so_file_name + "-so", "\t", - `os.stat(dest_path + "/" + so_file_name + "-so")[ST_SIZE]`) + str(os.stat(dest_path + "/" + so_file_name + "-so")[ST_SIZE])) - debug(DEBUG_VERBOSE, dest_path + "/" + so_file_name + "-so-stripped", -- "\t", `os.stat(dest_path + "/" + so_file_name + "-so-stripped")[ST_SIZE]`) +- "\t", str(os.stat(dest_path + "/" + so_file_name + "-so-stripped")[ST_SIZE])) # Finalising libs and cleaning up -for lib in regexpfilter(os.listdir(dest_path), "(.*)-so-stripped$"): @@ -47,4 +47,4 @@ + os.rename(dest_path + "/" + lib + "-so", dest_path + "/" + lib) # Canonicalize library names. - for lib in regexpfilter(os.listdir(dest_path), "(.*so[.\d]*)$"): + for lib in sorted(regexpfilter(os.listdir(dest_path), "(.*so[.\d]*)$")): diff --git a/tools/mklibs/patches/004-libpthread_link.patch b/tools/mklibs/patches/004-libpthread_link.patch index 657e232b0cb..3a630ea288a 100644 --- a/tools/mklibs/patches/004-libpthread_link.patch +++ b/tools/mklibs/patches/004-libpthread_link.patch @@ -17,7 +17,7 @@ if match.group('ld'): ret.append(find_lib(match.group(0))) elif match.group('lib'): -@@ -619,7 +619,7 @@ while 1: +@@ -628,7 +628,7 @@ while 1: cmd.extend(extra_flags) cmd.append("-lgcc") cmd.extend(["-L%s" % a for a in [dest_path] + [sysroot + b for b in lib_path if sysroot == "" or b not in ("/" + libdir + "/", "/usr/" + libdir + "/")]]) diff --git a/tools/mklibs/patches/005-duplicate_syms.patch b/tools/mklibs/patches/005-duplicate_syms.patch index 8428abfc9a0..2627203fabb 100644 --- a/tools/mklibs/patches/005-duplicate_syms.patch +++ b/tools/mklibs/patches/005-duplicate_syms.patch @@ -1,6 +1,6 @@ --- a/src/mklibs +++ b/src/mklibs -@@ -531,7 +531,6 @@ while 1: +@@ -540,7 +540,6 @@ while 1: library_symbols = {} library_symbols_used = {} @@ -8,7 +8,7 @@ # WORKAROUND: Always add libgcc on old-abi arm header = elf_header(find_lib(libraries.copy().pop())) -@@ -549,20 +548,13 @@ while 1: +@@ -558,20 +557,13 @@ while 1: library_symbols_used[library] = set() for symbol in symbols: for name in symbol.base_names(): @@ -23,7 +23,7 @@ for name in needed_symbols: - if not name in symbol_provider: - if not needed_symbols[name].weak: -- print "WARNING: Unresolvable symbol %s" % name +- print("WARNING: Unresolvable symbol %s" % name) - else: - lib = symbol_provider[name] - library_symbols_used[lib].add(library_symbols[lib][name]) @@ -32,4 +32,4 @@ + library_symbols_used[lib].add(library_symbols[lib][name]) # reduce libraries - for library in libraries: + for library in sorted(libraries): diff --git a/tools/mklibs/patches/006-uclibc_init.patch b/tools/mklibs/patches/006-uclibc_init.patch deleted file mode 100644 index 2df7fe43556..00000000000 --- a/tools/mklibs/patches/006-uclibc_init.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/src/mklibs -+++ b/src/mklibs -@@ -595,6 +595,11 @@ while 1: - extra_post_obj.append(sysroot + libc_extras_dir + "/sofini.o") - symbols.add(ProvidedSymbol('__dso_handle', None, None, True)) - -+ if soname in ("libc.so.0"): -+ symbols.add(ProvidedSymbol('__uClibc_init', None, None, True)) -+ symbols.add(ProvidedSymbol('__uClibc_fini', None, None, True)) -+ extra_flags.append("-Wl,-init,__uClibc_init") -+ - map_file = find_pic_map(library) - if map_file: - extra_flags.append("-Wl,--version-script=" + map_file) diff --git a/tools/mklibs/patches/007-gc_sections.patch b/tools/mklibs/patches/007-gc_sections.patch index 068d88a532a..3d098ae4267 100644 --- a/tools/mklibs/patches/007-gc_sections.patch +++ b/tools/mklibs/patches/007-gc_sections.patch @@ -1,6 +1,6 @@ --- a/src/mklibs +++ b/src/mklibs -@@ -607,7 +607,7 @@ while 1: +@@ -611,7 +611,7 @@ while 1: # compile in only used symbols cmd = [] cmd.extend(gcc_options) diff --git a/tools/mklibs/patches/008-uclibc_libgcc_link.patch b/tools/mklibs/patches/008-uclibc_libgcc_link.patch index 432a313b6c3..a221278d2ad 100644 --- a/tools/mklibs/patches/008-uclibc_libgcc_link.patch +++ b/tools/mklibs/patches/008-uclibc_libgcc_link.patch @@ -14,7 +14,7 @@ return ' '.join(ret) class Symbol(object): -@@ -584,6 +581,7 @@ while 1: +@@ -593,6 +590,7 @@ while 1: extra_flags = [] extra_pre_obj = [] extra_post_obj = [] @@ -22,7 +22,7 @@ symbols.update(library_symbols_used[library]) -@@ -614,9 +612,10 @@ while 1: +@@ -618,9 +616,10 @@ while 1: cmd.append(pic_file) cmd.extend(extra_post_obj) cmd.extend(extra_flags) diff --git a/tools/mklibs/patches/009-uclibc_libpthread_symbols.patch b/tools/mklibs/patches/009-uclibc_libpthread_symbols.patch deleted file mode 100644 index 34866f72905..00000000000 --- a/tools/mklibs/patches/009-uclibc_libpthread_symbols.patch +++ /dev/null @@ -1,63 +0,0 @@ ---- a/src/mklibs -+++ b/src/mklibs -@@ -162,9 +162,10 @@ def undefined_symbols(obj): - return result - - class ProvidedSymbol(Symbol): -- def __init__(self, name, version, library, default_version): -+ def __init__(self, name, version, library, default_version, weak): - super(ProvidedSymbol, self).__init__(name, version, library) - self.default_version = default_version -+ self.weak = weak - - def base_names(self): - ret = [] -@@ -205,11 +206,15 @@ def provided_symbols(obj): - if version_string.lower() not in ('base', 'none'): - version = version_string - -+ weak = False -+ if weak_string.lower() == 'true': -+ weak = True -+ - default_version = False - if default_version_string.lower() == 'true': - default_version = True - -- result.append(ProvidedSymbol(name, version, library, default_version)) -+ result.append(ProvidedSymbol(name, version, library, default_version, weak)) - - return result - -@@ -500,6 +505,9 @@ while 1: - debug(DEBUG_SPAM, "present_symbols adding %s" % symbol) - names = symbol.base_names() - for name in names: -+ if name in present_symbols: -+ if symbol.library != present_symbols[name].library: -+ needed_symbols[name] = UndefinedSymbol(name, True, symbol.version, symbol.library) - present_symbols[name] = symbol - - # are we finished? -@@ -591,12 +599,16 @@ while 1: - # may segfault in ptmalloc_init due to undefined weak reference - extra_pre_obj.append(sysroot + libc_extras_dir + "/soinit.o") - extra_post_obj.append(sysroot + libc_extras_dir + "/sofini.o") -- symbols.add(ProvidedSymbol('__dso_handle', None, None, True)) -+ symbols.add(ProvidedSymbol('__dso_handle', None, None, True, True)) - -- if soname in ("libc.so.0"): -- symbols.add(ProvidedSymbol('__uClibc_init', None, None, True)) -- symbols.add(ProvidedSymbol('__uClibc_fini', None, None, True)) -- extra_flags.append("-Wl,-init,__uClibc_init") -+ if soname == "libc.so.0": -+ symbols.add(ProvidedSymbol('__uClibc_init', None, None, True, True)) -+ symbols.add(ProvidedSymbol('__uClibc_fini', None, None, True, True)) -+ extra_pre_obj.append("-Wl,-init,__uClibc_init") -+ -+ if soname == "libpthread.so.0": -+ symbols.add(ProvidedSymbol('__pthread_initialize_minimal_internal', None, None, True, True)) -+ extra_flags.append("-Wl,-z,nodelete,-z,initfirst,-init=__pthread_initialize_minimal_internal") - - map_file = find_pic_map(library) - if map_file: diff --git a/tools/mklibs/patches/011-remove_multiarch.patch b/tools/mklibs/patches/011-remove_multiarch.patch index a32d8ee17a8..8c0bfdf1a09 100644 --- a/tools/mklibs/patches/011-remove_multiarch.patch +++ b/tools/mklibs/patches/011-remove_multiarch.patch @@ -1,6 +1,6 @@ --- a/src/mklibs +++ b/src/mklibs -@@ -263,6 +263,7 @@ def extract_soname(so_file): +@@ -269,6 +269,7 @@ def extract_soname(so_file): return "" def multiarch(paths): diff --git a/tools/mklibs/patches/100-apply-2to3.patch b/tools/mklibs/patches/100-apply-2to3.patch new file mode 100644 index 00000000000..dcacbab2052 --- /dev/null +++ b/tools/mklibs/patches/100-apply-2to3.patch @@ -0,0 +1,154 @@ +--- a/src/mklibs ++++ b/src/mklibs +@@ -57,17 +57,17 @@ debuglevel = DEBUG_NORMAL + + def debug(level, *msg): + if debuglevel >= level: +- print(string.join(msg)) ++ print(' '.join(msg)) + + # return a list of lines of output of the command + def command(command, *args): +- debug(DEBUG_SPAM, "calling", command, string.join(args)) ++ debug(DEBUG_SPAM, "calling", command, ' '.join(args)) + pipe = os.popen(command + ' ' + ' '.join(args), 'r') + output = pipe.read().strip() + status = pipe.close() + if status is not None and os.WEXITSTATUS(status) != 0: + print("Command failed with status", os.WEXITSTATUS(status), ":", \ +- command, string.join(args)) ++ command, ' '.join(args)) + print("With output:", output) + sys.exit(1) + return [i for i in output.split('\n') if i] +@@ -296,7 +296,7 @@ def usage(was_err): + print("Make a set of minimal libraries for FILE(s, file=outfd) in DEST.", file=outfd) + print("" , file=outfd) + print(" -d, --dest-dir DIRECTORY create libraries in DIRECTORY", file=outfd) +- print(" -D, --no-default-lib omit default libpath (", ':'.join(default_lib_path, file=outfd), ", file=outfd)", file=outfd) ++ print(" -D, --no-default-lib omit default libpath (", ':'.join(default_lib_path), ")", file=outfd) + print(" -L DIRECTORY[:DIRECTORY]... add DIRECTORY(s, file=outfd) to the library search path", file=outfd) + print(" -l LIBRARY add LIBRARY always", file=outfd) + print(" --ldlib LDLIB use LDLIB for the dynamic linker", file=outfd) +@@ -372,7 +372,7 @@ for opt, arg in optlist: + if debuglevel < DEBUG_SPAM: + debuglevel = debuglevel + 1 + elif opt == "-L": +- lib_path.extend(string.split(arg, ":")) ++ lib_path.extend(arg.split(":")) + elif opt in ("-d", "--dest-dir"): + dest_path = arg + elif opt in ("-D", "--no-default-lib"): +@@ -391,7 +391,7 @@ for opt, arg in optlist: + elif opt in ("-l",): + force_libs.append(arg) + elif opt == "--gcc-options": +- gcc_options.extend(string.split(arg, " ")) ++ gcc_options.extend(arg.split(" ")) + elif opt == "--libdir": + libdir = arg + elif opt in ("--help", "-h"): +@@ -419,17 +419,17 @@ if ldlib == "LDLIB": + objects = {} # map from inode to filename + for prog in proglist: + inode = os.stat(prog)[ST_INO] +- if objects.has_key(inode): ++ if inode in objects: + debug(DEBUG_SPAM, prog, "is a hardlink to", objects[inode]) + elif so_pattern.match(prog): + debug(DEBUG_SPAM, prog, "is a library") +- elif script_pattern.match(open(prog).read(256)): ++ elif script_pattern.match(open(prog, 'r', encoding='iso-8859-1').read(256)): + debug(DEBUG_SPAM, prog, "is a script") + else: + objects[inode] = prog + + if not ldlib: +- for obj in objects.values(): ++ for obj in list(objects.values()): + output = command("mklibs-readelf", "--print-interp", obj) + if output: + ldlib = output.pop() +@@ -462,9 +462,9 @@ previous_pass_unresolved = set() + while 1: + debug(DEBUG_NORMAL, "I: library reduction pass", str(passnr)) + if debuglevel >= DEBUG_VERBOSE: +- print("Objects:",) +- for obj in sorted([x[string.rfind(x, '/') + 1:] for x in objects.values()]): +- print(obj,) ++ print("Objects:", end=' ') ++ for obj in sorted([x[x.rfind('/') + 1:] for x in list(objects.values())]): ++ print(obj, end=' ') + print() + + passnr = passnr + 1 +@@ -474,7 +474,7 @@ while 1: + obj = dest_path + "/" + lib + small_libs.append(obj) + inode = os.stat(obj)[ST_INO] +- if objects.has_key(inode): ++ if inode in objects: + debug(DEBUG_SPAM, obj, "is hardlink to", objects[inode]) + else: + objects[inode] = obj +@@ -504,7 +504,7 @@ while 1: + present_symbols = {} + checked_libs = small_libs + checked_libs.extend(available_libs) +- checked_libs.append(ldlib) ++ checked_libs.append(sysroot + "/" + ldlib) + for lib in checked_libs: + for symbol in provided_symbols(lib): + debug(DEBUG_SPAM, "present_symbols adding %s" % symbol) +--- a/src/mklibs-copy ++++ b/src/mklibs-copy +@@ -159,7 +159,7 @@ if include_default_lib_path: + objects = {} # map from inode to filename + for prog in proglist: + inode = os.stat(prog)[ST_INO] +- if objects.has_key(inode): ++ if inode in objects: + logger.debug("%s is a hardlink to %s", prog, objects[inode]) + elif so_pattern.match(prog): + logger.debug("%s is a library", prog) +@@ -169,7 +169,7 @@ for prog in proglist: + logger.debug("%s is no ELF", prog) + + if not ldlib: +- for obj in objects.values(): ++ for obj in list(objects.values()): + output = command("mklibs-readelf", "-i", obj) + for x in output: + ldlib = x +@@ -182,7 +182,7 @@ if not ldlib: + logger.info('Using %s as dynamic linker', ldlib) + + # Check for rpaths +-for obj in objects.values(): ++for obj in list(objects.values()): + rpath_val = rpath(obj) + if rpath_val: + if root: +@@ -208,18 +208,18 @@ while 1: + obj = dest_path + "/" + lib + small_libs.append(obj) + inode = os.stat(obj)[ST_INO] +- if objects.has_key(inode): ++ if inode in objects: + logger.debug("%s is hardlink to %s", obj, objects[inode]) + else: + objects[inode] = obj + +- for obj in objects.values(): ++ for obj in list(objects.values()): + small_libs.append(obj) + +- logger.verbose('Objects: %r', ' '.join([i[i.rfind('/') + 1:] for i in objects.itervalues()])) ++ logger.verbose('Objects: %r', ' '.join([i[i.rfind('/') + 1:] for i in objects.values()])) + + libraries = set() +- for obj in objects.values(): ++ for obj in list(objects.values()): + libraries.update(library_depends(obj)) + + if libraries == previous_pass_libraries: diff --git a/tools/mtd-utils/Makefile b/tools/mtd-utils/Makefile index e36f141619d..9e920bcb43b 100644 --- a/tools/mtd-utils/Makefile +++ b/tools/mtd-utils/Makefile @@ -7,18 +7,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mtd-utils -PKG_VERSION:=1.5.1 +PKG_VERSION:=1.5.2 -PKG_SOURCE_VERSION:=92686f212c9a4e16891c6a3c57629cbf4f0f8360 -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz +PKG_SOURCE_VERSION:=aea36417067dade75192bafa03af70b6eb2677b1 PKG_SOURCE_URL:=git://git.infradead.org/mtd-utils.git -PKG_SOURCE_BRANCH:=nbd/master PKG_SOURCE_PROTO:=git -PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) -PKG_MIRROR_MD5SUM:=9fe0518213feddacd1842935dddeb6c8 -PKG_CAT:=zcat - -HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/$(PKG_NAME)-$(PKG_VERSION) +PKG_MIRROR_HASH:=e11b342b85a36b2e438a8412ec52f87621d3046aec1a93039f8c72de9990b2a7 include $(INCLUDE_DIR)/host-build.mk @@ -26,6 +20,9 @@ HOST_CFLAGS += -I$(STAGING_DIR_HOST)/include/e2fsprogs CFLAGS := $(HOST_CFLAGS) -I$(HOST_BUILD_DIR)/include -L$(HOST_BUILD_DIR) -L$(STAGING_DIR_HOST)/lib -DNO_NATIVE_SUPPORT ifneq ($(HOST_OS),Linux) CFLAGS += -Dloff_t=off_t -D__BYTE_ORDER=BYTE_ORDER -include getline.h -include endian.h -I$(CURDIR)/include -include fls.h +MTD_STATIC := 0 +else +MTD_STATIC := 1 endif MTD_MAKEOPTS = \ @@ -33,7 +30,9 @@ MTD_MAKEOPTS = \ LDFLAGS="$(HOST_LDFLAGS)" \ WITHOUT_LZO=1 WITHOUT_XATTR=1 \ SUBDIRS="" \ - BUILDDIR="$(HOST_BUILD_DIR)" + BUILDDIR="$(HOST_BUILD_DIR)" \ + STATIC=$(MTD_STATIC) \ + V=$(if $(findstring c,$(OPENWRT_VERBOSE)),1) define Host/Compile $(MAKE) -C $(HOST_BUILD_DIR) \ diff --git a/tools/mtd-utils/patches/110-portability.patch b/tools/mtd-utils/patches/110-portability.patch index 4ad209a4491..c4cdab928ae 100644 --- a/tools/mtd-utils/patches/110-portability.patch +++ b/tools/mtd-utils/patches/110-portability.patch @@ -150,27 +150,6 @@ #include #include "version.h" -@@ -117,11 +116,6 @@ extern "C" { - fprintf(stderr, "%s: warning!: " fmt "\n", PROGRAM_NAME, ##__VA_ARGS__); \ - } while(0) - --#if defined(__UCLIBC__) --/* uClibc versions before 0.9.34 don't have rpmatch() */ --#if __UCLIBC_MAJOR__ == 0 && \ -- (__UCLIBC_MINOR__ < 9 || \ -- (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ < 34)) - #undef rpmatch - #define rpmatch __rpmatch - static inline int __rpmatch(const char *resp) -@@ -129,8 +123,6 @@ static inline int __rpmatch(const char * - return (resp[0] == 'y' || resp[0] == 'Y') ? 1 : - (resp[0] == 'n' || resp[0] == 'N') ? 0 : -1; - } --#endif --#endif - - /** - * prompt the user for confirmation --- a/include/mtd/ubifs-media.h +++ b/include/mtd/ubifs-media.h @@ -33,7 +33,15 @@ diff --git a/tools/mtd-utils/patches/120-include_sysmacros.patch b/tools/mtd-utils/patches/120-include_sysmacros.patch new file mode 100644 index 00000000000..81ba1cfb2b8 --- /dev/null +++ b/tools/mtd-utils/patches/120-include_sysmacros.patch @@ -0,0 +1,25 @@ +From 9a06f45ec71116d76ee4b268ebe1b33d45b06fc0 Mon Sep 17 00:00:00 2001 +From: Mike Frysinger +Date: Sat, 16 Apr 2016 22:10:43 -0400 +Subject: [PATCH mtd-utils] include sys/sysmacros.h for major/minor/makedev + +These functions have always been defined in sys/sysmacros.h under +Linux C libraries. For some, including sys/types.h implicitly +includes that as well, but glibc wants to deprecate that, and some +others already have. Include the header explicitly for the funcs. + +Signed-off-by: Mike Frysinger +--- + include/common.h | 1 + + 1 file changed, 1 insertion(+) + +--- a/include/common.h ++++ b/include/common.h +@@ -27,6 +27,7 @@ + #include + #include + #include ++#include + #include "version.h" + + #ifndef PROGRAM_NAME diff --git a/tools/mtd-utils/patches/130-lzma_jffs2.patch b/tools/mtd-utils/patches/130-lzma_jffs2.patch index 17f9978bef1..b04f0199226 100644 --- a/tools/mtd-utils/patches/130-lzma_jffs2.patch +++ b/tools/mtd-utils/patches/130-lzma_jffs2.patch @@ -1,7 +1,7 @@ --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ - VERSION = 1.5.1 + VERSION = 1.5.2 CPPFLAGS += -D_GNU_SOURCE -I./include -I$(BUILDDIR)/include -I./ubi-utils/include $(ZLIBCPPFLAGS) $(LZOCPPFLAGS) $(UUIDCPPFLAGS) +CPPFLAGS += -I./include/linux/lzma @@ -123,7 +123,7 @@ +} + +STATIC int jffs2_lzma_compress(unsigned char *data_in, unsigned char *cpage_out, -+ uint32_t *sourcelen, uint32_t *dstlen, void *model) ++ uint32_t *sourcelen, uint32_t *dstlen) +{ + SizeT compress_size = (SizeT)(*dstlen); + int ret; @@ -148,7 +148,7 @@ +} + +STATIC int jffs2_lzma_decompress(unsigned char *data_in, unsigned char *cpage_out, -+ uint32_t srclen, uint32_t destlen, void *model) ++ uint32_t srclen, uint32_t destlen) +{ + int ret; + SizeT dl = (SizeT)destlen; diff --git a/tools/mtd-utils/patches/136-mkfs.ubifs-xz-support.patch b/tools/mtd-utils/patches/136-mkfs.ubifs-xz-support.patch deleted file mode 100644 index d97c244fafb..00000000000 --- a/tools/mtd-utils/patches/136-mkfs.ubifs-xz-support.patch +++ /dev/null @@ -1,378 +0,0 @@ ---- a/Makefile -+++ b/Makefile -@@ -4,7 +4,7 @@ - VERSION = 1.5.1 - - CPPFLAGS += -D_GNU_SOURCE -I./include -I$(BUILDDIR)/include -I./ubi-utils/include $(ZLIBCPPFLAGS) $(LZOCPPFLAGS) $(UUIDCPPFLAGS) --CPPFLAGS += -I./include/linux/lzma -+CPPFLAGS += $(XZCPPFLAGS) -I./include/linux/lzma - - ifeq ($(WITHOUT_XATTR), 1) - CPPFLAGS += -DWITHOUT_XATTR -@@ -113,8 +113,13 @@ ifeq ($(WITHOUT_LZO), 1) - else - LZOLDLIBS = -llzo2 - endif -+ifeq ($(WITHOUT_XZ), 1) -+ CPPFLAGS += -DWITHOUT_XZ -+else -+ XZLDLIBS = -llzma -+endif - --LDLIBS_mkfs.ubifs = -lz $(LZOLDLIBS) -lm -luuid -+LDLIBS_mkfs.ubifs = -lz $(LZOLDLIBS) $(XZLDLIBS) -lm -luuid - $(call mkdep,mkfs.ubifs/,mkfs.ubifs,,ubi-utils/libubi.a) - - # ---- a/mkfs.ubifs/compr.c -+++ b/mkfs.ubifs/compr.c -@@ -126,6 +126,114 @@ static inline int lzo_init(void) { retur - static inline void lzo_fini(void) { } - #endif - -+#ifndef WITHOUT_XZ -+ -+#include -+ -+struct xz_ctx { -+ lzma_filter filters[3]; -+ lzma_options_lzma opts; -+}; -+ -+static struct xz_ctx *xz_ctx; -+ -+#define LZMA_COMPRESSION_LEVEL 9 -+ -+static struct xz_ctx *xz_ctx_init(void) -+{ -+ struct xz_ctx *ctx; -+ lzma_options_lzma *opts_lzma; -+ uint32_t preset; -+ int ret; -+ -+ ctx = malloc(sizeof(struct xz_ctx)); -+ if (ctx == NULL) -+ goto err; -+ -+ memset(ctx, 0, sizeof(struct xz_ctx)); -+ -+ opts_lzma = &ctx->opts; -+ -+ preset = LZMA_COMPRESSION_LEVEL | LZMA_PRESET_EXTREME; -+ ret = lzma_lzma_preset(opts_lzma, preset); -+ if (ret) -+ goto err_free_ctx; -+ -+ /* TODO: allow to specify LZMA options via command line */ -+#if 0 -+ opts_lzma->lc = 3; -+ opts_lzma->lp = 0; -+ opts_lzma->pb = 2; -+ opts_lzma->nice_len = 64; -+#else -+ opts_lzma->lc = 0; -+ opts_lzma->lp = 2; -+ opts_lzma->pb = 2; -+ opts_lzma->nice_len = 64; -+#endif -+ -+ ctx->filters[0].id = LZMA_FILTER_LZMA2; -+ ctx->filters[0].options = opts_lzma; -+ ctx->filters[1].id = LZMA_VLI_UNKNOWN; -+ -+ return ctx; -+ -+err_free_ctx: -+ free(ctx); -+err: -+ return NULL; -+} -+ -+static void xz_ctx_free(struct xz_ctx *ctx) -+{ -+ free(ctx); -+} -+ -+static int xz_init(void) -+{ -+ xz_ctx = xz_ctx_init(); -+ if (xz_ctx == NULL) -+ return -1; -+ -+ return 0; -+} -+ -+static void xz_fini(void) -+{ -+ xz_ctx_free(xz_ctx); -+} -+ -+static int xz_compress(void *in_buf, size_t in_len, void *out_buf, -+ size_t *out_len) -+{ -+ size_t ret_len; -+ lzma_ret ret_xz; -+ int ret; -+ -+ ret = -1; -+ -+ ret_len = 0; -+ ret_xz = lzma_stream_buffer_encode(xz_ctx->filters, LZMA_CHECK_CRC32, -+ NULL, in_buf, in_len, out_buf, -+ &ret_len, *out_len); -+ if (ret_xz != LZMA_OK) { -+ fprintf(stderr, "XZ error: %d\n", (int) ret_xz); -+ goto out; -+ } -+ -+ *out_len = ret_len; -+ -+ ret = 0; -+out: -+ return ret; -+} -+#else -+static inline int xz_init(void) { return 0; } -+static inline void xz_fini(void) { } -+static inline int xz_compress(void *in_buf, size_t in_len, void *out_buf, -+ size_t *out_len) { return -1; } -+#endif -+ - static int no_compress(void *in_buf, size_t in_len, void *out_buf, - size_t *out_len) - { -@@ -198,6 +306,9 @@ int compress_data(void *in_buf, size_t i - case MKFS_UBIFS_COMPR_LZO: - ret = lzo_compress(in_buf, in_len, out_buf, out_len); - break; -+ case MKFS_UBIFS_COMPR_XZ: -+ ret = xz_compress(in_buf, in_len, out_buf, out_len); -+ break; - case MKFS_UBIFS_COMPR_ZLIB: - ret = zlib_deflate(in_buf, in_len, out_buf, out_len); - break; -@@ -225,12 +336,18 @@ int init_compression(void) - if (ret) - goto err; - -+ ret = xz_init(); -+ if (ret) -+ goto err_lzo; -+ - zlib_buf = malloc(UBIFS_BLOCK_SIZE * WORST_COMPR_FACTOR); - if (!zlib_buf) -- goto err_lzo; -+ goto err_xz; - - return 0; - -+err_xz: -+ xz_fini(); - err_lzo: - lzo_fini(); - err: -@@ -240,6 +357,7 @@ err: - void destroy_compression(void) - { - free(zlib_buf); -+ xz_fini(); - lzo_fini(); - if (errcnt) - fprintf(stderr, "%llu compression errors occurred\n", errcnt); ---- a/mkfs.ubifs/compr.h -+++ b/mkfs.ubifs/compr.h -@@ -36,6 +36,7 @@ enum compression_type - MKFS_UBIFS_COMPR_NONE, - MKFS_UBIFS_COMPR_LZO, - MKFS_UBIFS_COMPR_ZLIB, -+ MKFS_UBIFS_COMPR_XZ, - }; - - int compress_data(void *in_buf, size_t in_len, void *out_buf, size_t *out_len, ---- a/mkfs.ubifs/mkfs.ubifs.c -+++ b/mkfs.ubifs/mkfs.ubifs.c -@@ -99,6 +99,9 @@ struct ubifs_info info_; - static struct ubifs_info *c = &info_; - static libubi_t ubi; - -+static int force_compr_set; -+static int force_compr; -+ - /* Debug levels are: 0 (none), 1 (statistics), 2 (files) ,3 (more details) */ - int debug_level; - int verbose; -@@ -133,7 +136,7 @@ static struct inum_mapping **hash_table; - /* Inode creation sequence number */ - static unsigned long long creat_sqnum; - --static const char *optstring = "d:r:m:o:D:yh?vVe:c:g:f:Fp:k:x:X:j:R:l:j:UQq"; -+static const char *optstring = "d:r:m:o:D:yh?vVe:c:g:f:Fp:k:x:X:z:j:R:l:j:UQq"; - - static const struct option longopts[] = { - {"root", 1, NULL, 'r'}, -@@ -151,6 +154,7 @@ static const struct option longopts[] = - {"reserved", 1, NULL, 'R'}, - {"compr", 1, NULL, 'x'}, - {"favor-percent", 1, NULL, 'X'}, -+ {"force-compr", 1, NULL, 'z'}, - {"fanout", 1, NULL, 'f'}, - {"space-fixup", 0, NULL, 'F'}, - {"keyhash", 1, NULL, 'k'}, -@@ -178,11 +182,13 @@ static const char *helptext = - "-o, --output=FILE output to FILE\n" - "-j, --jrn-size=SIZE journal size\n" - "-R, --reserved=SIZE how much space should be reserved for the super-user\n" --"-x, --compr=TYPE compression type - \"lzo\", \"favor_lzo\", \"zlib\" or\n" --" \"none\" (default: \"lzo\")\n" -+"-x, --compr=TYPE default compression type - \"lzo\", \"favor_lzo\",\n" -+" \"zlib\" or \"none\" (default: \"lzo\")\n" - "-X, --favor-percent may only be used with favor LZO compression and defines\n" - " how many percent better zlib should compress to make\n" - " mkfs.ubifs use zlib instead of LZO (default 20%)\n" -+"-z, --force-compr=TYPE force to build the fs with different compression -\n" -+" \"lzo\", \"zlib\" or \"none\"\n" - "-f, --fanout=NUM fanout NUM (default: 8)\n" - "-F, --space-fixup file-system free space has to be fixed up on first mount\n" - " (requires kernel version 3.0 or greater)\n" -@@ -472,6 +478,43 @@ static int open_ubi(const char *node) - return 0; - } - -+static const char *get_compr_str(int compr) -+{ -+ switch (compr) { -+ case UBIFS_COMPR_LZO: -+ return "lzo"; -+ case UBIFS_COMPR_ZLIB: -+ return "zlib"; -+ case UBIFS_COMPR_XZ: -+ return "xz"; -+ case UBIFS_COMPR_NONE: -+ return "none"; -+ } -+ -+ return "unknown"; -+} -+ -+static int get_compr_option(char *opt, int *compr_type, int *favor_lzo) -+{ -+ *compr_type = UBIFS_COMPR_LZO; -+ -+ if (favor_lzo) -+ *favor_lzo = 0; -+ -+ if (favor_lzo && strcmp(optarg, "favor_lzo") == 0) -+ *favor_lzo = 1; -+ else if (strcmp(optarg, "zlib") == 0) -+ *compr_type = UBIFS_COMPR_ZLIB; -+ else if (strcmp(optarg, "xz") == 0) -+ *compr_type = UBIFS_COMPR_XZ; -+ else if (strcmp(optarg, "none") == 0) -+ *compr_type = UBIFS_COMPR_NONE; -+ else if (strcmp(optarg, "lzo") != 0) -+ return -1; -+ -+ return 0; -+} -+ - static int get_options(int argc, char**argv) - { - int opt, i; -@@ -594,14 +637,13 @@ static int get_options(int argc, char**a - return err_msg("bad key hash"); - break; - case 'x': -- if (strcmp(optarg, "favor_lzo") == 0) -- c->favor_lzo = 1; -- else if (strcmp(optarg, "zlib") == 0) -- c->default_compr = UBIFS_COMPR_ZLIB; -- else if (strcmp(optarg, "none") == 0) -- c->default_compr = UBIFS_COMPR_NONE; -- else if (strcmp(optarg, "lzo") != 0) -- return err_msg("bad compressor name"); -+ if (get_compr_option(optarg, &c->default_compr, -+ &c->favor_lzo)) -+ return err_msg("bad compressor name '%s'", -+ optarg); -+ if (c->default_compr == UBIFS_COMPR_XZ) -+ return err_msg("'%s' can't be used as default compressor", -+ optarg); - break; - case 'X': - c->favor_percent = strtol(optarg, &endp, 0); -@@ -610,6 +652,12 @@ static int get_options(int argc, char**a - return err_msg("bad favor LZO percent '%s'", - optarg); - break; -+ case 'z': -+ if (get_compr_option(optarg, &force_compr, NULL)) -+ return err_msg("bad forced compressor name '%s'", -+ optarg); -+ force_compr_set = 1; -+ break; - case 'j': - c->max_bud_bytes = get_bytes(optarg); - if (c->max_bud_bytes <= 0) -@@ -684,6 +732,9 @@ static int get_options(int argc, char**a - c->min_io_size = 8; - c->rp_size = add_space_overhead(c->rp_size); - -+ if (force_compr_set == 0) -+ force_compr = c->default_compr; -+ - if (verbose) { - printf("mkfs.ubifs\n"); - printf("\troot: %s\n", root); -@@ -693,17 +744,10 @@ static int get_options(int argc, char**a - printf("\toutput: %s\n", output); - printf("\tjrn_size: %llu\n", c->max_bud_bytes); - printf("\treserved: %llu\n", c->rp_size); -- switch (c->default_compr) { -- case UBIFS_COMPR_LZO: -- printf("\tcompr: lzo\n"); -- break; -- case UBIFS_COMPR_ZLIB: -- printf("\tcompr: zlib\n"); -- break; -- case UBIFS_COMPR_NONE: -- printf("\tcompr: none\n"); -- break; -- } -+ printf("\tcompr: %s\n", get_compr_str(c->default_compr)); -+ if (force_compr_set) -+ printf("\tforced compr: %s\n", -+ get_compr_str(force_compr)); - printf("\tkeyhash: %s\n", (c->key_hash == key_r5_hash) ? - "r5" : "test"); - printf("\tfanout: %d\n", c->fanout); -@@ -1284,7 +1328,7 @@ static int add_file(const char *path_nam - use_compr = UBIFS_COMPR_LZO; - else - #endif -- use_compr = c->default_compr; -+ use_compr = force_compr; - compr_type = compress_data(buf, bytes_read, &dn->data, - &out_len, use_compr); - dn->compr_type = cpu_to_le16(compr_type); ---- a/mkfs.ubifs/mkfs.ubifs.h -+++ b/mkfs.ubifs/mkfs.ubifs.h -@@ -83,6 +83,9 @@ - #if MKFS_UBIFS_COMPR_ZLIB != UBIFS_COMPR_ZLIB - #error MKFS_UBIFS_COMPR_ZLIB != UBIFS_COMPR_ZLIB - #endif -+#if MKFS_UBIFS_COMPR_XZ != UBIFS_COMPR_XZ -+#error MKFS_UBIFS_COMPR_XZ != UBIFS_COMPR_XZ -+#endif - - extern int verbose; - extern int debug_level; ---- a/include/mtd/ubifs-media.h -+++ b/include/mtd/ubifs-media.h -@@ -313,6 +313,7 @@ enum { - UBIFS_COMPR_NONE, - UBIFS_COMPR_LZO, - UBIFS_COMPR_ZLIB, -+ UBIFS_COMPR_XZ, - UBIFS_COMPR_TYPES_CNT, - }; - diff --git a/tools/mtd-utils/patches/137-no_extern_inline.patch b/tools/mtd-utils/patches/137-no_extern_inline.patch deleted file mode 100644 index d871d670d29..00000000000 --- a/tools/mtd-utils/patches/137-no_extern_inline.patch +++ /dev/null @@ -1,41 +0,0 @@ ---- a/mkfs.ubifs/hashtable/hashtable_itr.c -+++ b/mkfs.ubifs/hashtable/hashtable_itr.c -@@ -35,18 +35,6 @@ hashtable_iterator(struct hashtable *h) - } - - /*****************************************************************************/ --/* key - return the key of the (key,value) pair at the current position */ --/* value - return the value of the (key,value) pair at the current position */ -- --void * --hashtable_iterator_key(struct hashtable_itr *i) --{ return i->e->k; } -- --void * --hashtable_iterator_value(struct hashtable_itr *i) --{ return i->e->v; } -- --/*****************************************************************************/ - /* advance - advance the iterator to the next element - * returns zero if advanced to end of table */ - ---- a/mkfs.ubifs/hashtable/hashtable_itr.h -+++ b/mkfs.ubifs/hashtable/hashtable_itr.h -@@ -28,7 +28,7 @@ hashtable_iterator(struct hashtable *h); - /* hashtable_iterator_key - * - return the value of the (key,value) pair at the current position */ - --extern inline void * -+static inline void * - hashtable_iterator_key(struct hashtable_itr *i) - { - return i->e->k; -@@ -37,7 +37,7 @@ hashtable_iterator_key(struct hashtable_ - /*****************************************************************************/ - /* value - return the value of the (key,value) pair at the current position */ - --extern inline void * -+static inline void * - hashtable_iterator_value(struct hashtable_itr *i) - { - return i->e->v; diff --git a/tools/mtd-utils/patches/300-libfec_use_standard_unsigned_long.patch b/tools/mtd-utils/patches/300-libfec_use_standard_unsigned_long.patch deleted file mode 100644 index 73a68b58609..00000000000 --- a/tools/mtd-utils/patches/300-libfec_use_standard_unsigned_long.patch +++ /dev/null @@ -1,35 +0,0 @@ ---- a/lib/libfec.c -+++ b/lib/libfec.c -@@ -61,8 +61,6 @@ struct timeval { - }; - #define gettimeofday(x, dummy) { (x)->ticks = clock() ; } - #define DIFF_T(a,b) (1+ 1000000*(a.ticks - b.ticks) / CLOCKS_PER_SEC ) --typedef unsigned long u_long ; --typedef unsigned short u_short ; - #else /* typically, unix systems */ - #include - #define DIFF_T(a,b) \ -@@ -75,12 +73,12 @@ typedef unsigned short u_short ; - t = x.tv_usec + 1000000* (x.tv_sec & 0xff ) ; \ - } - #define TOCK(t) \ -- { u_long t1 ; TICK(t1) ; \ -+ { unsigned long t1 ; TICK(t1) ; \ - if (t1 < t) t = 256000000 + t1 - t ; \ - else t = t1 - t ; \ - if (t == 0) t = 1 ;} - --u_long ticks[10]; /* vars for timekeeping */ -+unsigned long ticks[10]; /* vars for timekeeping */ - #else - #define DEB(x) - #define DDB(x) -@@ -625,7 +623,7 @@ init_fec(void) - #define FEC_MAGIC 0xFECC0DEC - - struct fec_parms { -- u_long magic ; -+ unsigned long magic ; - int k, n ; /* parameters of the code */ - gf *enc_matrix ; - } ; diff --git a/tools/mtd-utils/patches/301-mtd-utils-ubi-tests-fix-a-some-overflows.patch b/tools/mtd-utils/patches/301-mtd-utils-ubi-tests-fix-a-some-overflows.patch deleted file mode 100644 index d8ba442ee92..00000000000 --- a/tools/mtd-utils/patches/301-mtd-utils-ubi-tests-fix-a-some-overflows.patch +++ /dev/null @@ -1,56 +0,0 @@ -From e76eeca21de23ae884e415a12809ac683960cbca Mon Sep 17 00:00:00 2001 -From: Dongsheng Yang -Date: Mon, 29 Jun 2015 16:49:19 +0800 -Subject: [PATCH] mtd-utils: ubi-tests: fix a some overflows - -Signed-off-by: Dongsheng Yang -Reviewed-by: Richard Weinberger -Signed-off-by: Brian Norris ---- - tests/ubi-tests/mkvol_bad.c | 2 +- - tests/ubi-tests/mkvol_basic.c | 2 +- - tests/ubi-tests/rsvol.c | 2 +- - 3 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/tests/ubi-tests/mkvol_bad.c b/tests/ubi-tests/mkvol_bad.c -index 27f4795..486fbab 100644 ---- a/tests/ubi-tests/mkvol_bad.c -+++ b/tests/ubi-tests/mkvol_bad.c -@@ -106,7 +106,7 @@ static int test_mkvol(void) - return -1; - - req.alignment = dev_info.leb_size - dev_info.min_io_size; -- req.bytes = (dev_info.leb_size - dev_info.leb_size % req.alignment) * -+ req.bytes = (long long)(dev_info.leb_size - dev_info.leb_size % req.alignment) * - dev_info.avail_lebs + 1; - ret = ubi_mkvol(libubi, node, &req); - if (check_failed(ret, ENOSPC, "ubi_mkvol", "bytes = %lld", req.bytes)) -diff --git a/tests/ubi-tests/mkvol_basic.c b/tests/ubi-tests/mkvol_basic.c -index cda7241..2ff6ac1 100644 ---- a/tests/ubi-tests/mkvol_basic.c -+++ b/tests/ubi-tests/mkvol_basic.c -@@ -55,7 +55,7 @@ static int mkvol_alignment(void) - - /* Bear in mind alignment reduces EB size */ - ebsz = dev_info.leb_size - dev_info.leb_size % req.alignment; -- req.bytes = dev_info.avail_lebs * ebsz; -+ req.bytes = (long long)dev_info.avail_lebs * ebsz; - - req.vol_type = UBI_DYNAMIC_VOLUME; - req.name = name; -diff --git a/tests/ubi-tests/rsvol.c b/tests/ubi-tests/rsvol.c -index 60badb0..732bcaa 100644 ---- a/tests/ubi-tests/rsvol.c -+++ b/tests/ubi-tests/rsvol.c -@@ -169,7 +169,7 @@ static int test_rsvol1(struct ubi_vol_info *vol_info) - } - - if (ubi_rsvol(libubi, node, vol_info->vol_id, -- vol_info->leb_size * dev_info.avail_lebs)) { -+ (long long)vol_info->leb_size * dev_info.avail_lebs)) { - failed("ubi_rsvol"); - return -1; - } --- -1.7.9.5 - diff --git a/tools/mtd-utils/patches/310-add-static-linking-option.patch b/tools/mtd-utils/patches/310-add-static-linking-option.patch new file mode 100644 index 00000000000..828d7751e55 --- /dev/null +++ b/tools/mtd-utils/patches/310-add-static-linking-option.patch @@ -0,0 +1,43 @@ +--- a/common.mk ++++ b/common.mk +@@ -2,6 +2,16 @@ CC := $(CROSS)gcc + AR := $(CROSS)ar + RANLIB := $(CROSS)ranlib + ++ifeq ($(STATIC),1) ++ define static_link ++ -Wl,-Bstatic $(1) -Wl,-Bdynamic ++ endef ++else ++ define static_link ++ $(1) ++ endef ++endif ++ + # Stolen from Linux build system + comma = , + try-run = $(shell set -e; ($(1)) >/dev/null 2>&1 && echo "$(2)" || echo "$(3)") +--- a/Makefile ++++ b/Makefile +@@ -89,10 +89,10 @@ obj-mkfs.jffs2 = compr_rtime.o compr_zli + compr_lzma.o lzma/LzFind.o lzma/LzmaEnc.o lzma/LzmaDec.o \ + compr.o rbtree.o + LDFLAGS_mkfs.jffs2 = $(ZLIBLDFLAGS) $(LZOLDFLAGS) +-LDLIBS_mkfs.jffs2 = -lz $(LZOLDLIBS) ++LDLIBS_mkfs.jffs2 = $(call static_link,-lz $(LZOLDLIBS)) + + LDFLAGS_jffs2reader = $(ZLIBLDFLAGS) $(LZOLDFLAGS) +-LDLIBS_jffs2reader = -lz $(LZOLDLIBS) ++LDLIBS_jffs2reader = $(call static_link,-lz $(LZOLDLIBS)) + + $(foreach v,$(MTD_BINS),$(eval $(call mkdep,,$(v)))) + +@@ -114,7 +114,7 @@ else + LZOLDLIBS = -llzo2 + endif + +-LDLIBS_mkfs.ubifs = -lz $(LZOLDLIBS) -lm -luuid ++LDLIBS_mkfs.ubifs = $(call static_link,-lz $(LZOLDLIBS)) -lm $(call static_link,-luuid) + $(call mkdep,mkfs.ubifs/,mkfs.ubifs,,ubi-utils/libubi.a) + + # diff --git a/tools/quilt/Makefile b/tools/quilt/Makefile index 01b0bd298fa..d0532b5984e 100644 --- a/tools/quilt/Makefile +++ b/tools/quilt/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2014 OpenWrt.org +# Copyright (C) 2006-2015 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -7,17 +7,14 @@ include $(TOPDIR)/rules.mk PKG_NAME:=quilt -PKG_VERSION:=0.63 +PKG_VERSION:=0.65 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@SAVANNAH/quilt -PKG_MD5SUM:=c0ef4beb58a6fa72563b955e70624b6e +PKG_HASH:=f6cbc788e5cbbb381a3c6eab5b9efce67c776a8662a7795c7432fd27aa096819 include $(INCLUDE_DIR)/host-build.mk -HOST_CONFIGURE_ARGS += \ - --with-find=$(FIND) - define Host/Configure cd $(HOST_BUILD_DIR) && autoconf $(call Host/Configure/Default) diff --git a/tools/quilt/patches/000-relocatable.patch b/tools/quilt/patches/000-relocatable.patch index 99d7af5771d..0e0eb7380ce 100644 --- a/tools/quilt/patches/000-relocatable.patch +++ b/tools/quilt/patches/000-relocatable.patch @@ -1,49 +1,50 @@ --- a/bin/quilt.in +++ b/bin/quilt.in -@@ -15,9 +15,15 @@ +@@ -15,14 +15,22 @@ unset POSIXLY_CORRECT unset GREP_OPTIONS export TEXTDOMAIN=quilt -export TEXTDOMAINDIR=@LOCALEDIR@ -: ${QUILT_DIR=@QUILT_DIR@} -+if test -n "$STAGING_DIR"; then -+ export TEXTDOMAINDIR="$STAGING_DIR/../host/share/locale" -+ : ${QUILT_DIR=$STAGING_DIR/../host/share/quilt} ${QUILT_LIB=$STAGING_DIR/../host/lib/quilt} ++if test -n "$STAGING_DIR_HOST"; then ++ export TEXTDOMAINDIR="$STAGING_DIR_HOST/share/locale" ++ : ${QUILT_DIR=$STAGING_DIR_HOST/share/quilt} ${QUILT_LIB=$STAGING_DIR_HOST/lib/quilt} ++ : ${QUILT_ETC=$STAGING_DIR_HOST/etc} +else + export TEXTDOMAINDIR=@LOCALEDIR@ + : ${QUILT_DIR=@QUILT_DIR@} ++ : ${QUILT_ETC=@ETCDIR@} +fi + export QUILT_DIR if [ -z "$QUILTRC" ] + then +- for QUILTRC in $HOME/.quiltrc @ETCDIR@/quilt.quiltrc; do ++ for QUILTRC in $HOME/.quiltrc $QUILT_ETC/quilt.quiltrc; do + [ -e $QUILTRC ] && break + done + export QUILTRC --- a/quilt/scripts/edmail.in +++ b/quilt/scripts/edmail.in -@@ -29,7 +29,7 @@ BEGIN { +@@ -1,4 +1,6 @@ +-#! @PERL@ -w ++#! @PERL@ ++ ++use warnings; + + # RFCs important for this script: + # +@@ -29,7 +31,7 @@ BEGIN { } setlocale(LC_MESSAGES, ""); -bindtextdomain("quilt", "@LOCALEDIR@"); -+bindtextdomain("quilt", $ENV{'STAGING_DIR'} ? $ENV{'STAGING_DIR'} . '/../host/share/locale' : "@LOCALEDIR@"); ++bindtextdomain("quilt", $ENV{'STAGING_DIR_HOST'} ? $ENV{'STAGING_DIR_HOST'} . '/share/locale' : "@LOCALEDIR@"); textdomain("quilt"); sub _($) { ---- a/quilt/scripts/inspect.in -+++ b/quilt/scripts/inspect.in -@@ -6,7 +6,11 @@ - # - # See the COPYING and AUTHORS files for more details. - --: ${QUILT_DIR=@QUILT_DIR@} -+if test -n "$STAGING_DIR"; then -+ : ${QUILT_DIR="$STAGING_DIR/../host/share/quilt"} -+else -+ : ${QUILT_DIR=@QUILT_DIR@} -+fi - - if ! [ -r $QUILT_DIR/scripts/patchfns ] - then --- a/quilt/scripts/patchfns.in +++ b/quilt/scripts/patchfns.in @@ -8,7 +8,11 @@ @@ -51,8 +52,8 @@ export TEXTDOMAIN=quilt -export TEXTDOMAINDIR=@LOCALEDIR@ -+if [ -n "$STAGING_DIR" ]; then -+ export TEXTDOMAINDIR="$STAGING_DIR/../host/share/locale" ++if [ -n "$STAGING_DIR_HOST" ]; then ++ export TEXTDOMAINDIR="$STAGING_DIR_HOST/share/locale" +else + export TEXTDOMAINDIR=@LOCALEDIR@ +fi @@ -61,12 +62,109 @@ : ${LC_MESSAGES:=$LANG} --- a/quilt/scripts/remove-trailing-ws.in +++ b/quilt/scripts/remove-trailing-ws.in -@@ -31,7 +31,7 @@ BEGIN { +@@ -1,4 +1,6 @@ +-#! @PERL@ -w ++#! @PERL@ ++ ++use warnings; + + # Remove trailing whitespace from modified lines in working files. + # +@@ -31,7 +33,7 @@ BEGIN { } setlocale(LC_MESSAGES, ""); -bindtextdomain("quilt", "@LOCALEDIR@"); -+bindtextdomain("quilt", $ENV{'STAGING_DIR'} ? $ENV{'STAGING_DIR'} . '/../host/share/locale' : "@LOCALEDIR@"); ++bindtextdomain("quilt", $ENV{'STAGING_DIR_HOST'} ? $ENV{'STAGING_DIR_HOST'} . '/share/locale' : "@LOCALEDIR@"); textdomain("quilt"); sub _($) { +--- a/Makefile.in ++++ b/Makefile.in +@@ -21,8 +21,8 @@ COLUMN := @COLUMN@ + GETOPT := @GETOPT@ + CP := @CP@ + DATE := @DATE@ +-PERL := @PERL@ +-BASH := @BASH@ ++PERL := /usr/bin/env perl ++BASH := /usr/bin/env bash + SHELL:= @BASH@ # It does not work if dash is used as a shell, for example + GREP := @GREP@ + TAIL := @TAIL@ +@@ -32,7 +32,7 @@ AWK := @AWK@ + FIND := @FIND@ + XARGS := @XARGS@ + DIFF := @DIFF@ +-PATCH := @PATCH@ ++PATCH := /usr/bin/env patch + MKTEMP := @MKTEMP@ + MSGMERGE := @MSGMERGE@ + MSGFMT := @MSGFMT@ +@@ -48,8 +48,8 @@ USE_NLS := @USE_NLS@ + STAT_HARDLINK := @STAT_HARDLINK@ + PATCH_WRAPPER := @PATCH_WRAPPER@ + +-COMPAT_SYMLINKS := @COMPAT_SYMLINKS@ +-COMPAT_PROGRAMS := @COMPAT_PROGRAMS@ ++COMPAT_SYMLINKS := ++COMPAT_PROGRAMS := + + default: all + +--- a/quilt/scripts/backup-files.in ++++ b/quilt/scripts/backup-files.in +@@ -53,7 +53,12 @@ usage () + " + } + +-: ${QUILT_DIR=@QUILT_DIR@} ++if test -n "$STAGING_DIR_HOST"; then ++ : ${QUILT_DIR="$STAGING_DIR_HOST/share/quilt"} ++else ++ : ${QUILT_DIR=@QUILT_DIR@} ++fi ++ + . $QUILT_DIR/scripts/utilfns + + ensure_nolinks() +--- a/bin/guards.in ++++ b/bin/guards.in +@@ -1,4 +1,6 @@ +-#!@PERL@ -w ++#!@PERL@ ++ ++use warnings; + + # This script is free software; you can redistribute it and/or modify + # it under the terms of the GNU General Public License version 2 as +--- a/compat/date.in ++++ b/compat/date.in +@@ -1,4 +1,6 @@ +-#! @PERL@ -w ++#! @PERL@ ++ ++use warnings; + + # This script is free software; you can redistribute it and/or modify + # it under the terms of the GNU General Public License version 2 as +--- a/compat/getopt.in ++++ b/compat/getopt.in +@@ -1,4 +1,6 @@ +-#! @PERL@ -w ++#! @PERL@ ++ ++use warnings; + + # This script is free software; you can redistribute it and/or modify + # it under the terms of the GNU General Public License version 2 as +--- a/quilt/scripts/dependency-graph.in ++++ b/quilt/scripts/dependency-graph.in +@@ -1,4 +1,6 @@ +-#!@PERL@ -w ++#!@PERL@ ++ ++use warnings; + + # This script is free software; you can redistribute it and/or modify + # it under the terms of the GNU General Public License version 2 as diff --git a/tools/squashfs4/Makefile b/tools/squashfs4/Makefile index 50b70fbe1c9..e2c9fc91ccb 100644 --- a/tools/squashfs4/Makefile +++ b/tools/squashfs4/Makefile @@ -11,7 +11,7 @@ PKG_VERSION:=4.2 PKG_SOURCE:=squashfs$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@SF/squashfs -PKG_MD5SUM:=1b7a781fb4cf8938842279bd3e8ee852 +PKG_HASH:=d9e0195aa922dbb665ed322b9aaa96e04a476ee650f39bbeadb0d00b24022e96 PKG_CAT:=zcat HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/squashfs$(PKG_VERSION) diff --git a/tools/squashfs4/patches/130-include_sysmacros.patch b/tools/squashfs4/patches/130-include_sysmacros.patch new file mode 100644 index 00000000000..e8845130ef7 --- /dev/null +++ b/tools/squashfs4/patches/130-include_sysmacros.patch @@ -0,0 +1,20 @@ +--- a/squashfs-tools/mksquashfs.c ++++ b/squashfs-tools/mksquashfs.c +@@ -33,6 +33,7 @@ + #include + #include + #include ++#include + #include + #include + #include +--- a/squashfs-tools/unsquashfs.c ++++ b/squashfs-tools/unsquashfs.c +@@ -30,6 +30,7 @@ + #include "xattr.h" + + #include ++#include + + struct cache *fragment_cache, *data_cache; + struct queue *to_reader, *to_deflate, *to_writer, *from_writer; diff --git a/tools/squashfs4/patches/160-expose_lzma_xz_options.patch b/tools/squashfs4/patches/160-expose_lzma_xz_options.patch index d6063969d27..9e1c1fbb1ea 100644 --- a/tools/squashfs4/patches/160-expose_lzma_xz_options.patch +++ b/tools/squashfs4/patches/160-expose_lzma_xz_options.patch @@ -40,6 +40,7 @@ + + +struct lzma_opts { ++ uint32_t dict_size; + uint32_t flags; +#define LZMA_OPT_FLT_MASK 0xffff +#define LZMA_OPT_PRE_OFF 16 @@ -53,7 +54,6 @@ +#define LZMA_OPT_PB_OFF 6 +#define LZMA_OPT_PB_MASK (0x7 << LZMA_OPT_PB_OFF) + uint16_t fb; -+ uint32_t dict_size; +}; + +#if __BYTE_ORDER == __BIG_ENDIAN @@ -637,7 +637,7 @@ } name = argv[1]; -@@ -76,190 +73,50 @@ static int xz_options(char *argv[], int +@@ -76,190 +73,50 @@ static int xz_options(char *argv[], int } if(bcj[i].name == NULL) { fprintf(stderr, "xz: -Xbcj unrecognised " @@ -864,7 +864,7 @@ SQUASHFS_METADATA_SIZE; filter[0].filter[0].id = LZMA_FILTER_LZMA2; -@@ -323,14 +181,25 @@ static int xz_compress(void *strm, void +@@ -323,14 +181,25 @@ static int xz_compress(void *strm, void lzma_ret res = 0; struct xz_stream *stream = strm; struct filter *selected = NULL; diff --git a/tools/squashfs4/patches/170-add_support_for_LZMA_MAGIC_to_unsqashfs.patch b/tools/squashfs4/patches/170-add_support_for_LZMA_MAGIC_to_unsqashfs.patch index ad69b190ea9..bc7d6c7a4a0 100644 --- a/tools/squashfs4/patches/170-add_support_for_LZMA_MAGIC_to_unsqashfs.patch +++ b/tools/squashfs4/patches/170-add_support_for_LZMA_MAGIC_to_unsqashfs.patch @@ -16,7 +16,7 @@ #define SQUASHFS_METADATA_LOG 13 --- a/squashfs-tools/unsquashfs.c +++ b/squashfs-tools/unsquashfs.c -@@ -1463,10 +1463,12 @@ int read_super(char *source) +@@ -1464,10 +1464,12 @@ int read_super(char *source) */ read_fs_bytes(fd, SQUASHFS_START, sizeof(struct squashfs_super_block), &sBlk_4); @@ -31,7 +31,7 @@ sBlk_4.s_minor == 0) { s_ops.squashfs_opendir = squashfs_opendir_4; s_ops.read_fragment = read_fragment_4; -@@ -1479,7 +1481,11 @@ int read_super(char *source) +@@ -1480,7 +1482,11 @@ int read_super(char *source) /* * Check the compression type */ @@ -44,7 +44,7 @@ return TRUE; } -@@ -1494,8 +1500,10 @@ int read_super(char *source) +@@ -1495,8 +1501,10 @@ int read_super(char *source) * Check it is a SQUASHFS superblock */ swap = 0; @@ -57,7 +57,7 @@ squashfs_super_block_3 sblk; ERROR("Reading a different endian SQUASHFS filesystem " "on %s\n", source); -@@ -1573,7 +1581,11 @@ int read_super(char *source) +@@ -1574,7 +1582,11 @@ int read_super(char *source) /* * 1.x, 2.x and 3.x filesystems use gzip compression. */ diff --git a/tools/squashfs4/patches/180-openbsd_compat.patch b/tools/squashfs4/patches/180-openbsd_compat.patch index 6d7a857a05a..4f7afd89cc9 100644 --- a/tools/squashfs4/patches/180-openbsd_compat.patch +++ b/tools/squashfs4/patches/180-openbsd_compat.patch @@ -1,6 +1,5 @@ -diff -Nur squashfs4.2.orig/squashfs-tools/mksquashfs.c squashfs4.2/squashfs-tools/mksquashfs.c ---- squashfs4.2.orig/squashfs-tools/mksquashfs.c Tue Mar 5 16:20:49 2013 -+++ squashfs4.2/squashfs-tools/mksquashfs.c Tue Mar 5 16:25:10 2013 +--- a/squashfs-tools/mksquashfs.c ++++ b/squashfs-tools/mksquashfs.c @@ -32,6 +32,9 @@ #include #include @@ -9,11 +8,10 @@ diff -Nur squashfs4.2.orig/squashfs-tools/mksquashfs.c squashfs4.2/squashfs-tool +#include +#endif #include + #include #include - #include -diff -Nur squashfs4.2.orig/squashfs-tools/unsquashfs.h squashfs4.2/squashfs-tools/unsquashfs.h ---- squashfs4.2.orig/squashfs-tools/unsquashfs.h Tue Mar 5 16:20:49 2013 -+++ squashfs4.2/squashfs-tools/unsquashfs.h Tue Mar 5 16:25:57 2013 +--- a/squashfs-tools/unsquashfs.h ++++ b/squashfs-tools/unsquashfs.h @@ -25,6 +25,9 @@ #define TRUE 1 #define FALSE 0 diff --git a/tools/squashfs4/patches/190-no_nonstatic_inline.patch b/tools/squashfs4/patches/190-no_nonstatic_inline.patch index 7b5808afab5..8cab1208325 100644 --- a/tools/squashfs4/patches/190-no_nonstatic_inline.patch +++ b/tools/squashfs4/patches/190-no_nonstatic_inline.patch @@ -1,6 +1,6 @@ --- a/squashfs-tools/mksquashfs.c +++ b/squashfs-tools/mksquashfs.c -@@ -735,13 +735,13 @@ void cache_block_put(struct file_buffer +@@ -736,13 +736,13 @@ void cache_block_put(struct file_buffer + (((char *)A) - data_cache))) @@ -16,7 +16,7 @@ { pthread_mutex_lock(&progress_mutex); pthread_cond_signal(&progress_wait); -@@ -749,7 +749,7 @@ inline void update_progress_bar() +@@ -750,7 +750,7 @@ inline void update_progress_bar() } @@ -25,7 +25,7 @@ { TRACE("Waiting for thread %d\n", i); while(thread[i] != 0) -@@ -3358,7 +3358,7 @@ struct inode_info *lookup_inode(struct s +@@ -3359,7 +3359,7 @@ struct inode_info *lookup_inode(struct s } diff --git a/tools/squashfs4/patches/200-add-fixed-timestamp-option.patch b/tools/squashfs4/patches/200-add-fixed-timestamp-option.patch new file mode 100644 index 00000000000..7411b978449 --- /dev/null +++ b/tools/squashfs4/patches/200-add-fixed-timestamp-option.patch @@ -0,0 +1,82 @@ +--- a/squashfs-tools/mksquashfs.c ++++ b/squashfs-tools/mksquashfs.c +@@ -176,6 +176,9 @@ unsigned int cache_bytes = 0, cache_size + /* inode lookup table */ + squashfs_inode *inode_lookup_table = NULL; + ++/* override all timestamps */ ++time_t fixed_time = -1; ++ + /* in memory directory data */ + #define I_COUNT_SIZE 128 + #define DIR_ENTRIES 32 +@@ -2453,6 +2456,8 @@ again: + restat: + fstat(file, &buf2); + close(file); ++ if (fixed_time != -1) ++ buf2.st_mtime = fixed_time; + if(read_size != buf2.st_size) { + memcpy(buf, &buf2, sizeof(struct stat)); + file_buffer->error = 2; +@@ -3613,7 +3618,7 @@ void dir_scan(squashfs_inode *inode, cha + buf.st_mode = S_IRWXU | S_IRWXG | S_IRWXO | S_IFDIR; + buf.st_uid = getuid(); + buf.st_gid = getgid(); +- buf.st_mtime = time(NULL); ++ buf.st_mtime = fixed_time != -1 ? fixed_time : time(NULL); + buf.st_dev = 0; + buf.st_ino = 0; + dir_ent->inode = lookup_inode(&buf); +@@ -3624,6 +3629,8 @@ void dir_scan(squashfs_inode *inode, cha + pathname, strerror(errno)); + return; + } ++ if(fixed_time != -1) ++ buf.st_mtime = fixed_time; + dir_ent->inode = lookup_inode(&buf); + } + +@@ -3678,6 +3685,8 @@ struct dir_info *dir_scan1(char *pathnam + filename, strerror(errno)); + continue; + } ++ if(fixed_time != -1) ++ buf.st_mtime = fixed_time; + + if((buf.st_mode & S_IFMT) != S_IFREG && + (buf.st_mode & S_IFMT) != S_IFDIR && +@@ -3796,7 +3805,7 @@ struct dir_info *dir_scan2(struct dir_in + buf.st_gid = pseudo_ent->dev->gid; + buf.st_rdev = makedev(pseudo_ent->dev->major, + pseudo_ent->dev->minor); +- buf.st_mtime = time(NULL); ++ buf.st_mtime = fixed_time != -1 ? fixed_time : time(NULL); + buf.st_ino = pseudo_ino ++; + + if(pseudo_ent->dev->type == 'f') { +@@ -4675,6 +4684,15 @@ int main(int argc, char *argv[]) + progress = FALSE; + else if(strcmp(argv[i], "-no-exports") == 0) + exportable = FALSE; ++ else if(strcmp(argv[i], "-fixed-time") == 0) { ++ if((++i == argc) || (fixed_time = ++ strtoll(argv[i], &b, 10), *b != '\0')) { ++ ERROR("%s: -fixed-time missing or invalid " ++ "timestamp\n", argv[0]); ++ ++ exit(1); ++ } ++ } + else if(strcmp(argv[i], "-processors") == 0) { + if((++i == argc) || (processors = + strtol(argv[i], &b, 10), *b != '\0')) { +@@ -5315,7 +5333,7 @@ printOptions: + sBlk.flags = SQUASHFS_MKFLAGS(noI, noD, noF, noX, no_fragments, + always_use_fragments, duplicate_checking, exportable, + no_xattrs, comp_opts); +- sBlk.mkfs_time = time(NULL); ++ sBlk.mkfs_time = fixed_time != -1 ? fixed_time : time(NULL); + + restore_filesystem: + if(progress && estimated_uncompressed) {