From 505a102cb37f0a44c56cf6079a629debd08a8bad Mon Sep 17 00:00:00 2001 From: jow Date: Wed, 13 Jan 2010 18:39:44 +0000 Subject: [PATCH 001/210] [package] base-files, mac80211 (#6491) - fix wep key handling in iw with mac80211 based drivers - sanitize keys where necessary - put a procedure prepare_key_wep() into /sbin/wifi for use by other driver backends git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19118 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/sbin/wifi | 13 +++++++ package/mac80211/files/lib/wifi/mac80211.sh | 38 +++++++++++++-------- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/package/base-files/files/sbin/wifi b/package/base-files/files/sbin/wifi index 90aeef725..5b6007f0a 100755 --- a/package/base-files/files/sbin/wifi +++ b/package/base-files/files/sbin/wifi @@ -34,6 +34,19 @@ bridge_interface() {( [ "$iftype" = bridge ] && config_get "$cfg" ifname )} +prepare_key_wep() { + local key="$1" + local hex=1 + + echo -n "$key" | grep -qE "[^a-fA-F0-9]" && hex=0 + [ "${#key}" -eq 10 -a $hex -eq 1 ] || \ + [ "${#key}" -eq 26 -a $hex -eq 1 ] || { + [ "${key:0:2}" = "s:" ] && key="${key#s:}" + key="$(echo -n "$key" | hexdump -ve '1/1 "%02x" ""')" + } + echo "$key" +} + wifi_fixup_hwmode() { local device="$1" local default="$2" diff --git a/package/mac80211/files/lib/wifi/mac80211.sh b/package/mac80211/files/lib/wifi/mac80211.sh index 742c1bb44..06f4b84da 100644 --- a/package/mac80211/files/lib/wifi/mac80211.sh +++ b/package/mac80211/files/lib/wifi/mac80211.sh @@ -176,20 +176,30 @@ enable_mac80211() { # configured to handle the wep connection if [ ! "$mode" = "ap" ]; then case "$enc" in - wep) + *wep*) config_get keymgmt "$vif" keymgmt - if [ -n "$keymgmt" ]; then - for idx in 1 2 3 4; do - local zidx - zidx=$(($idx - 1)) - config_get key "$vif" "key${idx}" - if [ -n "$key" ]; then - append keystring "${zidx}:${key} " - fi - done + if [ -z "$keymgmt" ]; then + config_get key "$vif" key + key="${key:-1}" + case "$key" in + [1234]) + for idx in 1 2 3 4; do + local zidx + zidx=$(($idx - 1)) + config_get ckey "$vif" "key${idx}" + if [ -n "$ckey" ]; then + [ $idx -eq $key ] && zidx="d:${zidx}" + append keystring "${zidx}:$(prepare_key_wep "$ckey")" + fi + done + ;; + *) + keystring="d:0:$(prepare_key_wep "$key")" + ;; + esac fi ;; - *wpa*|*psk*) + *psk*|*wpa*) config_get key "$vif" key ;; esac @@ -241,10 +251,10 @@ enable_mac80211() { sta|mesh) config_get bssid "$vif" bssid case "$enc" in - wep) - if [ -n "$keymgmt" ]; then + *wep*) + if [ -z "$keymgmt" ]; then [ -n "$keystring" ] && - iw dev "$ifname" connect "$ssid" ${fixed:+$freq} $bssid key "$keystring" + iw dev "$ifname" connect "$ssid" ${fixed:+$freq} $bssid key $keystring else if eval "type wpa_supplicant_setup_vif" 2>/dev/null >/dev/null; then wpa_supplicant_setup_vif "$vif" wext || { From 65c8a9c39aa70187e836e4e8a78ad0beb2b3fb7d Mon Sep 17 00:00:00 2001 From: jow Date: Wed, 13 Jan 2010 19:31:47 +0000 Subject: [PATCH 002/210] [package] wpa_supplicant: add WEP key handling to conform with documented behaviour in mac80211.sh (#6493) git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19119 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../wpa_supplicant/files/wpa_supplicant.sh | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/package/wpa_supplicant/files/wpa_supplicant.sh b/package/wpa_supplicant/files/wpa_supplicant.sh index 1d1367a17..40e8ff55b 100644 --- a/package/wpa_supplicant/files/wpa_supplicant.sh +++ b/package/wpa_supplicant/files/wpa_supplicant.sh @@ -12,12 +12,33 @@ wpa_supplicant_setup_vif() { } case "$enc" in + *wep*) + key_mgmt='NONE' + config_get key "$vif" key + key="${key:-1}" + case "$key" in + [1234]) + for idx in 1 2 3 4; do + local zidx + zidx=$(($idx - 1)) + config_get ckey "$vif" "key${idx}" + if [ -n "$ckey" ] && \ + append "wep_key${zidx}" "wep_key${zidx}=$(prepare_key_wep "$ckey")" + done + wep_tx_keyidx="wep_tx_keyidx=$((key - 1))" + ;; + *) + wep_key0="wep_key0=$(prepare_key_wep "$key")" + wep_tx_keyidx="wep_tx_keyidx=0" + ;; + esac + ;; *psk*) key_mgmt='WPA-PSK' config_get_bool usepassphrase "$vif" passphrase 1 case "$enc" in *psk2*) - proto='RSN' + proto='proto=RSN' if [ "$usepassphrase" = "1" ]; then passphrase="psk=\"${key}\"" else @@ -25,7 +46,7 @@ wpa_supplicant_setup_vif() { fi ;; *psk*) - proto='WPA' + proto='proto=WPA' if [ "$usepassphrase" = "1" ]; then passphrase="psk=\"${key}\"" else @@ -35,7 +56,7 @@ wpa_supplicant_setup_vif() { esac ;; *wpa*|*8021x*) - proto='WPA2' + proto='proto=WPA2' key_mgmt='WPA-EAP' config_get ca_cert "$vif" ca_cert ca_cert=${ca_cert:+"ca_cert=\"$ca_cert\""} @@ -72,7 +93,7 @@ network={ ssid="$ssid" $bssid key_mgmt=$key_mgmt - proto=$proto + $proto $passphrase $pairwise $group @@ -83,7 +104,13 @@ network={ $phase2 $identity $password + $wep_key0 + $wep_key1 + $wep_key2 + $wep_key3 + $wep_tx_keyidx } EOF - [ -z "$proto" ] || wpa_supplicant ${bridge:+ -b $bridge} -B -P "/var/run/wifi-${ifname}.pid" -D ${driver:-wext} -i "$ifname" -c /var/run/wpa_supplicant-$ifname.conf + [ -z "$proto" -a "$key_mgmt" != "NONE" ] || + wpa_supplicant ${bridge:+ -b $bridge} -B -P "/var/run/wifi-${ifname}.pid" -D ${driver:-wext} -i "$ifname" -c /var/run/wpa_supplicant-$ifname.conf } From 0466bd77cfa952eca360e43835ac39402c4dc491 Mon Sep 17 00:00:00 2001 From: jow Date: Wed, 13 Jan 2010 19:38:53 +0000 Subject: [PATCH 003/210] [buildroot] allow download urls using the file:// schema (#6480) git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19120 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- include/download.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/download.mk b/include/download.mk index 78848b9c9..a50a5e936 100644 --- a/include/download.mk +++ b/include/download.mk @@ -11,7 +11,7 @@ DOWNLOAD_RDEP=$(STAMP_PREPARED) $(HOST_STAMP_PREPARED) define dl_method $(strip \ $(if $(2),$(2), \ - $(if $(filter @GNOME/% @GNU/% @KERNEL/% @SF/% ftp://% http://%,$(1)),default, \ + $(if $(filter @GNOME/% @GNU/% @KERNEL/% @SF/% ftp://% http://% file://%,$(1)),default, \ $(if $(filter git://%,$(1)),git, \ $(if $(filter svn://%,$(1)),svn, \ $(if $(filter cvs://%,$(1)),cvs, \ From 7d33089d1ad19c4e13e4972fc20b38b8fbddc41a Mon Sep 17 00:00:00 2001 From: jow Date: Wed, 13 Jan 2010 20:21:39 +0000 Subject: [PATCH 004/210] [package] opkg: fallback to dest->root_dir if specified overlay_root does not exist on filesystem (#6498) git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19121 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../opkg/patches/003-fs_overlay_support.patch | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/package/opkg/patches/003-fs_overlay_support.patch b/package/opkg/patches/003-fs_overlay_support.patch index 0716ae481..0d4402ed1 100644 --- a/package/opkg/patches/003-fs_overlay_support.patch +++ b/package/opkg/patches/003-fs_overlay_support.patch @@ -26,22 +26,35 @@ Signed-off-by: Nicolas Thill int noaction; --- a/libopkg/opkg_install.c +++ b/libopkg/opkg_install.c -@@ -189,13 +189,19 @@ +@@ -21,6 +21,7 @@ + #include + #include + #include ++#include + + #include "pkg.h" + #include "pkg_hash.h" +@@ -189,13 +190,24 @@ verify_pkg_installable(pkg_t *pkg) { unsigned long kbs_available, pkg_size_kbs; - char *root_dir; + char *root_dir = NULL; ++ struct stat s; if (conf->force_space || pkg->installed_size == 0) return 0; - root_dir = pkg->dest ? pkg->dest->root_dir : - conf->default_dest->root_dir; -+ if( !pkg->dest || !strcmp(pkg->dest->name, "root") ) -+ root_dir = conf->overlay_root; -+ else -+ root_dir = pkg->dest->root_dir; ++ if( pkg->dest ) ++ { ++ if( !strcmp(pkg->dest->name, "root") && conf->overlay_root ++ && !stat(conf->overlay_root, &s) && (s.st_mode & S_IFDIR) ) ++ root_dir = conf->overlay_root; ++ else ++ root_dir = pkg->dest->root_dir; ++ } + + if( !root_dir ) + root_dir = conf->default_dest->root_dir; From 57f44330bc0b2f82117b743f84d2755ea539d9a3 Mon Sep 17 00:00:00 2001 From: florian Date: Thu, 14 Jan 2010 12:27:46 +0000 Subject: [PATCH 005/210] [toolchain] add support for uClibc 0.9.30.2 git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19125 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- toolchain/uClibc/Config.in | 3 + toolchain/uClibc/Config.version | 1 + toolchain/uClibc/Makefile | 1 + toolchain/uClibc/config-0.9.30.2/arm | 25 + toolchain/uClibc/config-0.9.30.2/arm.gemini | 26 + toolchain/uClibc/config-0.9.30.2/arm.storm | 26 + toolchain/uClibc/config-0.9.30.2/armeb | 25 + toolchain/uClibc/config-0.9.30.2/avr32 | 10 + toolchain/uClibc/config-0.9.30.2/common | 179 + toolchain/uClibc/config-0.9.30.2/cris | 6 + toolchain/uClibc/config-0.9.30.2/i386 | 24 + toolchain/uClibc/config-0.9.30.2/i686 | 24 + toolchain/uClibc/config-0.9.30.2/m68k | 5 + toolchain/uClibc/config-0.9.30.2/mips | 17 + toolchain/uClibc/config-0.9.30.2/mips64 | 17 + toolchain/uClibc/config-0.9.30.2/mips64el | 17 + toolchain/uClibc/config-0.9.30.2/mipsel | 17 + .../uClibc/config-0.9.30.2/mipsel.brcm-2.4 | 18 + .../uClibc/config-0.9.30.2/mipsel.cobalt | 17 + toolchain/uClibc/config-0.9.30.2/powerpc | 7 + toolchain/uClibc/config-0.9.30.2/ubicom32 | 35 + toolchain/uClibc/config-0.9.30.2/x86_64 | 7 + .../patches-0.9.30.2/110-compat_macros.patch | 51 + .../patches-0.9.30.2/120-adjtimex.patch | 14 + .../130-pthread_weak_binding.patch | 10 + .../patches-0.9.30.2/140-math_decl.patch | 11 + .../patches-0.9.30.2/170-math_finite.patch | 23 + .../410-llvm_workaround.patch | 11 + .../450-powerpc_copysignl.patch | 103 + .../600-ubicom32-uClibc.patch | 4493 +++++++++++++++++ 30 files changed, 5223 insertions(+) create mode 100644 toolchain/uClibc/config-0.9.30.2/arm create mode 100644 toolchain/uClibc/config-0.9.30.2/arm.gemini create mode 100644 toolchain/uClibc/config-0.9.30.2/arm.storm create mode 100644 toolchain/uClibc/config-0.9.30.2/armeb create mode 100644 toolchain/uClibc/config-0.9.30.2/avr32 create mode 100644 toolchain/uClibc/config-0.9.30.2/common create mode 100644 toolchain/uClibc/config-0.9.30.2/cris create mode 100644 toolchain/uClibc/config-0.9.30.2/i386 create mode 100644 toolchain/uClibc/config-0.9.30.2/i686 create mode 100644 toolchain/uClibc/config-0.9.30.2/m68k create mode 100644 toolchain/uClibc/config-0.9.30.2/mips create mode 100644 toolchain/uClibc/config-0.9.30.2/mips64 create mode 100644 toolchain/uClibc/config-0.9.30.2/mips64el create mode 100644 toolchain/uClibc/config-0.9.30.2/mipsel create mode 100644 toolchain/uClibc/config-0.9.30.2/mipsel.brcm-2.4 create mode 100644 toolchain/uClibc/config-0.9.30.2/mipsel.cobalt create mode 100644 toolchain/uClibc/config-0.9.30.2/powerpc create mode 100644 toolchain/uClibc/config-0.9.30.2/ubicom32 create mode 100644 toolchain/uClibc/config-0.9.30.2/x86_64 create mode 100644 toolchain/uClibc/patches-0.9.30.2/110-compat_macros.patch create mode 100644 toolchain/uClibc/patches-0.9.30.2/120-adjtimex.patch create mode 100644 toolchain/uClibc/patches-0.9.30.2/130-pthread_weak_binding.patch create mode 100644 toolchain/uClibc/patches-0.9.30.2/140-math_decl.patch create mode 100644 toolchain/uClibc/patches-0.9.30.2/170-math_finite.patch create mode 100644 toolchain/uClibc/patches-0.9.30.2/410-llvm_workaround.patch create mode 100644 toolchain/uClibc/patches-0.9.30.2/450-powerpc_copysignl.patch create mode 100644 toolchain/uClibc/patches-0.9.30.2/600-ubicom32-uClibc.patch diff --git a/toolchain/uClibc/Config.in b/toolchain/uClibc/Config.in index 95113f325..e7f016a4c 100644 --- a/toolchain/uClibc/Config.in +++ b/toolchain/uClibc/Config.in @@ -10,6 +10,9 @@ choice config UCLIBC_VERSION_0_9_30_1 bool "uClibc 0.9.30.1" + config UCLIBC_VERSION_0_9_30_2 + bool "uClibc 0.9.30.2" + config UCLIBC_VERSION_NPTL bool "uClibc NPTL branch" depends BROKEN diff --git a/toolchain/uClibc/Config.version b/toolchain/uClibc/Config.version index 886b8cc9d..fe6c7ba99 100644 --- a/toolchain/uClibc/Config.version +++ b/toolchain/uClibc/Config.version @@ -2,5 +2,6 @@ config UCLIBC_VERSION string depends on USE_UCLIBC default "0.9.30.1" if UCLIBC_VERSION_0_9_30_1 + default "0.9.30.2" if UCLIBC_VERSION_0_9_30_2 default "0.9.30+nptl" if UCLIBC_VERSION_NPTL default "0.9.30.1" diff --git a/toolchain/uClibc/Makefile b/toolchain/uClibc/Makefile index 31b996d13..f1e6fedb8 100644 --- a/toolchain/uClibc/Makefile +++ b/toolchain/uClibc/Makefile @@ -25,6 +25,7 @@ PATCH_DIR:=./patches-$(PKG_VERSION) CONFIG_DIR:=./config-$(PKG_VERSION) PKG_MD5SUM_0.9.30.1 = 1a4b84e5536ad8170563ffa88c34679c +PKG_MD5SUM_0.9.30.2 = e759ec855500082ac3e671dd6cacfdb0 PKG_MD5SUM=$(PKG_MD5SUM_$(PKG_VERSION)) HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)-$(PKG_VERSION) diff --git a/toolchain/uClibc/config-0.9.30.2/arm b/toolchain/uClibc/config-0.9.30.2/arm new file mode 100644 index 000000000..d26b075b4 --- /dev/null +++ b/toolchain/uClibc/config-0.9.30.2/arm @@ -0,0 +1,25 @@ +ARCH_ANY_ENDIAN=y +ARCH_LITTLE_ENDIAN=y +ARCH_WANTS_LITTLE_ENDIAN=y +# CONFIG_ARM10T is not set +# CONFIG_ARM1136JF_S is not set +# CONFIG_ARM1176JZF_S is not set +# CONFIG_ARM1176JZ_S is not set +# CONFIG_ARM610 is not set +# CONFIG_ARM710 is not set +# CONFIG_ARM720T is not set +# CONFIG_ARM7TDMI is not set +# CONFIG_ARM920T is not set +# CONFIG_ARM922T is not set +# CONFIG_ARM926T is not set +# CONFIG_ARM_CORTEX_M1 is not set +# CONFIG_ARM_CORTEX_M3 is not set +# CONFIG_ARM_EABI is not set +# CONFIG_ARM_IWMMXT is not set +CONFIG_ARM_OABI=y +# CONFIG_ARM_SA110 is not set +# CONFIG_ARM_SA1100 is not set +CONFIG_ARM_XSCALE=y +# CONFIG_GENERIC_ARM is not set +TARGET_ARCH="arm" +TARGET_arm=y diff --git a/toolchain/uClibc/config-0.9.30.2/arm.gemini b/toolchain/uClibc/config-0.9.30.2/arm.gemini new file mode 100644 index 000000000..8043cf61b --- /dev/null +++ b/toolchain/uClibc/config-0.9.30.2/arm.gemini @@ -0,0 +1,26 @@ +ARCH_ANY_ENDIAN=y +ARCH_LITTLE_ENDIAN=y +ARCH_WANTS_LITTLE_ENDIAN=y +# CONFIG_ARM10T is not set +# CONFIG_ARM1136JF_S is not set +# CONFIG_ARM1176JZF_S is not set +# CONFIG_ARM1176JZ_S is not set +# CONFIG_ARM610 is not set +# CONFIG_ARM710 is not set +# CONFIG_ARM720T is not set +# CONFIG_ARM7TDMI is not set +CONFIG_ARM920T=y +# CONFIG_ARM922T is not set +# CONFIG_ARM926T is not set +# CONFIG_ARM_CORTEX_M1 is not set +# CONFIG_ARM_CORTEX_M3 is not set +# CONFIG_ARM_EABI is not set +# CONFIG_ARM_IWMMXT is not set +CONFIG_ARM_OABI=y +# CONFIG_ARM_SA110 is not set +# CONFIG_ARM_SA1100 is not set +# CONFIG_ARM_XSCALE is not set +# CONFIG_GENERIC_ARM is not set +TARGET_ARCH="arm" +TARGET_arm=y +# USE_BX is not set diff --git a/toolchain/uClibc/config-0.9.30.2/arm.storm b/toolchain/uClibc/config-0.9.30.2/arm.storm new file mode 100644 index 000000000..8043cf61b --- /dev/null +++ b/toolchain/uClibc/config-0.9.30.2/arm.storm @@ -0,0 +1,26 @@ +ARCH_ANY_ENDIAN=y +ARCH_LITTLE_ENDIAN=y +ARCH_WANTS_LITTLE_ENDIAN=y +# CONFIG_ARM10T is not set +# CONFIG_ARM1136JF_S is not set +# CONFIG_ARM1176JZF_S is not set +# CONFIG_ARM1176JZ_S is not set +# CONFIG_ARM610 is not set +# CONFIG_ARM710 is not set +# CONFIG_ARM720T is not set +# CONFIG_ARM7TDMI is not set +CONFIG_ARM920T=y +# CONFIG_ARM922T is not set +# CONFIG_ARM926T is not set +# CONFIG_ARM_CORTEX_M1 is not set +# CONFIG_ARM_CORTEX_M3 is not set +# CONFIG_ARM_EABI is not set +# CONFIG_ARM_IWMMXT is not set +CONFIG_ARM_OABI=y +# CONFIG_ARM_SA110 is not set +# CONFIG_ARM_SA1100 is not set +# CONFIG_ARM_XSCALE is not set +# CONFIG_GENERIC_ARM is not set +TARGET_ARCH="arm" +TARGET_arm=y +# USE_BX is not set diff --git a/toolchain/uClibc/config-0.9.30.2/armeb b/toolchain/uClibc/config-0.9.30.2/armeb new file mode 100644 index 000000000..ba3ea5c84 --- /dev/null +++ b/toolchain/uClibc/config-0.9.30.2/armeb @@ -0,0 +1,25 @@ +ARCH_ANY_ENDIAN=y +ARCH_BIG_ENDIAN=y +ARCH_WANTS_BIG_ENDIAN=y +# CONFIG_ARM10T is not set +# CONFIG_ARM1136JF_S is not set +# CONFIG_ARM1176JZF_S is not set +# CONFIG_ARM1176JZ_S is not set +# CONFIG_ARM610 is not set +# CONFIG_ARM710 is not set +# CONFIG_ARM720T is not set +# CONFIG_ARM7TDMI is not set +# CONFIG_ARM920T is not set +# CONFIG_ARM922T is not set +# CONFIG_ARM926T is not set +# CONFIG_ARM_CORTEX_M1 is not set +# CONFIG_ARM_CORTEX_M3 is not set +# CONFIG_ARM_EABI is not set +# CONFIG_ARM_IWMMXT is not set +CONFIG_ARM_OABI=y +# CONFIG_ARM_SA110 is not set +# CONFIG_ARM_SA1100 is not set +CONFIG_ARM_XSCALE=y +# CONFIG_GENERIC_ARM is not set +TARGET_ARCH="arm" +TARGET_arm=y diff --git a/toolchain/uClibc/config-0.9.30.2/avr32 b/toolchain/uClibc/config-0.9.30.2/avr32 new file mode 100644 index 000000000..bf7907aed --- /dev/null +++ b/toolchain/uClibc/config-0.9.30.2/avr32 @@ -0,0 +1,10 @@ +ARCH_BIG_ENDIAN=y +CONFIG_AVR32_AP7=y +FORCE_SHAREABLE_TEXT_SEGMENTS=y +LINKRELAX=y +TARGET_ARCH="avr32" +TARGET_avr32=y +UCLIBC_HAS_FPU=y +# UCLIBC_HAS_SCANF_GLIBC_A_FLAG is not set +# UCLIBC_HAS_STRING_ARCH_OPT is not set +UNIX98PTY_ONLY=y diff --git a/toolchain/uClibc/config-0.9.30.2/common b/toolchain/uClibc/config-0.9.30.2/common new file mode 100644 index 000000000..9cd2e3d1b --- /dev/null +++ b/toolchain/uClibc/config-0.9.30.2/common @@ -0,0 +1,179 @@ +# 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=y +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 +# EXTRA_WARNINGS is not set +FORCE_OPTIONS_FOR_ARCH=y +# FORCE_SHAREABLE_TEXT_SEGMENTS 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_LDD_SUPPORT=y +# LDSO_PRELOAD_FILE_SUPPORT is not set +LDSO_RUNPATH=y +LINUXTHREADS_OLD=y +# MALLOC is not set +MALLOC_GLIBC_COMPAT=y +# MALLOC_SIMPLE is not set +MALLOC_STANDARD=y +# PTHREADS_DEBUG_SUPPORT is not set +RUNTIME_PREFIX="/" +SHARED_LIB_LOADER_PREFIX="/lib" +# 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_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_ubicom32 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 is not set +# UCLIBC_HAS_ARC4RANDOM is not set +UCLIBC_HAS_BSD_ERR=y +UCLIBC_HAS_BSD_RES_CLOSE=y +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_FENV is not set +UCLIBC_HAS_FLOATS=y +UCLIBC_HAS_FNMATCH=y +UCLIBC_HAS_FNMATCH_OLD=y +UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE=y +# UCLIBC_HAS_FOPEN_LARGEFILE_MODE is not set +# UCLIBC_HAS_FPU is not set +UCLIBC_HAS_FTW=y +UCLIBC_HAS_FULL_RPC=y +UCLIBC_HAS_GETPT=y +UCLIBC_HAS_GLIBC_CUSTOM_PRINTF=y +UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y +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_LOCALE is not set +UCLIBC_HAS_NETWORK_SUPPORT=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_RPC=y +UCLIBC_HAS_SCANF_GLIBC_A_FLAG=y +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_WCHAR=y +UCLIBC_HAS_WORDEXP=y +# UCLIBC_HAS_XATTR is not set +UCLIBC_HAS___PROGNAME=y +# UCLIBC_LINUX_MODULE_24 is not set +UCLIBC_LINUX_SPECIFIC=y +# UCLIBC_MALLOC_DEBUGGING is not set +# UCLIBC_MJN3_ONLY is not set +# UCLIBC_NTP_LEGACY is not set +UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS=9 +UCLIBC_PWD_BUFFER_SIZE=256 +# UCLIBC_STATIC_LDCONFIG is not set +UCLIBC_SUPPORT_AI_ADDRCONFIG=y +UCLIBC_SUSV3_LEGACY=y +UCLIBC_SUSV3_LEGACY_MACROS=y +# UCLIBC_SV4_DEPRECATED is not set +UCLIBC_TZ_FILE_PATH="/etc/TZ" +UCLIBC_USE_NETLINK=y +# UNIX98PTY_ONLY is not set +USE_BX=y +WARNINGS="-Wall" diff --git a/toolchain/uClibc/config-0.9.30.2/cris b/toolchain/uClibc/config-0.9.30.2/cris new file mode 100644 index 000000000..b9ea676fc --- /dev/null +++ b/toolchain/uClibc/config-0.9.30.2/cris @@ -0,0 +1,6 @@ +ARCH_LITTLE_ENDIAN=y +CONFIG_CRIS=y +# CONFIG_CRISV32 is not set +TARGET_ARCH="cris" +TARGET_cris=y +UCLIBC_HAS_FPU=y diff --git a/toolchain/uClibc/config-0.9.30.2/i386 b/toolchain/uClibc/config-0.9.30.2/i386 new file mode 100644 index 000000000..521ce8c25 --- /dev/null +++ b/toolchain/uClibc/config-0.9.30.2/i386 @@ -0,0 +1,24 @@ +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 +LINUXTHREADS_NEW=y +# LINUXTHREADS_OLD is not set +TARGET_ARCH="i386" +TARGET_i386=y +UCLIBC_HAS_FPU=y +UCLIBC_HAS_LONG_DOUBLE_MATH=y diff --git a/toolchain/uClibc/config-0.9.30.2/i686 b/toolchain/uClibc/config-0.9.30.2/i686 new file mode 100644 index 000000000..22379f4a8 --- /dev/null +++ b/toolchain/uClibc/config-0.9.30.2/i686 @@ -0,0 +1,24 @@ +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 +LINUXTHREADS_NEW=y +# LINUXTHREADS_OLD is not set +TARGET_ARCH="i386" +TARGET_i386=y +UCLIBC_HAS_FPU=y +UCLIBC_HAS_LONG_DOUBLE_MATH=y diff --git a/toolchain/uClibc/config-0.9.30.2/m68k b/toolchain/uClibc/config-0.9.30.2/m68k new file mode 100644 index 000000000..ae984916d --- /dev/null +++ b/toolchain/uClibc/config-0.9.30.2/m68k @@ -0,0 +1,5 @@ +ARCH_BIG_ENDIAN=y +TARGET_ARCH="m68k" +TARGET_SUBARCH="" +TARGET_m68k=y +UCLIBC_HAS_LONG_DOUBLE_MATH=y diff --git a/toolchain/uClibc/config-0.9.30.2/mips b/toolchain/uClibc/config-0.9.30.2/mips new file mode 100644 index 000000000..7398c6692 --- /dev/null +++ b/toolchain/uClibc/config-0.9.30.2/mips @@ -0,0 +1,17 @@ +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.30.2/mips64 b/toolchain/uClibc/config-0.9.30.2/mips64 new file mode 100644 index 000000000..fa5bee3aa --- /dev/null +++ b/toolchain/uClibc/config-0.9.30.2/mips64 @@ -0,0 +1,17 @@ +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.30.2/mips64el b/toolchain/uClibc/config-0.9.30.2/mips64el new file mode 100644 index 000000000..1ca764f6e --- /dev/null +++ b/toolchain/uClibc/config-0.9.30.2/mips64el @@ -0,0 +1,17 @@ +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.30.2/mipsel b/toolchain/uClibc/config-0.9.30.2/mipsel new file mode 100644 index 000000000..7648f396b --- /dev/null +++ b/toolchain/uClibc/config-0.9.30.2/mipsel @@ -0,0 +1,17 @@ +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.30.2/mipsel.brcm-2.4 b/toolchain/uClibc/config-0.9.30.2/mipsel.brcm-2.4 new file mode 100644 index 000000000..785786846 --- /dev/null +++ b/toolchain/uClibc/config-0.9.30.2/mipsel.brcm-2.4 @@ -0,0 +1,18 @@ +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 +UCLIBC_LINUX_MODULE_24=y diff --git a/toolchain/uClibc/config-0.9.30.2/mipsel.cobalt b/toolchain/uClibc/config-0.9.30.2/mipsel.cobalt new file mode 100644 index 000000000..323b0aa52 --- /dev/null +++ b/toolchain/uClibc/config-0.9.30.2/mipsel.cobalt @@ -0,0 +1,17 @@ +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.30.2/powerpc b/toolchain/uClibc/config-0.9.30.2/powerpc new file mode 100644 index 000000000..4e5cd43ba --- /dev/null +++ b/toolchain/uClibc/config-0.9.30.2/powerpc @@ -0,0 +1,7 @@ +ARCH_BIG_ENDIAN=y +CONFIG_CLASSIC=y +# CONFIG_E500 is not set +TARGET_ARCH="powerpc" +TARGET_SUBARCH="classic" +TARGET_powerpc=y +UCLIBC_HAS_LONG_DOUBLE_MATH=y diff --git a/toolchain/uClibc/config-0.9.30.2/ubicom32 b/toolchain/uClibc/config-0.9.30.2/ubicom32 new file mode 100644 index 000000000..ef00e7935 --- /dev/null +++ b/toolchain/uClibc/config-0.9.30.2/ubicom32 @@ -0,0 +1,35 @@ +ARCH_BIG_ENDIAN=y +ARCH_HAS_NO_MMU=y +COMPAT_ATEXIT=y +# CONFIG_UC_UBICOM32_V3 is not set +CONFIG_UC_UBICOM32_V4=y +# DOSTRIP is not set +EXCLUDE_BRK=y +FORCE_SHAREABLE_TEXT_SEGMENTS=y +LDSO_PRELOAD_FILE_SUPPORT=y +MALLOC=y +# MALLOC_STANDARD is not set +PTHREADS_DEBUG_SUPPORT=y +SUPPORT_LD_DEBUG=y +TARGET_ARCH="ubicom32" +TARGET_ubicom32=y +# UCLIBC_FORMAT_ELF is not set +UCLIBC_FORMAT_FDPIC_ELF=y +# UCLIBC_FORMAT_FLAT is not set +# UCLIBC_FORMAT_FLAT_SEP_DATA is not set +# UCLIBC_FORMAT_SHARED_FLAT is not set +UCLIBC_HAS_ADVANCED_REALTIME=y +UCLIBC_HAS_FOPEN_LARGEFILE_MODE=y +UCLIBC_HAS_FPU=y +# UCLIBC_HAS_GETPT is not set +UCLIBC_HAS_OBSOLETE_BSD_SIGNAL=y +UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL=y +UCLIBC_HAS_PROFILING=y +UCLIBC_HAS_REENTRANT_RPC=y +UCLIBC_HAS_STUBS=y +UCLIBC_HAS_XATTR=y +UCLIBC_NTP_LEGACY=y +UCLIBC_STATIC_LDCONFIG=y +UCLIBC_SV4_DEPRECATED=y +UCLIBC_UCLINUX_BROKEN_MUNMAP=y +UNIX98PTY_ONLY=y diff --git a/toolchain/uClibc/config-0.9.30.2/x86_64 b/toolchain/uClibc/config-0.9.30.2/x86_64 new file mode 100644 index 000000000..20a18f1a0 --- /dev/null +++ b/toolchain/uClibc/config-0.9.30.2/x86_64 @@ -0,0 +1,7 @@ +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 +UCLIBC_HAS_LONG_DOUBLE_MATH=y diff --git a/toolchain/uClibc/patches-0.9.30.2/110-compat_macros.patch b/toolchain/uClibc/patches-0.9.30.2/110-compat_macros.patch new file mode 100644 index 000000000..7659e465c --- /dev/null +++ b/toolchain/uClibc/patches-0.9.30.2/110-compat_macros.patch @@ -0,0 +1,51 @@ +--- ./include/string.h.orig 2008-06-08 22:38:53.000000000 +0200 ++++ ./include/string.h 2009-01-02 16:09:03.000000000 +0100 +@@ -355,18 +355,40 @@ + /* 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.30.2/120-adjtimex.patch b/toolchain/uClibc/patches-0.9.30.2/120-adjtimex.patch new file mode 100644 index 000000000..5127701df --- /dev/null +++ b/toolchain/uClibc/patches-0.9.30.2/120-adjtimex.patch @@ -0,0 +1,14 @@ +Index: uClibc-0.9.29/include/sys/timex.h +=================================================================== +--- uClibc-0.9.29.orig/include/sys/timex.h 2007-12-30 17:34:21.983513096 +0100 ++++ uClibc-0.9.29/include/sys/timex.h 2007-12-30 17:34:32.180094169 +0100 +@@ -116,7 +116,8 @@ + + __BEGIN_DECLS + +-extern int __adjtimex (struct timex *__ntx) __THROW; ++#undef __adjtimex ++#define __adjtimex adjtimex + extern int adjtimex (struct timex *__ntx) __THROW; + + extern int ntp_gettime (struct ntptimeval *__ntv) __THROW; diff --git a/toolchain/uClibc/patches-0.9.30.2/130-pthread_weak_binding.patch b/toolchain/uClibc/patches-0.9.30.2/130-pthread_weak_binding.patch new file mode 100644 index 000000000..92227cf41 --- /dev/null +++ b/toolchain/uClibc/patches-0.9.30.2/130-pthread_weak_binding.patch @@ -0,0 +1,10 @@ +--- a/libc/unistd/daemon.c ++++ b/libc/unistd/daemon.c +@@ -54,7 +54,6 @@ + libc_hidden_proto(dup2) + libc_hidden_proto(setsid) + libc_hidden_proto(chdir) +-libc_hidden_proto(fork) + + int daemon( int nochdir, int noclose ) + { diff --git a/toolchain/uClibc/patches-0.9.30.2/140-math_decl.patch b/toolchain/uClibc/patches-0.9.30.2/140-math_decl.patch new file mode 100644 index 000000000..3b9a6a99c --- /dev/null +++ b/toolchain/uClibc/patches-0.9.30.2/140-math_decl.patch @@ -0,0 +1,11 @@ +--- a/libc/sysdeps/linux/common/bits/mathcalls.h ++++ b/libc/sysdeps/linux/common/bits/mathcalls.h +@@ -229,7 +229,7 @@ + + + /* Return nonzero if VALUE is not a number. */ +-__MATHDECL_PRIV (int,__isnan,, (_Mdouble_ __value), (__const__)); ++__MATHDECL_PRIV (int,isnan,, (_Mdouble_ __value), (__const__)); + + #if defined __USE_MISC || defined __USE_XOPEN + /* Return nonzero if VALUE is not a number. */ diff --git a/toolchain/uClibc/patches-0.9.30.2/170-math_finite.patch b/toolchain/uClibc/patches-0.9.30.2/170-math_finite.patch new file mode 100644 index 000000000..973177235 --- /dev/null +++ b/toolchain/uClibc/patches-0.9.30.2/170-math_finite.patch @@ -0,0 +1,23 @@ +--- a/include/math.h ++++ b/include/math.h +@@ -179,7 +179,7 @@ + + + /* 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: +@@ -299,6 +299,11 @@ + + #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.30.2/410-llvm_workaround.patch b/toolchain/uClibc/patches-0.9.30.2/410-llvm_workaround.patch new file mode 100644 index 000000000..3847b720a --- /dev/null +++ b/toolchain/uClibc/patches-0.9.30.2/410-llvm_workaround.patch @@ -0,0 +1,11 @@ +--- a/libc/stdio/_stdio.c ++++ b/libc/stdio/_stdio.c +@@ -121,7 +121,7 @@ static FILE _stdio_streams[] = { + __FLAG_NBF|__FLAG_WRITEONLY, \ + 2, \ + NULL, \ +- NULL, \ ++ 0, \ + 0 ) + }; + diff --git a/toolchain/uClibc/patches-0.9.30.2/450-powerpc_copysignl.patch b/toolchain/uClibc/patches-0.9.30.2/450-powerpc_copysignl.patch new file mode 100644 index 000000000..2bdf1f34c --- /dev/null +++ b/toolchain/uClibc/patches-0.9.30.2/450-powerpc_copysignl.patch @@ -0,0 +1,103 @@ +--- 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 + + SSRC := \ + __longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S brk.S \ +--- /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.30.2/600-ubicom32-uClibc.patch b/toolchain/uClibc/patches-0.9.30.2/600-ubicom32-uClibc.patch new file mode 100644 index 000000000..256e022e2 --- /dev/null +++ b/toolchain/uClibc/patches-0.9.30.2/600-ubicom32-uClibc.patch @@ -0,0 +1,4493 @@ +Index: uClibc-0.9.30.2/Rules.mak +=================================================================== +--- uClibc-0.9.30.2.orig/Rules.mak 2010-01-13 22:22:31.000000000 +0100 ++++ uClibc-0.9.30.2/Rules.mak 2010-01-14 11:05:01.000000000 +0100 +@@ -406,6 +406,17 @@ + SYMBOL_PREFIX=_ + endif + ++ifeq ($(TARGET_ARCH),ubicom32) ++ OPTIMIZATION+=-fstrict-aliasing ++ CPU_CFLAGS-$(CONFIG_UBICOM32_V3)+=-march=ubicom32v3 ++ CPU_CFLAGS-$(CONFIG_UBICOM32_V4)+=-march=ubicom32v4 ++ifeq ($(UCLIBC_FORMAT_FDPIC_ELF),y) ++ CPU_CFLAGS-y:=-mfdpic ++ CPU_LDFLAGS-y += -Wl,-melf32ubicom32fdpic ++endif ++ ++endif ++ + ifeq ($(TARGET_ARCH),v850) + SYMBOL_PREFIX=_ + endif +Index: uClibc-0.9.30.2/extra/Configs/Config.in +=================================================================== +--- uClibc-0.9.30.2.orig/extra/Configs/Config.in 2010-01-13 22:22:31.000000000 +0100 ++++ uClibc-0.9.30.2/extra/Configs/Config.in 2010-01-14 11:05:01.000000000 +0100 +@@ -73,6 +73,9 @@ + config TARGET_sparc + bool "sparc" + ++config TARGET_ubicom32 ++ bool "ubicom32" ++ + config TARGET_v850 + bool "v850 (BROKEN)" + +@@ -174,6 +177,10 @@ + source "extra/Configs/Config.sparc" + endif + ++if TARGET_ubicom32 ++source "extra/Configs/Config.ubicom32" ++endif ++ + if TARGET_v850 + source "extra/Configs/Config.v850" + endif +Index: uClibc-0.9.30.2/extra/Configs/Config.in.arch +=================================================================== +--- uClibc-0.9.30.2.orig/extra/Configs/Config.in.arch 2010-01-13 22:22:31.000000000 +0100 ++++ uClibc-0.9.30.2/extra/Configs/Config.in.arch 2010-01-14 11:05:01.000000000 +0100 +@@ -149,7 +149,7 @@ + config DO_C99_MATH + bool "Enable full C99 math library support" + depends on UCLIBC_HAS_FLOATS +- default n ++ default y + help + If you want the uClibc math library to contain the full set C99 + math library features, then answer Y. If you leave this set to +Index: uClibc-0.9.30.2/extra/Configs/Config.ubicom32 +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/extra/Configs/Config.ubicom32 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,44 @@ ++# ++# For a description of the syntax of this configuration file, ++# see extra/config/Kconfig-language.txt ++# ++ ++config TARGET_ARCH ++ string ++ default "ubicom32" ++ ++config FORCE_OPTIONS_FOR_ARCH ++ bool ++ default y ++ select ARCH_BIG_ENDIAN ++ select ARCH_HAS_NO_MMU ++ ++choice ++ prompt "Target Processor Architecture" ++ default CONFIG_UC_UBICOM32_V3 ++ help ++ This selects the instruction set architecture of your Ubicom32 CPU. This ++ information is used for optimizing purposes. To build a library that ++ will run on any Ubicom32 CPU, you can specify "v3" here. ++ If you pick anything other than "v3," there is no ++ guarantee that uClibc will even run on anything other than the ++ selected processor type. ++ ++ You should probably select the Ubicom32 ISA that best matches the ++ CPU you will be using on your device. uClibc will be tuned ++ for that architecture. ++ ++ If you don't know what to do, choose "v3" ++ ++config CONFIG_UC_UBICOM32_V3 ++ bool "ISA v3" ++ ++config CONFIG_UC_UBICOM32_V4 ++ bool "ISA v4" ++endchoice ++ ++config ARCH_CFLAGS ++ string ++ ++config CROSS ++ string +Index: uClibc-0.9.30.2/include/elf.h +=================================================================== +--- uClibc-0.9.30.2.orig/include/elf.h 2010-01-13 22:22:31.000000000 +0100 ++++ uClibc-0.9.30.2/include/elf.h 2010-01-14 11:06:14.000000000 +0100 +@@ -337,6 +337,8 @@ + + #define EM_XSTORMY16 0xad45 + ++#define EM_UBICOM32 0xde3d /* Ubicom32; no ABI */ ++ + /* FRV magic number - no EABI available??. */ + #define EM_CYGNUS_FRV 0x5441 + +@@ -3063,6 +3065,55 @@ + /* Keep this the last entry. */ + #define R_XTENSA_NUM 50 + ++/* Ubicom32 ELF relocation types */ ++#define R_UBICOM32_NONE 0 ++#define R_UBICOM32_16 1 ++#define R_UBICOM32_32 2 ++#define R_UBICOM32_LO16 3 ++#define R_UBICOM32_HI16 4 ++#define R_UBICOM32_21_PCREL 5 ++#define R_UBICOM32_24_PCREL 6 ++#define R_UBICOM32_HI24 7 ++#define R_UBICOM32_LO7_S 8 ++#define R_UBICOM32_LO7_2_S 9 ++#define R_UBICOM32_LO7_4_S 10 ++#define R_UBICOM32_LO7_D 11 ++#define R_UBICOM32_LO7_2_D 12 ++#define R_UBICOM32_LO7_4_D 13 ++#define R_UBICOM32_32_HARVARD 14 ++#define R_UBICOM32_LO7_CALLI 15 ++#define R_UBICOM32_LO16_CALLI 16 ++#define R_UBICOM32_GOT_HI24 17 ++#define R_UBICOM32_GOT_LO7_S 18 ++#define R_UBICOM32_GOT_LO7_2_S 19 ++#define R_UBICOM32_GOT_LO7_4_S 20 ++#define R_UBICOM32_GOT_LO7_D 21 ++#define R_UBICOM32_GOT_LO7_2_D 22 ++#define R_UBICOM32_GOT_LO7_4_D 23 ++#define R_UBICOM32_FUNCDESC_GOT_HI24 24 ++#define R_UBICOM32_FUNCDESC_GOT_LO7_S 25 ++#define R_UBICOM32_FUNCDESC_GOT_LO7_2_S 26 ++#define R_UBICOM32_FUNCDESC_GOT_LO7_4_S 27 ++#define R_UBICOM32_FUNCDESC_GOT_LO7_D 28 ++#define R_UBICOM32_FUNCDESC_GOT_LO7_2_D 29 ++#define R_UBICOM32_FUNCDESC_GOT_LO7_4_D 30 ++#define R_UBICOM32_GOT_LO7_CALLI 31 ++#define R_UBICOM32_FUNCDESC_GOT_LO7_CALLI 32 ++#define R_UBICOM32_FUNCDESC_VALUE 33 ++#define R_UBICOM32_FUNCDESC 34 ++#define R_UBICOM32_GOTOFFSET_LO 35 ++#define R_UBICOM32_GOTOFFSET_HI 36 ++#define R_UBICOM32_FUNCDESC_GOTOFFSET_LO 37 ++#define R_UBICOM32_FUNCDESC_GOTOFFSET_HI 38 ++#define R_UBICOM32_GNU_VTINHERIT 200 ++#define R_UBICOM32_GNU_VTENTRY 201 ++ ++/* Ubicom32 Flags. */ ++#define EF_UBICOM32_V3 0x00000001 /* -fmarch=ubicom32v3 */ ++#define EF_UBICOM32_V4 0x00000002 /* -fmarch=ubicom32v4 */ ++#define EF_UBICOM32_PIC 0x80000000 /* -fpic */ ++#define EF_UBICOM32_FDPIC 0x40000000 /* -mfdpic */ ++ + #ifdef __cplusplus + } + #endif +Index: uClibc-0.9.30.2/include/features.h +=================================================================== +--- uClibc-0.9.30.2.orig/include/features.h 2010-01-13 22:22:31.000000000 +0100 ++++ uClibc-0.9.30.2/include/features.h 2010-01-14 11:05:01.000000000 +0100 +@@ -451,4 +451,10 @@ + # define __linux__ 1 + #endif + ++#ifndef libc_hidden_proto ++#define libc_hidden_proto(name, attrs...) ++#endif ++#ifndef libm_hidden_proto ++#define libm_hidden_proto(name, attrs...) ++#endif + #endif /* features.h */ +Index: uClibc-0.9.30.2/ldso/ldso/dl-startup.c +=================================================================== +--- uClibc-0.9.30.2.orig/ldso/ldso/dl-startup.c 2010-01-13 22:22:31.000000000 +0100 ++++ uClibc-0.9.30.2/ldso/ldso/dl-startup.c 2010-01-14 11:05:01.000000000 +0100 +@@ -164,10 +164,13 @@ + aux_dat += 2; + } + ++#if !defined __FDPIC__ + /* locate the ELF header. We need this done as soon as possible + * (esp since SEND_STDERR() needs this on some platforms... */ + if (!auxvt[AT_BASE].a_un.a_val) + auxvt[AT_BASE].a_un.a_val = elf_machine_load_address(); ++#endif ++ + DL_INIT_LOADADDR_BOOT(load_addr, auxvt[AT_BASE].a_un.a_val); + header = (ElfW(Ehdr) *) auxvt[AT_BASE].a_un.a_val; + +Index: uClibc-0.9.30.2/ldso/ldso/ldso.c +=================================================================== +--- uClibc-0.9.30.2.orig/ldso/ldso/ldso.c 2010-01-13 22:22:31.000000000 +0100 ++++ uClibc-0.9.30.2/ldso/ldso/ldso.c 2010-01-14 11:05:01.000000000 +0100 +@@ -179,10 +179,12 @@ + _dl_progname = argv[0]; + } + ++#if 0 // blackfin does this, we do to avoid die during reloc + if (_start == (void *) auxvt[AT_ENTRY].a_un.a_val) { + _dl_dprintf(_dl_debug_file, "Standalone execution is not supported yet\n"); + _dl_exit(1); + } ++#endif + + /* Start to build the tables of the modules that are required for + * this beast to run. We start with the basic executable, and then +Index: uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-debug.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-debug.h 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,72 @@ ++/* vi: set sw=4 ts=4: */ ++/* Ubicom32 ELF shared library loader suppport ++ * ++ * Copyright (c) 2009 Ubicom Inc. ++ * Copyright (c) 1994-2000 Eric Youngdale, Peter MacDonald, ++ * David Engel, Hongjiu Lu and Mitch D'Souza ++ * Copyright (C) 2001-2004 Erik Andersen ++ * ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. The name of the above contributors may not be ++ * used to endorse or promote products derived from this software ++ * without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE ++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ */ ++ ++static const char *_dl_reltypes_tab[] = ++{ ++ "R_UBICOM32_NONE", /* 0 */ ++ "R_UBICOM32_16", ++ "R_UBICOM32_32", ++ "R_UBICOM32_LO16", ++ "R_UBICOM32_HI16", ++ "R_UBICOM32_21_PCREL", /* 5 */ ++ "R_UBICOM32_24_PCREL", ++ "R_UBICOM32_HI24", ++ "R_UBICOM32_LO7_S", ++ "R_UBICOM32_LO7_2_S", ++ "R_UBICOM32_LO7_4_S", /* 10 */ ++ "R_UBICOM32_LO7_D", ++ "R_UBICOM32_LO7_2_D", ++ "R_UBICOM32_LO7_4_D", ++ "R_UBICOM32_32_HARVARD", ++ "R_UBICOM32_LO7_CALLI", /* 15 */ ++ "R_UBICOM32_LO16_CALLI", ++ "R_UBICOM32_GOT_HI24", ++ "R_UBICOM32_GOT_LO7_S", ++ "R_UBICOM32_GOT_LO7_2_S" ++ "R_UBICOM32_GOT_LO7_4_S", /* 20 */ ++ "R_UBICOM32_GOT_LO7_D", ++ "R_UBICOM32_GOT_LO7_2_D", ++ "R_UBICOM32_GOT_LO7_4_D", ++ "R_UBICOM32_FUNCDESC_GOT_HI24 24", ++ "R_UBICOM32_FUNCDESC_GOT_LO7_S", /* 25 */ ++ "R_UBICOM32_FUNCDESC_GOT_LO7_2_S", ++ "R_UBICOM32_FUNCDESC_GOT_LO7_4_S", ++ "R_UBICOM32_FUNCDESC_GOT_LO7_D", ++ "R_UBICOM32_FUNCDESC_GOT_LO7_2_D", ++ "R_UBICOM32_FUNCDESC_GOT_LO7_4_D", /* 30 */ ++ "R_UBICOM32_GOT_LO7_CALLI", ++ "R_UBICOM32_FUNCDESC_VALUE", ++ "R_UBICOM32_FUNCDESC", ++#if 1 ++ [200] "R_UBICOM32_GNU_VTINHERIT" , "R_UBICOM32_GNU_VTENTRY" ++#endif ++}; +Index: uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-inlines.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-inlines.h 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,582 @@ ++ /* Copyright (C) 2003, 2004 Red Hat, Inc. ++ Contributed by Alexandre Oliva ++ ++This file is part of uClibc. ++ ++uClibc 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. ++ ++uClibc 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 ++Library General Public License for more details. ++ ++You should have received a copy of the GNU Lesser General Public ++License along with uClibc; see the file COPYING.LIB. If not, write to ++the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, ++USA. */ ++ ++//#include ++#define SRAM_TEST(x) 0 ++#ifndef _dl_assert ++# define _dl_assert(expr) ++#endif ++ ++/* Initialize a DL_LOADADDR_TYPE given a got pointer and a complete ++ load map. */ ++static __always_inline void ++__dl_init_loadaddr_map (struct elf32_fdpic_loadaddr *loadaddr, Elf32_Addr dl_boot_got_pointer, ++ struct elf32_fdpic_loadmap *map) ++{ ++ if (map->version != 0) ++ { ++ SEND_EARLY_STDERR ("Invalid loadmap version number\n"); ++ _dl_exit(-1); ++ } ++ if (map->nsegs == 0) ++ { ++ SEND_EARLY_STDERR ("Invalid segment count in loadmap\n"); ++ _dl_exit(-1); ++ } ++ loadaddr->got_value = (void*)dl_boot_got_pointer; ++ loadaddr->map = map; ++} ++ ++/* Figure out how many LOAD segments there are in the given headers, ++ and allocate a block for the load map big enough for them. ++ got_value will be properly initialized later on, with INIT_GOT. */ ++static __always_inline int ++__dl_init_loadaddr (struct elf32_fdpic_loadaddr *loadaddr, Elf32_Phdr *ppnt, ++ int pcnt) ++{ ++ int count = 0, i; ++ size_t size; ++ ++ for (i = 0; i < pcnt; i++) ++ if (ppnt[i].p_type == PT_LOAD) ++ count++; ++ ++ loadaddr->got_value = 0; ++ ++ size = sizeof (struct elf32_fdpic_loadmap) ++ + sizeof (struct elf32_fdpic_loadseg) * count; ++ loadaddr->map = _dl_malloc (size); ++ if (! loadaddr->map) ++ _dl_exit (-1); ++ ++ loadaddr->map->version = 0; ++ loadaddr->map->nsegs = 0; ++ ++ return count; ++} ++ ++#if defined (__SUPPORT_LD_DEBUG__) ++extern char *_dl_debug; ++extern int _dl_debug_file; ++#endif ++ ++/* Incrementally initialize a load map. */ ++static __always_inline void ++__dl_init_loadaddr_hdr (struct elf32_fdpic_loadaddr loadaddr, void *addr, ++ Elf32_Phdr *phdr, int maxsegs) ++{ ++ struct elf32_fdpic_loadseg *segdata; ++ ++ if (loadaddr.map->nsegs == maxsegs) ++ _dl_exit (-1); ++ ++ segdata = &loadaddr.map->segs[loadaddr.map->nsegs++]; ++ segdata->addr = (Elf32_Addr) addr; ++ segdata->p_vaddr = phdr->p_vaddr; ++ segdata->p_memsz = phdr->p_memsz; ++ ++#if defined (__SUPPORT_LD_DEBUG__) ++ { ++ if (_dl_debug) ++ _dl_dprintf(_dl_debug_file, "%i: mapped %x at %x, size %x\n", ++ loadaddr.map->nsegs-1, ++ segdata->p_vaddr, segdata->addr, segdata->p_memsz); ++ } ++#endif ++} ++ ++static __always_inline void __dl_loadaddr_unmap ++(struct elf32_fdpic_loadaddr loadaddr, struct funcdesc_ht *funcdesc_ht); ++ ++/* Figure out whether the given address is in one of the mapped ++ segments. */ ++static __always_inline int ++__dl_addr_in_loadaddr (void *p, struct elf32_fdpic_loadaddr loadaddr) ++{ ++ struct elf32_fdpic_loadmap *map = loadaddr.map; ++ int c; ++ ++ for (c = 0; c < map->nsegs; c++) ++ if ((void*)map->segs[c].addr <= p ++ && (char*)p < (char*)map->segs[c].addr + map->segs[c].p_memsz) ++ return 1; ++ ++ return 0; ++} ++ ++static __always_inline void * _dl_funcdesc_for (void *entry_point, void *got_value); ++ ++/* The hashcode handling code below is heavily inspired in libiberty's ++ hashtab code, but with most adaptation points and support for ++ deleting elements removed. ++ ++ Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. ++ Contributed by Vladimir Makarov (vmakarov@cygnus.com). */ ++ ++static __always_inline unsigned long ++higher_prime_number (unsigned long n) ++{ ++ /* These are primes that are near, but slightly smaller than, a ++ power of two. */ ++ static const unsigned long primes[] = { ++ (unsigned long) 7, ++ (unsigned long) 13, ++ (unsigned long) 31, ++ (unsigned long) 61, ++ (unsigned long) 127, ++ (unsigned long) 251, ++ (unsigned long) 509, ++ (unsigned long) 1021, ++ (unsigned long) 2039, ++ (unsigned long) 4093, ++ (unsigned long) 8191, ++ (unsigned long) 16381, ++ (unsigned long) 32749, ++ (unsigned long) 65521, ++ (unsigned long) 131071, ++ (unsigned long) 262139, ++ (unsigned long) 524287, ++ (unsigned long) 1048573, ++ (unsigned long) 2097143, ++ (unsigned long) 4194301, ++ (unsigned long) 8388593, ++ (unsigned long) 16777213, ++ (unsigned long) 33554393, ++ (unsigned long) 67108859, ++ (unsigned long) 134217689, ++ (unsigned long) 268435399, ++ (unsigned long) 536870909, ++ (unsigned long) 1073741789, ++ (unsigned long) 2147483647, ++ /* 4294967291L */ ++ ((unsigned long) 2147483647) + ((unsigned long) 2147483644), ++ }; ++ ++ const unsigned long *low = &primes[0]; ++ const unsigned long *high = &primes[sizeof(primes) / sizeof(primes[0])]; ++ ++ while (low != high) ++ { ++ const unsigned long *mid = low + (high - low) / 2; ++ if (n > *mid) ++ low = mid + 1; ++ else ++ high = mid; ++ } ++ ++#if 0 ++ /* If we've run out of primes, abort. */ ++ if (n > *low) ++ { ++ fprintf (stderr, "Cannot find prime bigger than %lu\n", n); ++ abort (); ++ } ++#endif ++ ++ return *low; ++} ++ ++struct funcdesc_ht ++{ ++ /* Table itself. */ ++ struct funcdesc_value **entries; ++ ++ /* Current size (in entries) of the hash table */ ++ size_t size; ++ ++ /* Current number of elements. */ ++ size_t n_elements; ++}; ++ ++static __always_inline int ++hash_pointer (const void *p) ++{ ++ return (int) ((long)p >> 3); ++} ++ ++static __always_inline struct funcdesc_ht * ++htab_create (void) ++{ ++ struct funcdesc_ht *ht = _dl_malloc (sizeof (struct funcdesc_ht)); ++ ++ if (! ht) ++ return NULL; ++ ht->size = 3; ++ ht->entries = _dl_malloc (sizeof (struct funcdesc_ht_value *) * ht->size); ++ if (! ht->entries) ++ return NULL; ++ ++ ht->n_elements = 0; ++ ++ _dl_memset (ht->entries, 0, sizeof (struct funcdesc_ht_value *) * ht->size); ++ ++ return ht; ++} ++ ++/* This is only called from _dl_loadaddr_unmap, so it's safe to call ++ _dl_free(). See the discussion below. */ ++static __always_inline void ++htab_delete (struct funcdesc_ht *htab) ++{ ++ int i; ++ ++ for (i = htab->size - 1; i >= 0; i--) ++ if (htab->entries[i]) ++ _dl_free (htab->entries[i]); ++ ++ _dl_free (htab->entries); ++ _dl_free (htab); ++} ++ ++/* Similar to htab_find_slot, but without several unwanted side effects: ++ - Does not call htab->eq_f when it finds an existing entry. ++ - Does not change the count of elements/searches/collisions in the ++ hash table. ++ This function also assumes there are no deleted entries in the table. ++ HASH is the hash value for the element to be inserted. */ ++ ++static __always_inline struct funcdesc_value ** ++find_empty_slot_for_expand (struct funcdesc_ht *htab, int hash) ++{ ++ size_t size = htab->size; ++ unsigned int index = hash % size; ++ struct funcdesc_value **slot = htab->entries + index; ++ int hash2; ++ ++ if (! *slot) ++ return slot; ++ ++ hash2 = 1 + hash % (size - 2); ++ for (;;) ++ { ++ index += hash2; ++ if (index >= size) ++ index -= size; ++ ++ slot = htab->entries + index; ++ if (! *slot) ++ return slot; ++ } ++} ++ ++/* The following function changes size of memory allocated for the ++ entries and repeatedly inserts the table elements. The occupancy ++ of the table after the call will be about 50%. Naturally the hash ++ table must already exist. Remember also that the place of the ++ table entries is changed. If memory allocation failures are allowed, ++ this function will return zero, indicating that the table could not be ++ expanded. If all goes well, it will return a non-zero value. */ ++ ++static __always_inline int ++htab_expand (struct funcdesc_ht *htab) ++{ ++ struct funcdesc_value **oentries; ++ struct funcdesc_value **olimit; ++ struct funcdesc_value **p; ++ struct funcdesc_value **nentries; ++ size_t nsize; ++ ++ oentries = htab->entries; ++ olimit = oentries + htab->size; ++ ++ /* Resize only when table after removal of unused elements is either ++ too full or too empty. */ ++ if (htab->n_elements * 2 > htab->size) ++ nsize = higher_prime_number (htab->n_elements * 2); ++ else ++ nsize = htab->size; ++ ++ nentries = _dl_malloc (sizeof (struct funcdesc_value *) * nsize); ++ _dl_memset (nentries, 0, sizeof (struct funcdesc_value *) * nsize); ++ if (nentries == NULL) ++ return 0; ++ htab->entries = nentries; ++ htab->size = nsize; ++ ++ p = oentries; ++ do ++ { ++ if (*p) ++ *find_empty_slot_for_expand (htab, hash_pointer ((*p)->entry_point)) ++ = *p; ++ ++ p++; ++ } ++ while (p < olimit); ++ ++#if 0 /* We can't tell whether this was allocated by the _dl_malloc() ++ built into ld.so or malloc() in the main executable or libc, ++ and calling free() for something that wasn't malloc()ed could ++ do Very Bad Things (TM). Take the conservative approach ++ here, potentially wasting as much memory as actually used by ++ the hash table, even if multiple growths occur. That's not ++ so bad as to require some overengineered solution that would ++ enable us to keep track of how it was allocated. */ ++ _dl_free (oentries); ++#endif ++ return 1; ++} ++ ++/* This function searches for a hash table slot containing an entry ++ equal to the given element. To delete an entry, call this with ++ INSERT = 0, then call htab_clear_slot on the slot returned (possibly ++ after doing some checks). To insert an entry, call this with ++ INSERT = 1, then write the value you want into the returned slot. ++ When inserting an entry, NULL may be returned if memory allocation ++ fails. */ ++ ++static __always_inline struct funcdesc_value ** ++htab_find_slot (struct funcdesc_ht *htab, void *ptr, int insert) ++{ ++ unsigned int index; ++ int hash, hash2; ++ size_t size; ++ struct funcdesc_value **entry; ++ ++ if (htab->size * 3 <= htab->n_elements * 4 ++ && htab_expand (htab) == 0) ++ return NULL; ++ ++ hash = hash_pointer (ptr); ++ ++ size = htab->size; ++ index = hash % size; ++ ++ entry = &htab->entries[index]; ++ if (!*entry) ++ goto empty_entry; ++ else if ((*entry)->entry_point == ptr) ++ return entry; ++ ++ hash2 = 1 + hash % (size - 2); ++ for (;;) ++ { ++ index += hash2; ++ if (index >= size) ++ index -= size; ++ ++ entry = &htab->entries[index]; ++ if (!*entry) ++ goto empty_entry; ++ else if ((*entry)->entry_point == ptr) ++ return entry; ++ } ++ ++ empty_entry: ++ if (!insert) ++ return NULL; ++ ++ htab->n_elements++; ++ return entry; ++} ++ ++void * ++_dl_funcdesc_for (void *entry_point, void *got_value) ++{ ++ struct elf_resolve *tpnt = ((void**)got_value)[2]; ++ struct funcdesc_ht *ht = tpnt->funcdesc_ht; ++ struct funcdesc_value **entry; ++ ++ _dl_assert (got_value == tpnt->loadaddr.got_value); ++ ++ if (! ht) ++ { ++ ht = htab_create (); ++ if (! ht) ++ return (void*)-1; ++ tpnt->funcdesc_ht = ht; ++ } ++ ++ entry = htab_find_slot (ht, entry_point, 1); ++ if (*entry) ++ { ++ _dl_assert ((*entry)->entry_point == entry_point); ++ return _dl_stabilize_funcdesc (*entry); ++ } ++ ++ *entry = _dl_malloc (sizeof (struct funcdesc_value)); ++ (*entry)->entry_point = entry_point; ++ (*entry)->got_value = got_value; ++ ++ return _dl_stabilize_funcdesc (*entry); ++} ++ ++static __always_inline void const * ++_dl_lookup_address (void const *address) ++{ ++ struct elf_resolve *rpnt; ++ struct funcdesc_value const *fd; ++ ++ /* Make sure we don't make assumptions about its alignment. */ ++ __asm__ ("" : "+r" (address)); ++ ++ if ((Elf32_Addr)address & 7) ++ /* It's not a function descriptor. */ ++ return address; ++ ++ fd = (struct funcdesc_value const *)address; ++ ++ for (rpnt = _dl_loaded_modules; rpnt; rpnt = rpnt->next) ++ { ++ if (! rpnt->funcdesc_ht) ++ continue; ++ ++ if (fd->got_value != rpnt->loadaddr.got_value) ++ continue; ++ ++ address = htab_find_slot (rpnt->funcdesc_ht, (void*)fd->entry_point, 0); ++ ++ if (address && *(struct funcdesc_value *const*)address == fd) ++ { ++ address = (*(struct funcdesc_value *const*)address)->entry_point; ++ break; ++ } ++ else ++ address = fd; ++ } ++ ++ return address; ++} ++ ++void ++__dl_loadaddr_unmap (struct elf32_fdpic_loadaddr loadaddr, ++ struct funcdesc_ht *funcdesc_ht) ++{ ++ int i; ++ ++ for (i = 0; i < loadaddr.map->nsegs; i++) ++ { ++ struct elf32_fdpic_loadseg *segdata; ++ ssize_t offs; ++ segdata = loadaddr.map->segs + i; ++ ++#if 0 /* SRAM */ ++ /* FIXME: ++ A more cleaner way is to add type for struct elf32_fdpic_loadseg, ++ and release the memory according to the type. ++ Currently, we hardcode the memory address of L1 SRAM. */ ++ if ((segdata->addr & 0xff800000) == 0xff800000) ++ { ++ _dl_sram_free ((void *)segdata->addr); ++ continue; ++ } ++#endif ++ offs = (segdata->p_vaddr & ADDR_ALIGN); ++ _dl_munmap ((void*)segdata->addr - offs, ++ segdata->p_memsz + offs); ++ } ++ /* _dl_unmap is only called for dlopen()ed libraries, for which ++ calling free() is safe, or before we've completed the initial ++ relocation, in which case calling free() is probably pointless, ++ but still safe. */ ++ _dl_free (loadaddr.map); ++ if (funcdesc_ht) ++ htab_delete (funcdesc_ht); ++} ++ ++#if 0 /* XXX TODO will look at enabling this if we decide to add support for OCM ++ * code/data */ ++// OLD BLACKFIN CODE ++static __always_inline int ++__dl_is_special_segment (Elf32_Ehdr *epnt, ++ Elf32_Phdr *ppnt) ++{ ++ if (ppnt->p_type != PT_LOAD) ++ return 0; ++ ++ if ((epnt->e_flags & EF_BFIN_CODE_IN_L1) ++ && !(ppnt->p_flags & PF_W) ++ && (ppnt->p_flags & PF_X)) ++ return 1; ++ ++ if ((epnt->e_flags & EF_BFIN_DATA_IN_L1) ++ && (ppnt->p_flags & PF_W) ++ && !(ppnt->p_flags & PF_X)) ++ return 1; ++ ++ /* 0xff700000, 0xff800000, 0xff900000 and 0xffa00000 are also used in ++ GNU ld and linux kernel. They need to be keep synchronized. */ ++ if (ppnt->p_vaddr == 0xff700000 ++ || ppnt->p_vaddr == 0xff800000 ++ || ppnt->p_vaddr == 0xff900000 ++ || ppnt->p_vaddr == 0xffa00000) ++ return 1; ++ ++ return 0; ++} ++ ++static __always_inline char * ++__dl_map_segment (Elf32_Ehdr *epnt, ++ Elf32_Phdr *ppnt, ++ int infile, ++ int flags) ++{ ++ char *status, *tryaddr, *l1addr; ++ size_t size; ++ ++ ++ if (((epnt->e_flags & EF_BFIN_CODE_IN_L1) || ppnt->p_vaddr == 0xffa00000) ++ && !(ppnt->p_flags & PF_W) ++ && (ppnt->p_flags & PF_X)) { ++ status = (char *) _dl_mmap ++ (tryaddr = 0, ++ size = (ppnt->p_vaddr & ADDR_ALIGN) + ppnt->p_filesz, ++ LXFLAGS(ppnt->p_flags), ++ flags | MAP_EXECUTABLE | MAP_DENYWRITE, ++ infile, ppnt->p_offset & OFFS_ALIGN); ++ if (_dl_mmap_check_error(status) ++ || (tryaddr && tryaddr != status)) ++ return NULL; ++ l1addr = (char *) _dl_sram_alloc (ppnt->p_filesz, L1_INST_SRAM); ++ if (l1addr != NULL) ++ _dl_dma_memcpy (l1addr, status + (ppnt->p_vaddr & ADDR_ALIGN), ppnt->p_filesz); ++ _dl_munmap (status, size); ++ if (l1addr == NULL) ++ _dl_dprintf(2, "%s:%i: L1 allocation failed\n", _dl_progname, __LINE__); ++ return l1addr; ++ } ++ ++ if (((epnt->e_flags & EF_BFIN_DATA_IN_L1) ++ || ppnt->p_vaddr == 0xff700000 ++ || ppnt->p_vaddr == 0xff800000 ++ || ppnt->p_vaddr == 0xff900000) ++ && (ppnt->p_flags & PF_W) ++ && !(ppnt->p_flags & PF_X)) { ++ if (ppnt->p_vaddr == 0xff800000) ++ l1addr = (char *) _dl_sram_alloc (ppnt->p_memsz, L1_DATA_A_SRAM); ++ else if (ppnt->p_vaddr == 0xff900000) ++ l1addr = (char *) _dl_sram_alloc (ppnt->p_memsz, L1_DATA_B_SRAM); ++ else ++ l1addr = (char *) _dl_sram_alloc (ppnt->p_memsz, L1_DATA_SRAM); ++ if (l1addr == NULL) { ++ _dl_dprintf(2, "%s:%i: L1 allocation failed\n", _dl_progname, __LINE__); ++ } else { ++ if (_DL_PREAD (infile, l1addr, ppnt->p_filesz, ppnt->p_offset) != ppnt->p_filesz) { ++ _dl_sram_free (l1addr); ++ return NULL; ++ } ++ if (ppnt->p_filesz < ppnt->p_memsz) ++ _dl_memset (l1addr + ppnt->p_filesz, 0, ppnt->p_memsz - ppnt->p_filesz); ++ } ++ return l1addr; ++ } ++ return 0; ++} ++#endif +Index: uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-startup.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-startup.h 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,232 @@ ++/* ++ Copyright (C) 2009 Ubicom, Inc. ++ Copyright (C) 2003 Red Hat, Inc. ++ Contributed by Alexandre Oliva ++ ++This file is part of uClibc. ++ ++uClibc 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. ++ ++uClibc 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 ++Library General Public License for more details. ++ ++You should have received a copy of the GNU Lesser General Public ++License along with uClibc; see the file COPYING.LIB. If not, write to ++the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, ++USA. */ ++ ++/* Any assembly language/system dependent hacks needed to setup ++ * boot1.c so it will work as expected and cope with whatever platform ++ * specific wierdness is needed for this architecture. ++ ++ * We override the default _dl_boot function, and replace it with a ++ * bit of asm. Then call the real _dl_boot function, which is now ++ * named _dl_boot2. */ ++ ++/* At program start-up, p0 contains a pointer to a ++ elf32_fdpic_loadmap that describes how the executable was loaded ++ into memory. p1 contains a pointer to the interpreter (our!) ++ loadmap, if there is an interpreter, or 0 if we're being run as an ++ executable. p2 holds a pointer to the interpreter's dynamic ++ section, if there is an interpreter, or to the executable's dynamic ++ section, otherwise. If the executable is not dynamic, gr18 is 0. ++ ++ We rely on the fact that the linker adds a pointer to the ++ _GLOBAL_OFFSET_TABLE_ as the last ROFIXUP entry, and that ++ __self_reloc returns the relocated pointer to us, so that we can ++ use this value to initialize the PIC register. */ ++ ++ ++/* ++ * _dl_boot is the entry point for ldso. ++ * ++ * The kernel leaves the main apps args on the stack (positive offsets), and ++ * communicates the load maps as follows ++ * ++ * - d1 is set to the exec_map_addr (struct elf32_fdpic_loadmap *), which is the ++ * current state of the mapped application. ++ * ++ * - d2 is set to interp_map_addr (struct elf32_fdpic_loadmap *), which is use ++ * by ldso to relocate itself. ++ * ++ * - d3 is dynamic_addr which as far as I can tell is the stack pointer. ++ * ++ * - a1 is set to zero and will later be initialised to ldso _dl_fini funcdesc ++ */ ++ ++__asm__( ++ " .text \n\t" ++ " .global _start \n\t" ++ " .type _start,@function \n\t" ++ "_start:\n\t" ++ /* ++ * Jump to .Lcall storing the location .Lcall in a5 ++ */ ++ " call a5, .Lcall \n\t" ++ ".Lcall: \n\t" ++ /* ++ * Reserve and Push inputs to stack. ++ * 32 byte stack layout as follows ++ * offset 0 exec_map_addr ++ * 4 interp_map_addr ++ * 8 dynamic_addr ++ * 12 not used ++ * 16 dl_main_funcdesc structure for _dl_boot ++ * (12 bytes sizeof funcdesc_value) ++ * 28 reserved ++ * 32 start of &original stack ++ */ ++ " pdec sp, 32(sp); reserve stack space \n\t" ++ " move.4 0(sp), d1 ; exec_map_addr \n\t" ++ " move.4 4(sp), d2 ; interp_map_addr \n\t" ++ " move.4 8(sp), d3; dynamic_addr \n\t" ++ ++ /* ++ * Load linker version of .Lcall in to d0 ++ */ ++ " moveai a3, #%hi(.Lcall) \n\t" ++ " lea.1 d0, %lo(.Lcall)(a3) \n\t" ++ ++ /* ++ * Determine the offset from loaded .Lcall and put it in d0. ++ */ ++ " sub.4 d0, a5, d0 \n\t" ++ ++ /* ++ * Load linker version of __ROFIXUP_LIST__ and __ROFIXUP_END__ in to d1 ++ * and d2. ++ */ ++ " moveai a3, #%hi(__ROFIXUP_LIST__) \n\t" ++ " lea.1 d1, %lo(__ROFIXUP_LIST__)(a3) \n\t" ++ " moveai a3, #%hi(__ROFIXUP_END__) \n\t" ++ " lea.1 d2, %lo(__ROFIXUP_END__)(a3) \n\t" ++ /* ++ * Use offset determined above to find the loaded versions. ++ */ ++ " add.4 d1, d1, d0 \n\t" ++ " add.4 d2, d2, d0 \n\t" ++ ++ /* ++ * Load interp_map_addr into d0, if interp_map_addr is null use ++ * exec_map_addr. ++ */ ++ " move.4 d0, 4(sp) ; load interp_map_addr \n\t" ++ " cmpi d0, #0 \n\t" ++ " jmpne.f 1f \n\t" ++ " move.4 d0, 0(sp) ; load exec_map_addr \n\t" ++ ++ /* ++ * call __self_reloc(map, void ***p, void ***e) ++ * it returns the the GOT in d0. ++ */ ++ "1: call a5, __self_reloc ; returns a0 in d0 \n\t" ++ " move.4 a0, d0 ; set GOT \n\t" ++ " move.4 a2, d0 ; save GOT \n\t" ++ ++ /* ++ * now setup to call ++ * _dl_start (Elf32_Addr dl_boot_got_pointer, (d0) ++ * struct elf32_fdpic_loadmap *dl_boot_progmap, (d1) ++ * struct elf32_fdpic_loadmap *dl_boot_ldsomap, (d2) ++ * Elf32_Dyn *dl_boot_ldso_dyn_pointer, (d3) ++ * struct funcdesc_value *dl_main_funcdesc, (d4) ++ * unsigned long args (d5) ++ * ++ * NOTE: for dl_main_funcdesc we reserved space on the stack for this ++ * structure. ++ */ ++ " move.4 d1, 0(sp) ; d1 = exec_map_addr \n\t" ++ " move.4 d2, 4(sp) ; d2 = interp_map_addr \n\t" ++ " move.4 d3, 8(sp) ; d3 = dynamic_addr \n\t" ++ " lea.1 d4, 16(sp) ; d4 = &dl_main_funcdesc \n\t" ++ " lea.1 d5, 32(sp) ; d5 = original stack ptr (args)\n\t" ++ " call a5, _dl_start \n\t" ++ ++ /* ++ * Setup to call the main entry point, starting with passing our FINI ++ * ptr() to the user in a1 (remember we saved the got in a2) ++ */ ++ " movei d15, #%got_funcdesc_lo(_dl_fini) \n\t" ++ " move.4 a1, (a2, d15) \n\t" ++ ++ /* ++ * restore the load map from the kernel. ++ */ ++ " move.4 d1, 0(sp) ; restore exec_map_addr \n\t" ++ " move.4 d2, 4(sp) ; restore interp_map_addr \n\t" ++ " move.4 d3, 8(sp) ; restore dynamic_addr \n\t" ++ ++ /* ++ * _dl_start returned the main apps entry point in dl_main_funcdesc, ++ * load that information now. ++ */ ++ " move.4 a5, 16(sp) ; a5 = dl_main_funcdesc.entry_point \n\t" ++ " move.4 a0, 20(sp) ; a0 = dl_main_funcdesc.got_value \n\t" ++ " lea.1 sp, 32(sp); restore original stack ptr (args) \n\t" ++ " calli a5, 0(a5) \n\t" ++ " bkpt -1; should never get here \n\t" ++ " .size _start, . - _start \n\t" ++); ++ ++#undef DL_START ++#define DL_START(X) \ ++static void __attribute__ ((used)) \ ++_dl_start (Elf32_Addr dl_boot_got_pointer, \ ++ struct elf32_fdpic_loadmap *dl_boot_progmap, \ ++ struct elf32_fdpic_loadmap *dl_boot_ldsomap, \ ++ Elf32_Dyn *dl_boot_ldso_dyn_pointer, \ ++ struct funcdesc_value *dl_main_funcdesc, \ ++ X) ++ ++struct elf32_fdpic_loadmap; ++ ++/* ++ * Get a pointer to the argv array. On many platforms this can be just ++ * the address if the first argument, on other platforms we need to ++ * do something a little more subtle here. ++ */ ++#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*) ARGS) + 1) ++ ++/* ++ * Here is a macro to perform a relocation. This is only used when ++ * bootstrapping the dynamic loader. RELP is the relocation that we ++ * are performing, REL is the pointer to the address we are relocating. ++ * SYMBOL is the symbol involved in the relocation, and LOAD is the ++ * load address. ++ */ ++#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \ ++ switch(ELF32_R_TYPE((RELP)->r_info)){ \ ++ case R_UBICOM32_32: \ ++ *(REL) += (SYMBOL); \ ++ break; \ ++ case R_UBICOM32_FUNCDESC_VALUE: \ ++ { \ ++ struct funcdesc_value fv = { \ ++ (void*)((SYMBOL) + *(REL)), \ ++ (LOAD).got_value \ ++ }; \ ++ *(struct funcdesc_value volatile *)(REL) = fv; \ ++ break; \ ++ } \ ++ default: \ ++ _dl_exit(1); \ ++ } ++ ++/* ++ * Transfer control to the user's application, once the dynamic loader ++ * is done. We return the address of the function's entry point to ++ * _dl_boot, see boot1_arch.h. ++ */ ++#define START() do { \ ++ struct elf_resolve *exec_mod = _dl_loaded_modules; \ ++ dl_main_funcdesc->entry_point = _dl_elf_main; \ ++ while (exec_mod->libtype != elf_executable) \ ++ exec_mod = exec_mod->next; \ ++ dl_main_funcdesc->got_value = exec_mod->loadaddr.got_value; \ ++ return; \ ++} while (0) +Index: uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-syscalls.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-syscalls.h 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,206 @@ ++/* Copyright (C) 2003, 2004 Red Hat, Inc. ++ Contributed by Alexandre Oliva ++ ++This file is part of uClibc. ++ ++uClibc 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. ++ ++uClibc 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 ++Library General Public License for more details. ++ ++You should have received a copy of the GNU Lesser General Public ++License along with uClibc; see the file COPYING.LIB. If not, write to ++the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, ++USA. */ ++ ++/* We can't use the real errno in ldso, since it has not yet ++ * been dynamicly linked in yet. */ ++#include "sys/syscall.h" ++extern int _dl_errno; ++#undef __set_errno ++#define __set_errno(X) {(_dl_errno) = (X);} ++#include ++ ++/* The code below is extracted from libc/sysdeps/linux/frv/_mmap.c */ ++ ++#if defined(DYNAMIC_LOADER_IN_SIMULATOR) && DYNAMIC_LOADER_IN_SIMULATOR ++#define __NR___syscall_mmap2 __NR_mmap2 ++static __inline__ _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr, ++ size_t, len, int, prot, int, flags, int, fd, off_t, offset); ++ ++/* Make sure we don't get another definition of _dl_mmap from the ++ machine-independent code. */ ++#undef __NR_mmap ++#undef __NR_mmap2 ++ ++/* This is always 12, even on architectures where PAGE_SHIFT != 12. */ ++# ifndef MMAP2_PAGE_SHIFT ++# define MMAP2_PAGE_SHIFT 12 ++# endif ++ ++#include /* for PAGE_SIZE */ ++static __always_inline void *_dl_memset(void*,int,size_t); ++static __always_inline ssize_t _dl_pread(int fd, void *buf, size_t count, off_t offset); ++ ++static __ptr_t ++_dl_mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t offset) ++{ ++ size_t plen = (len + PAGE_SIZE - 1) & -PAGE_SIZE; ++ ++/* This is a hack to enable the dynamic loader to run within a ++ simulator that doesn't support mmap, with a number of very ugly ++ tricks. Also, it's not as useful as it sounds, since only dynamic ++ executables without DT_NEEDED dependencies can be run. AFAIK, they ++ can only be created with -pie. This trick suffices to enable the ++ dynamic loader to obtain a blank page that it maps early in the ++ bootstrap. */ ++ if ((flags & MAP_FIXED) == 0) ++ { ++ void *_dl_mmap_base = 0; ++ __ptr_t *ret = 0; ++ ++ if (! _dl_mmap_base) ++ { ++ void *stack; ++ __asm__ ("mov sp, %0" : "=r" (stack)); ++ _dl_mmap_base = (void *)(((long)stack + 2 * PAGE_SIZE) & -PAGE_SIZE); ++ retry: ++ if (((void **)_dl_mmap_base)[0] == _dl_mmap_base ++ && ((void **)_dl_mmap_base)[1023] == _dl_mmap_base ++ && (((void **)_dl_mmap_base)[177] ++ == ((void **)_dl_mmap_base)[771])) ++ { ++ while (((void**)_dl_mmap_base)[177]) ++ { ++ _dl_mmap_base = ((void**)_dl_mmap_base)[177]; ++ if (!(((void **)_dl_mmap_base)[0] == _dl_mmap_base ++ && ((void **)_dl_mmap_base)[1023] == _dl_mmap_base ++ && (((void **)_dl_mmap_base)[177] ++ == ((void**)_dl_mmap_base)[771]))) ++ ((void(*)())0)(); ++ } ++ } ++ else ++ { ++ int i; ++ for (i = 0; i < (int)PAGE_SIZE; i++) ++ if (*(char*)(_dl_mmap_base + i)) ++ break; ++ if (i != PAGE_SIZE) ++ { ++ _dl_mmap_base = (void*)((long)_dl_mmap_base + PAGE_SIZE); ++ goto retry; ++ } ++ ((void**)_dl_mmap_base)[-1] = ++ ((void**)_dl_mmap_base)[0] = ++ ((void**)_dl_mmap_base)[1023] = ++ _dl_mmap_base; ++ } ++ } ++ ++ if (_dl_mmap_base) ++ { ++ if (!(((void **)_dl_mmap_base)[0] == _dl_mmap_base ++ && ((void **)_dl_mmap_base)[1023] == _dl_mmap_base ++ && (((void **)_dl_mmap_base)[177] ++ == ((void**)_dl_mmap_base)[771]))) ++ ((void(*)())0)(); ++ ret = (__ptr_t)((char*)_dl_mmap_base + PAGE_SIZE); ++ _dl_mmap_base = ++ ((void**)_dl_mmap_base)[177] = ++ ((void**)_dl_mmap_base)[771] = ++ (char*)_dl_mmap_base + plen + PAGE_SIZE; ++ ((void**)_dl_mmap_base)[0] = ++ ((void**)_dl_mmap_base)[1023] = ++ _dl_mmap_base; ++ } ++ ++ if ((flags & MAP_ANONYMOUS) != 0) ++ { ++ _dl_memset (ret, 0, plen); ++ return ret; ++ } ++ ++ flags |= MAP_FIXED; ++ addr = ret; ++ } ++ if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1)) { ++#if 0 ++ __set_errno (EINVAL); ++#endif ++ return MAP_FAILED; ++ } ++ if ((flags & MAP_FIXED) != 0) ++ { ++ if (_dl_pread(fd, addr, len, offset) != (ssize_t)len) ++ return (void*)MAP_FAILED; ++ if (plen != len) ++ _dl_memset (addr + len, 0, plen - len); ++ return addr; ++ } ++ return(__syscall_mmap2(addr, len, prot, flags, fd, (off_t) (offset >> MMAP2_PAGE_SHIFT))); ++} ++#endif ++ ++#ifdef __NR_pread64 ++#ifdef DYNAMIC_LOADER_IN_SIMULATOR ++#include ++ ++#define __NR___syscall_lseek __NR_lseek ++static __always_inline unsigned long _dl_read(int fd, const void *buf, unsigned long count); ++ ++static __always_inline _syscall3(__off_t, __syscall_lseek, int, fd, __off_t, offset, ++ int, whence); ++static __always_inline ssize_t ++_dl_pread(int fd, void *buf, size_t count, off_t offset) ++{ ++ __off_t orig = __syscall_lseek (fd, 0, SEEK_CUR); ++ ssize_t ret; ++ ++ if (orig == -1) ++ return -1; ++ ++ if (__syscall_lseek (fd, offset, SEEK_SET) != offset) ++ return -1; ++ ++ ret = _dl_read (fd, buf, count); ++ ++ if (__syscall_lseek (fd, orig, SEEK_SET) != orig) ++ ((void(*)())0)(); ++ ++ return ret; ++} ++#else ++#define __NR___syscall_pread __NR_pread64 ++static __always_inline _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf, ++ size_t, count, off_t, offset_hi, off_t, offset_lo); ++ ++static __always_inline ssize_t ++_dl_pread(int fd, void *buf, size_t count, off_t offset) ++{ ++ return(__syscall_pread(fd,buf,count,__LONG_LONG_PAIR (offset >> 31, offset))); ++} ++#endif ++#endif ++ ++#ifdef __NR_sram_alloc ++#define __NR__dl_sram_alloc __NR_sram_alloc ++static __always_inline _syscall2(__ptr_t, _dl_sram_alloc, ++ size_t, len, unsigned long, flags); ++#endif ++ ++#ifdef __NR_sram_free ++#define __NR__dl_sram_free __NR_sram_free ++static __always_inline _syscall1(int, _dl_sram_free, __ptr_t, addr); ++#endif ++ ++#ifdef __NR_dma_memcpy ++#define __NR__dl_dma_memcpy __NR_dma_memcpy ++static __always_inline _syscall3(__ptr_t, _dl_dma_memcpy, ++ __ptr_t, dest, __ptr_t, src, size_t, len); ++#endif +Index: uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-sysdep.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-sysdep.h 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,243 @@ ++ /* Copyright (C) 2003, 2004 Red Hat, Inc. ++ Contributed by Alexandre Oliva ++ Based on ../i386/dl-sysdep.h ++ ++This file is part of uClibc. ++ ++uClibc 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. ++ ++uClibc 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 ++Library General Public License for more details. ++ ++You should have received a copy of the GNU Lesser General Public ++License along with uClibc; see the file COPYING.LIB. If not, write to ++the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, ++USA. */ ++ ++/* ++ * Various assembly language/system dependent hacks that are required ++ * so that we can minimize the amount of platform specific code. ++ */ ++ ++/* ++ * Define this if the system uses RELOCA. ++ */ ++#undef ELF_USES_RELOCA ++ ++/* JMPREL relocs are inside the DT_RELA table. */ ++#define ELF_MACHINE_PLTREL_OVERLAP ++ ++#define DL_NO_COPY_RELOCS ++ ++#define HAVE_DL_INLINES_H ++ ++/* ++ * Initialization sequence for a GOT. Copy the resolver function ++ * descriptor and the pointer to the elf_resolve/link_map data ++ * structure. Initialize the got_value in the module while at that. ++ */ ++#define INIT_GOT(GOT_BASE,MODULE) \ ++{ \ ++ (MODULE)->loadaddr.got_value = (GOT_BASE); \ ++ GOT_BASE[0] = ((unsigned long *)&_dl_linux_resolve)[0]; \ ++ GOT_BASE[1] = ((unsigned long *)&_dl_linux_resolve)[1]; \ ++ GOT_BASE[2] = (unsigned long) MODULE; \ ++} ++ ++/* Here we define the magic numbers that this dynamic loader should accept */ ++#define MAGIC1 EM_UBICOM32 ++#undef MAGIC2 ++ ++/* Used for error messages */ ++#define ELF_TARGET "UBICOM32" ++ ++struct elf_resolve; ++ ++struct funcdesc_value ++{ ++ void *entry_point; ++ void *got_value; ++/*int relocation; not sure if this required, but it does exist */ ++}; ++ ++extern int _dl_linux_resolve(void) __attribute__((__visibility__("hidden"))); ++extern struct funcdesc_value volatile *__attribute__((__visibility__("hidden"))) ++ _dl_linux_resolver (struct elf_resolve *tpnt, int reloc_entry); ++ ++/* 4KiB page alignment. Should perhaps be made dynamic using ++ getpagesize(), based on AT_PAGESZ from auxvt? */ ++#define PAGE_ALIGN 0xfffff000 ++#define ADDR_ALIGN 0xfff ++#define OFFS_ALIGN 0x7ffff000 ++ ++struct funcdesc_ht; ++ ++/* ++ * This asm does a quick relcation of string S (which is stored in the text ++ * section as thats all we can use ++ */ ++#undef SEND_EARLY_STDERR ++#define SEND_EARLY_STDERR(S) \ ++do { \ ++ static const char __attribute__((section(".text"))) __s[] = (S); \ ++ const char *__p, *__scratch; \ ++ __asm__ ( \ ++ " call a3, 1f; \n\t" \ ++ "1: movei %0, #%%got_lo(1b) \n\t" \ ++ " move.4 %0, (%3, %0) \n\t" \ ++ " sub.4 %1, a3, %0; \n\t" \ ++ " add.4 %1, %1, %2; \n\t" \ ++ : "=&d" (__scratch), "=&d" (__p) \ ++ : "d" (__s), "a" (dl_boot_got_pointer) \ ++ : "a3", "a4", "d15"); \ ++ SEND_STDERR (__p); \ ++ { int __t; \ ++ for (__t = 0; __t < 0x100000; __t++) __asm__ __volatile__ (""); } \ ++} while (0) ++ ++#define DL_LOADADDR_TYPE struct elf32_fdpic_loadaddr ++ ++#define DL_RELOC_ADDR(LOADADDR, ADDR) \ ++ ((ElfW(Addr))__reloc_pointer ((void*)(ADDR), (LOADADDR).map)) ++ ++#define DL_ADDR_TO_FUNC_PTR(ADDR, LOADADDR) \ ++ ((void(*)(void)) _dl_funcdesc_for ((void*)(ADDR), (LOADADDR).got_value)) ++ ++#define _dl_stabilize_funcdesc(val) \ ++ ({ __asm__ ("" : "+m" (*(val))); (val); }) ++ ++#define DL_CALL_FUNC_AT_ADDR(ADDR, LOADADDR, SIGNATURE, ...) \ ++ ({ struct funcdesc_value fd = { (void*)(ADDR), (LOADADDR).got_value }; \ ++ void (*pf)(void) = (void*) _dl_stabilize_funcdesc (&fd); \ ++ (* SIGNATURE pf)(__VA_ARGS__); }) ++ ++#define DL_INIT_LOADADDR_BOOT(LOADADDR, BASEADDR) \ ++ (__dl_init_loadaddr_map (&(LOADADDR), dl_boot_got_pointer, \ ++ dl_boot_ldsomap ?: dl_boot_progmap)) ++ ++#define DL_INIT_LOADADDR_PROG(LOADADDR, BASEADDR) \ ++ (__dl_init_loadaddr_map (&(LOADADDR), 0, dl_boot_progmap)) ++ ++#define DL_INIT_LOADADDR_EXTRA_DECLS \ ++ int dl_init_loadaddr_load_count; ++#define DL_INIT_LOADADDR(LOADADDR, BASEADDR, PHDR, PHDRCNT) \ ++ (dl_init_loadaddr_load_count = \ ++ __dl_init_loadaddr (&(LOADADDR), (PHDR), (PHDRCNT))) ++#define DL_INIT_LOADADDR_HDR(LOADADDR, ADDR, PHDR) \ ++ (__dl_init_loadaddr_hdr ((LOADADDR), (ADDR), (PHDR), \ ++ dl_init_loadaddr_load_count)) ++#define DL_LOADADDR_UNMAP(LOADADDR, LEN) \ ++ (__dl_loadaddr_unmap ((LOADADDR), (NULL))) ++#define DL_LIB_UNMAP(LIB, LEN) \ ++ (__dl_loadaddr_unmap ((LIB)->loadaddr, (LIB)->funcdesc_ht)) ++#define DL_LOADADDR_BASE(LOADADDR) \ ++ ((LOADADDR).got_value) ++ ++/* This is called from dladdr(), such that we map a function ++ descriptor's address to the function's entry point before trying to ++ find in which library it's defined. */ ++#define DL_LOOKUP_ADDRESS(ADDRESS) (_dl_lookup_address (ADDRESS)) ++ ++#define DL_ADDR_IN_LOADADDR(ADDR, TPNT, TFROM) \ ++ (! (TFROM) && __dl_addr_in_loadaddr ((void*)(ADDR), (TPNT)->loadaddr)) ++ ++/* ++ * Compute the GOT address. On several platforms, we use assembly ++ * here. on FR-V FDPIC, there's no way to compute the GOT address, ++ * since the offset between text and data is not fixed, so we arrange ++ * for the assembly _dl_boot to pass this value as an argument to ++ * _dl_boot. */ ++#define DL_BOOT_COMPUTE_GOT(got) ((got) = dl_boot_got_pointer) ++ ++#define DL_BOOT_COMPUTE_DYN(dpnt, got, load_addr) \ ++ ((dpnt) = dl_boot_ldso_dyn_pointer) ++ ++/* We only support loading FDPIC independently-relocatable shared ++ libraries. It probably wouldn't be too hard to support loading ++ shared libraries that require relocation by the same amount, but we ++ don't know that they exist or would be useful, and the dynamic ++ loader code could leak the whole-library map unless we keeping a ++ bit more state for DL_LOADADDR_UNMAP and DL_LIB_UNMAP, so let's ++ keep things simple for now. */ ++#define DL_CHECK_LIB_TYPE(epnt, piclib, _dl_progname, libname) \ ++do \ ++{ \ ++ if (((epnt)->e_flags & EF_UBICOM32_FDPIC) && ! ((epnt)->e_flags & EF_UBICOM32_PIC)) \ ++ (piclib) = 2; \ ++ else \ ++ { \ ++ _dl_internal_error_number = LD_ERROR_NOTDYN; \ ++ _dl_dprintf(2, "%s: '%s' is not an FDPIC shared library" \ ++ "\n", (_dl_progname), (libname)); \ ++ _dl_close(infile); \ ++ return NULL; \ ++ } \ ++\ ++} \ ++while (0) ++ ++/* We want want to apply all relocations in the interpreter during ++ bootstrap. Because of this, we have to skip the interpreter ++ relocations in _dl_parse_relocation_information(), see ++ elfinterp.c. */ ++#define DL_SKIP_BOOTSTRAP_RELOC(SYMTAB, INDEX, STRTAB) 0 ++ ++#ifdef __NR_pread64 ++#define _DL_PREAD(FD, BUF, SIZE, OFFSET) \ ++ (_dl_pread((FD), (BUF), (SIZE), (OFFSET))) ++#endif ++ ++/* We want to return to dlsym() a function descriptor if the symbol ++ turns out to be a function. */ ++#define DL_FIND_HASH_VALUE(TPNT, TYPE_CLASS, SYM) \ ++ (((TYPE_CLASS) & ELF_RTYPE_CLASS_DLSYM) \ ++ && ELF32_ST_TYPE((SYM)->st_info) == STT_FUNC \ ++ ? _dl_funcdesc_for ((void *)DL_RELOC_ADDR ((TPNT)->loadaddr, (SYM)->st_value), \ ++ (TPNT)->loadaddr.got_value) \ ++ : DL_RELOC_ADDR ((TPNT)->loadaddr, (SYM)->st_value)) ++ ++#if 0 /* XXX TODO will look at enabling this if we decide to add support for OCM ++ * code/data */ ++ ++#define DL_IS_SPECIAL_SEGMENT(EPNT, PPNT) \ ++ __dl_is_special_segment(EPNT, PPNT) ++#define DL_MAP_SEGMENT(EPNT, PPNT, INFILE, FLAGS) \ ++ __dl_map_segment (EPNT, PPNT, INFILE, FLAGS) ++ ++#endif ++ ++ ++#define DL_GET_READY_TO_RUN_EXTRA_PARMS \ ++ , struct elf32_fdpic_loadmap *dl_boot_progmap, Elf32_Addr dl_boot_got_pointer ++#define DL_GET_READY_TO_RUN_EXTRA_ARGS \ ++ , dl_boot_progmap, dl_boot_got_pointer ++ ++ ++#ifdef __USE_GNU ++# include ++#else ++# define __USE_GNU ++# include ++# undef __USE_GNU ++#endif ++ ++#include ++static __inline__ void ++elf_machine_relative (DL_LOADADDR_TYPE load_off, const Elf32_Addr rel_addr, ++ Elf32_Word relative_count) ++{ ++#if 0 ++ Elf32_Rel * rpnt = (void *) rel_addr; ++ --rpnt; ++ do { ++ Elf32_Addr *const reloc_addr = (void *) (load_off + (++rpnt)->r_offset); ++ ++ *reloc_addr = DL_RELOC_ADDR (load_off, *reloc_addr); ++ } while (--relative_count); ++#endif ++} +Index: uClibc-0.9.30.2/ldso/ldso/ubicom32/elfinterp.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/ldso/ldso/ubicom32/elfinterp.c 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,366 @@ ++/* Blackfin ELF shared library loader suppport ++ Copyright (C) 2003, 2004 Red Hat, Inc. ++ Contributed by Alexandre Oliva ++ Lots of code copied from ../i386/elfinterp.c, so: ++ Copyright (c) 1994-2000 Eric Youngdale, Peter MacDonald, ++ David Engel, Hongjiu Lu and Mitch D'Souza ++ Copyright (C) 2001-2002, Erik Andersen ++ All rights reserved. ++ ++This file is part of uClibc. ++ ++uClibc 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. ++ ++uClibc 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 ++Library General Public License for more details. ++ ++You should have received a copy of the GNU Lesser General Public ++License along with uClibc; see the file COPYING.LIB. If not, write to ++the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, ++USA. */ ++ ++#include /* __attribute_used__ */ ++ ++/* Program to load an ELF binary on a linux system, and run it. ++ References to symbols in sharable libraries can be resolved by either ++ an ELF sharable library or a linux style of shared library. */ ++ ++/* Disclaimer: I have never seen any AT&T source code for SVr4, nor have ++ I ever taken any courses on internals. This program was developed using ++ information available through the book "UNIX SYSTEM V RELEASE 4, ++ Programmers guide: Ansi C and Programming Support Tools", which did ++ a more than adequate job of explaining everything required to get this ++ working. */ ++extern int _dl_ubicom32_resolve_pending(void) __attribute__((__visibility__("hidden"))); ++ ++struct funcdesc_value volatile *__attribute__((__visibility__("hidden"))) ++_dl_linux_resolver (struct elf_resolve *tpnt, int reloc_entry) ++{ ++ int reloc_type; ++ ELF_RELOC *this_reloc; ++ char *strtab; ++ ElfW(Sym) *symtab; ++ int symtab_index; ++ char *rel_addr; ++ struct elf_resolve *new_tpnt; ++ char *new_addr; ++ struct funcdesc_value funcval; ++ struct funcdesc_value volatile *got_entry; ++ char *symname; ++ ++ rel_addr = (char *)tpnt->dynamic_info[DT_JMPREL]; ++ ++ this_reloc = (ELF_RELOC *)(intptr_t)(rel_addr + reloc_entry); ++ reloc_type = ELF_R_TYPE(this_reloc->r_info); ++ symtab_index = ELF_R_SYM(this_reloc->r_info); ++ ++ symtab = (Elf32_Sym *) tpnt->dynamic_info[DT_SYMTAB]; ++ strtab = (char *) tpnt->dynamic_info[DT_STRTAB]; ++ symname= strtab + symtab[symtab_index].st_name; ++ ++ if (reloc_type != R_UBICOM32_FUNCDESC_VALUE) { ++ _dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n", ++ _dl_progname); ++ _dl_exit(1); ++ } ++ ++ /* Address of GOT entry fix up */ ++ got_entry = (struct funcdesc_value *) DL_RELOC_ADDR(tpnt->loadaddr, this_reloc->r_offset); ++ ++ /* Get the address to be used to fill in the GOT entry. */ ++ new_addr = _dl_lookup_hash(symname, tpnt->symbol_scope, NULL, 0, &new_tpnt); ++ if (!new_addr) { ++ new_addr = _dl_lookup_hash(symname, NULL, NULL, 0, &new_tpnt); ++ if (!new_addr) { ++ _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", ++ _dl_progname, symname); ++ _dl_exit(1); ++ } ++ } ++ ++ funcval.entry_point = new_addr; ++ funcval.got_value = new_tpnt->loadaddr.got_value; ++ ++#if defined (__SUPPORT_LD_DEBUG__) ++ if (_dl_debug_bindings) { ++ _dl_dprintf(_dl_debug_file, "\nresolve function: %s", symname); ++ if (_dl_debug_detail) ++ _dl_dprintf(_dl_debug_file, ++ "\n\tpatched (%x,%x) ==> (%x,%x) @ %x\n", ++ got_entry->entry_point, got_entry->got_value, ++ funcval.entry_point, funcval.got_value, ++ got_entry); ++ } ++ if (1 || !_dl_debug_nofixups) { ++ got_entry->entry_point = ((unsigned long *)&_dl_ubicom32_resolve_pending)[0]; ++ got_entry->got_value = funcval.got_value; ++ got_entry->entry_point = funcval.entry_point; ++ } ++#else ++ /* ++ * initially set the entry point to resolve pending before starting ++ * the update. This has the effect of putting all other requests in a ++ * holding pattern until the resolution is completed. ++ */ ++ got_entry->entry_point = ((unsigned long *)&_dl_ubicom32_resolve_pending)[0]; ++ got_entry->got_value = funcval.got_value; ++ got_entry->entry_point = funcval.entry_point; ++#endif ++ ++ return got_entry; ++} ++ ++static int ++_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope, ++ unsigned long rel_addr, unsigned long rel_size, ++ int (*reloc_fnc) (struct elf_resolve *tpnt, struct dyn_elf *scope, ++ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)) ++{ ++ unsigned int i; ++ char *strtab; ++ ElfW(Sym) *symtab; ++ ELF_RELOC *rpnt; ++ int symtab_index; ++ ++ /* Now parse the relocation information */ ++ rpnt = (ELF_RELOC *) rel_addr; ++ rel_size = rel_size / sizeof(ELF_RELOC); ++ ++ symtab = (ElfW(Sym) *) tpnt->dynamic_info[DT_SYMTAB]; ++ strtab = (char *) tpnt->dynamic_info[DT_STRTAB]; ++ ++ for (i = 0; i < rel_size; i++, rpnt++) { ++ int res; ++ ++ symtab_index = ELF_R_SYM(rpnt->r_info); ++ debug_sym(symtab,strtab,symtab_index); ++ debug_reloc(symtab,strtab,rpnt); ++ ++ res = reloc_fnc (tpnt, scope, rpnt, symtab, strtab); ++ ++ if (res==0) continue; ++ ++ _dl_dprintf(2, "\n%s: ",_dl_progname); ++ ++ if (symtab_index) ++ _dl_dprintf(2, "symbol '%s': ", strtab + symtab[symtab_index].st_name); ++ ++ if (res <0) { ++ int reloc_type = ELF_R_TYPE(rpnt->r_info); ++#if defined (__SUPPORT_LD_DEBUG__) ++ _dl_dprintf(2, "can't handle reloc type %s\n ", _dl_reltypes(reloc_type)); ++#else ++ _dl_dprintf(2, "can't handle reloc type %x\n", reloc_type); ++#endif ++ _dl_exit(-res); ++ } else if (res >0) { ++ _dl_dprintf(2, "can't resolve symbol\n"); ++ return res; ++ } ++ } ++ return 0; ++} ++ ++static int ++_dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope, ++ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab) ++{ ++ int reloc_type; ++ int symtab_index; ++ char *symname; ++ unsigned long reloc_value = 0, *reloc_addr; ++ struct { unsigned long v; } __attribute__((__packed__)) ++ *reloc_addr_packed; ++ unsigned long symbol_addr; ++ struct elf_resolve *symbol_tpnt; ++ struct funcdesc_value funcval; ++#if defined (__SUPPORT_LD_DEBUG__) ++ unsigned long old_val; ++#endif ++ ++ reloc_addr = (unsigned long *) DL_RELOC_ADDR(tpnt->loadaddr, rpnt->r_offset); ++ __asm__ ("" : "=r" (reloc_addr_packed) : "0" (reloc_addr)); ++ reloc_type = ELF_R_TYPE(rpnt->r_info); ++ symtab_index = ELF_R_SYM(rpnt->r_info); ++ symbol_addr = 0; ++ symname = strtab + symtab[symtab_index].st_name; ++ ++ if (ELF_ST_BIND (symtab[symtab_index].st_info) == STB_LOCAL) { ++ symbol_addr = (unsigned long) DL_RELOC_ADDR(tpnt->loadaddr, symtab[symtab_index].st_value); ++ symbol_tpnt = tpnt; ++ } else { ++ ++ symbol_addr = (unsigned long) ++ _dl_lookup_hash(symname, scope, NULL, 0, &symbol_tpnt); ++ ++ /* ++ * We want to allow undefined references to weak symbols - this might ++ * have been intentional. We should not be linking local symbols ++ * here, so all bases should be covered. ++ */ ++ ++ if (!symbol_addr && ELF_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) { ++ _dl_dprintf (2, "%s: can't resolve symbol '%s'\n", ++ _dl_progname, strtab + symtab[symtab_index].st_name); ++ _dl_exit (1); ++ } ++ } ++ ++#if defined (__SUPPORT_LD_DEBUG__) ++ if (_dl_debug_reloc && _dl_debug_detail) ++ { ++ if ((long)reloc_addr_packed & 3) ++ old_val = reloc_addr_packed->v; ++ else ++ old_val = *reloc_addr; ++ } ++ else ++ old_val = 0; ++#endif ++ switch (reloc_type) { ++ case R_UBICOM32_NONE: ++ break; ++ case R_UBICOM32_32: ++ if ((long)reloc_addr_packed & 3) ++ reloc_value = reloc_addr_packed->v += symbol_addr; ++ else ++ reloc_value = *reloc_addr += symbol_addr; ++ break; ++ case R_UBICOM32_FUNCDESC_VALUE: ++ funcval.entry_point = (void*)symbol_addr; ++ /* The addend of FUNCDESC_VALUE ++ relocations referencing global ++ symbols must be ignored, because it ++ may hold the address of a lazy PLT ++ entry. */ ++ if (ELF_ST_BIND(symtab[symtab_index].st_info) == STB_LOCAL) ++ funcval.entry_point += *reloc_addr; ++ reloc_value = (unsigned long)funcval.entry_point; ++ if (symbol_addr) ++ funcval.got_value ++ = symbol_tpnt->loadaddr.got_value; ++ else ++ funcval.got_value = 0; ++ ++/// XXX this is my best guess as to what I should be doing, but I'm ++/// putting a break-point here so I can inspect the first time this is ++/// used. ++ __asm__ ( ++ " move.4 4(%0), 4(%1) \n\t" ++ " move.4 0(%0), 0(%1) \n\t" /* Must to entry_point last */ ++ : ++ : "a" (reloc_addr), "a" (&funcval) ++ : "memory" ); ++ break; ++ case R_UBICOM32_FUNCDESC: ++ if ((long)reloc_addr_packed & 3) ++ reloc_value = reloc_addr_packed->v; ++ else ++ reloc_value = *reloc_addr; ++ if (symbol_addr) ++ reloc_value = (unsigned long)_dl_funcdesc_for ++ ((char *)symbol_addr + reloc_value, ++ symbol_tpnt->loadaddr.got_value); ++ else ++ reloc_value = 0; ++ if ((long)reloc_addr_packed & 3) ++ reloc_addr_packed->v = reloc_value; ++ else ++ *reloc_addr = reloc_value; ++ break; ++ default: ++ return -1; ++ } ++#if defined (__SUPPORT_LD_DEBUG__) ++ if (_dl_debug_reloc && _dl_debug_detail) { ++ _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x", old_val, reloc_value, reloc_addr); ++ switch (reloc_type) { ++ case R_UBICOM32_FUNCDESC_VALUE: ++ _dl_dprintf(_dl_debug_file, " got %x", ((struct funcdesc_value *)reloc_value)->got_value); ++ break; ++ case R_UBICOM32_FUNCDESC: ++ if (! reloc_value) ++ break; ++ _dl_dprintf(_dl_debug_file, " funcdesc (%x,%x)", ++ ((struct funcdesc_value *)reloc_value)->entry_point, ++ ((struct funcdesc_value *)reloc_value)->got_value); ++ break; ++ } ++ } ++#endif ++ ++ return 0; ++} ++ ++static int ++_dl_do_lazy_reloc (struct elf_resolve *tpnt, ++ struct dyn_elf *scope __attribute__((unused)), ++ ELF_RELOC *rpnt, ElfW(Sym) *symtab __attribute__((unused)), ++ char *strtab __attribute__((unused))) ++{ ++ int reloc_type; ++ struct funcdesc_value volatile *reloc_addr; ++ struct funcdesc_value funcval; ++#if defined (__SUPPORT_LD_DEBUG__) ++ unsigned long old_val; ++#endif ++ ++ reloc_addr = (struct funcdesc_value *) DL_RELOC_ADDR(tpnt->loadaddr, rpnt->r_offset); ++ reloc_type = ELF_R_TYPE(rpnt->r_info); ++ ++#if defined (__SUPPORT_LD_DEBUG__) ++ old_val = (unsigned long)reloc_addr->entry_point; ++#endif ++ switch (reloc_type) { ++ case R_UBICOM32_NONE: ++ break; ++ case R_UBICOM32_FUNCDESC_VALUE: ++ funcval = *reloc_addr; ++ funcval.entry_point = (void*)DL_RELOC_ADDR(tpnt->loadaddr, funcval.entry_point); ++ funcval.got_value = tpnt->loadaddr.got_value; ++ *reloc_addr = funcval; ++ break; ++ default: ++ return -1; ++ } ++#if defined (__SUPPORT_LD_DEBUG__) ++ if (_dl_debug_reloc && _dl_debug_detail) ++ _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x", old_val, reloc_addr->entry_point, reloc_addr); ++#endif ++ return 0; ++ ++} ++ ++void ++_dl_parse_lazy_relocation_information ++(struct dyn_elf *rpnt, unsigned long rel_addr, unsigned long rel_size) ++{ ++ _dl_parse(rpnt->dyn, NULL, rel_addr, rel_size, _dl_do_lazy_reloc); ++} ++ ++int ++_dl_parse_relocation_information ++(struct dyn_elf *rpnt, unsigned long rel_addr, unsigned long rel_size) ++{ ++ return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size, _dl_do_reloc); ++} ++ ++#if 0 ++/* We don't have copy relocs. */ ++int ++_dl_parse_copy_information ++(struct dyn_elf *rpnt __attribute__((unused)), ++ unsigned long rel_addr __attribute__((unused)), ++ unsigned long rel_size __attribute__((unused))) ++{ ++ return 0; ++} ++#endif ++#ifndef IS_IN_libdl ++# include "../../libc/sysdeps/linux/ubicom32/crtreloc.c" ++#endif +Index: uClibc-0.9.30.2/ldso/ldso/ubicom32/resolve.S +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/ldso/ldso/ubicom32/resolve.S 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,161 @@ ++ /* Copyright (C) 2003 Red Hat, Inc. ++ Contributed by Alexandre Oliva ++ ++ Copyright (C) 2009 Ubicom Inc. ++ Ported to Ubicom32 by Ubicom Inc. ++ ++This file is part of uClibc. ++ ++uClibc 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. ++ ++uClibc 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 ++Library General Public License for more details. ++ ++You should have received a copy of the GNU Lesser General Public ++License along with uClibc; see the file COPYING.LIB. If not, write to ++the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, ++USA. */ ++ ++ ++/* ++ * The function below is tail-called by resolver stubs when a lazily-bound * ++ * function is called. It must preserve all registers that could * be used to ++ * pass arguments to the actual function. ++ * ++ * On entry to the function d0-d13 contain parameters to the actual function of ++ * interest ++ * ++ * a5 contains the return address ++ * a0 is pointing to the GOT table for the original function ++ * (a0) _dl_linux_resolve ++ * 4(a0) GOT for _dl_linux_resolve ++ * 8(a0) is pointer to "structure elf_resolve" of the module where the call ++ * originated from ++ * ++ * a3 is pointing to the function descriptor in the GOT table, and 8(a3) the ++ * resolver lookup information. ++ * ++ * _dl_linux_resolve calls _dl_linux_resolver passing it pointer to ++ * struct elf_resolve and the relocation entry. ++ * ++ * _dl_linux_resolver() figures out where the jump symbol is _really_ supposed ++ * to have jumped to and returns that to us. Once we have that, we prepare to ++ * tail-call the actual function, clean up after ourselves, restoring the ++ * original arguments, then jump to the fixed up address. ++ */ ++ ++#if 0 ++ /* ++ * Here is what the linker will use for the PLT. ++ */ ++sample_PLT_functionX: /* (at entry a0 contains GOT for this library) */ ++ movei d15, # -%lo(got_funcdescX) ; load offset for GOT ++ lea.4 a3, (a0, d15) ; a4 is now the function descriptor ++ move.4 a4, 0(a3) ; get entry_point ++ move.4 a0, 4(a3) ; set new GOT ++ ++ /* ++ * jump to resovled function OR PLT_trampoline Nat had some code here ++ * that uses the stack instead of a3 to reduces hazards. ++ */ ++ calli a4, 0(a4) ++ ++ ++sample_PLT_trampoline: ++ /* ++ * find the old got by undoing what was done above. An alternative ++ * could have been to ā€˜saveā€™ the old got in say d14 but that would add 1 ++ * instruction to every PLT and there is only 1 PLT trampoline per library. ++ */ ++ ret (a0) ; jump to _dl_linux_resolve ++#endif ++ ++ .text ++ .p2align 4 ++ ++ .hidden _dl_linux_resolve ++ .global _dl_linux_resolve ++ .type _dl_linux_resolve,@function ++_dl_linux_resolve: ++ /* Preserve arguments and return address */ ++ move.4 -4(sp)++, d0 ++ move.4 -4(sp)++, d1 ++ move.4 -4(sp)++, d2 ++ move.4 -4(sp)++, d3 ++ move.4 -4(sp)++, d4 ++ move.4 -4(sp)++, d5 ++ move.4 -4(sp)++, d6 ++ move.4 -4(sp)++, d7 ++ move.4 -4(sp)++, d8 ++ move.4 -4(sp)++, d9 ++ move.4 -4(sp)++, d10 ++ move.4 -4(sp)++, d11 ++ move.4 -4(sp)++, d12 ++ move.4 -4(sp)++, d13 ++ move.4 -4(sp)++, a5 ++ ++ /* Prepare to call _dl_linux_resolver. */ ++ move.4 d0, 8(a0) ; reference to elf_resolve ++ /* Not aligned for space reasons. */ ++ move.4 d1, mac_hi ; reference to GOT table entry which ++ ; contains the relocation information. ++ ++ move.4 a0, 4(a0) ; switch to GOT for _dl_linux_resolve ++ call a5, _dl_linux_resolver; ++ ++ /* Move aside return value that contains the FUNCDESC_VALUE. */ ++ ;P3 = R0; ++ move.4 a3, d0; ++ ++ /* Restore arguments. */ ++ move.4 a5, (sp)4++ ++ move.4 d13, (sp)4++ ++ move.4 d12, (sp)4++ ++ move.4 d11, (sp)4++ ++ move.4 d10, (sp)4++ ++ move.4 d9, (sp)4++ ++ move.4 d8, (sp)4++ ++ move.4 d7, (sp)4++ ++ move.4 d6, (sp)4++ ++ move.4 d5, (sp)4++ ++ move.4 d4, (sp)4++ ++ move.4 d3, (sp)4++ ++ move.4 d2, (sp)4++ ++ move.4 d1, (sp)4++ ++ move.4 d0, (sp)4++ ++ ++ /* Now jump to the actual function. */ ++ /* a3 contains func_desc resolution */ ++ move.4 a4, 0(a3) ; address of function X ++ move.4 a0, 4(a3) ; switch to GOT for function X ++ calli a4, 0(a4) ; call through a4, a5 remains ++ ++ .size _dl_linux_resolve, . - _dl_linux_resolve ++ ++ .hidden _dl_ubicom32_resolve_pending ++ .global _dl_ubicom32_resolve_pending ++ .type _dl_ubicom32_resolve_pending,@function ++ ++_dl_ubicom32_resolve_pending: ++ /* ++ * A special function that is used to ensure thread saftly when the fd ++ * for a particular resolution is being updated. ++ * ++ * At entry, a3 must point to the FD. While the FD is being updated the ++ * entry_point will continue to point to _dl_ubicom32_resolve_pending so ++ * we will effectively spin until the resolver update is complete. ++ */ ++ ++ move.4 a4, 0(a3) ; get entry_point ++ move.4 a0, 4(a3) ; set new GOT ++ ++ /* ++ * jump to resovled function or back to _dl_ubicom32_resolve_pending. ++ */ ++ calli a4, 0(a4) ++ .size _dl_ubicom32_resolve_pending, . - _dl_ubicom32_resolve_pending +Index: uClibc-0.9.30.2/libc/misc/Makefile.in +=================================================================== +--- uClibc-0.9.30.2.orig/libc/misc/Makefile.in 2010-01-13 22:22:31.000000000 +0100 ++++ uClibc-0.9.30.2/libc/misc/Makefile.in 2010-01-14 11:05:01.000000000 +0100 +@@ -12,7 +12,9 @@ + include $(top_srcdir)libc/misc/ctype/Makefile.in + include $(top_srcdir)libc/misc/dirent/Makefile.in + include $(top_srcdir)libc/misc/error/Makefile.in ++ifneq ($(ARCH_HAS_NO_LDSO),y) + include $(top_srcdir)libc/misc/elf/Makefile.in ++endif + include $(top_srcdir)libc/misc/file/Makefile.in + include $(top_srcdir)libc/misc/fnmatch/Makefile.in + include $(top_srcdir)libc/misc/ftw/Makefile.in +Index: uClibc-0.9.30.2/libc/misc/elf/dl-iterate-phdr.c +=================================================================== +--- uClibc-0.9.30.2.orig/libc/misc/elf/dl-iterate-phdr.c 2010-01-13 22:22:31.000000000 +0100 ++++ uClibc-0.9.30.2/libc/misc/elf/dl-iterate-phdr.c 2010-01-14 11:05:01.000000000 +0100 +@@ -14,7 +14,7 @@ + + #include + #include +- ++#include + /* we want this in libc but nowhere else */ + #ifdef __USE_GNU + +Index: uClibc-0.9.30.2/libc/stdlib/malloc/malloc.c +=================================================================== +--- uClibc-0.9.30.2.orig/libc/stdlib/malloc/malloc.c 2010-01-13 22:22:31.000000000 +0100 ++++ uClibc-0.9.30.2/libc/stdlib/malloc/malloc.c 2010-01-14 11:05:01.000000000 +0100 +@@ -25,7 +25,7 @@ + + /* The malloc heap. We provide a bit of initial static space so that + programs can do a little mallocing without mmaping in more space. */ +-HEAP_DECLARE_STATIC_FREE_AREA (initial_fa, 256); ++HEAP_DECLARE_STATIC_FREE_AREA (initial_fa, 32768); + struct heap_free_area *__malloc_heap = HEAP_INIT_WITH_FA (initial_fa); + #ifdef HEAP_USE_LOCKING + pthread_mutex_t __malloc_heap_lock = PTHREAD_MUTEX_INITIALIZER; +Index: uClibc-0.9.30.2/libc/string/ubicom32/Makefile +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/string/ubicom32/Makefile 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,13 @@ ++# Makefile for uClibc ++# ++# Copyright (C) 2000-2005 Erik Andersen ++# ++# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. ++# ++ ++top_srcdir:=../../../ ++top_builddir:=../../../ ++all: objs ++include $(top_builddir)Rules.mak ++include ../Makefile.in ++include $(top_srcdir)Makerules +Index: uClibc-0.9.30.2/libc/string/ubicom32/memcpy.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/string/ubicom32/memcpy.c 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,152 @@ ++/* Copy memory to memory until the specified number of bytes ++ has been copied. Overlap is NOT handled correctly. ++ Copyright (C) 1991, 1997, 2003 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ Contributed by Torbjorn Granlund (tege@sics.se). ++ ++ 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, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++ ++typedef unsigned long addr_t; ++ ++libc_hidden_proto(memcpy) ++ ++void *memcpy (void *dest, const void *src, size_t n) ++{ ++ void *dest_ret = dest; ++ void *aligned_start; ++ ++ if (likely((((addr_t)dest ^ (addr_t)src) & 3) == 0) && likely(n > 6)) { ++ size_t m; ++ n -= (4 - (addr_t)dest) & 0x03; ++ m = n >> 2; ++ __asm__ volatile ( ++ " call %4, 99f \n\t" // load %4 with address of 99 ++ "99: movei d15, #%%lo(1f-99b) \n\t" // load d15 with offset to 1 from 99 ++ " add.4 %4, %4, d15 \n\t" // add difference ++ ++ " sub.4 d15, #0, %2 \n\t" // set up for jump table ++ " and.4 d15, #(32-1), d15 \n\t" // d15 = (-m) & (32 - 1) ++ " lea.4 %4, (%4,d15) \n\t" ++ ++ " bfextu d15, %0, #2 \n\t" // d15 = (dest & 3) ++ " jmpne.w.f 100f \n\t" ++ " calli %4, 0(%4) \n\t" // 4-byte alignment ++ ++ "100: cmpi d15, #2 \n\t" ++ " jmpne.s.f 101f \n\t" ++ " move.2 (%0)2++, (%1)2++ \n\t" ++ " calli %4, 0(%4) \n\t" // 2-byte alignment ++ ++ "101: move.1 (%0)1++, (%1)1++ \n\t" ++ " jmpgt.s.f 102f \n\t" // 3-byte alignment ++ " move.2 (%0)2++, (%1)2++ \n\t" // 1-byte alignment ++ "102: calli %4, 0(%4) \n\t" ++ ++ "200: cmpi %3, #2 \n\t" ++ " jmplt.s.f 201f \n\t" ++ " move.2 (%0)2++, (%1)2++ \n\t" ++ " jmpeq.s.t 2f \n\t" ++ "201: move.1 (%0)1++, (%1)1++ \n\t" ++ " jmpt.w.t 2f \n\t" ++ ++ "1: .rept 25 \n\t" ++ " movea (%0)4++, (%1)4++ \n\t" ++ " .endr \n\t" ++ " .rept 7 \n\t" ++ " move.4 (%0)4++, (%1)4++ \n\t" ++ " .endr \n\t" ++ " add.4 %2, #-32, %2 \n\t" ++ " jmpgt.w.f 1b \n\t" ++ ++ " and.4 %3, #3, %3 \n\t" // check n ++ " jmpne.w.f 200b \n\t" ++ "2: \n\t" ++ : "+a"(dest), "+a"(src), "+d"(m), "+d"(n), "=a"(aligned_start) ++ : ++ : "d15", "memory", "cc" ++ ); ++ ++ return dest_ret; ++ } ++ ++ if (likely((((addr_t)dest ^ (addr_t)src) & 1) == 0) && likely(n > 2)) { ++ size_t m; ++ n -= (addr_t)dest & 0x01; ++ m = n >> 1; ++ __asm__ volatile ( ++ " call %4, 99f \n\t" // load %4 with address of 99 ++ "99: movei d15, #%%lo(1f-99b) \n\t" // load d15 with offset to 1 from 99 ++ " add.4 %4, %4, d15 \n\t" // add difference ++ ++ " sub.4 d15, #0, %2 \n\t" // set up for jump table ++ " and.4 d15, #(32-1), d15 \n\t" // d15 = (-m) & (32 - 1) ++ " lea.4 %4, (%4,d15) \n\t" ++ ++ " btst %0, #0 \n\t" // check bit 0 ++ " jmpne.w.f 100f \n\t" ++ " calli %4, 0(%4) \n\t" // 4-byte alignment ++ ++ "100: move.1 (%0)1++, (%1)1++ \n\t" ++ " calli %4, 0(%4) \n\t" ++ ++ "200: move.1 (%0)1++, (%1)1++ \n\t" ++ " jmpt.w.t 2f \n\t" ++ ++ "1: .rept 32 \n\t" ++ " move.2 (%0)2++, (%1)2++ \n\t" ++ " .endr \n\t" ++ " add.4 %2, #-32, %2 \n\t" ++ " jmpgt.w.f 1b \n\t" ++ ++ " and.4 %3, #1, %3 \n\t" // check n ++ " jmpne.w.f 200b \n\t" ++ "2: \n\t" ++ ++ : "+a"(dest), "+a"(src), "+d"(m), "+d"(n), "=a"(aligned_start) ++ : ++ : "d15", "memory", "cc" ++ ); ++ return dest_ret; ++ } ++ ++ __asm__ volatile ( ++ " call %3, 99f \n\t" // load %3 with address of 99 ++ "99: movei d15, #%%lo(1f-99b) \n\t" // load d15 with offset to 1 from 99 ++ " add.4 %3, %3, d15 \n\t" // add difference ++ ++ " sub.4 d15, #0, %2 \n\t" ++ " jmpeq.w.f 2f \n\t" ++ " and.4 d15, #(16-1), d15 \n\t" // d15 = (-n) & (16 - 1) ++ " lea.4 %3, (%3,d15) \n\t" ++ " calli %3, 0(%3) \n\t" ++ ++ "1: .rept 16 \n\t" ++ " move.1 (%0)1++, (%1)1++ \n\t" ++ " .endr \n\t" ++ " add.4 %2, #-16, %2 \n\t" ++ " jmpgt.w.f 1b \n\t" ++ "2: \n\t" ++ ++ : "+a"(dest), "+a"(src), "+d"(n), "=a"(aligned_start) ++ : ++ : "d15", "memory", "cc" ++ ); ++ ++ return dest_ret; ++} ++libc_hidden_def(memcpy) +Index: uClibc-0.9.30.2/libc/string/ubicom32/memset.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/string/ubicom32/memset.c 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,107 @@ ++/* Copyright (C) 1991, 1997, 2003 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, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++ ++typedef unsigned long addr_t; ++ ++libc_hidden_proto(memset) ++void *memset (void *s, int c, size_t n) ++{ ++ void *s_ret = s; ++ void *aligned_start; ++ if (likely(n > 6)) { ++ size_t m; ++ n -= (4 - (addr_t)s) & 0x03; ++ m = n >> 2; ++ __asm__ volatile ( ++ " call %4, 99f \n\t" // load %4 with address of 99 ++ "99: movei d15, #%%lo(1f-99b) \n\t" // load d15 with offset to 1 from 99 ++ " add.4 %4, %4, d15 \n\t" // add difference ++ ++ " sub.4 d15, #0, %2 \n\t" // set up for jump table ++ " and.4 d15, #(32-1), d15 \n\t" // d15 = (-m) & (32 - 1) ++ " shmrg.1 %1, %1, %1 \n\t" ++ " shmrg.2 %1, %1, %1 \n\t" // %1 = (c<<24)|(c<<16)|(c<<8)|c ++ " lea.4 %4, (%4,d15) \n\t" ++ ++ " bfextu d15, %0, #2 \n\t" // d15 = (s & 3) ++ " jmpne.w.f 100f \n\t" ++ " calli %4, 0(%4) \n\t" // 4-byte alignment ++ ++ "100: cmpi d15, #2 \n\t" ++ " jmpne.s.f 101f \n\t" ++ " move.2 (%0)2++, %1 \n\t" ++ " calli %4, 0(%4) \n\t" // 2-byte alignment ++ ++ "101: move.1 (%0)1++, %1 \n\t" ++ " jmpgt.s.f 102f \n\t" // 3-byte alignment ++ " move.2 (%0)2++, %1 \n\t" // 1-byte alignment ++ "102: calli %4, 0(%4) \n\t" ++ ++ "200: cmpi %3, #2 \n\t" ++ " jmplt.s.f 201f \n\t" ++ " move.2 (%0)2++, %1 \n\t" ++ " jmpeq.s.t 2f \n\t" ++ "201: move.1 (%0)1++, %1 \n\t" ++ " jmpt.w.t 2f \n\t" ++ ++ "1: .rept 25 \n\t" ++ " movea (%0)4++, %1 \n\t" ++ " .endr \n\t" ++ " .rept 7 \n\t" ++ " move.4 (%0)4++, %1 \n\t" ++ " .endr \n\t" ++ " add.4 %2, #-32, %2 \n\t" ++ " jmpgt.w.f 1b \n\t" ++ ++ " and.4 %3, #3, %3 \n\t" // test bit 1 of n ++ " jmpne.w.f 200b \n\t" ++ "2: \n\t" ++ : "+a"(s), "+d"(c), "+d"(m), "+d"(n), "=a"(aligned_start) ++ : ++ : "d15", "memory", "cc" ++ ); ++ ++ return s_ret; ++ } ++ ++ __asm__ volatile ( ++ " call %3, 99f \n\t" // load %3 with address of 99 ++ "99: movei d15, #%%lo(1f-99b) \n\t" // load d15 with offset to 1 from 99 ++ " add.4 %3, %3, d15 \n\t" // add difference ++ ++ " sub.4 d15, #0, %2 \n\t" ++ " jmpeq.w.f 2f \n\t" ++ " and.4 d15, #(8-1), d15 \n\t" // d15 = (-%2) & (16 - 1) ++ " lea.4 %3, (%3,d15) \n\t" ++ " calli %3, 0(%3) \n\t" ++ ++ "1: .rept 8 \n\t" ++ " move.1 (%0)1++, %1 \n\t" ++ " .endr \n\t" ++ "2: \n\t" ++ ++ : "+a"(s), "+d"(c), "+d"(n), "=a"(aligned_start) ++ : ++ : "d15", "memory", "cc" ++ ); ++ ++ return s_ret; ++} ++libc_hidden_def(memset) +Index: uClibc-0.9.30.2/libc/sysdeps/linux/common/sys/user.h +=================================================================== +--- uClibc-0.9.30.2.orig/libc/sysdeps/linux/common/sys/user.h 2010-01-13 22:22:31.000000000 +0100 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/common/sys/user.h 2010-01-14 11:05:01.000000000 +0100 +@@ -1 +1,4 @@ ++#if 0 ++/* As of linux v2.6.25 this is not part of the exported linux headers */ + #include ++#endif +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/Makefile +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/Makefile 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,13 @@ ++# Makefile for uClibc ++# ++# Copyright (C) 2000-2006 Erik Andersen ++# ++# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. ++# ++ ++top_srcdir=../../../../ ++top_builddir=../../../../ ++all: objs ++include $(top_builddir)Rules.mak ++include Makefile.arch ++include $(top_srcdir)Makerules +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/Makefile.arch +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/Makefile.arch 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,28 @@ ++# Makefile for uClibc ++# ++# Copyright (C) 2000-2006 Erik Andersen ++# ++# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. ++# ++ ++#CSRC := \ ++# brk.c \ ++# crtbegin.c \ ++# crtend.c ++# ++#SSRC := \ ++# __longjmp.S \ ++# bsd-_setjmp.S \ ++# bsd-setjmp.S \ ++# setjmp.S \ ++# clone.S \ ++# vfork.S ++ ++CSRC := \ ++ syscall.c __syscall_error.c ++ ++SSRC := \ ++ clone.S setjmp.S vfork.S ++ ++ARCH_CFLAGS := $(CPU_CFLAGS-y) ++include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/__syscall_error.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/__syscall_error.c 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,11 @@ ++#include ++#include ++ ++/* This routine is jumped to by some of the syscall handlers, to stash ++ * an error number into errno. */ ++int __syscall_error(int err_no) attribute_hidden; ++int __syscall_error(int err_no) ++{ ++ __set_errno(err_no); ++ return -1; ++} +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/elf-fdpic.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/elf-fdpic.h 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,115 @@ ++/* Copyright 2003, 2004 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. ++ ++In addition to the permissions in the GNU Lesser General Public ++License, the Free Software Foundation gives you unlimited ++permission to link the compiled version of this file with other ++programs, and to distribute those programs without any restriction ++coming from the use of this file. (The GNU Lesser General Public ++License restrictions do apply in other respects; for example, they ++cover modification of the file, and distribution when not linked ++into another program.) ++ ++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 ++Library 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; see the file COPYING.LIB. If ++not, write to the Free Software Foundation, Inc., 675 Mass Ave, ++Cambridge, MA 02139, USA. */ ++ ++#ifndef _BITS_ELF_FDPIC_H ++#define _BITS_ELF_FDPIC_H ++ ++/* These data structures are described in the FDPIC ABI extension. ++ The kernel passes a process a memory map, such that for every LOAD ++ segment there is an elf32_fdpic_loadseg entry. A pointer to an ++ elf32_fdpic_loadmap is passed in d8 at start-up, and a pointer to ++ an additional such map is passed in d9 for the interpreter, when ++ there is one. */ ++ ++#include ++ ++/* This data structure represents a PT_LOAD segment. */ ++struct elf32_fdpic_loadseg ++{ ++ /* Core address to which the segment is mapped. */ ++ Elf32_Addr addr; ++ /* VMA recorded in the program header. */ ++ Elf32_Addr p_vaddr; ++ /* Size of this segment in memory. */ ++ Elf32_Word p_memsz; ++}; ++ ++struct elf32_fdpic_loadmap { ++ /* Protocol version number, must be zero. */ ++ Elf32_Half version; ++ /* Number of segments in this map. */ ++ Elf32_Half nsegs; ++ /* The actual memory map. */ ++ struct elf32_fdpic_loadseg segs[/*nsegs*/]; ++}; ++ ++struct elf32_fdpic_loadaddr { ++ struct elf32_fdpic_loadmap *map; ++ void *got_value; ++}; ++ ++/* Map a pointer's VMA to its corresponding address according to the ++ load map. */ ++static __always_inline void * ++__reloc_pointer (void *p, ++ const struct elf32_fdpic_loadmap *map) ++{ ++ int c; ++ ++#if 0 ++ if (map->version != 0) ++ /* Crash. */ ++ ((void(*)())0)(); ++#endif ++ ++ /* No special provision is made for NULL. We don't want NULL ++ addresses to go through relocation, so they shouldn't be in ++ .rofixup sections, and, if they're present in dynamic ++ relocations, they shall be mapped to the NULL address without ++ undergoing relocations. */ ++ ++ for (c = 0; ++ /* Take advantage of the fact that the loadmap is ordered by ++ virtual addresses. In general there will only be 2 entries, ++ so it's not profitable to do a binary search. */ ++ c < map->nsegs && p >= (void*)map->segs[c].p_vaddr; ++ c++) ++ { ++ /* This should be computed as part of the pointer comparison ++ above, but we want to use the carry in the comparison, so we ++ can't convert it to an integer type beforehand. */ ++ unsigned long offset = p - (void*)map->segs[c].p_vaddr; ++ /* We only check for one-past-the-end for the last segment, ++ assumed to be the data segment, because other cases are ++ ambiguous in the absence of padding between segments, and ++ rofixup already serves as padding between text and data. ++ Unfortunately, unless we special-case the last segment, we ++ fail to relocate the _end symbol. */ ++ if (offset < map->segs[c].p_memsz ++ || (offset == map->segs[c].p_memsz && c + 1 == map->nsegs)) ++ return (char*)map->segs[c].addr + offset; ++ } ++ ++ /* We might want to crash instead. */ ++ return (void*)-1; ++} ++ ++# define __RELOC_POINTER(ptr, loadaddr) \ ++ (__reloc_pointer ((void*)(ptr), \ ++ (loadaddr).map)) ++ ++#endif /* _BITS_ELF_FDPIC_H */ +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/endian.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/endian.h 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,7 @@ ++/* Ubicom32 is big-endian. */ ++ ++#ifndef _ENDIAN_H ++# error "Never use directly; include instead." ++#endif ++ ++#define __BYTE_ORDER __BIG_ENDIAN +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/fcntl.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/fcntl.h 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,224 @@ ++/* O_*, F_*, FD_* bit values for Linux. ++ Copyright (C) 2000 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, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#ifndef _FCNTL_H ++# error "Never use directly; include instead." ++#endif ++ ++ ++#include ++#ifdef __USE_GNU ++# include ++#endif ++ ++/* open/fcntl - O_SYNC is only implemented on blocks devices and on files ++ located on an ext2 file system */ ++#define O_ACCMODE 0003 ++#define O_RDONLY 00 ++#define O_WRONLY 01 ++#define O_RDWR 02 ++#define O_CREAT 0100 /* not fcntl */ ++#define O_EXCL 0200 /* not fcntl */ ++#define O_NOCTTY 0400 /* not fcntl */ ++#define O_TRUNC 01000 /* not fcntl */ ++#define O_APPEND 02000 ++#define O_NONBLOCK 04000 ++#define O_NDELAY O_NONBLOCK ++#define O_SYNC 010000 ++#define O_FSYNC O_SYNC ++#define O_ASYNC 020000 ++ ++#ifdef __USE_GNU ++# define O_DIRECTORY 040000 /* Must be a directory. */ ++# define O_NOFOLLOW 0100000 /* Do not follow links. */ ++# define O_DIRECT 0200000 /* Direct disk access. */ ++# define O_STREAMING 04000000/* streaming access */ ++#endif ++ ++/* For now Linux has synchronisity options for data and read operations. ++ We define the symbols here but let them do the same as O_SYNC since ++ this is a superset. */ ++#if defined __USE_POSIX199309 || defined __USE_UNIX98 ++# define O_DSYNC O_SYNC /* Synchronize data. */ ++# define O_RSYNC O_SYNC /* Synchronize read operations. */ ++#endif ++ ++#ifdef __USE_LARGEFILE64 ++# define O_LARGEFILE 0400000 ++#endif ++ ++/* Values for the second argument to `fcntl'. */ ++#define F_DUPFD 0 /* Duplicate file descriptor. */ ++#define F_GETFD 1 /* Get file descriptor flags. */ ++#define F_SETFD 2 /* Set file descriptor flags. */ ++#define F_GETFL 3 /* Get file status flags. */ ++#define F_SETFL 4 /* Set file status flags. */ ++#ifndef __USE_FILE_OFFSET64 ++# define F_GETLK 5 /* Get record locking info. */ ++# define F_SETLK 6 /* Set record locking info (non-blocking). */ ++# define F_SETLKW 7 /* Set record locking info (blocking). */ ++#else ++# define F_GETLK F_GETLK64 /* Get record locking info. */ ++# define F_SETLK F_SETLK64 /* Set record locking info (non-blocking).*/ ++# define F_SETLKW F_SETLKW64 /* Set record locking info (blocking). */ ++#endif ++#define F_GETLK64 12 /* Get record locking info. */ ++#define F_SETLK64 13 /* Set record locking info (non-blocking). */ ++#define F_SETLKW64 14 /* Set record locking info (blocking). */ ++ ++#if defined __USE_BSD || defined __USE_XOPEN2K ++# define F_SETOWN 8 /* Get owner of socket (receiver of SIGIO). */ ++# define F_GETOWN 9 /* Set owner of socket (receiver of SIGIO). */ ++#endif ++ ++#ifdef __USE_GNU ++# define F_SETSIG 10 /* Set number of signal to be sent. */ ++# define F_GETSIG 11 /* Get number of signal to be sent. */ ++#endif ++ ++#ifdef __USE_GNU ++# define F_SETLEASE 1024 /* Set a lease. */ ++# define F_GETLEASE 1025 /* Enquire what lease is active. */ ++# define F_NOTIFY 1026 /* Request notfications on a directory. */ ++#endif ++ ++/* For F_[GET|SET]FL. */ ++#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ ++ ++/* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */ ++#define F_RDLCK 0 /* Read lock. */ ++#define F_WRLCK 1 /* Write lock. */ ++#define F_UNLCK 2 /* Remove lock. */ ++ ++/* For old implementation of bsd flock(). */ ++#define F_EXLCK 4 /* or 3 */ ++#define F_SHLCK 8 /* or 4 */ ++ ++#ifdef __USE_BSD ++/* Operations for bsd flock(), also used by the kernel implementation. */ ++# define LOCK_SH 1 /* shared lock */ ++# define LOCK_EX 2 /* exclusive lock */ ++# define LOCK_NB 4 /* or'd with one of the above to prevent ++ blocking */ ++# define LOCK_UN 8 /* remove lock */ ++#endif ++ ++#ifdef __USE_GNU ++# define LOCK_MAND 32 /* This is a mandatory flock: */ ++# define LOCK_READ 64 /* ... which allows concurrent read operations. */ ++# define LOCK_WRITE 128 /* ... which allows concurrent write operations. */ ++# define LOCK_RW 192 /* ... Which allows concurrent read & write operations. */ ++#endif ++ ++#ifdef __USE_GNU ++/* Types of directory notifications that may be requested with F_NOTIFY. */ ++# define DN_ACCESS 0x00000001 /* File accessed. */ ++# define DN_MODIFY 0x00000002 /* File modified. */ ++# define DN_CREATE 0x00000004 /* File created. */ ++# define DN_DELETE 0x00000008 /* File removed. */ ++# define DN_RENAME 0x00000010 /* File renamed. */ ++# define DN_ATTRIB 0x00000020 /* File changed attibutes. */ ++# define DN_MULTISHOT 0x80000000 /* Don't remove notifier. */ ++#endif ++ ++struct flock ++ { ++ short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */ ++ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */ ++#ifndef __USE_FILE_OFFSET64 ++ __off_t l_start; /* Offset where the lock begins. */ ++ __off_t l_len; /* Size of the locked area; zero means until EOF. */ ++#else ++ __off64_t l_start; /* Offset where the lock begins. */ ++ __off64_t l_len; /* Size of the locked area; zero means until EOF. */ ++#endif ++ __pid_t l_pid; /* Process holding the lock. */ ++ }; ++ ++#ifdef __USE_LARGEFILE64 ++struct flock64 ++ { ++ short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */ ++ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */ ++ __off64_t l_start; /* Offset where the lock begins. */ ++ __off64_t l_len; /* Size of the locked area; zero means until EOF. */ ++ __pid_t l_pid; /* Process holding the lock. */ ++ }; ++#endif ++ ++/* Define some more compatibility macros to be backward compatible with ++ BSD systems which did not managed to hide these kernel macros. */ ++#ifdef __USE_BSD ++# define FAPPEND O_APPEND ++# define FFSYNC O_FSYNC ++# define FASYNC O_ASYNC ++# define FNONBLOCK O_NONBLOCK ++# define FNDELAY O_NDELAY ++#endif /* Use BSD. */ ++ ++/* Advise to `posix_fadvise'. */ ++#ifdef __USE_XOPEN2K ++# define POSIX_FADV_NORMAL 0 /* No further special treatment. */ ++# define POSIX_FADV_RANDOM 1 /* Expect random page references. */ ++# define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */ ++# define POSIX_FADV_WILLNEED 3 /* Will need these pages. */ ++# define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */ ++# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */ ++#endif ++ ++#ifdef __USE_GNU ++# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages ++ in the range before performing the ++ write. */ ++# define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those ++ dirty pages in the range which are ++ not presently under writeback. */ ++# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in ++ the range after performing the ++ write. */ ++#endif ++ ++__BEGIN_DECLS ++ ++#ifdef __USE_GNU ++ ++/* Provide kernel hint to read ahead. */ ++extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count) ++ __THROW; ++ ++/* Selective file content synch'ing. */ ++extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to, ++ unsigned int __flags); ++ ++/* Splice address range into a pipe. */ ++extern ssize_t vmsplice (int __fdout, const struct iovec *__iov, ++ size_t __count, unsigned int __flags); ++ ++/* Splice two files together. */ ++extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout, ++ __off64_t *__offout, size_t __len, ++ unsigned int __flags); ++ ++/* In-kernel implementation of tee for pipe buffers. */ ++extern ssize_t tee (int __fdin, int __fdout, size_t __len, ++ unsigned int __flags); ++ ++#endif ++ ++__END_DECLS +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/kernel_stat.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/kernel_stat.h 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,61 @@ ++#ifndef _BITS_STAT_STRUCT_H ++#define _BITS_STAT_STRUCT_H ++ ++#ifndef _LIBC ++#error bits/kernel_stat.h is for internal uClibc use only! ++#endif ++ ++/* This file provides whatever this particular arch's kernel thinks ++ * struct kernel_stat should look like... It turns out each arch has a ++ * different opinion on the subject... */ ++ ++struct kernel_stat { ++ unsigned short st_dev; ++ unsigned short __pad1; ++ unsigned long st_ino; ++ unsigned short st_mode; ++ unsigned short st_nlink; ++ unsigned short st_uid; ++ unsigned short st_gid; ++ unsigned short st_rdev; ++ unsigned short __pad2; ++ unsigned long st_size; ++ unsigned long st_blksize; ++ unsigned long st_blocks; ++ unsigned long st_atime; ++ unsigned long __unused1; ++ unsigned long st_mtime; ++ unsigned long __unused2; ++ unsigned long st_ctime; ++ unsigned long __unused3; ++ unsigned long __unused4; ++ unsigned long __unused5; ++}; ++ ++struct kernel_stat64 { ++ unsigned char __pad0[6]; ++ unsigned short st_dev; ++ unsigned char __pad1[4]; ++#define _HAVE_STAT64___ST_INO ++ unsigned long __st_ino; ++ unsigned int st_mode; ++ unsigned int st_nlink; ++ unsigned long st_uid; ++ unsigned long st_gid; ++ unsigned char __pad2[6]; ++ unsigned short st_rdev; ++ unsigned char __pad3[4]; ++ long long st_size; ++ unsigned long st_blksize; ++ unsigned long st_blocks; /* Number 512-byte blocks allocated. */ ++ unsigned long __pad4; /* future possible st_blocks high bits */ ++ unsigned long st_atime; ++ unsigned long __pad5; ++ unsigned long st_mtime; ++ unsigned long __pad6; ++ unsigned long st_ctime; ++ unsigned long __pad7; /* will be high 32 bits of ctime someday */ ++ unsigned long long st_ino; ++}; ++ ++#endif /* _BITS_STAT_STRUCT_H */ +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/kernel_types.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/kernel_types.h 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,44 @@ ++/* Note that we use the exact same include guard #define names ++ * as asm/posix_types.h. This will avoid gratuitous conflicts ++ * with the posix_types.h kernel header, and will ensure that ++ * our private content, and not the kernel header, will win. ++ * -Erik ++ */ ++#ifndef __ARCH_UBICOM32_POSIX_TYPES_H ++#define __ARCH_UBICOM32_POSIX_TYPES_H ++ ++typedef unsigned long __kernel_dev_t; ++typedef unsigned long __kernel_ino_t; ++typedef unsigned short __kernel_mode_t; ++typedef unsigned short __kernel_nlink_t; ++typedef long __kernel_off_t; ++typedef int __kernel_pid_t; ++typedef unsigned short __kernel_ipc_pid_t; ++typedef unsigned short __kernel_uid_t; ++typedef unsigned short __kernel_gid_t; ++typedef unsigned int __kernel_size_t; ++typedef int __kernel_ssize_t; ++typedef int __kernel_ptrdiff_t; ++typedef long __kernel_time_t; ++typedef long __kernel_suseconds_t; ++typedef long __kernel_clock_t; ++typedef int __kernel_daddr_t; ++typedef char * __kernel_caddr_t; ++typedef unsigned short __kernel_uid16_t; ++typedef unsigned short __kernel_gid16_t; ++typedef unsigned int __kernel_uid32_t; ++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 long __kernel_loff_t; ++ ++typedef struct { ++#ifdef __USE_ALL ++ int val[2]; ++#else ++ int __val[2]; ++#endif ++} __kernel_fsid_t; ++ ++#endif /* __ARCH_UBICOM32_POSIX_TYPES_H */ +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/mman.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/mman.h 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,102 @@ ++/* Definitions for POSIX memory map interface. Linux/m68k version. ++ Copyright (C) 1997, 2000, 2003, 2005 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, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#ifndef _SYS_MMAN_H ++# error "Never use directly; include instead." ++#endif ++ ++/* The following definitions basically come from the kernel headers. ++ But the kernel header is not namespace clean. */ ++ ++ ++/* Protections are chosen from these bits, OR'd together. The ++ implementation does not necessarily support PROT_EXEC or PROT_WRITE ++ without PROT_READ. The only guarantees are that no writing will be ++ allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */ ++ ++#define PROT_READ 0x1 /* Page can be read. */ ++#define PROT_WRITE 0x2 /* Page can be written. */ ++#define PROT_EXEC 0x4 /* Page can be executed. */ ++#define PROT_NONE 0x0 /* Page can not be accessed. */ ++#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of ++ growsdown vma (mprotect only). */ ++#define PROT_GROWSUP 0x02000000 /* Extend change to start of ++ growsup vma (mprotect only). */ ++ ++/* Sharing types (must choose one and only one of these). */ ++#define MAP_SHARED 0x01 /* Share changes. */ ++#define MAP_PRIVATE 0x02 /* Changes are private. */ ++#ifdef __USE_MISC ++# define MAP_TYPE 0x0f /* Mask for type of mapping. */ ++#endif ++ ++/* Other flags. */ ++#define MAP_FIXED 0x10 /* Interpret addr exactly. */ ++#ifdef __USE_MISC ++# define MAP_FILE 0 ++# define MAP_ANONYMOUS 0x20 /* Don't use a file. */ ++# define MAP_ANON MAP_ANONYMOUS ++#endif ++ ++/* These are Linux-specific. */ ++#ifdef __USE_MISC ++# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */ ++# define MAP_DENYWRITE 0x00800 /* ETXTBSY */ ++# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */ ++# define MAP_LOCKED 0x02000 /* Lock the mapping. */ ++# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */ ++# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */ ++# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */ ++#endif ++ ++/* Flags to `msync'. */ ++#define MS_ASYNC 1 /* Sync memory asynchronously. */ ++#define MS_SYNC 4 /* Synchronous memory sync. */ ++#define MS_INVALIDATE 2 /* Invalidate the caches. */ ++ ++/* Flags for `mlockall'. */ ++#define MCL_CURRENT 1 /* Lock all currently mapped pages. */ ++#define MCL_FUTURE 2 /* Lock all additions to address ++ space. */ ++ ++/* Flags for `mremap'. */ ++#ifdef __USE_GNU ++# define MREMAP_MAYMOVE 1 ++# define MREMAP_FIXED 2 ++#endif ++ ++/* Advice to `madvise'. */ ++#ifdef __USE_BSD ++# define MADV_NORMAL 0 /* No further special treatment. */ ++# define MADV_RANDOM 1 /* Expect random page references. */ ++# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ ++# define MADV_WILLNEED 3 /* Will need these pages. */ ++# define MADV_DONTNEED 4 /* Don't need these pages. */ ++# define MADV_DONTFORK 10 /* Do not inherit across fork. */ ++# define MADV_DOFORK 11 /* Do inherit across fork. */ ++#endif ++ ++/* The POSIX people had to invent similar names for the same things. */ ++#ifdef __USE_XOPEN2K ++# define POSIX_MADV_NORMAL 0 /* No further special treatment. */ ++# define POSIX_MADV_RANDOM 1 /* Expect random page references. */ ++# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */ ++# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */ ++# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */ ++#endif +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/setjmp.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/setjmp.h 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,52 @@ ++/* Define the machine-dependent type `jmp_buf'. Ubicom32 version. ++ Copyright (C) 1992,93,95,97,2000 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, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#ifndef _BITS_SETJMP_H ++#define _BITS_SETJMP_H 1 ++ ++#if !defined _SETJMP_H && !defined _PTHREAD_H ++# error "Never include directly; use instead." ++#endif ++ ++#ifndef _ASM ++/* ++ * This is the structure where we are going to save D10-D13, A0, A1, A2, A5, A6 and SP(A7). ++ * A5 is the return address. Call to setjmp will save these. Call to longjmp will return ++ * Control to the address in A5. ++ */ ++typedef struct setjmp_save_struct { ++ unsigned long d10; /* D10 */ ++ unsigned long d11; /* D11 */ ++ unsigned long d12; /* D12 */ ++ unsigned long d13; /* D13 */ ++ unsigned long a1; /* A1 */ ++ unsigned long a2; /* A2 */ ++ unsigned long a5; /* A5 return address. */ ++ unsigned long a6; /* A6 */ ++ unsigned long sp; /* A7 stack pointer. */ ++} __jmp_buf[1]; ++ ++#endif ++ ++/* Test if longjmp to JMPBUF would unwind the frame ++ containing a local variable at ADDRESS. */ ++#define _JMPBUF_UNWINDS(jmpbuf, address) \ ++ ((void *) (address) < (void*)(jmpbuf)->sp) ++ ++#endif /* bits/setjmp.h */ +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/stackinfo.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/stackinfo.h 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,28 @@ ++/* Copyright (C) 1999 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, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++/* This file contains a bit of information about the stack allocation ++ of the processor. */ ++ ++#ifndef _STACKINFO_H ++#define _STACKINFO_H 1 ++ ++/* On Ubicom32 the stack grows down. */ ++#define _STACK_GROWS_DOWN 1 ++ ++#endif /* stackinfo.h */ +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/syscalls.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/syscalls.h 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,169 @@ ++#ifndef _BITS_SYSCALLS_H ++#define _BITS_SYSCALLS_H ++#ifndef _SYSCALL_H ++# error "Never use directly; include instead." ++#endif ++ ++/* m68k headers does stupid stuff with __NR_iopl / __NR_vm86: ++ * #define __NR_iopl not supported ++ * #define __NR_vm86 not supported ++ */ ++#undef __NR_iopl ++#undef __NR_vm86 ++ ++#ifndef __ASSEMBLER__ ++ ++#include ++ ++/* Linux takes system call arguments in registers: ++ ++ syscall number %d8 ++ arg 1 %d0 ++ arg 2 %d1 ++ arg 3 %d2 ++ arg 4 %d3 ++ arg 5 %d4 ++ arg 6 %d5 ++*/ ++ ++#define __syscall_return(type, res) \ ++ do { \ ++ if (likely((unsigned long)(res) < (unsigned long)(-125))) { \ ++ return (type) (res); \ ++ } else { \ ++ /* avoid using res which is declared to be in register d0; \ ++ errno might expand to a function call and clobber it. */ \ ++ int __err = -(res); \ ++ __set_errno(__err); \ ++ return (type) -1; \ ++ } \ ++ } while (0) ++ ++extern void __illegally_sized_syscall_arg1 (void); ++extern void __illegally_sized_syscall_arg2 (void); ++extern void __illegally_sized_syscall_arg3 (void); ++extern void __illegally_sized_syscall_arg4 (void); ++extern void __illegally_sized_syscall_arg5 (void); ++extern void __illegally_sized_syscall_arg6 (void); ++ ++#define __loadargs_0(name, dummy) \ ++ d8 = name ++ ++#define __loadargs_1(name, __arg1) \ ++ __loadargs_0(name, 0); \ ++ if (__builtin_classify_type (__arg1) != 5 && sizeof (__arg1) > 4) \ ++ __illegally_sized_syscall_arg1 (); \ ++ d0_retval = (long int) __arg1 ++#define __loadargs_2(name, __arg1, __arg2) \ ++ __loadargs_1(name, __arg1); \ ++ if (__builtin_classify_type (__arg2) != 5 && sizeof (__arg2) > 4) \ ++ __illegally_sized_syscall_arg2 (); \ ++ d1 = (long int) __arg2 ++ ++#define __loadargs_3(name, __arg1, __arg2, __arg3) \ ++ __loadargs_2(name, __arg1, __arg2); \ ++ if (__builtin_classify_type (__arg3) != 5 && sizeof (__arg3) > 4) \ ++ __illegally_sized_syscall_arg3 (); \ ++ d2 = (long int) __arg3 ++ ++#define __loadargs_4(name, __arg1, __arg2, __arg3, __arg4) \ ++ __loadargs_3(name, __arg1, __arg2, __arg3); \ ++ if (__builtin_classify_type (__arg4) != 5 && sizeof (__arg4) > 4) \ ++ __illegally_sized_syscall_arg4 (); \ ++ d3 = (long int)__arg4 ++ ++#define __loadargs_5(name, __arg1, __arg2, __arg3, __arg4, __arg5) \ ++ __loadargs_4(name, __arg1, __arg2, __arg3, __arg4); \ ++ if (__builtin_classify_type (__arg5) != 5 && sizeof (__arg5) > 4) \ ++ __illegally_sized_syscall_arg5 (); \ ++ d4 = (long int)__arg5 ++ ++#define __loadargs_6(name, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \ ++ __loadargs_5(name, __arg1, __arg2, __arg3, __arg4, __arg5); \ ++ if (__builtin_classify_type (__arg6) != 5 && sizeof (__arg6) > 4) \ ++ __illegally_sized_syscall_arg6 (); \ ++ d5 = (long int)__arg6 ++ ++#define __internal_syscall_body(name, nr, args...) \ ++ register long int d0_retval __asm__ ("d0"); \ ++ register long int d1 __asm__ ("d1"); \ ++ register long int d2 __asm__ ("d2"); \ ++ register long int d3 __asm__ ("d3"); \ ++ register long int d4 __asm__ ("d4"); \ ++ register long int d5 __asm__ ("d5"); \ ++ register long int d8 __asm__ ("d8"); \ ++ __loadargs_##nr (__NR_##name, args); \ ++ __asm__ __volatile__ ( \ ++ " moveai a5, #%%hi(0x40400000)\n\t" \ ++ " calli a5, 16(a5)\n\t" \ ++ : "+r" (d0_retval), "+r" (d1), "+r" (d2), "+r" (d3), \ ++ "+r" (d4), "+r" (d5), "+r" (d8) : \ ++ : "cc", "memory", \ ++ "acc0_lo", "acc0_hi", "acc1_lo", "acc1_hi", \ ++ "source3", \ ++ "a0", "a3", "a4", "a5", \ ++ "d6", "d7", "d9", "d14", "d15" \ ++ ); ++ ++#define INLINE_SYSCALL(name, nr, args...) \ ++ ({ \ ++ __internal_syscall_body(name, nr, args); \ ++ if (unlikely((unsigned long)(d0_retval) >= (unsigned long)(-125))) { \ ++ __set_errno (-d0_retval); \ ++ d0_retval = -1L; \ ++ } \ ++ d0_retval; \ ++ }) ++ ++ ++#undef _syscall0 ++#define _syscall0(type,name) \ ++type name(void){ \ ++ __internal_syscall_body(name, 0); \ ++ __syscall_return(type, d0_retval); \ ++} ++ ++#undef _syscall1 ++#define _syscall1(type,name,type1,arg1) \ ++type name(type1 arg1){ \ ++ __internal_syscall_body(name, 1, arg1); \ ++ __syscall_return(type, d0_retval); \ ++} ++ ++#undef _syscall2 ++#define _syscall2(type,name,type1,arg1,type2,arg2) \ ++type name(type1 arg1, type2 arg2){ \ ++ __internal_syscall_body(name, 2, arg1, arg2); \ ++ __syscall_return(type, d0_retval); \ ++} ++ ++#undef _syscall3 ++#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ ++type name(type1 arg1, type2 arg2, type3 arg3){ \ ++ __internal_syscall_body(name, 3, arg1, arg2, arg3); \ ++ __syscall_return(type, d0_retval); \ ++} ++ ++#undef _syscall4 ++#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ ++type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4){ \ ++ __internal_syscall_body(name, 4, arg1, arg2, arg3, arg4); \ ++ __syscall_return(type, d0_retval); \ ++} ++ ++#undef _syscall5 ++#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \ ++type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5){ \ ++ __internal_syscall_body(name, 5, arg1, arg2, arg3, arg4, arg5); \ ++ __syscall_return(type, d0_retval); \ ++} ++ ++#undef _syscall6 ++#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \ ++type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6){ \ ++ __internal_syscall_body(name, 6, arg1, arg2, arg3, arg4, arg5, arg6); \ ++ __syscall_return(type, d0_retval); \ ++} ++ ++#endif /* __ASSEMBLER__ */ ++#endif /* _BITS_SYSCALLS_H */ +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/uClibc_arch_features.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/uClibc_arch_features.h 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,45 @@ ++/* ++ * Track misc arch-specific features that aren't config options ++ */ ++ ++#ifndef _BITS_UCLIBC_ARCH_FEATURES_H ++#define _BITS_UCLIBC_ARCH_FEATURES_H ++ ++/* instruction used when calling abort() to kill yourself */ ++/*#define __UCLIBC_ABORT_INSTRUCTION__ "asm instruction"*/ ++#undef __UCLIBC_ABORT_INSTRUCTION__ ++ ++/* can your target use syscall6() for mmap ? */ ++#undef __UCLIBC_MMAP_HAS_6_ARGS__ ++ ++/* does your target use syscall4() for truncate64 ? (32bit arches only) */ ++#undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__ ++ ++/* does your target have a broken create_module() ? */ ++#undef __UCLIBC_BROKEN_CREATE_MODULE__ ++ ++/* does your target have to worry about older [gs]etrlimit() ? */ ++#undef __UCLIBC_HANDLE_OLDER_RLIMIT__ ++ ++/* does your target prefix all symbols with an _ ? */ ++#define __UCLIBC_NO_UNDERSCORES__ ++ ++/* does your target have an asm .set ? */ ++#define __UCLIBC_HAVE_ASM_SET_DIRECTIVE__ ++ ++/* define if target doesn't like .global */ ++#undef __UCLIBC_ASM_GLOBAL_DIRECTIVE__ ++ ++/* define if target supports .weak */ ++#define __UCLIBC_HAVE_ASM_WEAK_DIRECTIVE__ ++ ++/* define if target supports .weakext */ ++#undef __UCLIBC_HAVE_ASM_WEAKEXT_DIRECTIVE__ ++ ++/* needed probably only for ppc64 */ ++#undef __UCLIBC_HAVE_ASM_GLOBAL_DOT_NAME__ ++ ++/* define if target supports IEEE signed zero floats */ ++#define __UCLIBC_HAVE_SIGNED_ZERO__ ++ ++#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */ +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/wordsize.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/wordsize.h 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,19 @@ ++/* Copyright (C) 1999 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, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#define __WORDSIZE 32 +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/clone.S +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/clone.S 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,71 @@ ++#include ++ ++ .global __syscall_error ++ ++/* int _clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */ ++ .text ++ .type clone,@function ++ .global clone ++clone: ++ /* Sanity check arguments. */ ++ sub.4 #0, #0, d0 /* Test if fn is zero. */ ++ jmpeq.f 1f /* arg bad */ ++ sub.4 #0, #0, d1 /* Test if child_stack is zero. */ ++ jmpeq.f 1f /* arg bad */ ++ ++ /* Set up child_stack frame.. arg and fn */ ++ move.4 a3, d1 ++ move.4 -4(a3)++, d3 /* push 'arg' to child stack */ ++ move.4 -4(a3)++, d0 /* push fn to child stack, this will become a5 ++ * on new child */ ++ move.4 d1, a3 ++ move.4 -4(sp)++, a5 /* push a5 to our stack */ ++ ++ /* ++ * The syscall clone is clone(int flags, void *child_stack) so we set ++ * that up now ++ */ ++ move.4 d0, d2 /* Move flags to d0 */ ++ ++ /* Do Clone syscall */ ++ movei d8, #__NR_clone ++ moveai a5, #%hi(0x40400000) ++ calli a5, 0x10(a5) ++ move.4 a5, (sp)4++ /* pop a5 from stack */ ++ ++ /* Clone Complete */ ++ cmpi d0, #0 /* Test if d0 is less than zero. If it is we ++ * return the error */ ++ jmplt.f 2f /* If return is less than we had an error */ ++ jmpeq.f 3f /* If return is 0 we are in the clone, jump to ++ * thread start */ ++ ret a5 /* d0 is pid */ ++ ++ /* Invalid Value */ ++1: movei d0, #-22 /* EINVAL */ ++ ++ /* Call syscall Error */ ++2: sub.4 d0, #0, d0 /* d0 = -d0 */ ++#if defined(__UBICOM32_FDPIC__) ++ call a3, __syscall_error ++#else ++ moveai a3, #%hi(__syscall_error) ++ calli a3, %lo(__syscall_error)(a3) ++#endif ++ /* Child Thread Start */ ++3: ++#if defined(__UBICOM32_FDPIC__) ++ /* a5 actually contains a function descriptor for fdpic */ ++ move.4 a0, 4(a5) /* set GOT for this function */ ++ move.4 a5, 0(a5) /* get address of entry point */ ++#endif ++ move.4 d0, (sp)4++ /* pop 'arg' to stack */ ++ calli a5, 0(a5) ++ movei d8, #__NR_exit ++ moveai a3, #%hi(0x40400000) ++ calli a3, 0x10(a3) ++ ++ .size clone, . - clone ++ .global __GI_clone ++ .hidden __GI_clone ++ .set __GI_clone,clone +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crt1.S +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crt1.S 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,179 @@ ++/* Startup code compliant to the ELF m68k ABI. ++ Copyright (C) 1996, 1997, 1998, 2001, 2002 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. ++ ++ In addition to the permissions in the GNU Lesser General Public ++ License, the Free Software Foundation gives you unlimited ++ permission to link the compiled version of this file with other ++ programs, and to distribute those programs without any restriction ++ coming from the use of this file. (The GNU Lesser General Public ++ License restrictions do apply in other respects; for example, they ++ cover modification of the file, and distribution when not linked ++ into another program.) ++ ++ Note that people who make modified versions of this file are not ++ obligated to grant this special exception for their modified ++ versions; it is their choice whether to do so. The GNU Lesser ++ General Public License gives permission to release a modified ++ version without this exception; this exception also makes it ++ possible to release a modified version which carries forward this ++ exception. ++ ++ 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, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++ ++/* This is the canonical entry point, usually the first thing in the text ++ segment. The SVR4/m68k ABI says that when the entry point runs, ++ most registers' values are unspecified, except for: ++ ++ %a1 Contains a function pointer to be registered with `atexit'. ++ This is how the dynamic linker arranges to have DT_FINI ++ functions called for shared libraries that have been loaded ++ before this code runs. ++ ++ %sp The stack contains the arguments and environment: ++ 0(%sp) argc ++ 4(%sp) argv[0] ++ ... ++ (4*argc)(%sp) NULL ++ (4*(argc+1))(%sp) envp[0] ++ ... ++ NULL ++ ++ The uclinux conventions are different. %a1 is not defined on entry ++ and the stack is laid out as follows: ++ ++ 0(%sp) argc ++ 4(%sp) argv ++ 8(%sp) envp ++*/ ++ ++ ++ .text ++ .type main,@function ++ .type _init,%function ++ .type _fini,%function ++#ifndef __UCLIBC_CTOR_DTOR__ ++ .weak _init ++ .weak _fini ++#endif ++ .globl _start ++ .global __uClibc_main; ++ .type __uClibc_main,@function; ++ .type _start,@function ++_start: ++ ++#if defined(__UBICOM32_FDPIC__) && !defined(L_Scrt1) ++ /* P0 contains a pointer to the program's load map. */ ++ call a3, .Lcall; ++.Lcall: ++ move.4 d0, d1 ; load exec_map_addr ++ moveai a4, #%hi(.Lcall) ++ lea.1 d15, %lo(.Lcall)(a4) ++ sub.4 d15, a3, d15 ; difference between .Lcall and actual address of .Lcall ++ moveai a3, #%hi(__ROFIXUP_LIST__) ++ lea.1 d1, %lo(__ROFIXUP_LIST__)(a3) ++ moveai a3, #%hi(__ROFIXUP_END__) ++ lea.1 d2, %lo(__ROFIXUP_END__)(a3) ++ add.4 d1, d1, d15 ++ add.4 d2, d2, d15 ++ call a5, __self_reloc ; returns GOT in d0 ++ move.4 a0, d0 ; set GOT ++#endif ++ ++/* ++ all this is setup to make the following call. ++ ++ void __uClibc_main( ++ d0 - int (*main)(int, char **, char **), ++ d1 - int argc, (d1) ++ d2 - char **argv, ++ d3 - void (*app_init)(void), ++ d4 - void (*app_fini)(void), ++ d5 - void (*rtld_fini)(void), ++ d6 - void *stack_end ++ ); ++ */ ++ ++ /* ++ * Load pointer to main into d0 ++ */ ++#ifdef __UBICOM32_FDPIC__ ++ movei d0, #%got_funcdesc_lo(main) ++ move.4 d0, (a0, d0) ++#else ++ moveai a3, #%hi(main) ++ lea.1 d0, %lo(main)(a3) ++#endif ++ ++ /* ++ * Grab the environment stuff from stack and set up d1, d2 with it. ++ */ ++ move.4 d1, (sp) ++#ifdef __UBICOM32_FDPIC__ ++ /* For FDPIC the calling convention is different than flat */ ++ lea.1 d2, 4(sp) ++#else ++ move.4 d2, 4(sp) ++#endif ++ ++#ifdef __UCLIBC_CTOR_DTOR__ ++ /* ++ * Load pointer to _init into d3 ++ */ ++#ifdef __UBICOM32_FDPIC__ ++ movei d3, #%got_funcdesc_lo(_init) ++ move.4 d3, (a0, d3) ++#else ++ moveai a3, #%hi(_init) ++ lea.1 d3, %lo(_init)(a3) ++#endif ++ ++ /* ++ * Load pointer to _fini into d4 ++ */ ++#ifdef __UBICOM32_FDPIC__ ++ movei d4, #%got_funcdesc_lo(_fini) ++ move.4 d4, (a0, d4) ++#else ++ moveai a3, #%hi(_fini) ++ lea.1 d4, %lo(_fini)(a3) ++#endif ++ ++#else /* !__UCLIBC_CTOR_DTOR__ */ ++ move.4 d3, #0 ; _init ++ move.4 d4, #0 ; _fini ++#endif ++ ++#ifdef __UBICOM32_FDPIC__ ++ move.4 d5, a1 ; ldso _fini funcdesc (see dl-startup.h) ++#else ++ movei d5, #0 ; rtld_fini (not used) ++#endif ++ ++ move.4 d6, sp ; Stack End. ++ ++ /* Call the user's main function, and exit with its value. But ++ let the libc call main. */ ++#ifdef __UBICOM32_FDPIC__ ++ call a5, __uClibc_main ++#else ++ moveai a5, #%hi(__uClibc_main) ++ calli a5, %lo(__uClibc_main)(a5) ++#endif ++ ++ bkpt #-1 ; Crash if somehow `exit' does return. +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crti.S +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crti.S 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,54 @@ ++/* Specialized code needed to support construction and destruction of ++ file-scope objects in C++ and Java code, and to support exception handling. ++ Copyright (C) 1999 Free Software Foundation, Inc. ++ Contributed by Charles-Antoine Gauthier (charles.gauthier@iit.nrc.ca). ++ ++This file is part of GCC. ++ ++GCC is free software; you can redistribute it and/or modify ++it under the terms of the GNU General Public License as published by ++the Free Software Foundation; either version 2, or (at your option) ++any later version. ++ ++GCC is distributed in the hope that it will be useful, ++but WITHOUT ANY WARRANTY; without even the implied warranty of ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++GNU General Public License for more details. ++ ++You should have received a copy of the GNU General Public License ++along with GCC; see the file COPYING. If not, write to ++the Free Software Foundation, 59 Temple Place - Suite 330, ++Boston, MA 02111-1307, USA. */ ++ ++/* As a special exception, if you link this library with files ++ compiled with GCC to produce an executable, this does not cause ++ the resulting executable to be covered by the GNU General Public License. ++ This exception does not however invalidate any other reasons why ++ the executable file might be covered by the GNU General Public License. */ ++ ++/* ++ * This file just supplies function prologues for the .init and .fini ++ * sections. It is linked in before crtbegin.o. ++ */ ++ .file "crti.o" ++ .ident "GNU C crti.o" ++ ++ .section .init ++ .align 2 ++ .globl _init ++ .type _init, @function ++_init: ++ move.4 -4(sp)++, a5 ++#ifdef __UBICOM32_FDPIC__ ++ move.4 -4(sp)++, a0 ++#endif ++ ++ .section .fini ++ .align 2 ++ .globl _fini ++ .type _fini, @function ++_fini: ++ move.4 -4(sp)++, a5 ++#ifdef __UBICOM32_FDPIC__ ++ move.4 -4(sp)++, a0 ++#endif +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crtn.S +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crtn.S 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,47 @@ ++/* Specialized code needed to support construction and destruction of ++ file-scope objects in C++ and Java code, and to support exception handling. ++ Copyright (C) 1999 Free Software Foundation, Inc. ++ Contributed by Charles-Antoine Gauthier (charles.gauthier@iit.nrc.ca). ++ ++This file is part of GCC. ++ ++GCC is free software; you can redistribute it and/or modify ++it under the terms of the GNU General Public License as published by ++the Free Software Foundation; either version 2, or (at your option) ++any later version. ++ ++GCC is distributed in the hope that it will be useful, ++but WITHOUT ANY WARRANTY; without even the implied warranty of ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++GNU General Public License for more details. ++ ++You should have received a copy of the GNU General Public License ++along with GCC; see the file COPYING. If not, write to ++the Free Software Foundation, 59 Temple Place - Suite 330, ++Boston, MA 02111-1307, USA. */ ++ ++/* As a special exception, if you link this library with files ++ compiled with GCC to produce an executable, this does not cause ++ the resulting executable to be covered by the GNU General Public License. ++ This exception does not however invalidate any other reasons why ++ the executable file might be covered by the GNU General Public License. */ ++ ++/* ++ * This file supplies function epilogues for the .init and .fini sections. ++ * It is linked in after all other files. ++ */ ++ ++ .file "crtn.o" ++ .ident "GNU C crtn.o" ++ ++ .section .init ++#ifdef __UBICOM32_FDPIC__ ++ move.4 a0, (sp)4++ ++#endif ++ ret (sp)4++ ++ ++ .section .fini ++#ifdef __UBICOM32_FDPIC__ ++ move.4 a0, (sp)4++ ++#endif ++ ret (sp)4++ +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crtreloc.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crtreloc.c 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,145 @@ ++/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. ++ written by Alexandre Oliva ++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. ++ ++In addition to the permissions in the GNU Lesser General Public ++License, the Free Software Foundation gives you unlimited ++permission to link the compiled version of this file with other ++programs, and to distribute those programs without any restriction ++coming from the use of this file. (The GNU Lesser General Public ++License restrictions do apply in other respects; for example, they ++cover modification of the file, and distribution when not linked ++into another program.) ++ ++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 ++Library 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; see the file COPYING.LIB. If ++not, write to the Free Software Foundation, Inc., 675 Mass Ave, ++Cambridge, MA 02139, USA. */ ++ ++#ifdef __UBICOM32_FDPIC__ ++ ++#include ++#include ++ ++/* This file is to be compiled into crt object files, to enable ++ executables to easily self-relocate. */ ++ ++union word { ++ char c[4]; ++ void *v; ++}; ++ ++/* Compute the runtime address of pointer in the range [p,e), and then ++ map the pointer pointed by it. */ ++static __always_inline void *** ++reloc_range_indirect (void ***p, void ***e, ++ const struct elf32_fdpic_loadmap *map) ++{ ++ while (p < e) ++ { ++ if (*p != (void **)-1) ++ { ++ void *ptr = __reloc_pointer (*p, map); ++ if (ptr != (void *)-1) ++ { ++ void *pt; ++ if ((long)ptr & 3) ++ { ++ unsigned char *c = ptr; ++ int i; ++ unsigned long v = 0; ++ for (i = 0; i < 4; i++) ++ v |= c[i] << 8 * i; ++ pt = (void *)v; ++ } ++ else ++ pt = *(void**)ptr; ++ pt = __reloc_pointer (pt, map); ++ if ((long)ptr & 3) ++ { ++ unsigned char *c = ptr; ++ int i; ++ unsigned long v = (unsigned long)pt; ++ for (i = 0; i < 4; i++, v >>= 8) ++ c[i] = v; ++ } ++ else ++ *(void**)ptr = pt; ++ } ++ } ++ p++; ++ } ++ return p; ++} ++ ++/* Call __reloc_range_indirect for the given range except for the last ++ entry, whose contents are only relocated. It's expected to hold ++ the GOT value. */ ++void* attribute_hidden ++__self_reloc (const struct elf32_fdpic_loadmap *map, ++ void ***p, void ***e) ++{ ++ p = reloc_range_indirect (p, e-1, map); ++ ++ if (p >= e) ++ return (void*)-1; ++ ++ return __reloc_pointer (*p, map); ++} ++ ++#if 0 ++/* These are other functions that might be useful, but that we don't ++ need. */ ++ ++/* Remap pointers in [p,e). */ ++static __always_inline void** ++reloc_range (void **p, void **e, ++ const struct elf32_fdpic_loadmap *map) ++{ ++ while (p < e) ++ { ++ *p = __reloc_pointer (*p, map); ++ p++; ++ } ++ return p; ++} ++ ++/* Remap p, adjust e by the same offset, then map the pointers in the ++ range determined by them. */ ++void attribute_hidden ++__reloc_range (const struct elf32_fdpic_loadmap *map, ++ void **p, void **e) ++{ ++ void **old = p; ++ ++ p = __reloc_pointer (p, map); ++ e += p - old; ++ reloc_range (p, e, map); ++} ++ ++/* Remap p, adjust e by the same offset, then map pointers referenced ++ by the (unadjusted) pointers in the range. Return the relocated ++ value of the last pointer in the range. */ ++void* attribute_hidden ++__reloc_range_indirect (const struct elf32_fdpic_loadmap *map, ++ void ***p, void ***e) ++{ ++ void ***old = p; ++ ++ p = __reloc_pointer (p, map); ++ e += p - old; ++ return reloc_range_indirect (p, e, map); ++} ++#endif ++ ++#endif /* __UBICOM32_FDPIC__ */ +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/setjmp.S +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/setjmp.S 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,72 @@ ++/* Setjmp for Ubicom32 */ ++ .text ++ .global _setjmp ++ .type _setjmp,@function ++_setjmp: ++ movea a3, d0 ; A3 now holds the jmp buf that was passed in. ++ move.4 (a3)4++, d10 ++ move.4 (a3)4++, d11 ++ move.4 (a3)4++, d12 ++ move.4 (a3)4++, d13 ++ move.4 (a3)4++, a1 ++ move.4 (a3)4++, a2 ++ move.4 (a3)4++, a5 ++ move.4 (a3)4++, a6 ++ move.4 (a3)4++, a7 ++ move.4 d0, #0 ++ ++ calli a5, 0(a5) ++ .size _setjmp, . - _setjmp ++ ++/* ++ * __sigsetjmp for Ubicom32 ++ * d0 holds sigjmp_buf and d1 holds the savemask. We will save the frame and then just call __sigjmp_save to do the mask save. ++ */ ++ .global __sigsetjmp ++ .type __sigsetjmp,@function ++__sigsetjmp: ++ movea a3, d0 ; A3 now holds the jmp buf that was passed in. ++ move.4 (a3)4++, d10 ++ move.4 (a3)4++, d11 ++ move.4 (a3)4++, d12 ++ move.4 (a3)4++, d13 ++ move.4 (a3)4++, a1 ++ move.4 (a3)4++, a2 ++ move.4 (a3)4++, a5 ++ move.4 (a3)4++, a6 ++ move.4 (a3)4++, a7 ++ ++ ;; The frame has been saved. Call _sigjmp_save to get sigmask saved. a5 still has the return address and it will go back to that. ++#if defined(__UBICOM32_FDPIC__) ++ call a3, __sigjmp_save ++#else ++ moveai a3, #%hi(__sigjmp_save) ++ calli a3, %lo(__sigjmp_save)(a3) ++#endif ++ .size __sigjmp_save, . - __sigjmp_save ++ ++ .global __longjmp ++ .type __longjmp,@function ++__longjmp: ++ movea a3, d0 ; A3 now holds the jmp buf that was passed in. ++ move.4 d10, (a3)4++ ++ move.4 d11, (a3)4++ ++ move.4 d12, (a3)4++ ++ move.4 d13, (a3)4++ ++ move.4 a1 , (a3)4++ ++ move.4 a2 , (a3)4++ ++ move.4 a5 , (a3)4++ ++ move.4 a6 , (a3)4++ ++ move.4 a7 , (a3)4++ ++ ++ sub.4 #0, #0, d1 ; Test if d1 is zero. If it is we have to return 1 other wise return content of d1 ++ jmpeq.t 2f ++ move.4 d0, d1 ; d1 is non zero load it into d0 ++ jmpt.t 3f ++ ++2: move.4 d0, #1 ++3: calli a5, 0(a5) ++ .size __longjmp, . - __longjmp ++ .global __GI___longjmp ++ .hidden __GI___longjmp ++ .set __GI___longjmp,__longjmp +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/sys/procfs.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/sys/procfs.h 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,122 @@ ++/* Copyright (C) 1996, 1997, 1999, 2000 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, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#ifndef _SYS_PROCFS_H ++#define _SYS_PROCFS_H 1 ++ ++/* This is somehow modelled after the file of the same name on SysVr4 ++ systems. It provides a definition of the core file format for ELF ++ used on Linux. */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++__BEGIN_DECLS ++ ++#define ELF_NGREG 38 ++ ++typedef struct ++ { ++ union ++ { ++ unsigned long pr_regs[32]; ++ double pr_dregs[16]; ++ } pr_fr; ++ unsigned long __unused; ++ unsigned long pr_fsr; ++ unsigned char pr_qcnt; ++ unsigned char pr_q_entrysize; ++ unsigned char pr_en; ++ unsigned int pr_q[64]; ++ } elf_fpregset_t; ++ ++typedef unsigned long elf_greg_t; ++typedef elf_greg_t elf_gregset_t[ELF_NGREG]; ++ ++struct elf_siginfo ++ { ++ int si_signo; /* Signal number. */ ++ int si_code; /* Extra code. */ ++ int si_errno; /* Errno. */ ++ }; ++ ++/* Definitions to generate Intel SVR4-like core files. These mostly ++ have the same names as the SVR4 types with "elf_" tacked on the ++ front to prevent clashes with linux definitions, and the typedef ++ forms have been avoided. This is mostly like the SVR4 structure, ++ but more Linuxy, with things that Linux does not support and which ++ gdb doesn't really use excluded. Fields present but not used are ++ marked with "XXX". */ ++struct elf_prstatus ++ { ++ struct elf_siginfo pr_info; /* Info associated with signal. */ ++ short int pr_cursig; /* Current signal. */ ++ unsigned long int pr_sigpend; /* Set of pending signals. */ ++ unsigned long int pr_sighold; /* Set of held signals. */ ++ __pid_t pr_pid; ++ __pid_t pr_ppid; ++ __pid_t pr_pgrp; ++ __pid_t pr_sid; ++ struct timeval pr_utime; /* User time. */ ++ struct timeval pr_stime; /* System time. */ ++ struct timeval pr_cutime; /* Cumulative user time. */ ++ struct timeval pr_cstime; /* Cumulative system time. */ ++ elf_gregset_t pr_reg; /* GP registers. */ ++ int pr_fpvalid; /* True if math copro being used. */ ++ }; ++ ++ ++#define ELF_PRARGSZ (80) /* Number of chars for args */ ++ ++struct elf_prpsinfo ++ { ++ char pr_state; /* Numeric process state. */ ++ char pr_sname; /* Char for pr_state. */ ++ char pr_zomb; /* Zombie. */ ++ char pr_nice; /* Nice val. */ ++ unsigned long int pr_flag; /* Flags. */ ++ unsigned short int pr_uid; ++ unsigned short int pr_gid; ++ int pr_pid, pr_ppid, pr_pgrp, pr_sid; ++ /* Lots missing */ ++ char pr_fname[16]; /* Filename of executable. */ ++ char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */ ++ }; ++ ++/* Addresses. */ ++typedef void *psaddr_t; ++ ++/* Register sets. Linux has different names. */ ++typedef elf_gregset_t prgregset_t; ++typedef elf_fpregset_t prfpregset_t; ++ ++/* We don't have any differences between processes and threads, ++ therefore have only one PID type. */ ++typedef __pid_t lwpid_t; ++ ++ ++typedef struct elf_prstatus prstatus_t; ++typedef struct elf_prpsinfo prpsinfo_t; ++ ++__END_DECLS ++ ++#endif /* sys/procfs.h */ +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/sys/ucontext.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/sys/ucontext.h 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,104 @@ ++/* Copyright (C) 1998, 1999 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, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#ifndef _SYS_UCONTEXT_H ++#define _SYS_UCONTEXT_H 1 ++ ++#include ++#include ++/* ++ * Location of the users' stored registers relative to R0. ++ * Usage is as an index into a gregset_t array or as u.u_ar0[XX]. ++ */ ++#define REG_PSR (0) ++#define REG_PC (1) ++#define REG_SPARE (2) ++#define REG_WVALID (3) ++#define REG_G1 (4) ++#define REG_G2 (5) ++#define REG_G3 (6) ++#define REG_G4 (7) ++#define REG_G5 (8) ++#define REG_G6 (9) ++#define REG_G7 (10) ++#define REG_O0 (11) ++#define REG_O1 (12) ++#define REG_O2 (13) ++#define REG_O3 (14) ++#define REG_O4 (15) ++#define REG_O5 (16) ++#define REG_O6 (17) ++#define REG_O7 (18) ++#define REG_GLOBALS (19) ++ ++/* ++ * A gregset_t is defined as an array type for compatibility with the reference ++ * source. This is important due to differences in the way the C language ++ * treats arrays and structures as parameters. ++ * ++ * Note that NGREG is really (sizeof (struct regs) / sizeof (greg_t)), ++ * but that the ABI defines it absolutely to be 21 (resp. 19). ++ */ ++ ++#define NGREG 20 ++typedef int greg_t; ++ ++typedef greg_t gregset_t[NGREG]; ++ ++/* ++ * The following structures define how a register window can appear on the ++ * stack. This structure is available (when required) through the `gwins' ++ * field of an mcontext (nested within ucontext). NIOS_MAXWINDOW is the ++ * maximum number of outstanding register windows defined in the NIOS ++ * architecture (*not* implementation). ++ */ ++#define NIOS_MAXREGWINDOW 31 /* max windows in NIOS arch. */ ++struct rwindow ++ { ++ greg_t rw_local[8]; /* locals */ ++ greg_t rw_in[8]; /* ins */ ++ }; ++ ++#define rw_fp rw_in[6] /* frame pointer */ ++#define rw_rtn rw_in[7] /* return address */ ++ ++typedef struct gwindows ++ { ++ int wbcnt; ++ int *spbuf[NIOS_MAXREGWINDOW]; ++ struct rwindow wbuf[NIOS_MAXREGWINDOW]; ++ } gwindows_t; ++ ++typedef struct ++ { ++ gregset_t gregs; /* general register set */ ++ gwindows_t *gwins; /* POSSIBLE pointer to register windows */ ++ } mcontext_t; ++ ++ ++/* Userlevel context. */ ++typedef struct ucontext ++ { ++ unsigned long uc_flags; ++ struct ucontext *uc_link; ++ __sigset_t uc_sigmask; ++ stack_t uc_stack; ++ mcontext_t uc_mcontext; ++ } ucontext_t; ++ ++#endif /* sys/ucontext.h */ +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/syscall.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/syscall.c 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,32 @@ ++/* vi: set sw=4 ts=4: */ ++/* syscall for ubicom32/uClibc ++ * ++ * Copyright (C) 2008 by Ubicom Inc. ++ * Copyright (C) 2002 by Erik Andersen ++ * ++ * This program is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU Library General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or (at your ++ * option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, but WITHOUT ++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License ++ * for more details. ++ * ++ * You should have received a copy of the GNU Library General Public License ++ * along with this program; if not, write to the Free Software Foundation, ++ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ */ ++ ++#include ++#include ++#include ++#include ++ ++extern long syscall(long sysnum, long a, long b, long c, long d, long e, long f); ++long syscall(long sysnum, long a, long b, long c, long d, long e, long f) ++{ ++ int __NR_syscall_number = sysnum; ++ return (long) INLINE_SYSCALL(syscall_number, 6, a, b, c, d, e, f); ++} +Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/vfork.S +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/vfork.S 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,35 @@ ++#include ++ ++ .text ++ .type vfork,@function ++ .global vfork ++vfork: ++ move.4 -4(sp)++, a5 ; Save return address on the stack. ++ movei d8, #__NR_vfork ++ moveai a3, #%hi(0x40400000) ++ calli a5, 0x10(a3) ++ ++ /* ++ * You get here only if the syscall bombed. If things had worked out the ++ * parent and child would have both returned to the instruction after ++ * the vfork call. ++ */ ++ move.4 a5, (sp)4++ ; Pop the return address off the stack. ++ movei d1, #-125 ++ sub.4 #0, d0, d1 ++ jmplt.t 1f ++ ++ ;; We have an error. ++ sub.4 d0, #0, d0 ; d0 = -res. Call __set_errno with that. ++#if defined(__UBICOM32_FDPIC__) ++ call a3, __syscall_error ++#else ++ moveai a3, #%hi(__syscall_error) ++ calli a3, %lo(__syscall_error)(a3) ; __syscall_error will return -1 and not come back here. ++#endif ++1: ++ calli a5, 0(a5) ++ .size vfork, . - vfork ++ .global __GI_vfork ++ .hidden __GI_vfork ++ .set __GI_vfork,vfork +Index: uClibc-0.9.30.2/libpthread/linuxthreads.old/pthread.c +=================================================================== +--- uClibc-0.9.30.2.orig/libpthread/linuxthreads.old/pthread.c 2010-01-13 22:22:31.000000000 +0100 ++++ uClibc-0.9.30.2/libpthread/linuxthreads.old/pthread.c 2010-01-14 11:05:01.000000000 +0100 +@@ -393,6 +393,10 @@ + #endif + + __libc_multiple_threads_ptr = __libc_pthread_init (ptr_pthread_functions); ++#ifndef __ARCH_USE_MMU__ ++ __pthread_initial_thread_tos = ++ (char *)(((long)CURRENT_STACK_FRAME + getpagesize()) & ~(getpagesize() - 1)); ++#endif /* __ARCH_USE_MMU__ */ + } + + +@@ -461,8 +465,11 @@ + * __pthread_initial_thread_bos at address 0. These bounds are refined as we + * malloc other stack frames such that they don't overlap. -StS + */ +- __pthread_initial_thread_tos = +- (char *)(((long)CURRENT_STACK_FRAME + getpagesize()) & ~(getpagesize() - 1)); ++ if (__pthread_initial_thread_tos == NULL) { ++ __pthread_initial_thread_tos = ++ (char *)(((long)CURRENT_STACK_FRAME + getpagesize()) & ~(getpagesize() - 1)); ++ } ++ + __pthread_initial_thread_bos = (char *) 1; /* set it non-zero so we know we have been here */ + PDEBUG("initial thread stack bounds: bos=%p, tos=%p\n", + __pthread_initial_thread_bos, __pthread_initial_thread_tos); +Index: uClibc-0.9.30.2/libpthread/linuxthreads.old/sysdeps/ubicom32/pt-machine.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libpthread/linuxthreads.old/sysdeps/ubicom32/pt-machine.h 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,68 @@ ++/* Machine-dependent pthreads configuration and inline functions. ++ ++ Copyright (C) 1996, 1997, 1998, 2000, 2002, 2003, 2004 ++ Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ Contributed by Ralf Baechle . ++ Based on the Alpha version by Richard Henderson . ++ ++ 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; see the file COPYING.LIB. If ++ not, write to the Free Software Foundation, Inc., ++ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ++ ++#ifndef _PT_MACHINE_H ++#define _PT_MACHINE_H 1 ++ ++#include ++ ++/* ++ * XXX try to make this inline ++ */ ++extern long int testandset (int *spinlock); ++ ++#ifndef PT_EI ++#define PT_EI ++#else ++/* Spinlock implementation; required. */ ++ ++/* ++ * testandset() is the basis for the pthread spin lock. ++ * ++ * This implementation only requires that we 'set' the state of *spinlock. As ++ * bset is allows us to atomically 'testandset' a single bit define our 'set' is ++ * such that we will set bit 0 (ignoring all other bits, which should also be ++ * zero). ++ * Return value of 1 implies that the bit was already set and is still ++ * set. ++ * Return value of 0 implies that the bit was not previously set but it ++ * now is. ++ */ ++long int ++testandset (int *spinlock) ++{ ++ int ret; ++ __asm__ volatile ( ++ " move.4 %0, #0 \n\t" /* Assume that the bit is not currently set */ ++ " bset %1, %1, #0 \n\t" /* Attempt to 'set' bit 0 */ ++ " jmpeq.t 1f \n\t" ++ " move.4 %0, #1 \n\t" /* Bit was already set, so return 1 */ ++ " 1: \n\t" ++ : "=r"(ret), "+U4"(*spinlock) ++ : ++ : "memory", "cc" ++ ); ++ return ret; ++} ++#endif ++#endif /* pt-machine.h */ +Index: uClibc-0.9.30.2/libpthread/linuxthreads.old/sysdeps/ubicom32/tls.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ uClibc-0.9.30.2/libpthread/linuxthreads.old/sysdeps/ubicom32/tls.h 2010-01-14 11:05:01.000000000 +0100 +@@ -0,0 +1,26 @@ ++/* Definitions for thread-local data handling. linuxthreads/MIPS version. ++ Copyright (C) 2005 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, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#ifndef _TLS_H ++#define _TLS_H ++#ifdef HAVE_TLS_SUPPORT ++#warning no tls support ++#undef USE_TLS ++#endif ++#endif /* tls.h */ From 5cc23dc78f5956ef12d4f49d6655e34b02614572 Mon Sep 17 00:00:00 2001 From: jow Date: Thu, 14 Jan 2010 18:43:05 +0000 Subject: [PATCH 006/210] [package] dropbear: add GatewayPorts (-a) option (#6503) git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19127 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/dropbear/Makefile | 2 +- package/dropbear/files/dropbear.init | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/package/dropbear/Makefile b/package/dropbear/Makefile index 290addef0..5a6ab3bba 100644 --- a/package/dropbear/Makefile +++ b/package/dropbear/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=dropbear PKG_VERSION:=0.52 -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:= \ diff --git a/package/dropbear/files/dropbear.init b/package/dropbear/files/dropbear.init index 30cb44b1b..36c37001c 100755 --- a/package/dropbear/files/dropbear.init +++ b/package/dropbear/files/dropbear.init @@ -38,10 +38,13 @@ dropbear_start() local bannerfile config_get bannerfile ${section} BannerFile [ -f $bannerfile ] || bannerfile='' - + # D) gatewayports + local gatewayports + config_get_bool gatewayports "${section}" GatewayPorts 0 + [ "${gatewayports}" -eq 1 ] || gatewayports='' # concatenate parameters local args - args="${nopasswd:+-s }${port:+-p ${port} }${bannerfile:+-b $bannerfile }-P /var/run/${NAME}.${PIDCOUNT}.pid" + args="${nopasswd:+-s }${port:+-p ${port} }${bannerfile:+-b $bannerfile }${gatewayports:+-a }-P /var/run/${NAME}.${PIDCOUNT}.pid" # execute program and return its exit code [ "${verbosed}" -ne 0 ] && echo "${initscript}: section ${section} starting ${PROG} ${args}" From eea8df93ec3b54fae1e9582bf96f6a14cb773775 Mon Sep 17 00:00:00 2001 From: jow Date: Thu, 14 Jan 2010 18:48:42 +0000 Subject: [PATCH 007/210] [package] wpa_supplicant: fix two syntax errors in wpa_supplicant.sh (#6504) git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19128 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/wpa_supplicant/files/wpa_supplicant.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/wpa_supplicant/files/wpa_supplicant.sh b/package/wpa_supplicant/files/wpa_supplicant.sh index 40e8ff55b..ea10b386e 100644 --- a/package/wpa_supplicant/files/wpa_supplicant.sh +++ b/package/wpa_supplicant/files/wpa_supplicant.sh @@ -22,7 +22,7 @@ wpa_supplicant_setup_vif() { local zidx zidx=$(($idx - 1)) config_get ckey "$vif" "key${idx}" - if [ -n "$ckey" ] && \ + [ -n "$ckey" ] && \ append "wep_key${zidx}" "wep_key${zidx}=$(prepare_key_wep "$ckey")" done wep_tx_keyidx="wep_tx_keyidx=$((key - 1))" @@ -111,6 +111,6 @@ network={ $wep_tx_keyidx } EOF - [ -z "$proto" -a "$key_mgmt" != "NONE" ] || + [ -z "$proto" -a "$key_mgmt" != "NONE" ] || \ wpa_supplicant ${bridge:+ -b $bridge} -B -P "/var/run/wifi-${ifname}.pid" -D ${driver:-wext} -i "$ifname" -c /var/run/wpa_supplicant-$ifname.conf } From 23e340324090a30fa3fa50aa2301a9ec6e78bd1f Mon Sep 17 00:00:00 2001 From: nbd Date: Fri, 15 Jan 2010 01:16:34 +0000 Subject: [PATCH 008/210] iw: update to 0.9.19 git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19138 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/iw/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/iw/Makefile b/package/iw/Makefile index 827413ab4..debb90e6f 100644 --- a/package/iw/Makefile +++ b/package/iw/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=iw -PKG_VERSION:=0.9.18 +PKG_VERSION:=0.9.19 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=http://wireless.kernel.org/download/iw/ -PKG_MD5SUM:=9734080d8a5c4b768c5e0da665a48950 +PKG_MD5SUM:=3b88743f9c6ce8a7e2f5fd7d18fdea42 PKG_BUILD_DEPENDS:=mac80211 include $(INCLUDE_DIR)/package.mk From 8f8c254d1f6b42d1a6f67b26e29fd4f2dcb91c61 Mon Sep 17 00:00:00 2001 From: nbd Date: Fri, 15 Jan 2010 01:16:40 +0000 Subject: [PATCH 009/210] mac80211: update to wireless-testing+wireless-2.6 from 2010-01-13 git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19139 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/mac80211/Makefile | 4 +- .../mac80211/patches/001-disable_b44.patch | 2 +- .../mac80211/patches/002-disable_rfkill.patch | 6 +- package/mac80211/patches/003-disable_bt.patch | 8 +- .../patches/007-remove_misc_drivers.patch | 4 +- ...09-remove_mac80211_module_dependence.patch | 2 +- package/mac80211/patches/010-b43_config.patch | 4 +- .../mac80211/patches/012-remove_rfkill.patch | 2 +- .../201-ath5k-WAR-for-AR71xx-PCI-bug.patch | 2 +- .../patches/300-ath9k_fix_init_crash.patch | 35 +++++++ ...1-ath9k-dont-register-leds-on-ar9100.patch | 20 ++-- ...ROM-only-if-no-platform-data-present.patch | 16 +-- .../patches/510-ath9k_debugfs_chainmask.patch | 8 +- .../patches/520-ath9k_debugfs_regaccess.patch | 14 +-- .../patches/530-mac80211_work_fix.patch | 30 ------ ...tch => 530-monitor_queue_select_fix.patch} | 2 +- .../patches/540-wds_assoc_dummyframe.patch | 76 -------------- .../patches/550-vlan_sta_lookup.patch | 98 ------------------- .../patches/560-4addr_vlan_check.patch | 15 --- 19 files changed, 83 insertions(+), 265 deletions(-) create mode 100644 package/mac80211/patches/300-ath9k_fix_init_crash.patch delete mode 100644 package/mac80211/patches/530-mac80211_work_fix.patch rename package/mac80211/patches/{570-monitor_queue_select_fix.patch => 530-monitor_queue_select_fix.patch} (88%) delete mode 100644 package/mac80211/patches/540-wds_assoc_dummyframe.patch delete mode 100644 package/mac80211/patches/550-vlan_sta_lookup.patch delete mode 100644 package/mac80211/patches/560-4addr_vlan_check.patch diff --git a/package/mac80211/Makefile b/package/mac80211/Makefile index 0f02b4835..b173300db 100644 --- a/package/mac80211/Makefile +++ b/package/mac80211/Makefile @@ -10,12 +10,12 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=mac80211 -PKG_VERSION:=2010-01-11 +PKG_VERSION:=2010-01-13 PKG_RELEASE:=1 PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources # http://www.orbit-lab.org/kernel/compat-wireless-2.6/2010/11 \ # http://wireless.kernel.org/download/compat-wireless-2.6 -PKG_MD5SUM:=78a36bb7d28be7028f640a10eaa4692b +PKG_MD5SUM:=b773266f141a1a6349b6e09b84948f02 PKG_SOURCE:=compat-wireless-$(PKG_VERSION).tar.bz2 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/compat-wireless-$(PKG_VERSION) diff --git a/package/mac80211/patches/001-disable_b44.patch b/package/mac80211/patches/001-disable_b44.patch index 165e7283f..1a14a6d17 100644 --- a/package/mac80211/patches/001-disable_b44.patch +++ b/package/mac80211/patches/001-disable_b44.patch @@ -1,6 +1,6 @@ --- a/config.mk +++ b/config.mk -@@ -270,10 +270,10 @@ endif +@@ -281,10 +281,10 @@ endif CONFIG_P54_PCI=m diff --git a/package/mac80211/patches/002-disable_rfkill.patch b/package/mac80211/patches/002-disable_rfkill.patch index da07a76bd..222cd9b54 100644 --- a/package/mac80211/patches/002-disable_rfkill.patch +++ b/package/mac80211/patches/002-disable_rfkill.patch @@ -1,7 +1,7 @@ --- a/config.mk +++ b/config.mk -@@ -16,7 +16,7 @@ include $(KLIB_BUILD)/.config - endif +@@ -73,7 +73,7 @@ endif # build check + endif # kernel Makefile check # These both are needed by compat-wireless || compat-bluetooth so enable them - CONFIG_COMPAT_RFKILL=y @@ -9,7 +9,7 @@ ifeq ($(CONFIG_MAC80211),y) $(error "ERROR: you have MAC80211 compiled into the kernel, CONFIG_MAC80211=y, as such you cannot replace its mac80211 driver. You need this set to CONFIG_MAC80211=m. If you are using Fedora upgrade your kernel as later version should this set as modular. For further information on Fedora see https://bugzilla.redhat.com/show_bug.cgi?id=470143. If you are using your own kernel recompile it and make mac80211 modular") -@@ -463,8 +463,8 @@ endif +@@ -474,8 +474,8 @@ endif # We need the backported rfkill module on kernel < 2.6.31. # In more recent kernel versions use the in kernel rfkill module. ifdef CONFIG_COMPAT_KERNEL_31 diff --git a/package/mac80211/patches/003-disable_bt.patch b/package/mac80211/patches/003-disable_bt.patch index c8ac12478..147450da7 100644 --- a/package/mac80211/patches/003-disable_bt.patch +++ b/package/mac80211/patches/003-disable_bt.patch @@ -1,13 +1,13 @@ --- a/config.mk +++ b/config.mk -@@ -36,8 +36,8 @@ endif +@@ -95,8 +95,8 @@ ifndef CONFIG_COMPAT_KERNEL_27 ifeq ($(CONFIG_BT),y) # we'll ignore compiling bluetooth else --CONFIG_COMPAT_BLUETOOTH=y --CONFIG_COMPAT_BLUETOOTH_MODULES=m +- CONFIG_COMPAT_BLUETOOTH=y +- CONFIG_COMPAT_BLUETOOTH_MODULES=m +# CONFIG_COMPAT_BLUETOOTH=y +# CONFIG_COMPAT_BLUETOOTH_MODULES=m endif + endif # Kernel >= 2.6.26 - # We will warn when you don't have MQ support or NET_SCHED enabled. diff --git a/package/mac80211/patches/007-remove_misc_drivers.patch b/package/mac80211/patches/007-remove_misc_drivers.patch index 0730e504f..7a5b11566 100644 --- a/package/mac80211/patches/007-remove_misc_drivers.patch +++ b/package/mac80211/patches/007-remove_misc_drivers.patch @@ -1,6 +1,6 @@ --- a/config.mk +++ b/config.mk -@@ -303,10 +303,10 @@ CONFIG_PCI_ATMEL=m +@@ -314,10 +314,10 @@ CONFIG_PCI_ATMEL=m CONFIG_MWL8K=m # Ethernet drivers go here @@ -15,7 +15,7 @@ endif ## end of PCI -@@ -345,10 +345,10 @@ CONFIG_USB_NET_COMPAT_RNDIS_HOST=n +@@ -356,10 +356,10 @@ CONFIG_USB_NET_COMPAT_RNDIS_HOST=n CONFIG_USB_NET_COMPAT_RNDIS_WLAN=n CONFIG_USB_NET_COMPAT_CDCETHER=n else diff --git a/package/mac80211/patches/009-remove_mac80211_module_dependence.patch b/package/mac80211/patches/009-remove_mac80211_module_dependence.patch index 6efd127d7..68420d8a2 100644 --- a/package/mac80211/patches/009-remove_mac80211_module_dependence.patch +++ b/package/mac80211/patches/009-remove_mac80211_module_dependence.patch @@ -1,6 +1,6 @@ --- a/config.mk +++ b/config.mk -@@ -69,21 +69,6 @@ $(error "ERROR: Your 2.6.27 kernel has C +@@ -44,21 +44,6 @@ $(error "ERROR: Your 2.6.27 kernel has C endif endif diff --git a/package/mac80211/patches/010-b43_config.patch b/package/mac80211/patches/010-b43_config.patch index 4aafdf32d..ed86f4054 100644 --- a/package/mac80211/patches/010-b43_config.patch +++ b/package/mac80211/patches/010-b43_config.patch @@ -1,6 +1,6 @@ --- a/config.mk +++ b/config.mk -@@ -188,9 +188,9 @@ CONFIG_B43_HWRNG=y +@@ -199,9 +199,9 @@ CONFIG_B43_HWRNG=y CONFIG_B43_PCI_AUTOSELECT=y CONFIG_B43_PCICORE_AUTOSELECT=y ifneq ($(CONFIG_PCMCIA),) @@ -12,7 +12,7 @@ CONFIG_B43_LEDS=y CONFIG_B43_PHY_LP=y # CONFIG_B43_DEBUG=y -@@ -245,8 +245,8 @@ CONFIG_SSB_PCIHOST_POSSIBLE=y +@@ -256,8 +256,8 @@ CONFIG_SSB_PCIHOST_POSSIBLE=y CONFIG_SSB_PCIHOST=y CONFIG_SSB_B43_PCI_BRIDGE=y ifneq ($(CONFIG_PCMCIA),) diff --git a/package/mac80211/patches/012-remove_rfkill.patch b/package/mac80211/patches/012-remove_rfkill.patch index a47168a05..ae80b6ef9 100644 --- a/package/mac80211/patches/012-remove_rfkill.patch +++ b/package/mac80211/patches/012-remove_rfkill.patch @@ -26,7 +26,7 @@ int (*set_block)(void *data, bool blocked); }; --#if defined(CONFIG_RFKILL_BACKPORT) || defined(CONFIG_RFKILL_MODULE_BACKPORT) +-#if defined(CONFIG_RFKILL_BACKPORT) || defined(CONFIG_RFKILL_BACKPORT_MODULE) +#if 0 /** * rfkill_alloc - allocate rfkill structure diff --git a/package/mac80211/patches/201-ath5k-WAR-for-AR71xx-PCI-bug.patch b/package/mac80211/patches/201-ath5k-WAR-for-AR71xx-PCI-bug.patch index 25e6f3ddd..4f3446976 100644 --- a/package/mac80211/patches/201-ath5k-WAR-for-AR71xx-PCI-bug.patch +++ b/package/mac80211/patches/201-ath5k-WAR-for-AR71xx-PCI-bug.patch @@ -1,6 +1,6 @@ --- a/drivers/net/wireless/ath/ath5k/reset.c +++ b/drivers/net/wireless/ath/ath5k/reset.c -@@ -1357,10 +1357,18 @@ int ath5k_hw_reset(struct ath5k_hw *ah, +@@ -1360,10 +1360,18 @@ int ath5k_hw_reset(struct ath5k_hw *ah, * guess we can tweak it and see how it goes ;-) */ if (ah->ah_version != AR5K_AR5210) { diff --git a/package/mac80211/patches/300-ath9k_fix_init_crash.patch b/package/mac80211/patches/300-ath9k_fix_init_crash.patch new file mode 100644 index 000000000..8f3540b5d --- /dev/null +++ b/package/mac80211/patches/300-ath9k_fix_init_crash.patch @@ -0,0 +1,35 @@ +--- a/drivers/net/wireless/ath/ath9k/ahb.c ++++ b/drivers/net/wireless/ath/ath9k/ahb.c +@@ -121,6 +121,9 @@ static int ath_ahb_probe(struct platform + sc->mem = mem; + sc->irq = irq; + ++ /* Will be cleared in ath9k_start() */ ++ sc->sc_flags |= SC_OP_INVALID; ++ + ret = request_irq(irq, ath_isr, IRQF_SHARED, "ath9k", sc); + if (ret) { + dev_err(&pdev->dev, "request_irq failed\n"); +--- a/drivers/net/wireless/ath/ath9k/init.c ++++ b/drivers/net/wireless/ath/ath9k/init.c +@@ -534,8 +534,6 @@ static int ath9k_init_softc(u16 devid, s + int ret = 0, i; + int csz = 0; + +- sc->sc_flags |= SC_OP_INVALID; +- + ah = kzalloc(sizeof(struct ath_hw), GFP_KERNEL); + if (!ah) + return -ENOMEM; +--- a/drivers/net/wireless/ath/ath9k/pci.c ++++ b/drivers/net/wireless/ath/ath9k/pci.c +@@ -202,6 +202,9 @@ static int ath_pci_probe(struct pci_dev + sc->dev = &pdev->dev; + sc->mem = mem; + ++ /* Will be cleared in ath9k_start() */ ++ sc->sc_flags |= SC_OP_INVALID; ++ + ret = request_irq(pdev->irq, ath_isr, IRQF_SHARED, "ath9k", sc); + if (ret) { + dev_err(&pdev->dev, "request_irq failed\n"); diff --git a/package/mac80211/patches/401-ath9k-dont-register-leds-on-ar9100.patch b/package/mac80211/patches/401-ath9k-dont-register-leds-on-ar9100.patch index a4af5c98d..96c22a0d0 100644 --- a/package/mac80211/patches/401-ath9k-dont-register-leds-on-ar9100.patch +++ b/package/mac80211/patches/401-ath9k-dont-register-leds-on-ar9100.patch @@ -1,8 +1,8 @@ ---- a/drivers/net/wireless/ath/ath9k/main.c -+++ b/drivers/net/wireless/ath/ath9k/main.c -@@ -1103,6 +1103,9 @@ static void ath_unregister_led(struct at +--- a/drivers/net/wireless/ath/ath9k/gpio.c ++++ b/drivers/net/wireless/ath/ath9k/gpio.c +@@ -119,6 +119,9 @@ static void ath_unregister_led(struct at - static void ath_deinit_leds(struct ath_softc *sc) + void ath_deinit_leds(struct ath_softc *sc) { + if (AR_SREV_9100(sc->sc_ah)) + return; @@ -10,13 +10,13 @@ ath_unregister_led(&sc->assoc_led); sc->sc_flags &= ~SC_OP_LED_ASSOCIATED; ath_unregister_led(&sc->tx_led); -@@ -1121,6 +1124,9 @@ static void ath_init_leds(struct ath_sof - else - sc->sc_ah->led_pin = ATH_LED_PIN_DEF; +@@ -132,6 +135,9 @@ void ath_init_leds(struct ath_softc *sc) + char *trigger; + int ret; + if (AR_SREV_9100(sc->sc_ah)) + return; + - /* Configure gpio 1 for output */ - ath9k_hw_cfg_output(sc->sc_ah, sc->sc_ah->led_pin, - AR_GPIO_OUTPUT_MUX_AS_OUTPUT); + if (AR_SREV_9287(sc->sc_ah)) + sc->sc_ah->led_pin = ATH_LED_PIN_9287; + else diff --git a/package/mac80211/patches/406-ath9k-set-AH_USE_EEPROM-only-if-no-platform-data-present.patch b/package/mac80211/patches/406-ath9k-set-AH_USE_EEPROM-only-if-no-platform-data-present.patch index 6be788814..c09935ee7 100644 --- a/package/mac80211/patches/406-ath9k-set-AH_USE_EEPROM-only-if-no-platform-data-present.patch +++ b/package/mac80211/patches/406-ath9k-set-AH_USE_EEPROM-only-if-no-platform-data-present.patch @@ -22,22 +22,24 @@ #include "ath9k.h" #include "btcoex.h" -@@ -1597,6 +1598,7 @@ static int ath_init_softc(u16 devid, str +--- a/drivers/net/wireless/ath/ath9k/init.c ++++ b/drivers/net/wireless/ath/ath9k/init.c +@@ -531,6 +531,7 @@ static int ath9k_init_softc(u16 devid, s { struct ath_hw *ah = NULL; struct ath_common *common; + struct ath9k_platform_data *pdata; - int r = 0, i; + int ret = 0, i; int csz = 0; - int qnum; -@@ -1619,6 +1621,10 @@ static int ath_init_softc(u16 devid, str - ah->hw_version.devid = devid; +@@ -542,6 +543,10 @@ static int ath9k_init_softc(u16 devid, s ah->hw_version.subsysid = subsysid; + sc->sc_ah = ah; + + pdata = (struct ath9k_platform_data *) sc->dev->platform_data; + if (!pdata) + ah->ah_flags |= AH_USE_EEPROM; + - sc->sc_ah = ah; - common = ath9k_hw_common(ah); + common->ops = &ath9k_common_ops; + common->bus_ops = bus_ops; diff --git a/package/mac80211/patches/510-ath9k_debugfs_chainmask.patch b/package/mac80211/patches/510-ath9k_debugfs_chainmask.patch index 157098a69..7d043d693 100644 --- a/package/mac80211/patches/510-ath9k_debugfs_chainmask.patch +++ b/package/mac80211/patches/510-ath9k_debugfs_chainmask.patch @@ -91,7 +91,7 @@ static ssize_t read_file_dma(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { -@@ -600,6 +684,16 @@ int ath9k_init_debug(struct ath_hw *ah) +@@ -710,6 +794,16 @@ int ath9k_init_debug(struct ath_hw *ah) goto err; #endif @@ -108,18 +108,18 @@ sc->debug.debugfs_dma = debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc, &fops_dma); if (!sc->debug.debugfs_dma) -@@ -643,6 +737,8 @@ void ath9k_exit_debug(struct ath_hw *ah) +@@ -760,6 +854,8 @@ void ath9k_exit_debug(struct ath_hw *ah) struct ath_common *common = ath9k_hw_common(ah); struct ath_softc *sc = (struct ath_softc *) common->priv; + debugfs_remove(sc->debug.debugfs_tx_chainmask); + debugfs_remove(sc->debug.debugfs_rx_chainmask); + debugfs_remove(sc->debug.debugfs_recv); debugfs_remove(sc->debug.debugfs_xmit); debugfs_remove(sc->debug.debugfs_wiphy); - debugfs_remove(sc->debug.debugfs_rcstat); --- a/drivers/net/wireless/ath/ath9k/debug.h +++ b/drivers/net/wireless/ath/ath9k/debug.h -@@ -123,6 +123,8 @@ struct ath_stats { +@@ -148,6 +148,8 @@ struct ath_stats { }; struct ath9k_debug { diff --git a/package/mac80211/patches/520-ath9k_debugfs_regaccess.patch b/package/mac80211/patches/520-ath9k_debugfs_regaccess.patch index b9fa0221d..02e4cac37 100644 --- a/package/mac80211/patches/520-ath9k_debugfs_regaccess.patch +++ b/package/mac80211/patches/520-ath9k_debugfs_regaccess.patch @@ -1,6 +1,6 @@ --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c -@@ -664,6 +664,86 @@ static const struct file_operations fops +@@ -774,6 +774,86 @@ static const struct file_operations fops .owner = THIS_MODULE }; @@ -87,8 +87,8 @@ int ath9k_init_debug(struct ath_hw *ah) { struct ath_common *common = ath9k_hw_common(ah); -@@ -726,6 +806,17 @@ int ath9k_init_debug(struct ath_hw *ah) - if (!sc->debug.debugfs_xmit) +@@ -843,6 +923,17 @@ int ath9k_init_debug(struct ath_hw *ah) + if (!sc->debug.debugfs_recv) goto err; + sc->debug.regidx = 0; @@ -105,21 +105,21 @@ return 0; err: ath9k_exit_debug(ah); -@@ -739,6 +830,8 @@ void ath9k_exit_debug(struct ath_hw *ah) +@@ -856,6 +947,8 @@ void ath9k_exit_debug(struct ath_hw *ah) debugfs_remove(sc->debug.debugfs_tx_chainmask); debugfs_remove(sc->debug.debugfs_rx_chainmask); + debugfs_remove(sc->debug.debugfs_regval); + debugfs_remove(sc->debug.debugfs_regidx); + debugfs_remove(sc->debug.debugfs_recv); debugfs_remove(sc->debug.debugfs_xmit); debugfs_remove(sc->debug.debugfs_wiphy); - debugfs_remove(sc->debug.debugfs_rcstat); --- a/drivers/net/wireless/ath/ath9k/debug.h +++ b/drivers/net/wireless/ath/ath9k/debug.h -@@ -132,6 +132,9 @@ struct ath9k_debug { - struct dentry *debugfs_rcstat; +@@ -158,6 +158,9 @@ struct ath9k_debug { struct dentry *debugfs_wiphy; struct dentry *debugfs_xmit; + struct dentry *debugfs_recv; + struct dentry *debugfs_regidx; + struct dentry *debugfs_regval; + u32 regidx; diff --git a/package/mac80211/patches/530-mac80211_work_fix.patch b/package/mac80211/patches/530-mac80211_work_fix.patch deleted file mode 100644 index 339a52d51..000000000 --- a/package/mac80211/patches/530-mac80211_work_fix.patch +++ /dev/null @@ -1,30 +0,0 @@ ---- a/net/mac80211/scan.c -+++ b/net/mac80211/scan.c -@@ -284,6 +284,7 @@ void ieee80211_scan_completed(struct iee - ieee80211_mlme_notify_scan_completed(local); - ieee80211_ibss_notify_scan_completed(local); - ieee80211_mesh_notify_scan_completed(local); -+ ieee80211_queue_work(&local->hw, &local->work_work); - } - EXPORT_SYMBOL(ieee80211_scan_completed); - ---- a/net/mac80211/work.c -+++ b/net/mac80211/work.c -@@ -818,6 +818,7 @@ static void ieee80211_work_work(struct w - wk->chan == local->tmp_channel && - wk->chan_type == local->tmp_channel_type) { - wk->started = true; -+ wk->timeout = jiffies; - } - - if (!wk->started && !local->tmp_channel) { -@@ -935,6 +936,9 @@ void ieee80211_add_work(struct ieee80211 - if (WARN_ON(!wk->done)) - return; - -+ if (WARN_ON(!ieee80211_sdata_running(wk->sdata))) -+ return; -+ - wk->started = false; - - local = wk->sdata->local; diff --git a/package/mac80211/patches/570-monitor_queue_select_fix.patch b/package/mac80211/patches/530-monitor_queue_select_fix.patch similarity index 88% rename from package/mac80211/patches/570-monitor_queue_select_fix.patch rename to package/mac80211/patches/530-monitor_queue_select_fix.patch index fc186c52a..a4fff5028 100644 --- a/package/mac80211/patches/570-monitor_queue_select_fix.patch +++ b/package/mac80211/patches/530-monitor_queue_select_fix.patch @@ -1,6 +1,6 @@ --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c -@@ -696,10 +696,14 @@ static u16 ieee80211_monitor_select_queu +@@ -697,10 +697,14 @@ static u16 ieee80211_monitor_select_queu hdr = (void *)((u8 *)skb->data + le16_to_cpu(rtap->it_len)); diff --git a/package/mac80211/patches/540-wds_assoc_dummyframe.patch b/package/mac80211/patches/540-wds_assoc_dummyframe.patch deleted file mode 100644 index 9efb3ac6d..000000000 --- a/package/mac80211/patches/540-wds_assoc_dummyframe.patch +++ /dev/null @@ -1,76 +0,0 @@ ---- a/net/mac80211/mlme.c -+++ b/net/mac80211/mlme.c -@@ -312,6 +312,38 @@ void ieee80211_send_nullfunc(struct ieee - ieee80211_tx_skb(sdata, skb); - } - -+static void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local, -+ struct ieee80211_sub_if_data *sdata) -+{ -+ struct sk_buff *skb; -+ struct ieee80211_hdr *nullfunc; -+ __le16 fc; -+ -+ if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) -+ return; -+ -+ skb = dev_alloc_skb(local->hw.extra_tx_headroom + 30); -+ if (!skb) { -+ printk(KERN_DEBUG "%s: failed to allocate buffer for 4addr " -+ "nullfunc frame\n", sdata->name); -+ return; -+ } -+ skb_reserve(skb, local->hw.extra_tx_headroom); -+ -+ nullfunc = (struct ieee80211_hdr *) skb_put(skb, 30); -+ memset(nullfunc, 0, 30); -+ fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC | -+ IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); -+ nullfunc->frame_control = fc; -+ memcpy(nullfunc->addr1, sdata->u.mgd.bssid, ETH_ALEN); -+ memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN); -+ memcpy(nullfunc->addr3, sdata->u.mgd.bssid, ETH_ALEN); -+ memcpy(nullfunc->addr4, sdata->vif.addr, ETH_ALEN); -+ -+ IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; -+ ieee80211_tx_skb(sdata, skb); -+} -+ - /* spectrum management related things */ - static void ieee80211_chswitch_work(struct work_struct *work) - { -@@ -1120,6 +1152,13 @@ static bool ieee80211_assoc_success(stru - ieee80211_set_associated(sdata, cbss, changed); - - /* -+ * If we're using 4-addr mode, let the AP know that we're -+ * doing so, so that it can create the STA VLAN on its side -+ */ -+ if (ifmgd->use_4addr) -+ ieee80211_send_4addr_nullfunc(local, sdata); -+ -+ /* - * Start timer to probe the connection to the AP now. - * Also start the timer that will detect beacon loss. - */ ---- a/net/mac80211/rx.c -+++ b/net/mac80211/rx.c -@@ -1111,6 +1111,18 @@ ieee80211_rx_h_sta_process(struct ieee80 - if (ieee80211_is_nullfunc(hdr->frame_control) || - ieee80211_is_qos_nullfunc(hdr->frame_control)) { - I802_DEBUG_INC(rx->local->rx_handlers_drop_nullfunc); -+ -+ /* -+ * If we receive a 4-addr nullfunc frame from a STA -+ * that was not moved to a 4-addr STA vlan yet, drop -+ * the frame to the monitor interface, to make sure -+ * that hostapd sees it -+ */ -+ if (ieee80211_has_a4(hdr->frame_control) && -+ (rx->sdata->vif.type == NL80211_IFTYPE_AP || -+ (rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && -+ !rx->sdata->u.vlan.sta))) -+ return RX_DROP_MONITOR; - /* - * Update counter and free packet here to avoid - * counting this as a dropped packed. diff --git a/package/mac80211/patches/550-vlan_sta_lookup.patch b/package/mac80211/patches/550-vlan_sta_lookup.patch deleted file mode 100644 index ad15ca974..000000000 --- a/package/mac80211/patches/550-vlan_sta_lookup.patch +++ /dev/null @@ -1,98 +0,0 @@ ---- a/net/mac80211/sta_info.c -+++ b/net/mac80211/sta_info.c -@@ -119,6 +119,27 @@ struct sta_info *sta_info_get(struct iee - return sta; - } - -+/* -+ * Get sta info either from the specified interface -+ * or from one of its vlans -+ */ -+struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata, -+ const u8 *addr) -+{ -+ struct ieee80211_local *local = sdata->local; -+ struct sta_info *sta; -+ -+ sta = rcu_dereference(local->sta_hash[STA_HASH(addr)]); -+ while (sta) { -+ if ((sta->sdata == sdata || -+ sta->sdata->bss == sdata->bss) && -+ memcmp(sta->sta.addr, addr, ETH_ALEN) == 0) -+ break; -+ sta = rcu_dereference(sta->hnext); -+ } -+ return sta; -+} -+ - struct sta_info *sta_info_get_by_idx(struct ieee80211_sub_if_data *sdata, - int idx) - { ---- a/net/mac80211/sta_info.h -+++ b/net/mac80211/sta_info.h -@@ -408,6 +408,9 @@ static inline u32 get_sta_flags(struct s - struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata, - const u8 *addr); - -+struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata, -+ const u8 *addr); -+ - static inline - void for_each_sta_info_type_check(struct ieee80211_local *local, - const u8 *addr, ---- a/net/mac80211/cfg.c -+++ b/net/mac80211/cfg.c -@@ -148,7 +148,7 @@ static int ieee80211_add_key(struct wiph - rcu_read_lock(); - - if (mac_addr) { -- sta = sta_info_get(sdata, mac_addr); -+ sta = sta_info_get_bss(sdata, mac_addr); - if (!sta) { - ieee80211_key_free(key); - err = -ENOENT; -@@ -179,7 +179,7 @@ static int ieee80211_del_key(struct wiph - if (mac_addr) { - ret = -ENOENT; - -- sta = sta_info_get(sdata, mac_addr); -+ sta = sta_info_get_bss(sdata, mac_addr); - if (!sta) - goto out_unlock; - -@@ -226,7 +226,7 @@ static int ieee80211_get_key(struct wiph - rcu_read_lock(); - - if (mac_addr) { -- sta = sta_info_get(sdata, mac_addr); -+ sta = sta_info_get_bss(sdata, mac_addr); - if (!sta) - goto out; - -@@ -419,7 +419,7 @@ static int ieee80211_get_station(struct - - rcu_read_lock(); - -- sta = sta_info_get(sdata, mac); -+ sta = sta_info_get_bss(sdata, mac); - if (sta) { - ret = 0; - sta_set_sinfo(sta, sinfo); -@@ -775,7 +775,7 @@ static int ieee80211_del_station(struct - if (mac) { - rcu_read_lock(); - -- sta = sta_info_get(sdata, mac); -+ sta = sta_info_get_bss(sdata, mac); - if (!sta) { - rcu_read_unlock(); - return -ENOENT; -@@ -803,7 +803,7 @@ static int ieee80211_change_station(stru - - rcu_read_lock(); - -- sta = sta_info_get(sdata, mac); -+ sta = sta_info_get_bss(sdata, mac); - if (!sta) { - rcu_read_unlock(); - return -ENOENT; diff --git a/package/mac80211/patches/560-4addr_vlan_check.patch b/package/mac80211/patches/560-4addr_vlan_check.patch deleted file mode 100644 index 7079957ee..000000000 --- a/package/mac80211/patches/560-4addr_vlan_check.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/mac80211/tx.c -+++ b/net/mac80211/tx.c -@@ -1051,8 +1051,11 @@ ieee80211_tx_prepare(struct ieee80211_su - - hdr = (struct ieee80211_hdr *) skb->data; - -- if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) -+ if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { - tx->sta = rcu_dereference(sdata->u.vlan.sta); -+ if (!tx->sta && sdata->dev->ieee80211_ptr->use_4addr) -+ return TX_DROP; -+ } - if (!tx->sta) - tx->sta = sta_info_get(sdata, hdr->addr1); - From 67599df0cbc74955ee3ad8443b800b0514934350 Mon Sep 17 00:00:00 2001 From: nbd Date: Fri, 15 Jan 2010 01:16:44 +0000 Subject: [PATCH 010/210] iw: add patch for setting coverage class / distance git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19140 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/iw/patches/001-sync_nl80211_h.patch | 167 ++++++++++++++++++++ package/iw/patches/100-coverage_class.patch | 81 ++++++++++ 2 files changed, 248 insertions(+) create mode 100644 package/iw/patches/001-sync_nl80211_h.patch create mode 100644 package/iw/patches/100-coverage_class.patch diff --git a/package/iw/patches/001-sync_nl80211_h.patch b/package/iw/patches/001-sync_nl80211_h.patch new file mode 100644 index 000000000..fecb35d25 --- /dev/null +++ b/package/iw/patches/001-sync_nl80211_h.patch @@ -0,0 +1,167 @@ +--- a/nl80211.h ++++ b/nl80211.h +@@ -270,6 +270,35 @@ + * @NL80211_CMD_SET_WIPHY_NETNS: Set a wiphy's netns. Note that all devices + * associated with this wiphy must be down and will follow. + * ++ * @NL80211_CMD_REMAIN_ON_CHANNEL: Request to remain awake on the specified ++ * channel for the specified amount of time. This can be used to do ++ * off-channel operations like transmit a Public Action frame and wait for ++ * a response while being associated to an AP on another channel. ++ * %NL80211_ATTR_WIPHY or %NL80211_ATTR_IFINDEX is used to specify which ++ * radio is used. %NL80211_ATTR_WIPHY_FREQ is used to specify the ++ * frequency for the operation and %NL80211_ATTR_WIPHY_CHANNEL_TYPE may be ++ * optionally used to specify additional channel parameters. ++ * %NL80211_ATTR_DURATION is used to specify the duration in milliseconds ++ * to remain on the channel. This command is also used as an event to ++ * notify when the requested duration starts (it may take a while for the ++ * driver to schedule this time due to other concurrent needs for the ++ * radio). ++ * When called, this operation returns a cookie (%NL80211_ATTR_COOKIE) ++ * that will be included with any events pertaining to this request; ++ * the cookie is also used to cancel the request. ++ * @NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL: This command can be used to cancel a ++ * pending remain-on-channel duration if the desired operation has been ++ * completed prior to expiration of the originally requested duration. ++ * %NL80211_ATTR_WIPHY or %NL80211_ATTR_IFINDEX is used to specify the ++ * radio. The %NL80211_ATTR_COOKIE attribute must be given as well to ++ * uniquely identify the request. ++ * This command is also used as an event to notify when a requested ++ * remain-on-channel duration has expired. ++ * ++ * @NL80211_CMD_SET_TX_BITRATE_MASK: Set the mask of rates to be used in TX ++ * rate selection. %NL80211_ATTR_IFINDEX is used to specify the interface ++ * and @NL80211_ATTR_TX_RATES the set of allowed rates. ++ * + * @NL80211_CMD_MAX: highest used command number + * @__NL80211_CMD_AFTER_LAST: internal use + */ +@@ -349,6 +378,15 @@ enum nl80211_commands { + NL80211_CMD_GET_SURVEY, + NL80211_CMD_NEW_SURVEY_RESULTS, + ++ NL80211_CMD_SET_PMKSA, ++ NL80211_CMD_DEL_PMKSA, ++ NL80211_CMD_FLUSH_PMKSA, ++ ++ NL80211_CMD_REMAIN_ON_CHANNEL, ++ NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL, ++ ++ NL80211_CMD_SET_TX_BITRATE_MASK, ++ + /* add new commands above here */ + + /* used to define NL80211_CMD_MAX below */ +@@ -398,6 +436,8 @@ enum nl80211_commands { + * @NL80211_ATTR_WIPHY_RTS_THRESHOLD: RTS threshold (TX frames with length + * larger than or equal to this use RTS/CTS handshake); allowed range: + * 0..65536, disable with (u32)-1; dot11RTSThreshold; u32 ++ * @NL80211_ATTR_WIPHY_COVERAGE_CLASS: Coverage Class as defined by IEEE 802.11 ++ * section 7.3.2.9; dot11CoverageClass; u8 + * + * @NL80211_ATTR_IFINDEX: network interface index of the device to operate on + * @NL80211_ATTR_IFNAME: network interface name +@@ -598,6 +638,21 @@ enum nl80211_commands { + * the survey response for %NL80211_CMD_GET_SURVEY, nested attribute + * containing info as possible, see &enum survey_info. + * ++ * @NL80211_ATTR_PMKID: PMK material for PMKSA caching. ++ * @NL80211_ATTR_MAX_NUM_PMKIDS: maximum number of PMKIDs a firmware can ++ * cache, a wiphy attribute. ++ * ++ * @NL80211_ATTR_DURATION: Duration of an operation in milliseconds, u32. ++ * ++ * @NL80211_ATTR_COOKIE: Generic 64-bit cookie to identify objects. ++ * ++ * @NL80211_ATTR_TX_RATES: Nested set of attributes ++ * (enum nl80211_tx_rate_attributes) describing TX rates per band. The ++ * enum nl80211_band value is used as the index (nla_type() of the nested ++ * data. If a band is not included, it will be configured to allow all ++ * rates based on negotiated supported rates information. This attribute ++ * is used with %NL80211_CMD_SET_TX_BITRATE_MASK. ++ * + * @NL80211_ATTR_MAX: highest attribute number currently defined + * @__NL80211_ATTR_AFTER_LAST: internal use + */ +@@ -732,6 +787,17 @@ enum nl80211_attrs { + + NL80211_ATTR_SURVEY_INFO, + ++ NL80211_ATTR_PMKID, ++ NL80211_ATTR_MAX_NUM_PMKIDS, ++ ++ NL80211_ATTR_DURATION, ++ ++ NL80211_ATTR_COOKIE, ++ ++ NL80211_ATTR_WIPHY_COVERAGE_CLASS, ++ ++ NL80211_ATTR_TX_RATES, ++ + /* add attributes here, update the policy in nl80211.c */ + + __NL80211_ATTR_AFTER_LAST, +@@ -1312,13 +1378,20 @@ enum nl80211_channel_type { + * @NL80211_BSS_BEACON_INTERVAL: beacon interval of the (I)BSS (u16) + * @NL80211_BSS_CAPABILITY: capability field (CPU order, u16) + * @NL80211_BSS_INFORMATION_ELEMENTS: binary attribute containing the +- * raw information elements from the probe response/beacon (bin) ++ * raw information elements from the probe response/beacon (bin); ++ * if the %NL80211_BSS_BEACON_IES attribute is present, the IEs here are ++ * from a Probe Response frame; otherwise they are from a Beacon frame. ++ * However, if the driver does not indicate the source of the IEs, these ++ * IEs may be from either frame subtype. + * @NL80211_BSS_SIGNAL_MBM: signal strength of probe response/beacon + * in mBm (100 * dBm) (s32) + * @NL80211_BSS_SIGNAL_UNSPEC: signal strength of the probe response/beacon + * in unspecified units, scaled to 0..100 (u8) + * @NL80211_BSS_STATUS: status, if this BSS is "used" + * @NL80211_BSS_SEEN_MS_AGO: age of this BSS entry in ms ++ * @NL80211_BSS_BEACON_IES: binary attribute containing the raw information ++ * elements from a Beacon frame (bin); not present if no Beacon frame has ++ * yet been received + * @__NL80211_BSS_AFTER_LAST: internal + * @NL80211_BSS_MAX: highest BSS attribute + */ +@@ -1334,6 +1407,7 @@ enum nl80211_bss { + NL80211_BSS_SIGNAL_UNSPEC, + NL80211_BSS_STATUS, + NL80211_BSS_SEEN_MS_AGO, ++ NL80211_BSS_BEACON_IES, + + /* keep last */ + __NL80211_BSS_AFTER_LAST, +@@ -1431,4 +1505,33 @@ enum nl80211_key_attributes { + NL80211_KEY_MAX = __NL80211_KEY_AFTER_LAST - 1 + }; + ++/** ++ * enum nl80211_tx_rate_attributes - TX rate set attributes ++ * @__NL80211_TXRATE_INVALID: invalid ++ * @NL80211_TXRATE_LEGACY: Legacy (non-MCS) rates allowed for TX rate selection ++ * in an array of rates as defined in IEEE 802.11 7.3.2.2 (u8 values with ++ * 1 = 500 kbps) but without the IE length restriction (at most ++ * %NL80211_MAX_SUPP_RATES in a single array). ++ * @__NL80211_TXRATE_AFTER_LAST: internal ++ * @NL80211_TXRATE_MAX: highest TX rate attribute ++ */ ++enum nl80211_tx_rate_attributes { ++ __NL80211_TXRATE_INVALID, ++ NL80211_TXRATE_LEGACY, ++ ++ /* keep last */ ++ __NL80211_TXRATE_AFTER_LAST, ++ NL80211_TXRATE_MAX = __NL80211_TXRATE_AFTER_LAST - 1 ++}; ++ ++/** ++ * enum nl80211_band - Frequency band ++ * @NL80211_BAND_2GHZ - 2.4 GHz ISM band ++ * @NL80211_BAND_5GHZ - around 5 GHz band (4.9 - 5.7 GHz) ++ */ ++enum nl80211_band { ++ NL80211_BAND_2GHZ, ++ NL80211_BAND_5GHZ, ++}; ++ + #endif /* __LINUX_NL80211_H */ diff --git a/package/iw/patches/100-coverage_class.patch b/package/iw/patches/100-coverage_class.patch new file mode 100644 index 000000000..8e18e038d --- /dev/null +++ b/package/iw/patches/100-coverage_class.patch @@ -0,0 +1,81 @@ +--- a/info.c ++++ b/info.c +@@ -156,6 +156,14 @@ static int print_phy_handler(struct nl_m + printf("\tRTS threshold: %d\n", rts); + } + ++ if (tb_msg[NL80211_ATTR_WIPHY_COVERAGE_CLASS]) { ++ unsigned char coverage; ++ ++ coverage = nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_COVERAGE_CLASS]); ++ /* See handle_distance() for an explanation where the '450' comes from */ ++ printf("\tCoverage class: %d (up to %dm)\n", coverage, 450 * coverage); ++ } ++ + if (!tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES]) + goto commands; + +--- a/phy.c ++++ b/phy.c +@@ -164,3 +164,61 @@ static int handle_netns(struct nl80211_s + COMMAND(set, netns, "", + NL80211_CMD_SET_WIPHY_NETNS, 0, CIB_PHY, handle_netns, + "Put this wireless device into a different network namespace"); ++ ++static int handle_coverage(struct nl80211_state *state, ++ struct nl_cb *cb, ++ struct nl_msg *msg, ++ int argc, char **argv) ++{ ++ unsigned int coverage; ++ ++ if (argc != 1) ++ return 1; ++ ++ coverage = strtoul(argv[0], NULL, 10); ++ if (coverage > 255) ++ return 1; ++ ++ NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_COVERAGE_CLASS, coverage); ++ ++ return 0; ++ nla_put_failure: ++ return -ENOBUFS; ++} ++COMMAND(set, coverage, "", ++ NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_coverage, ++ "Set coverage class (1 for every 3 usec of air propagation time).\n" ++ "Valid values: 0 - 255."); ++ ++static int handle_distance(struct nl80211_state *state, ++ struct nl_cb *cb, ++ struct nl_msg *msg, ++ int argc, char **argv) ++{ ++ unsigned int distance, coverage; ++ ++ if (argc != 1) ++ return 1; ++ ++ distance = strtoul(argv[0], NULL, 10); ++ ++ /* ++ * Divide double the distance by the speed of light in m/usec (300) to ++ * get round-trip time in microseconds and then divide the result by ++ * three to get coverage class as specified in IEEE 802.11-2007 table ++ * 7-27. Values are rounded upwards. ++ */ ++ coverage = (distance + 449) / 450; ++ if (coverage > 255) ++ return 1; ++ ++ NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_COVERAGE_CLASS, coverage); ++ ++ return 0; ++ nla_put_failure: ++ return -ENOBUFS; ++} ++COMMAND(set, distance, "", ++ NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_distance, ++ "Set appropriate coverage class for given link distance in meters.\n" ++ "Valid values: 0 - 114750"); From 128fd665e55e2f136db6bfdaaa68ae7481cb877e Mon Sep 17 00:00:00 2001 From: nbd Date: Fri, 15 Jan 2010 01:16:48 +0000 Subject: [PATCH 011/210] ath9k: fix short slot vs long slot handling, implement support for setting the coverage class git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19141 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../patches/540-short_slot_handling.patch | 11 + .../550-ath9k_clean_up_timing_handling.patch | 229 ++++++++++++++++++ .../patches/560-ath9k_coverage_class.patch | 60 +++++ 3 files changed, 300 insertions(+) create mode 100644 package/mac80211/patches/540-short_slot_handling.patch create mode 100644 package/mac80211/patches/550-ath9k_clean_up_timing_handling.patch create mode 100644 package/mac80211/patches/560-ath9k_coverage_class.patch diff --git a/package/mac80211/patches/540-short_slot_handling.patch b/package/mac80211/patches/540-short_slot_handling.patch new file mode 100644 index 000000000..ed6831fbe --- /dev/null +++ b/package/mac80211/patches/540-short_slot_handling.patch @@ -0,0 +1,11 @@ +--- a/net/mac80211/mlme.c ++++ b/net/mac80211/mlme.c +@@ -670,6 +670,8 @@ static u32 ieee80211_handle_bss_capabili + } + + use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME); ++ if (sdata->local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) ++ use_short_slot = true; + + if (use_protection != bss_conf->use_cts_prot) { + bss_conf->use_cts_prot = use_protection; diff --git a/package/mac80211/patches/550-ath9k_clean_up_timing_handling.patch b/package/mac80211/patches/550-ath9k_clean_up_timing_handling.patch new file mode 100644 index 000000000..dc6502274 --- /dev/null +++ b/package/mac80211/patches/550-ath9k_clean_up_timing_handling.patch @@ -0,0 +1,229 @@ +--- a/drivers/net/wireless/ath/ath9k/main.c ++++ b/drivers/net/wireless/ath/ath9k/main.c +@@ -1790,6 +1790,7 @@ static void ath9k_bss_info_changed(struc + struct ath_hw *ah = sc->sc_ah; + struct ath_common *common = ath9k_hw_common(ah); + struct ath_vif *avp = (void *)vif->drv_priv; ++ int slottime; + int error; + + mutex_lock(&sc->mutex); +@@ -1825,6 +1826,25 @@ static void ath9k_bss_info_changed(struc + ath_beacon_config(sc, vif); + } + ++ if (changed & BSS_CHANGED_ERP_SLOT) { ++ if (bss_conf->use_short_slot) ++ slottime = 9; ++ else ++ slottime = 20; ++ if (vif->type == NL80211_IFTYPE_AP) { ++ /* ++ * Defer update, so that connected stations can adjust ++ * their settings at the same time. ++ * See beacon.c for more details ++ */ ++ sc->beacon.slottime = slottime; ++ sc->beacon.updateslot = UPDATE; ++ } else { ++ ah->slottime = slottime; ++ ath9k_hw_init_global_settings(ah); ++ } ++ } ++ + /* Disable transmission of beacons */ + if ((changed & BSS_CHANGED_BEACON_ENABLED) && !bss_conf->enable_beacon) + ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq); +--- a/drivers/net/wireless/ath/ath9k/hw.c ++++ b/drivers/net/wireless/ath/ath9k/hw.c +@@ -55,28 +55,6 @@ module_exit(ath9k_exit); + /* Helper Functions */ + /********************/ + +-static u32 ath9k_hw_mac_usec(struct ath_hw *ah, u32 clks) +-{ +- struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf; +- +- if (!ah->curchan) /* should really check for CCK instead */ +- return clks / ATH9K_CLOCK_RATE_CCK; +- if (conf->channel->band == IEEE80211_BAND_2GHZ) +- return clks / ATH9K_CLOCK_RATE_2GHZ_OFDM; +- +- return clks / ATH9K_CLOCK_RATE_5GHZ_OFDM; +-} +- +-static u32 ath9k_hw_mac_to_usec(struct ath_hw *ah, u32 clks) +-{ +- struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf; +- +- if (conf_is_ht40(conf)) +- return ath9k_hw_mac_usec(ah, clks) / 2; +- else +- return ath9k_hw_mac_usec(ah, clks); +-} +- + static u32 ath9k_hw_mac_clks(struct ath_hw *ah, u32 usecs) + { + struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf; +@@ -413,8 +391,6 @@ static void ath9k_hw_init_defaults(struc + ah->beacon_interval = 100; + ah->enable_32kHz_clock = DONT_USE_32KHZ; + ah->slottime = (u32) -1; +- ah->acktimeout = (u32) -1; +- ah->ctstimeout = (u32) -1; + ah->globaltxtimeout = (u32) -1; + ah->power_mode = ATH9K_PM_UNDEFINED; + } +@@ -1196,34 +1172,25 @@ static void ath9k_hw_init_interrupt_mask + } + } + +-static bool ath9k_hw_set_ack_timeout(struct ath_hw *ah, u32 us) ++static void ath9k_hw_setslottime(struct ath_hw *ah, u32 us) + { +- if (us > ath9k_hw_mac_to_usec(ah, MS(0xffffffff, AR_TIME_OUT_ACK))) { +- ath_print(ath9k_hw_common(ah), ATH_DBG_RESET, +- "bad ack timeout %u\n", us); +- ah->acktimeout = (u32) -1; +- return false; +- } else { +- REG_RMW_FIELD(ah, AR_TIME_OUT, +- AR_TIME_OUT_ACK, ath9k_hw_mac_to_clks(ah, us)); +- ah->acktimeout = us; +- return true; +- } ++ u32 val = ath9k_hw_mac_to_clks(ah, us); ++ val = min(val, (u32) 0xFFFF); ++ REG_WRITE(ah, AR_D_GBL_IFS_SLOT, val); + } + +-static bool ath9k_hw_set_cts_timeout(struct ath_hw *ah, u32 us) ++static void ath9k_hw_set_ack_timeout(struct ath_hw *ah, u32 us) + { +- if (us > ath9k_hw_mac_to_usec(ah, MS(0xffffffff, AR_TIME_OUT_CTS))) { +- ath_print(ath9k_hw_common(ah), ATH_DBG_RESET, +- "bad cts timeout %u\n", us); +- ah->ctstimeout = (u32) -1; +- return false; +- } else { +- REG_RMW_FIELD(ah, AR_TIME_OUT, +- AR_TIME_OUT_CTS, ath9k_hw_mac_to_clks(ah, us)); +- ah->ctstimeout = us; +- return true; +- } ++ u32 val = ath9k_hw_mac_to_clks(ah, us); ++ val = min(val, (u32) MS(0xFFFFFFFF, AR_TIME_OUT_ACK)); ++ REG_RMW_FIELD(ah, AR_TIME_OUT, AR_TIME_OUT_ACK, val); ++} ++ ++static void ath9k_hw_set_cts_timeout(struct ath_hw *ah, u32 us) ++{ ++ u32 val = ath9k_hw_mac_to_clks(ah, us); ++ val = min(val, (u32) MS(0xFFFFFFFF, AR_TIME_OUT_CTS)); ++ REG_RMW_FIELD(ah, AR_TIME_OUT, AR_TIME_OUT_CTS, val); + } + + static bool ath9k_hw_set_global_txtimeout(struct ath_hw *ah, u32 tu) +@@ -1240,23 +1207,32 @@ static bool ath9k_hw_set_global_txtimeou + } + } + +-static void ath9k_hw_init_user_settings(struct ath_hw *ah) ++void ath9k_hw_init_global_settings(struct ath_hw *ah) + { ++ struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf; ++ int acktimeout; ++ int sifstime; ++ + ath_print(ath9k_hw_common(ah), ATH_DBG_RESET, "ah->misc_mode 0x%x\n", + ah->misc_mode); + + if (ah->misc_mode != 0) + REG_WRITE(ah, AR_PCU_MISC, + REG_READ(ah, AR_PCU_MISC) | ah->misc_mode); +- if (ah->slottime != (u32) -1) +- ath9k_hw_setslottime(ah, ah->slottime); +- if (ah->acktimeout != (u32) -1) +- ath9k_hw_set_ack_timeout(ah, ah->acktimeout); +- if (ah->ctstimeout != (u32) -1) +- ath9k_hw_set_cts_timeout(ah, ah->ctstimeout); ++ ++ if (conf->channel && conf->channel->band == IEEE80211_BAND_5GHZ) ++ sifstime = 16; ++ else ++ sifstime = 10; ++ ++ acktimeout = ah->slottime + sifstime; ++ ath9k_hw_setslottime(ah, ah->slottime); ++ ath9k_hw_set_ack_timeout(ah, acktimeout); ++ ath9k_hw_set_cts_timeout(ah, acktimeout); + if (ah->globaltxtimeout != (u32) -1) + ath9k_hw_set_global_txtimeout(ah, ah->globaltxtimeout); + } ++EXPORT_SYMBOL(ath9k_hw_init_global_settings); + + void ath9k_hw_deinit(struct ath_hw *ah) + { +@@ -2077,7 +2053,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st + if (ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT) + ath9k_enable_rfkill(ah); + +- ath9k_hw_init_user_settings(ah); ++ ath9k_hw_init_global_settings(ah); + + if (AR_SREV_9287_12_OR_LATER(ah)) { + REG_WRITE(ah, AR_D_GBL_IFS_SIFS, +@@ -3674,21 +3650,6 @@ u64 ath9k_hw_extend_tsf(struct ath_hw *a + } + EXPORT_SYMBOL(ath9k_hw_extend_tsf); + +-bool ath9k_hw_setslottime(struct ath_hw *ah, u32 us) +-{ +- if (us < ATH9K_SLOT_TIME_9 || us > ath9k_hw_mac_to_usec(ah, 0xffff)) { +- ath_print(ath9k_hw_common(ah), ATH_DBG_RESET, +- "bad slot time %u\n", us); +- ah->slottime = (u32) -1; +- return false; +- } else { +- REG_WRITE(ah, AR_D_GBL_IFS_SLOT, ath9k_hw_mac_to_clks(ah, us)); +- ah->slottime = us; +- return true; +- } +-} +-EXPORT_SYMBOL(ath9k_hw_setslottime); +- + void ath9k_hw_set11nmac2040(struct ath_hw *ah) + { + struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf; +--- a/drivers/net/wireless/ath/ath9k/hw.h ++++ b/drivers/net/wireless/ath/ath9k/hw.h +@@ -553,8 +553,6 @@ struct ath_hw { + int16_t txpower_indexoffset; + u32 beacon_interval; + u32 slottime; +- u32 acktimeout; +- u32 ctstimeout; + u32 globaltxtimeout; + + /* ANI */ +@@ -668,7 +666,7 @@ void ath9k_hw_settsf64(struct ath_hw *ah + void ath9k_hw_reset_tsf(struct ath_hw *ah); + void ath9k_hw_set_tsfadjust(struct ath_hw *ah, u32 setting); + u64 ath9k_hw_extend_tsf(struct ath_hw *ah, u32 rstamp); +-bool ath9k_hw_setslottime(struct ath_hw *ah, u32 us); ++void ath9k_hw_init_global_settings(struct ath_hw *ah); + void ath9k_hw_set11nmac2040(struct ath_hw *ah); + void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period); + void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah, +--- a/drivers/net/wireless/ath/ath9k/beacon.c ++++ b/drivers/net/wireless/ath/ath9k/beacon.c +@@ -480,7 +480,8 @@ void ath_beacon_tasklet(unsigned long da + sc->beacon.updateslot = COMMIT; /* commit next beacon */ + sc->beacon.slotupdate = slot; + } else if (sc->beacon.updateslot == COMMIT && sc->beacon.slotupdate == slot) { +- ath9k_hw_setslottime(sc->sc_ah, sc->beacon.slottime); ++ ah->slottime = sc->beacon.slottime; ++ ath9k_hw_init_global_settings(ah); + sc->beacon.updateslot = OK; + } + if (bfaddr != 0) { diff --git a/package/mac80211/patches/560-ath9k_coverage_class.patch b/package/mac80211/patches/560-ath9k_coverage_class.patch new file mode 100644 index 000000000..035eabb1f --- /dev/null +++ b/package/mac80211/patches/560-ath9k_coverage_class.patch @@ -0,0 +1,60 @@ +--- a/drivers/net/wireless/ath/ath9k/hw.c ++++ b/drivers/net/wireless/ath/ath9k/hw.c +@@ -1211,6 +1211,7 @@ void ath9k_hw_init_global_settings(struc + { + struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf; + int acktimeout; ++ int slottime; + int sifstime; + + ath_print(ath9k_hw_common(ah), ATH_DBG_RESET, "ah->misc_mode 0x%x\n", +@@ -1225,8 +1226,10 @@ void ath9k_hw_init_global_settings(struc + else + sifstime = 10; + +- acktimeout = ah->slottime + sifstime; +- ath9k_hw_setslottime(ah, ah->slottime); ++ /* As defined by IEEE 802.11-2007 17.3.8.6 */ ++ slottime = ah->slottime + 3 * ah->coverage_class; ++ acktimeout = slottime + sifstime; ++ ath9k_hw_setslottime(ah, slottime); + ath9k_hw_set_ack_timeout(ah, acktimeout); + ath9k_hw_set_cts_timeout(ah, acktimeout); + if (ah->globaltxtimeout != (u32) -1) +--- a/drivers/net/wireless/ath/ath9k/hw.h ++++ b/drivers/net/wireless/ath/ath9k/hw.h +@@ -551,6 +551,7 @@ struct ath_hw { + u32 *bank6Temp; + + int16_t txpower_indexoffset; ++ int coverage_class; + u32 beacon_interval; + u32 slottime; + u32 globaltxtimeout; +--- a/drivers/net/wireless/ath/ath9k/main.c ++++ b/drivers/net/wireless/ath/ath9k/main.c +@@ -2015,6 +2015,18 @@ static void ath9k_sw_scan_complete(struc + mutex_unlock(&sc->mutex); + } + ++static void ath9k_set_coverage_class(struct ieee80211_hw *hw, u8 coverage_class) ++{ ++ struct ath_wiphy *aphy = hw->priv; ++ struct ath_softc *sc = aphy->sc; ++ struct ath_hw *ah = sc->sc_ah; ++ ++ mutex_lock(&sc->mutex); ++ ah->coverage_class = coverage_class; ++ ath9k_hw_init_global_settings(ah); ++ mutex_unlock(&sc->mutex); ++} ++ + struct ieee80211_ops ath9k_ops = { + .tx = ath9k_tx, + .start = ath9k_start, +@@ -2034,4 +2046,5 @@ struct ieee80211_ops ath9k_ops = { + .sw_scan_start = ath9k_sw_scan_start, + .sw_scan_complete = ath9k_sw_scan_complete, + .rfkill_poll = ath9k_rfkill_poll_state, ++ .set_coverage_class = ath9k_set_coverage_class, + }; From 461c02892a66114b759f4b0483ff93b643e835a5 Mon Sep 17 00:00:00 2001 From: nbd Date: Fri, 15 Jan 2010 01:16:52 +0000 Subject: [PATCH 012/210] mac80211: implement the distance setting git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19142 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/mac80211/files/lib/wifi/mac80211.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package/mac80211/files/lib/wifi/mac80211.sh b/package/mac80211/files/lib/wifi/mac80211.sh index 06f4b84da..942a635f7 100644 --- a/package/mac80211/files/lib/wifi/mac80211.sh +++ b/package/mac80211/files/lib/wifi/mac80211.sh @@ -77,6 +77,7 @@ enable_mac80211() { config_get vifs "$device" vifs config_get txpower "$device" txpower config_get country "$device" country + config_get distance "$device" distance find_mac80211_phy "$device" || return 0 config_get phy "$device" phy local i=0 @@ -87,6 +88,8 @@ enable_mac80211() { fixed=1 } + [ -n "$distance" ] && iw phy "$phy" set distance "$distance" + export channel fixed # convert channel to frequency local freq="$(get_freq "$phy" "${fixed:+$channel}")" From c8e6838a62832eac5e5780e6f98d3109a805d394 Mon Sep 17 00:00:00 2001 From: nbd Date: Fri, 15 Jan 2010 02:03:25 +0000 Subject: [PATCH 013/210] mac80211: add a missing chunk of the short slot patch git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19143 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../patches/540-short_slot_handling.patch | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/package/mac80211/patches/540-short_slot_handling.patch b/package/mac80211/patches/540-short_slot_handling.patch index ed6831fbe..70341473e 100644 --- a/package/mac80211/patches/540-short_slot_handling.patch +++ b/package/mac80211/patches/540-short_slot_handling.patch @@ -9,3 +9,19 @@ if (use_protection != bss_conf->use_cts_prot) { bss_conf->use_cts_prot = use_protection; +--- a/net/mac80211/cfg.c ++++ b/net/mac80211/cfg.c +@@ -1087,6 +1087,13 @@ static int ieee80211_change_bss(struct w + params->use_short_preamble; + changed |= BSS_CHANGED_ERP_PREAMBLE; + } ++ ++ if (!sdata->vif.bss_conf.use_short_slot && ++ sdata->local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) { ++ sdata->vif.bss_conf.use_short_slot = true; ++ changed |= BSS_CHANGED_ERP_SLOT; ++ } ++ + if (params->use_short_slot_time >= 0) { + sdata->vif.bss_conf.use_short_slot = + params->use_short_slot_time; From 57f7e19c5830714e4863e0117f9bc5613ddf01cf Mon Sep 17 00:00:00 2001 From: nbd Date: Fri, 15 Jan 2010 02:55:29 +0000 Subject: [PATCH 014/210] mac80211: fix ht capability detection (thx, stintel) git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19144 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/mac80211/files/lib/wifi/mac80211.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/mac80211/files/lib/wifi/mac80211.sh b/package/mac80211/files/lib/wifi/mac80211.sh index 942a635f7..82ff95822 100644 --- a/package/mac80211/files/lib/wifi/mac80211.sh +++ b/package/mac80211/files/lib/wifi/mac80211.sh @@ -317,7 +317,7 @@ detect_mac80211() { mode_band="g" channel="5" ht_cap=0 - for cap in $(iw phy "$dev" info | grep 'HT capabilities' | cut -d: -f2); do + for cap in $(iw phy "$dev" info | grep 'Capabilities:' | cut -d: -f2); do ht_cap="$(($ht_cap | $cap))" done ht_capab=""; From 7a2b1e4d355ee5b7399eb07c3a06284970d05c36 Mon Sep 17 00:00:00 2001 From: nbd Date: Fri, 15 Jan 2010 07:39:27 +0000 Subject: [PATCH 015/210] mac80211: add some ibss related fixes from linux-wireless@ git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19145 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../patches/301-mac80211_tx_queue_wake.patch | 15 +++++++++++++++ .../patches/302-mac80211_pwr_mgmt_fix.patch | 12 ++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 package/mac80211/patches/301-mac80211_tx_queue_wake.patch create mode 100644 package/mac80211/patches/302-mac80211_pwr_mgmt_fix.patch diff --git a/package/mac80211/patches/301-mac80211_tx_queue_wake.patch b/package/mac80211/patches/301-mac80211_tx_queue_wake.patch new file mode 100644 index 000000000..1934fccac --- /dev/null +++ b/package/mac80211/patches/301-mac80211_tx_queue_wake.patch @@ -0,0 +1,15 @@ +--- a/net/mac80211/offchannel.c ++++ b/net/mac80211/offchannel.c +@@ -153,9 +153,11 @@ void ieee80211_offchannel_return(struct + if (sdata->vif.type == NL80211_IFTYPE_STATION) { + if (sdata->u.mgd.associated) + ieee80211_offchannel_ps_disable(sdata); +- netif_tx_wake_all_queues(sdata->dev); + } + ++ if (sdata->vif.type != NL80211_IFTYPE_MONITOR) ++ netif_tx_wake_all_queues(sdata->dev); ++ + /* re-enable beaconing */ + if (enable_beaconing && + (sdata->vif.type == NL80211_IFTYPE_AP || diff --git a/package/mac80211/patches/302-mac80211_pwr_mgmt_fix.patch b/package/mac80211/patches/302-mac80211_pwr_mgmt_fix.patch new file mode 100644 index 000000000..628fc1d20 --- /dev/null +++ b/package/mac80211/patches/302-mac80211_pwr_mgmt_fix.patch @@ -0,0 +1,12 @@ +--- a/net/mac80211/cfg.c ++++ b/net/mac80211/cfg.c +@@ -1384,6 +1384,9 @@ static int ieee80211_set_power_mgmt(stru + struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); + struct ieee80211_conf *conf = &local->hw.conf; + ++ if (sdata->vif.type != NL80211_IFTYPE_STATION) ++ return 0; ++ + if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS)) + return -EOPNOTSUPP; + From cbe29e7ff2d39e884ce7f457b67f32435224b8d6 Mon Sep 17 00:00:00 2001 From: nbd Date: Fri, 15 Jan 2010 07:39:31 +0000 Subject: [PATCH 016/210] ath9k: tweak rx interrupt mitigation settings for better performance git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19146 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../patches/408-ath9k_tweak_rx_intr_mitigation.patch | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 package/mac80211/patches/408-ath9k_tweak_rx_intr_mitigation.patch diff --git a/package/mac80211/patches/408-ath9k_tweak_rx_intr_mitigation.patch b/package/mac80211/patches/408-ath9k_tweak_rx_intr_mitigation.patch new file mode 100644 index 000000000..b900f411f --- /dev/null +++ b/package/mac80211/patches/408-ath9k_tweak_rx_intr_mitigation.patch @@ -0,0 +1,11 @@ +--- a/drivers/net/wireless/ath/ath9k/hw.c ++++ b/drivers/net/wireless/ath/ath9k/hw.c +@@ -2109,7 +2109,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st + + if (ah->config.rx_intr_mitigation) { + REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_LAST, 500); +- REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_FIRST, 2000); ++ REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_FIRST, 500); + } + + ath9k_hw_init_bb(ah, chan); From e8b38260e28fffb965180d7816efce2c54517d6c Mon Sep 17 00:00:00 2001 From: nbd Date: Fri, 15 Jan 2010 07:39:35 +0000 Subject: [PATCH 017/210] ath9k: fix rts/cts handling git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19147 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../patches/570-ath9k_fix_rts_cts.patch | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 package/mac80211/patches/570-ath9k_fix_rts_cts.patch diff --git a/package/mac80211/patches/570-ath9k_fix_rts_cts.patch b/package/mac80211/patches/570-ath9k_fix_rts_cts.patch new file mode 100644 index 000000000..789623c67 --- /dev/null +++ b/package/mac80211/patches/570-ath9k_fix_rts_cts.patch @@ -0,0 +1,61 @@ +--- a/drivers/net/wireless/ath/ath9k/xmit.c ++++ b/drivers/net/wireless/ath/ath9k/xmit.c +@@ -1498,26 +1498,6 @@ static void ath_buf_set_rate(struct ath_ + if (sc->sc_flags & SC_OP_PREAMBLE_SHORT) + ctsrate |= rate->hw_value_short; + +- /* +- * ATH9K_TXDESC_RTSENA and ATH9K_TXDESC_CTSENA are mutually exclusive. +- * Check the first rate in the series to decide whether RTS/CTS +- * or CTS-to-self has to be used. +- */ +- if (rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) +- flags = ATH9K_TXDESC_CTSENA; +- else if (rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) +- flags = ATH9K_TXDESC_RTSENA; +- +- /* FIXME: Handle aggregation protection */ +- if (sc->config.ath_aggr_prot && +- (!bf_isaggr(bf) || (bf_isaggr(bf) && bf->bf_al < 8192))) { +- flags = ATH9K_TXDESC_RTSENA; +- } +- +- /* For AR5416 - RTS cannot be followed by a frame larger than 8K */ +- if (bf_isaggr(bf) && (bf->bf_al > sc->sc_ah->caps.rts_aggr_limit)) +- flags &= ~(ATH9K_TXDESC_RTSENA); +- + for (i = 0; i < 4; i++) { + bool is_40, is_sgi, is_sp; + int phy; +@@ -1529,8 +1509,15 @@ static void ath_buf_set_rate(struct ath_ + series[i].Tries = rates[i].count; + series[i].ChSel = common->tx_chainmask; + +- if (rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) ++ if ((sc->config.ath_aggr_prot && bf_isaggr(bf)) || ++ (rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS)) { + series[i].RateFlags |= ATH9K_RATESERIES_RTS_CTS; ++ flags |= ATH9K_TXDESC_RTSENA; ++ } else if (rates[i].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) { ++ series[i].RateFlags |= ATH9K_RATESERIES_RTS_CTS; ++ flags |= ATH9K_TXDESC_CTSENA; ++ } ++ + if (rates[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH) + series[i].RateFlags |= ATH9K_RATESERIES_2040; + if (rates[i].flags & IEEE80211_TX_RC_SHORT_GI) +@@ -1568,6 +1555,14 @@ static void ath_buf_set_rate(struct ath_ + phy, rate->bitrate * 100, bf->bf_frmlen, rix, is_sp); + } + ++ /* For AR5416 - RTS cannot be followed by a frame larger than 8K */ ++ if (bf_isaggr(bf) && (bf->bf_al > sc->sc_ah->caps.rts_aggr_limit)) ++ flags &= ~ATH9K_TXDESC_RTSENA; ++ ++ /* ATH9K_TXDESC_RTSENA and ATH9K_TXDESC_CTSENA are mutually exclusive. */ ++ if (flags & ATH9K_TXDESC_RTSENA) ++ flags &= ~ATH9K_TXDESC_CTSENA; ++ + /* set dur_update_en for l-sig computation except for PS-Poll frames */ + ath9k_hw_set11n_ratescenario(sc->sc_ah, bf->bf_desc, + bf->bf_lastbf->bf_desc, From 361f44c9ae18219e7f5f8bf0846106f7bfcb2256 Mon Sep 17 00:00:00 2001 From: juhosg Date: Fri, 15 Jan 2010 12:07:58 +0000 Subject: [PATCH 018/210] ar71xx: add GPIO driver for the NXP 74HC153 chip git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19149 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/ar71xx/config-2.6.30 | 1 + target/linux/ar71xx/config-2.6.31 | 1 + target/linux/ar71xx/config-2.6.32 | 1 + .../ar71xx/files/drivers/gpio/nxp_74hc153.c | 246 ++++++++++++++++++ .../ar71xx/files/include/linux/nxp_74hc153.h | 24 ++ .../206-nxp-74hc153-gpio-chip-driver.patch | 25 ++ .../206-nxp-74hc153-gpio-chip-driver.patch | 25 ++ .../206-nxp-74hc153-gpio-chip-driver.patch | 25 ++ 8 files changed, 348 insertions(+) create mode 100644 target/linux/ar71xx/files/drivers/gpio/nxp_74hc153.c create mode 100644 target/linux/ar71xx/files/include/linux/nxp_74hc153.h create mode 100644 target/linux/ar71xx/patches-2.6.30/206-nxp-74hc153-gpio-chip-driver.patch create mode 100644 target/linux/ar71xx/patches-2.6.31/206-nxp-74hc153-gpio-chip-driver.patch create mode 100644 target/linux/ar71xx/patches-2.6.32/206-nxp-74hc153-gpio-chip-driver.patch diff --git a/target/linux/ar71xx/config-2.6.30 b/target/linux/ar71xx/config-2.6.30 index 357913468..33bd591d6 100644 --- a/target/linux/ar71xx/config-2.6.30 +++ b/target/linux/ar71xx/config-2.6.30 @@ -102,6 +102,7 @@ CONFIG_GENERIC_FIND_NEXT_BIT=y CONFIG_GENERIC_GPIO=y CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y CONFIG_GPIOLIB=y +# CONFIG_GPIO_NXP_74HC153 is not set CONFIG_GPIO_PCF857X=y CONFIG_GPIO_SYSFS=y CONFIG_HARDWARE_WATCHPOINTS=y diff --git a/target/linux/ar71xx/config-2.6.31 b/target/linux/ar71xx/config-2.6.31 index 5c9affa74..848bf20d1 100644 --- a/target/linux/ar71xx/config-2.6.31 +++ b/target/linux/ar71xx/config-2.6.31 @@ -105,6 +105,7 @@ CONFIG_GENERIC_FIND_NEXT_BIT=y CONFIG_GENERIC_GPIO=y CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y CONFIG_GPIOLIB=y +# CONFIG_GPIO_NXP_74HC153 is not set CONFIG_GPIO_PCF857X=y CONFIG_GPIO_SYSFS=y CONFIG_HARDWARE_WATCHPOINTS=y diff --git a/target/linux/ar71xx/config-2.6.32 b/target/linux/ar71xx/config-2.6.32 index a4ac682ef..5c1559273 100644 --- a/target/linux/ar71xx/config-2.6.32 +++ b/target/linux/ar71xx/config-2.6.32 @@ -107,6 +107,7 @@ CONFIG_GENERIC_GPIO=y CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y CONFIG_GPIOLIB=y # CONFIG_GPIO_MC33880 is not set +# CONFIG_GPIO_NXP_74HC153 is not set CONFIG_GPIO_PCF857X=y CONFIG_GPIO_SYSFS=y CONFIG_HARDWARE_WATCHPOINTS=y diff --git a/target/linux/ar71xx/files/drivers/gpio/nxp_74hc153.c b/target/linux/ar71xx/files/drivers/gpio/nxp_74hc153.c new file mode 100644 index 000000000..b4f1662ae --- /dev/null +++ b/target/linux/ar71xx/files/drivers/gpio/nxp_74hc153.c @@ -0,0 +1,246 @@ +/* + * NXP 74HC153 - Dual 4-input multiplexer GPIO driver + * + * Copyright (C) 2010 Gabor Juhos + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include + +#define NXP_74HC153_NUM_GPIOS 8 +#define NXP_74HC153_S0_MASK 0x1 +#define NXP_74HC153_S1_MASK 0x2 +#define NXP_74HC153_BANK_MASK 0x4 + +struct nxp_74hc153_chip { + struct device *parent; + struct gpio_chip gpio_chip; + struct mutex lock; +}; + +static struct nxp_74hc153_chip *gpio_to_nxp(struct gpio_chip *gc) +{ + return container_of(gc, struct nxp_74hc153_chip, gpio_chip); +} + +static int nxp_74hc153_direction_input(struct gpio_chip *gc, unsigned offset) +{ + return 0; +} + +static int nxp_74hc153_direction_output(struct gpio_chip *gc, + unsigned offset, int val) +{ + return -EINVAL; +} + +static int nxp_74hc153_get_value(struct gpio_chip *gc, unsigned offset) +{ + struct nxp_74hc153_chip *nxp; + struct nxp_74hc153_platform_data *pdata; + unsigned s0; + unsigned s1; + unsigned pin; + int ret; + + nxp = gpio_to_nxp(gc); + pdata = nxp->parent->platform_data; + + s0 = !!(offset & NXP_74HC153_S0_MASK); + s1 = !!(offset & NXP_74HC153_S1_MASK); + pin = (offset & NXP_74HC153_BANK_MASK) ? pdata->gpio_pin_2y + : pdata->gpio_pin_1y; + + mutex_lock(&nxp->lock); + gpio_set_value(pdata->gpio_pin_s0, s0); + gpio_set_value(pdata->gpio_pin_s1, s1); + ret = gpio_get_value(pin); + mutex_unlock(&nxp->lock); + + return ret; +} + +static void nxp_74hc153_set_value(struct gpio_chip *gc, + unsigned offset, int val) +{ + /* not supported */ +} + +static int __devinit nxp_74hc153_probe(struct platform_device *pdev) +{ + struct nxp_74hc153_platform_data *pdata; + struct nxp_74hc153_chip *nxp; + struct gpio_chip *gc; + int err; + + pdata = pdev->dev.platform_data; + if (pdata == NULL) { + dev_dbg(&pdev->dev, "no platform data specified\n"); + return -EINVAL; + } + + nxp = kzalloc(sizeof(struct nxp_74hc153_chip), GFP_KERNEL); + if (nxp == NULL) { + dev_err(&pdev->dev, "no memory for private data\n"); + return -ENOMEM; + } + + err = gpio_request(pdata->gpio_pin_s0, dev_name(&pdev->dev)); + if (err) { + dev_err(&pdev->dev, "unable to claim gpio %u, err=%d\n", + pdata->gpio_pin_s0, err); + goto err_free_nxp; + } + + err = gpio_request(pdata->gpio_pin_s1, dev_name(&pdev->dev)); + if (err) { + dev_err(&pdev->dev, "unable to claim gpio %u, err=%d\n", + pdata->gpio_pin_s1, err); + goto err_free_s0; + } + + err = gpio_request(pdata->gpio_pin_1y, dev_name(&pdev->dev)); + if (err) { + dev_err(&pdev->dev, "unable to claim gpio %u, err=%d\n", + pdata->gpio_pin_1y, err); + goto err_free_s1; + } + + err = gpio_request(pdata->gpio_pin_2y, dev_name(&pdev->dev)); + if (err) { + dev_err(&pdev->dev, "unable to claim gpio %u, err=%d\n", + pdata->gpio_pin_2y, err); + goto err_free_1y; + } + + err = gpio_direction_output(pdata->gpio_pin_s0, 0); + if (err) { + dev_err(&pdev->dev, + "unable to set direction of gpio %u, err=%d\n", + pdata->gpio_pin_s0, err); + goto err_free_2y; + } + + err = gpio_direction_output(pdata->gpio_pin_s1, 0); + if (err) { + dev_err(&pdev->dev, + "unable to set direction of gpio %u, err=%d\n", + pdata->gpio_pin_s1, err); + goto err_free_2y; + } + + err = gpio_direction_input(pdata->gpio_pin_1y); + if (err) { + dev_err(&pdev->dev, + "unable to set direction of gpio %u, err=%d\n", + pdata->gpio_pin_1y, err); + goto err_free_2y; + } + + err = gpio_direction_input(pdata->gpio_pin_2y); + if (err) { + dev_err(&pdev->dev, + "unable to set direction of gpio %u, err=%d\n", + pdata->gpio_pin_2y, err); + goto err_free_2y; + } + + nxp->parent = &pdev->dev; + mutex_init(&nxp->lock); + + gc = &nxp->gpio_chip; + + gc->direction_input = nxp_74hc153_direction_input; + gc->direction_output = nxp_74hc153_direction_output; + gc->get = nxp_74hc153_get_value; + gc->set = nxp_74hc153_set_value; + gc->can_sleep = 1; + + gc->base = pdata->gpio_base; + gc->ngpio = NXP_74HC153_NUM_GPIOS; + gc->label = dev_name(nxp->parent); + gc->dev = nxp->parent; + gc->owner = THIS_MODULE; + + err = gpiochip_add(&nxp->gpio_chip); + if (err) { + dev_err(&pdev->dev, "unable to add gpio chip, err=%d\n", err); + goto err_free_2y; + } + + platform_set_drvdata(pdev, nxp); + return 0; + + err_free_2y: + gpio_free(pdata->gpio_pin_2y); + err_free_1y: + gpio_free(pdata->gpio_pin_1y); + err_free_s1: + gpio_free(pdata->gpio_pin_s1); + err_free_s0: + gpio_free(pdata->gpio_pin_s0); + err_free_nxp: + kfree(nxp); + return err; +} + +static int nxp_74hc153_remove(struct platform_device *pdev) +{ + struct nxp_74hc153_chip *nxp = platform_get_drvdata(pdev); + struct nxp_74hc153_platform_data *pdata = pdev->dev.platform_data; + + if (nxp) { + int err; + + err = gpiochip_remove(&nxp->gpio_chip); + if (err) { + dev_err(&pdev->dev, + "unable to remove gpio chip, err=%d\n", + err); + return err; + } + + gpio_free(pdata->gpio_pin_2y); + gpio_free(pdata->gpio_pin_1y); + gpio_free(pdata->gpio_pin_s1); + gpio_free(pdata->gpio_pin_s0); + + kfree(nxp); + platform_set_drvdata(pdev, NULL); + } + + return 0; +} + +static struct platform_driver nxp_74hc153_driver = { + .probe = nxp_74hc153_probe, + .remove = __devexit_p(nxp_74hc153_remove), + .driver = { + .name = NXP_74HC153_DRIVER_NAME, + .owner = THIS_MODULE, + }, +}; + +static int __init nxp_74hc153_init(void) +{ + return platform_driver_register(&nxp_74hc153_driver); +} +subsys_initcall(nxp_74hc153_init); + +static void __exit nxp_74hc153_exit(void) +{ + platform_driver_unregister(&nxp_74hc153_driver); +} +module_exit(nxp_74hc153_exit); + +MODULE_AUTHOR("Gabor Juhos "); +MODULE_DESCRIPTION("GPIO expander driver for NXP 74HC153"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:" NXP_74HC153_DRIVER_NAME); diff --git a/target/linux/ar71xx/files/include/linux/nxp_74hc153.h b/target/linux/ar71xx/files/include/linux/nxp_74hc153.h new file mode 100644 index 000000000..20b8845e5 --- /dev/null +++ b/target/linux/ar71xx/files/include/linux/nxp_74hc153.h @@ -0,0 +1,24 @@ +/* + * NXP 74HC153 - Dual 4-input multiplexer defines + * + * Copyright (C) 2010 Gabor Juhos + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef _NXP_74HC153_H +#define _NXP_74HC153_H + +#define NXP_74HC153_DRIVER_NAME "nxp-74hc153" + +struct nxp_74hc153_platform_data { + unsigned gpio_base; + unsigned gpio_pin_s0; + unsigned gpio_pin_s1; + unsigned gpio_pin_1y; + unsigned gpio_pin_2y; +}; + +#endif /* _NXP_74HC153_H */ diff --git a/target/linux/ar71xx/patches-2.6.30/206-nxp-74hc153-gpio-chip-driver.patch b/target/linux/ar71xx/patches-2.6.30/206-nxp-74hc153-gpio-chip-driver.patch new file mode 100644 index 000000000..0f1613c84 --- /dev/null +++ b/target/linux/ar71xx/patches-2.6.30/206-nxp-74hc153-gpio-chip-driver.patch @@ -0,0 +1,25 @@ +--- a/drivers/gpio/Kconfig ++++ b/drivers/gpio/Kconfig +@@ -176,4 +176,12 @@ config GPIO_MCP23S08 + SPI driver for Microchip MCP23S08 I/O expander. This provides + a GPIO interface supporting inputs and outputs. + ++comment "Other GPIO expanders" ++ ++config GPIO_NXP_74HC153 ++ tristate "NXP 74HC153 Dual 4-input multiplexer" ++ help ++ Platform driver for NXP 74HC153 Dual 4-input Multiplexer. This ++ provides a GPIO interface supporting inputs. ++ + endif +--- a/drivers/gpio/Makefile ++++ b/drivers/gpio/Makefile +@@ -7,6 +7,7 @@ obj-$(CONFIG_GPIOLIB) += gpiolib.o + obj-$(CONFIG_GPIO_MAX7301) += max7301.o + obj-$(CONFIG_GPIO_MAX732X) += max732x.o + obj-$(CONFIG_GPIO_MCP23S08) += mcp23s08.o ++obj-$(CONFIG_GPIO_NXP_74HC153) += nxp_74hc153.o + obj-$(CONFIG_GPIO_PCA953X) += pca953x.o + obj-$(CONFIG_GPIO_PCF857X) += pcf857x.o + obj-$(CONFIG_GPIO_TWL4030) += twl4030-gpio.o diff --git a/target/linux/ar71xx/patches-2.6.31/206-nxp-74hc153-gpio-chip-driver.patch b/target/linux/ar71xx/patches-2.6.31/206-nxp-74hc153-gpio-chip-driver.patch new file mode 100644 index 000000000..c722f34e8 --- /dev/null +++ b/target/linux/ar71xx/patches-2.6.31/206-nxp-74hc153-gpio-chip-driver.patch @@ -0,0 +1,25 @@ +--- a/drivers/gpio/Kconfig ++++ b/drivers/gpio/Kconfig +@@ -188,4 +188,12 @@ config GPIO_MCP23S08 + SPI driver for Microchip MCP23S08 I/O expander. This provides + a GPIO interface supporting inputs and outputs. + ++comment "Other GPIO expanders" ++ ++config GPIO_NXP_74HC153 ++ tristate "NXP 74HC153 Dual 4-input multiplexer" ++ help ++ Platform driver for NXP 74HC153 Dual 4-input Multiplexer. This ++ provides a GPIO interface supporting inputs. ++ + endif +--- a/drivers/gpio/Makefile ++++ b/drivers/gpio/Makefile +@@ -7,6 +7,7 @@ obj-$(CONFIG_GPIOLIB) += gpiolib.o + obj-$(CONFIG_GPIO_MAX7301) += max7301.o + obj-$(CONFIG_GPIO_MAX732X) += max732x.o + obj-$(CONFIG_GPIO_MCP23S08) += mcp23s08.o ++obj-$(CONFIG_GPIO_NXP_74HC153) += nxp_74hc153.o + obj-$(CONFIG_GPIO_PCA953X) += pca953x.o + obj-$(CONFIG_GPIO_PCF857X) += pcf857x.o + obj-$(CONFIG_GPIO_PL061) += pl061.o diff --git a/target/linux/ar71xx/patches-2.6.32/206-nxp-74hc153-gpio-chip-driver.patch b/target/linux/ar71xx/patches-2.6.32/206-nxp-74hc153-gpio-chip-driver.patch new file mode 100644 index 000000000..1192d99ee --- /dev/null +++ b/target/linux/ar71xx/patches-2.6.32/206-nxp-74hc153-gpio-chip-driver.patch @@ -0,0 +1,25 @@ +--- a/drivers/gpio/Kconfig ++++ b/drivers/gpio/Kconfig +@@ -230,4 +230,12 @@ config GPIO_UCB1400 + To compile this driver as a module, choose M here: the + module will be called ucb1400_gpio. + ++comment "Other GPIO expanders" ++ ++config GPIO_NXP_74HC153 ++ tristate "NXP 74HC153 Dual 4-input multiplexer" ++ help ++ Platform driver for NXP 74HC153 Dual 4-input Multiplexer. This ++ provides a GPIO interface supporting inputs. ++ + endif +--- a/drivers/gpio/Makefile ++++ b/drivers/gpio/Makefile +@@ -10,6 +10,7 @@ obj-$(CONFIG_GPIO_MAX7301) += max7301.o + obj-$(CONFIG_GPIO_MAX732X) += max732x.o + obj-$(CONFIG_GPIO_MC33880) += mc33880.o + obj-$(CONFIG_GPIO_MCP23S08) += mcp23s08.o ++obj-$(CONFIG_GPIO_NXP_74HC153) += nxp_74hc153.o + obj-$(CONFIG_GPIO_PCA953X) += pca953x.o + obj-$(CONFIG_GPIO_PCF857X) += pcf857x.o + obj-$(CONFIG_GPIO_PL061) += pl061.o From f010cfd099aefa17b69a1e2f2e0d9c861be98831 Mon Sep 17 00:00:00 2001 From: juhosg Date: Fri, 15 Jan 2010 12:08:03 +0000 Subject: [PATCH 019/210] ar71xx: add preliminary support for the Buffalo WZR-HP-G300NH git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19150 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/ar71xx/base-files/etc/diag.sh | 3 + target/linux/ar71xx/base-files/lib/ar71xx.sh | 3 + .../ar71xx/base-files/lib/upgrade/platform.sh | 2 +- target/linux/ar71xx/config-2.6.30 | 4 +- target/linux/ar71xx/config-2.6.31 | 3 +- target/linux/ar71xx/config-2.6.32 | 3 +- .../ar71xx/files/arch/mips/ar71xx/Kconfig | 8 + .../ar71xx/files/arch/mips/ar71xx/Makefile | 1 + .../arch/mips/ar71xx/mach-wzr-hp-g300nh.c | 264 ++++++++++++++++++ .../ar71xx/files/arch/mips/ar71xx/machtype.h | 1 + target/linux/ar71xx/profiles/buffalo.mk | 17 ++ 11 files changed, 304 insertions(+), 5 deletions(-) create mode 100644 target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c create mode 100644 target/linux/ar71xx/profiles/buffalo.mk diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh index 1fc2c34fe..2a6af7da2 100755 --- a/target/linux/ar71xx/base-files/etc/diag.sh +++ b/target/linux/ar71xx/base-files/etc/diag.sh @@ -96,6 +96,9 @@ get_status_led() { wrt160nl) status_led="wrt160nl:blue:wps" ;; + wzr-hp-g300nh) + status_led="wzr-hp-g300nh:green:router" + ;; esac; } diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index 327107b0d..f39d5dc9b 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -100,6 +100,9 @@ ar71xx_board_name() { *WRT400N) name="wrt400n" ;; + *WZR-HP-W300NH) + name="wzr-hp-w300nh" + ;; *) name="generic" ;; diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh index 13a154441..d9f2240c5 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -68,7 +68,7 @@ platform_check_image() { [ "$ARGC" -gt 1 ] && return 1 case "$board" in - ap81 | ap83 | dir-600-a1 | dir-615-c1 | dir-825-b1 | mzk-w04nu | mzk-w300nh | tew-632brp | wrt-400n | bullet-m | nano-m | rocket-m) + ap81 | ap83 | dir-600-a1 | dir-615-c1 | dir-825-b1 | mzk-w04nu | mzk-w300nh | tew-632brp | wrt-400n | bullet-m | nano-m | rocket-m | wzr-hp-g300nh) [ "$magic" != "2705" ] && { echo "Invalid image type." return 1 diff --git a/target/linux/ar71xx/config-2.6.30 b/target/linux/ar71xx/config-2.6.30 index 33bd591d6..698431982 100644 --- a/target/linux/ar71xx/config-2.6.30 +++ b/target/linux/ar71xx/config-2.6.30 @@ -36,6 +36,7 @@ CONFIG_AR71XX_MACH_WNR2000=y CONFIG_AR71XX_MACH_WP543=y CONFIG_AR71XX_MACH_WRT160NL=y CONFIG_AR71XX_MACH_WRT400N=y +CONFIG_AR71XX_MACH_WZR_HP_G300NH=y CONFIG_AR71XX_NVRAM=y CONFIG_AR71XX_WDT=y # CONFIG_ARCH_HAS_ILOG2_U32 is not set @@ -102,7 +103,7 @@ CONFIG_GENERIC_FIND_NEXT_BIT=y CONFIG_GENERIC_GPIO=y CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y CONFIG_GPIOLIB=y -# CONFIG_GPIO_NXP_74HC153 is not set +CONFIG_GPIO_NXP_74HC153=y CONFIG_GPIO_PCF857X=y CONFIG_GPIO_SYSFS=y CONFIG_HARDWARE_WATCHPOINTS=y @@ -149,7 +150,6 @@ CONFIG_MIPS_MT_DISABLED=y # CONFIG_MIPS_MT_SMTC is not set # CONFIG_MIPS_SIM is not set CONFIG_MTD_AR91XX_FLASH=y -# CONFIG_MTD_CFI is not set # CONFIG_MTD_CFI_INTELEXT is not set CONFIG_MTD_CMDLINE_PARTS=y CONFIG_MTD_JEDECPROBE=y diff --git a/target/linux/ar71xx/config-2.6.31 b/target/linux/ar71xx/config-2.6.31 index 848bf20d1..11543ab4e 100644 --- a/target/linux/ar71xx/config-2.6.31 +++ b/target/linux/ar71xx/config-2.6.31 @@ -38,6 +38,7 @@ CONFIG_AR71XX_MACH_WNR2000=y CONFIG_AR71XX_MACH_WP543=y CONFIG_AR71XX_MACH_WRT160NL=y CONFIG_AR71XX_MACH_WRT400N=y +CONFIG_AR71XX_MACH_WZR_HP_G300NH=y CONFIG_AR71XX_NVRAM=y CONFIG_AR71XX_WDT=y # CONFIG_ARCH_HAS_ILOG2_U32 is not set @@ -106,7 +107,7 @@ CONFIG_GENERIC_GPIO=y CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y CONFIG_GPIOLIB=y # CONFIG_GPIO_NXP_74HC153 is not set -CONFIG_GPIO_PCF857X=y +CONFIG_GPIO_NXP_74HC153=y CONFIG_GPIO_SYSFS=y CONFIG_HARDWARE_WATCHPOINTS=y CONFIG_HAS_DMA=y diff --git a/target/linux/ar71xx/config-2.6.32 b/target/linux/ar71xx/config-2.6.32 index 5c1559273..8c958af49 100644 --- a/target/linux/ar71xx/config-2.6.32 +++ b/target/linux/ar71xx/config-2.6.32 @@ -38,6 +38,7 @@ CONFIG_AR71XX_MACH_WNR2000=y CONFIG_AR71XX_MACH_WP543=y CONFIG_AR71XX_MACH_WRT160NL=y CONFIG_AR71XX_MACH_WRT400N=y +CONFIG_AR71XX_MACH_WZR_HP_G300NH=y CONFIG_AR71XX_NVRAM=y CONFIG_AR71XX_WDT=y # CONFIG_ARCH_HAS_ILOG2_U32 is not set @@ -107,7 +108,7 @@ CONFIG_GENERIC_GPIO=y CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y CONFIG_GPIOLIB=y # CONFIG_GPIO_MC33880 is not set -# CONFIG_GPIO_NXP_74HC153 is not set +CONFIG_GPIO_NXP_74HC153=y CONFIG_GPIO_PCF857X=y CONFIG_GPIO_SYSFS=y CONFIG_HARDWARE_WATCHPOINTS=y diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig b/target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig index a9ffcc311..29c5590c8 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig @@ -68,6 +68,14 @@ config AR71XX_MACH_AW_NR580 select AR71XX_DEV_LEDS_GPIO default n +config AR71XX_MACH_WZR_HP_G300NH + bool "Buffalo WZR-HP-G300NH board support" + select AR71XX_DEV_AR913X_WMAC + select AR71XX_DEV_GPIO_BUTTONS + select AR71XX_DEV_LEDS_GPIO + select AR71XX_DEV_USB + default y + config AR71XX_MACH_GENERIC bool "Generic AR71xx based machine support" default y diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/Makefile b/target/linux/ar71xx/files/arch/mips/ar71xx/Makefile index a441dc701..bf13b8d6e 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/Makefile +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/Makefile @@ -48,3 +48,4 @@ obj-$(CONFIG_AR71XX_MACH_WNR2000) += mach-wnr2000.o obj-$(CONFIG_AR71XX_MACH_WP543) += mach-wp543.o obj-$(CONFIG_AR71XX_MACH_WRT160NL) += mach-wrt160nl.o obj-$(CONFIG_AR71XX_MACH_WRT400N) += mach-wrt400n.o +obj-$(CONFIG_AR71XX_MACH_WZR_HP_G300NH) += mach-wzr-hp-g300nh.o diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c new file mode 100644 index 000000000..5ffb816bf --- /dev/null +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c @@ -0,0 +1,264 @@ +/* + * Buffalo WZR-HP-G300NH board support + * + * Copyright (C) 2010 Gabor Juhos + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "machtype.h" +#include "devices.h" +#include "dev-ar913x-wmac.h" +#include "dev-gpio-buttons.h" +#include "dev-leds-gpio.h" +#include "dev-usb.h" + +#define WZRHPG300NH_GPIO_LED_USB 0 +#define WZRHPG300NH_GPIO_LED_DIAG 1 +#define WZRHPG300NH_GPIO_LED_WIRELESS 6 +#define WZRHPG300NH_GPIO_LED_SECURITY 17 +#define WZRHPG300NH_GPIO_LED_ROUTER 18 + +#define WZRHPG300NH_GPIO_RTL8366_SDA 19 +#define WZRHPG300NH_GPIO_RTL8366_SCK 20 + +#define WZRHPG300NH_GPIO_74HC153_S0 9 +#define WZRHPG300NH_GPIO_74HC153_S1 11 +#define WZRHPG300NH_GPIO_74HC153_1Y 12 +#define WZRHPG300NH_GPIO_74HC153_2Y 14 + +#define WZRHPG300NH_GPIO_EXP_BASE 32 +#define WZRHPG300NH_GPIO_BTN_AOSS (WZRHPG300NH_GPIO_EXP_BASE + 0) +#define WZRHPG300NH_GPIO_BTN_RESET (WZRHPG300NH_GPIO_EXP_BASE + 1) +#define WZRHPG300NH_GPIO_BTN_ROUTER_ON (WZRHPG300NH_GPIO_EXP_BASE + 2) +#define WZRHPG300NH_GPIO_BTN_QOS_ON (WZRHPG300NH_GPIO_EXP_BASE + 3) +#define WZRHPG300NH_GPIO_BTN_USB (WZRHPG300NH_GPIO_EXP_BASE + 5) +#define WZRHPG300NH_GPIO_BTN_ROUTER_AUTO (WZRHPG300NH_GPIO_EXP_BASE + 6) +#define WZRHPG300NH_GPIO_BTN_QOS_OFF (WZRHPG300NH_GPIO_EXP_BASE + 7) + +#define WZRHPG300NH_BUTTONS_POLL_INTERVAL 20 + +#ifdef CONFIG_MTD_PARTITIONS +static struct mtd_partition wzrhpg300nh_flash_partitions[] = { + { + .name = "u-boot", + .offset = 0, + .size = 0x0040000, + .mask_flags = MTD_WRITEABLE, + }, { + .name = "u-boot-env", + .offset = 0x0040000, + .size = 0x0020000, + .mask_flags = MTD_WRITEABLE, + }, { + .name = "kernel", + .offset = 0x0060000, + .size = 0x0100000, + }, { + .name = "rootfs", + .offset = 0x0160000, + .size = 0x1e60000, + }, { + .name = "user_property", + .offset = 0x1fc0000, + .size = 0x0020000, + .mask_flags = MTD_WRITEABLE, + }, { + .name = "art", + .offset = 0x1fe0000, + .size = 0x0020000, + .mask_flags = MTD_WRITEABLE, + }, { + .name = "firmware", + .offset = 0x0060000, + .size = 0x1f60000, + } +}; +#endif /* CONFIG_MTD_PARTITIONS */ + +static struct ar91xx_flash_platform_data wzrhpg300nh_flash_data = { + .width = 2, +#ifdef CONFIG_MTD_PARTITIONS + .parts = wzrhpg300nh_flash_partitions, + .nr_parts = ARRAY_SIZE(wzrhpg300nh_flash_partitions), +#endif +}; + +#define WZRHPG300NH_FLASH_BASE 0x1e000000 +#define WZRHPG300NH_FLASH_SIZE (32 * 1024 * 1024) + +static struct resource wzrhpg300nh_flash_resources[] = { + [0] = { + .start = WZRHPG300NH_FLASH_BASE, + .end = WZRHPG300NH_FLASH_BASE + WZRHPG300NH_FLASH_SIZE - 1, + .flags = IORESOURCE_MEM, + }, +}; + +static struct platform_device wzrhpg300nh_flash_device = { + .name = "ar91xx-flash", + .id = -1, + .resource = wzrhpg300nh_flash_resources, + .num_resources = ARRAY_SIZE(wzrhpg300nh_flash_resources), + .dev = { + .platform_data = &wzrhpg300nh_flash_data, + } +}; + +static struct gpio_led wzrhpg300nh_leds_gpio[] __initdata = { + { + .name = "wzr-hp-g300nh:orange:security", + .gpio = WZRHPG300NH_GPIO_LED_SECURITY, + .active_low = 1, + }, { + .name = "wzr-hp-g300nh:green:wireless", + .gpio = WZRHPG300NH_GPIO_LED_WIRELESS, + .active_low = 1, + }, { + .name = "wzr-hp-g300nh:green:router", + .gpio = WZRHPG300NH_GPIO_LED_ROUTER, + .active_low = 1, + }, { + .name = "wzr-hp-g300nh:red:diag", + .gpio = WZRHPG300NH_GPIO_LED_DIAG, + .active_low = 1, + }, { + .name = "wzr-hp-g300nh:blue:usb", + .gpio = WZRHPG300NH_GPIO_LED_USB, + .active_low = 1, + } +}; + +static struct gpio_button wzrhpg300nh_gpio_buttons[] __initdata = { + { + .desc = "reset", + .type = EV_KEY, + .code = BTN_0, + .threshold = 3, + .gpio = WZRHPG300NH_GPIO_BTN_RESET, + .active_low = 1, + }, { + .desc = "aoss", + .type = EV_KEY, + .code = BTN_1, + .threshold = 3, + .gpio = WZRHPG300NH_GPIO_BTN_AOSS, + .active_low = 1, + }, { + .desc = "usb", + .type = EV_KEY, + .code = BTN_2, + .threshold = 3, + .gpio = WZRHPG300NH_GPIO_BTN_USB, + .active_low = 1, + }, { + .desc = "qos_on", + .type = EV_KEY, + .code = BTN_3, + .threshold = 3, + .gpio = WZRHPG300NH_GPIO_BTN_QOS_ON, + .active_low = 0, + }, { + .desc = "qos_off", + .type = EV_KEY, + .code = BTN_4, + .threshold = 3, + .gpio = WZRHPG300NH_GPIO_BTN_QOS_OFF, + .active_low = 0, + }, { + .desc = "router_on", + .type = EV_KEY, + .code = BTN_5, + .threshold = 3, + .gpio = WZRHPG300NH_GPIO_BTN_ROUTER_ON, + .active_low = 0, + }, { + .desc = "router_auto", + .type = EV_KEY, + .code = BTN_6, + .threshold = 3, + .gpio = WZRHPG300NH_GPIO_BTN_ROUTER_AUTO, + .active_low = 0, + } +}; + +static struct nxp_74hc153_platform_data wzrhpg300nh_74hc153_data = { + .gpio_base = WZRHPG300NH_GPIO_EXP_BASE, + .gpio_pin_s0 = WZRHPG300NH_GPIO_74HC153_S0, + .gpio_pin_s1 = WZRHPG300NH_GPIO_74HC153_S1, + .gpio_pin_1y = WZRHPG300NH_GPIO_74HC153_1Y, + .gpio_pin_2y = WZRHPG300NH_GPIO_74HC153_2Y, +}; + +static struct platform_device wzrhpg300nh_74hc153_device = { + .name = NXP_74HC153_DRIVER_NAME, + .id = -1, + .dev = { + .platform_data = &wzrhpg300nh_74hc153_data, + } +}; + +static struct rtl8366_smi_platform_data wzrhpg300nh_rtl8366_smi_data = { + .gpio_sda = WZRHPG300NH_GPIO_RTL8366_SDA, + .gpio_sck = WZRHPG300NH_GPIO_RTL8366_SCK, +}; + +static struct platform_device wzrhpg300nh_rtl8366_smi_device = { + .name = "rtl8366-smi", + .id = -1, + .dev = { + .platform_data = &wzrhpg300nh_rtl8366_smi_data, + } +}; + +static void __init wzrhpg300nh_setup(void) +{ + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000); + + ar71xx_set_mac_base(eeprom); + + ar71xx_eth0_pll_data.pll_1000 = 0x1e000100; + ar71xx_eth0_data.mii_bus_dev = &wzrhpg300nh_rtl8366_smi_device.dev; + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; + ar71xx_eth0_data.phy_mask = 0xf; + ar71xx_eth0_data.speed = SPEED_1000; + ar71xx_eth0_data.duplex = DUPLEX_FULL; + + ar71xx_eth1_pll_data.pll_1000 = 0x1e000100; + ar71xx_eth1_data.mii_bus_dev = &wzrhpg300nh_rtl8366_smi_device.dev; + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; + ar71xx_eth1_data.phy_mask = 0x10; + + ar71xx_add_device_eth(0); + ar71xx_add_device_eth(1); + + ar71xx_add_device_usb(); + ar913x_add_device_wmac(eeprom, NULL); + + platform_device_register(&wzrhpg300nh_74hc153_device); + platform_device_register(&wzrhpg300nh_flash_device); + platform_device_register(&wzrhpg300nh_rtl8366_smi_device); + + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wzrhpg300nh_leds_gpio), + wzrhpg300nh_leds_gpio); + + ar71xx_add_device_gpio_buttons(-1, WZRHPG300NH_BUTTONS_POLL_INTERVAL, + ARRAY_SIZE(wzrhpg300nh_gpio_buttons), + wzrhpg300nh_gpio_buttons); + +} + +MIPS_MACHINE(AR71XX_MACH_WZR_HP_G300NH, "WZR-HP-G300NH", + "Buffalo WZR-HP-G300NH", wzrhpg300nh_setup); diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h b/target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h index 98681c6c9..b97832ff1 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h @@ -51,6 +51,7 @@ enum ar71xx_mach_type { AR71XX_MACH_WP543, /* Compex WP543 */ AR71XX_MACH_WRT160NL, /* Linksys WRT160NL */ AR71XX_MACH_WRT400N, /* Linksys WRT400N */ + AR71XX_MACH_WZR_HP_G300NH, /* Buffalo WZR-HP-G300NH */ }; #endif /* _AR71XX_MACHTYPE_H */ diff --git a/target/linux/ar71xx/profiles/buffalo.mk b/target/linux/ar71xx/profiles/buffalo.mk new file mode 100644 index 000000000..429ecbaaa --- /dev/null +++ b/target/linux/ar71xx/profiles/buffalo.mk @@ -0,0 +1,17 @@ +# +# Copyright (C) 2009 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +define Profile/WZRHPG300NH + NAME:=Buffalo WZR-HP-G300NH + PACKAGES:=kmod-ath9k hostapd-mini kmod-usb-core kmod-usb-ohci kmod-usb2 +endef + +define Profile/WZRHPG300NH/Description + Package set optimized for the Buffalo WZR-HP-G300NH +endef + +$(eval $(call Profile,WZRHPG300NH)) From 4c2fa4ed06396476898e8abd6201a41842e27584 Mon Sep 17 00:00:00 2001 From: juhosg Date: Fri, 15 Jan 2010 12:11:05 +0000 Subject: [PATCH 020/210] ar71xx: fix typos in the ar71xx.sh git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19151 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/ar71xx/base-files/lib/ar71xx.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index f39d5dc9b..1816bf856 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -100,8 +100,8 @@ ar71xx_board_name() { *WRT400N) name="wrt400n" ;; - *WZR-HP-W300NH) - name="wzr-hp-w300nh" + *WZR-HP-G300NH) + name="wzr-hp-g300nh" ;; *) name="generic" From 6e2911b4f9b43249a3a8783f777e39591d89ef96 Mon Sep 17 00:00:00 2001 From: claudio Date: Fri, 15 Jan 2010 13:30:46 +0000 Subject: [PATCH 021/210] bcm63xx: add gpio leds to alice gate git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19152 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../arch/mips/bcm63xx/boards/board_bcm963xx.c | 49 +++++++++++++++++++ .../asm-mips/mach-bcm63xx/board_bcm963xx.h | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/target/linux/brcm63xx/files/arch/mips/bcm63xx/boards/board_bcm963xx.c b/target/linux/brcm63xx/files/arch/mips/bcm63xx/boards/board_bcm963xx.c index d9c4a20c6..ba5719045 100644 --- a/target/linux/brcm63xx/files/arch/mips/bcm63xx/boards/board_bcm963xx.c +++ b/target/linux/brcm63xx/files/arch/mips/bcm63xx/boards/board_bcm963xx.c @@ -559,6 +559,55 @@ static struct board_info __initdata board_AGPFS0 = { .has_ohci0 = 1, .has_ehci0 = 1, + + .leds = { + /*Each led on alice gate is bi-color so final char */ + /* is r for red and g for green leds */ + { + .name = "pwrr", + .gpio = 5, + .active_low = 1, + }, + { + .name = "pwrg", + .gpio = 4, + .active_low = 1, + .default_trigger = "default-on", + }, + { + .name = "wifir", + .gpio = 23, + .active_low = 1, + }, + { + .name = "wifig", + .gpio = 22, + .active_low = 1, + }, + { + .name = "usr1r", + .gpio = 27, + .active_low = 1, + }, + { + .name = "usr1g", + .gpio = 26, + .active_low = 1, + }, + { + .name = "usr2r", + .gpio = 30, + .active_low = 1, + }, + { + .name = "usr2g", + .gpio = 29, + .active_low = 1, + }, + }, + + .reset_btn = 37; /* sw2 */ + /* sw1 is connected to gpio34*/ }; static struct board_info __initdata board_DWVS0 = { diff --git a/target/linux/brcm63xx/files/include/asm-mips/mach-bcm63xx/board_bcm963xx.h b/target/linux/brcm63xx/files/include/asm-mips/mach-bcm63xx/board_bcm963xx.h index e07a07c88..0482c6954 100644 --- a/target/linux/brcm63xx/files/include/asm-mips/mach-bcm63xx/board_bcm963xx.h +++ b/target/linux/brcm63xx/files/include/asm-mips/mach-bcm63xx/board_bcm963xx.h @@ -55,7 +55,7 @@ struct board_info { struct bcm63xx_dsp_platform_data dsp; /* GPIO LEDs */ - struct gpio_led leds[5]; + struct gpio_led leds[8]; /* Reset button */ unsigned int reset_btn; From f3a35a3d8bcbff93e4d2536d45217263b8f7f9e0 Mon Sep 17 00:00:00 2001 From: claudio Date: Fri, 15 Jan 2010 13:40:18 +0000 Subject: [PATCH 022/210] etrax: fix detection of samsung flash chip (#6155) git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19153 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/etrax/patches-2.6.30/200-samsung_flash.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/etrax/patches-2.6.30/200-samsung_flash.patch b/target/linux/etrax/patches-2.6.30/200-samsung_flash.patch index ef4f8e57d..4176ec395 100644 --- a/target/linux/etrax/patches-2.6.30/200-samsung_flash.patch +++ b/target/linux/etrax/patches-2.6.30/200-samsung_flash.patch @@ -5,7 +5,7 @@ cfi_fixup_major_minor(cfi, extp); - if (extp->MajorVersion != '1' || -+ if (extp->MajorVersion < '1' || extp->MajorVersion > '3' || ++ if (extp->MajorVersion < '0' || extp->MajorVersion > '3' || (extp->MinorVersion < '0' || extp->MinorVersion > '4')) { if (cfi->mfr == MANUFACTURER_SAMSUNG && (extp->MajorVersion == '3' && extp->MinorVersion == '3')) { From f0e79d4172c0bedda3db145812c269856321bfd0 Mon Sep 17 00:00:00 2001 From: nbd Date: Fri, 15 Jan 2010 23:12:21 +0000 Subject: [PATCH 023/210] ath9k: add a workaround for the tx ack time issue triggered by the timing handling cleanups in 2.4 ghz, calculating the ack timeout the way it is described in 802.11-2007 currently leads to tx timeouts set it to a minimum of what the initvals set (64 usec) until we know what is causing this git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19156 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../patches/580-ath9k_ack_timeout_workaround.patch | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 package/mac80211/patches/580-ath9k_ack_timeout_workaround.patch diff --git a/package/mac80211/patches/580-ath9k_ack_timeout_workaround.patch b/package/mac80211/patches/580-ath9k_ack_timeout_workaround.patch new file mode 100644 index 000000000..953c07af6 --- /dev/null +++ b/package/mac80211/patches/580-ath9k_ack_timeout_workaround.patch @@ -0,0 +1,14 @@ +--- a/drivers/net/wireless/ath/ath9k/hw.c ++++ b/drivers/net/wireless/ath/ath9k/hw.c +@@ -1229,6 +1229,11 @@ void ath9k_hw_init_global_settings(struc + /* As defined by IEEE 802.11-2007 17.3.8.6 */ + slottime = ah->slottime + 3 * ah->coverage_class; + acktimeout = slottime + sifstime; ++ ++ /* Workaround for a hw issue */ ++ if (conf->channel && conf->channel->band == IEEE80211_BAND_2GHZ) ++ acktimeout = max(64, acktimeout); ++ + ath9k_hw_setslottime(ah, slottime); + ath9k_hw_set_ack_timeout(ah, acktimeout); + ath9k_hw_set_cts_timeout(ah, acktimeout); From efe8a21694715de2a94a3dc890730f9d69d31190 Mon Sep 17 00:00:00 2001 From: nbd Date: Sat, 16 Jan 2010 00:11:38 +0000 Subject: [PATCH 024/210] libuuid: only build the static variant - fixes compile on mac os x git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19157 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- tools/libuuid/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/libuuid/Makefile b/tools/libuuid/Makefile index 4e6602e48..f15a87a93 100644 --- a/tools/libuuid/Makefile +++ b/tools/libuuid/Makefile @@ -32,18 +32,18 @@ define Host/Configure endef define Host/Compile - $(MAKE) -C $(HOST_BUILD_DIR)/lib/uuid + $(MAKE) -C $(HOST_BUILD_DIR)/lib/uuid libuuid.a endef define Host/Install $(INSTALL_DIR) $(STAGING_DIR_HOST)/{lib,include/uuid} $(CP) $(HOST_BUILD_DIR)/lib/uuid/uuid.h $(STAGING_DIR_HOST)/include/uuid/ - $(CP) $(HOST_BUILD_DIR)/lib/uuid/libuuid.{so*,a} $(STAGING_DIR_HOST)/lib/ + $(CP) $(HOST_BUILD_DIR)/lib/uuid/libuuid.a $(STAGING_DIR_HOST)/lib/ endef define Host/Clean rm -f $(STAGING_DIR_HOST)/include/uuid/uuid.h - rm -f $(STAGING_DIR_HOST)/lib/uuid/libuuid.{so*,a} + rm -f $(STAGING_DIR_HOST)/lib/uuid/libuuid.* $(call Host/Clean/Default) endef From ac99782d2245327973139539118c449d576d90a0 Mon Sep 17 00:00:00 2001 From: nbd Date: Sat, 16 Jan 2010 00:11:43 +0000 Subject: [PATCH 025/210] mtd-utils: fix compile on mac os x git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19158 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- tools/mtd-utils/Makefile | 2 +- tools/mtd-utils/include/fls.h | 2 + tools/mtd-utils/include/linux/types.h | 18 ++++ tools/mtd-utils/patches/110-portability.patch | 100 ++++++++++++++++++ 4 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 tools/mtd-utils/include/fls.h create mode 100644 tools/mtd-utils/include/linux/types.h diff --git a/tools/mtd-utils/Makefile b/tools/mtd-utils/Makefile index 8938614e7..45a61ab3c 100644 --- a/tools/mtd-utils/Makefile +++ b/tools/mtd-utils/Makefile @@ -23,7 +23,7 @@ include $(INCLUDE_DIR)/host-build.mk CFLAGS := $(HOST_CFLAGS) -I$(HOST_BUILD_DIR)/include -L$(HOST_BUILD_DIR) -L$(STAGING_DIR_HOST)/lib ifneq ($(HOST_OS),Linux) -CFLAGS += -Dloff_t=off_t -D__BYTE_ORDER=BYTE_ORDER -include getline.h -include endian.h +CFLAGS += -Dloff_t=off_t -D__BYTE_ORDER=BYTE_ORDER -include getline.h -include endian.h -I$(CURDIR)/include -include fls.h endif MTD_MAKEOPTS = \ diff --git a/tools/mtd-utils/include/fls.h b/tools/mtd-utils/include/fls.h new file mode 100644 index 000000000..7514253cc --- /dev/null +++ b/tools/mtd-utils/include/fls.h @@ -0,0 +1,2 @@ +#include +#define fls local_fls diff --git a/tools/mtd-utils/include/linux/types.h b/tools/mtd-utils/include/linux/types.h new file mode 100644 index 000000000..559fac7a2 --- /dev/null +++ b/tools/mtd-utils/include/linux/types.h @@ -0,0 +1,18 @@ +#ifndef _LINUX_TYPES_H +#define _LINUX_TYPES_H + +#include + +typedef uint16_t __u16; +typedef uint32_t __u32; +typedef uint64_t __u64; + +typedef __u16 __le16; +typedef __u32 __le32; +typedef __u64 __le64; +typedef __u64 off64_t; + +typedef __u16 __sum16; +typedef __u32 __wsum; + +#endif /* _LINUX_TYPES_H */ diff --git a/tools/mtd-utils/patches/110-portability.patch b/tools/mtd-utils/patches/110-portability.patch index 4ef27d1f7..3d0037c90 100644 --- a/tools/mtd-utils/patches/110-portability.patch +++ b/tools/mtd-utils/patches/110-portability.patch @@ -58,3 +58,103 @@ /* The version of UBI images supported by this implementation */ #define UBI_VERSION 1 +--- a/mkfs.ubifs/mkfs.ubifs.h ++++ b/mkfs.ubifs/mkfs.ubifs.h +@@ -34,7 +34,14 @@ + #include + #include + #include ++#ifdef __linux__ + #include ++#else ++# ifndef O_LARGEFILE ++# define O_LARGEFILE 0 ++# endif ++# define llseek lseek ++#endif + + #include + #include +--- a/mkfs.ubifs/mkfs.ubifs.c ++++ b/mkfs.ubifs/mkfs.ubifs.c +@@ -773,8 +773,8 @@ int write_leb(int lnum, int len, void *b + if (ubi_leb_change_start(ubi, out_fd, lnum, c->leb_size, dtype)) + return sys_err_msg("ubi_leb_change_start failed"); + +- if (lseek64(out_fd, pos, SEEK_SET) != pos) +- return sys_err_msg("lseek64 failed seeking %lld", ++ if (llseek(out_fd, pos, SEEK_SET) != pos) ++ return sys_err_msg("llseek failed seeking %lld", + (long long)pos); + + if (write(out_fd, buf, c->leb_size) != c->leb_size) +@@ -1029,6 +1029,7 @@ static int add_inode_with_data(struct st + + if (c->default_compr != UBIFS_COMPR_NONE) + use_flags |= UBIFS_COMPR_FL; ++#ifdef __linux__ + if (flags & FS_COMPR_FL) + use_flags |= UBIFS_COMPR_FL; + if (flags & FS_SYNC_FL) +@@ -1039,6 +1040,7 @@ static int add_inode_with_data(struct st + use_flags |= UBIFS_APPEND_FL; + if (flags & FS_DIRSYNC_FL && S_ISDIR(st->st_mode)) + use_flags |= UBIFS_DIRSYNC_FL; ++#endif + + memset(ino, 0, UBIFS_INO_NODE_SZ); + +@@ -1108,7 +1110,9 @@ static int add_dir_inode(DIR *dir, ino_t + fd = dirfd(dir); + if (fd == -1) + return sys_err_msg("dirfd failed"); ++#ifdef __linux__ + if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1) ++#endif + flags = 0; + } + +@@ -1293,10 +1297,12 @@ static int add_file(const char *path_nam + key_write(&key, &dn->key); + dn->size = cpu_to_le32(bytes_read); + out_len = NODE_BUFFER_SIZE - UBIFS_DATA_NODE_SZ; ++#ifdef __linux__ + if (c->default_compr == UBIFS_COMPR_NONE && + (flags & FS_COMPR_FL)) + use_compr = UBIFS_COMPR_LZO; + else ++#endif + use_compr = c->default_compr; + compr_type = compress_data(buf, bytes_read, &dn->data, + &out_len, use_compr); +@@ -1338,7 +1344,9 @@ static int add_non_dir(const char *path_ + if (fd == -1) + return sys_err_msg("failed to open file '%s'", + path_name); ++#ifdef __linux__ + if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1) ++#endif + flags = 0; + if (close(fd) == -1) + return sys_err_msg("failed to close file '%s'", +--- a/mkfs.ubifs/devtable.c ++++ b/mkfs.ubifs/devtable.c +@@ -134,6 +134,7 @@ static int interpret_table_entry(const c + unsigned int mode = 0755, uid = 0, gid = 0, major = 0, minor = 0; + unsigned int start = 0, increment = 0, count = 0; + ++ buf[1023] = 0; + if (sscanf(line, "%1023s %c %o %u %u %u %u %u %u %u", + buf, &type, &mode, &uid, &gid, &major, &minor, + &start, &increment, &count) < 0) +@@ -144,8 +145,8 @@ static int interpret_table_entry(const c + buf, type, mode, uid, gid, major, minor, start, + increment, count); + +- len = strnlen(buf, 1024); +- if (len == 1024) ++ len = strlen(buf); ++ if (len == 1023) + return err_msg("too long path"); + + if (!strcmp(buf, "/")) From 2da653df8953b2d534136abb873da247c2ea55d3 Mon Sep 17 00:00:00 2001 From: nbd Date: Sat, 16 Jan 2010 00:11:47 +0000 Subject: [PATCH 026/210] mtd-utils: refresh the cygwin_fixes patch git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19159 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../mtd-utils/patches/120-cygwin_fixes.patch | 57 ++++++++----------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/tools/mtd-utils/patches/120-cygwin_fixes.patch b/tools/mtd-utils/patches/120-cygwin_fixes.patch index ac8bcf32d..61a6d5ef2 100644 --- a/tools/mtd-utils/patches/120-cygwin_fixes.patch +++ b/tools/mtd-utils/patches/120-cygwin_fixes.patch @@ -1,7 +1,6 @@ -diff -urN mtd-20090505/Makefile mtd-20090505.new/Makefile ---- mtd-20090505/Makefile 2009-06-05 16:59:08.000000000 +0200 -+++ mtd-20090505.new/Makefile 2010-01-05 11:11:24.000000000 +0100 -@@ -7,6 +7,11 @@ +--- a/Makefile ++++ b/Makefile +@@ -7,6 +7,11 @@ ifeq ($(WITHOUT_XATTR), 1) CPPFLAGS += -DWITHOUT_XATTR endif @@ -13,7 +12,7 @@ diff -urN mtd-20090505/Makefile mtd-20090505.new/Makefile SUBDIRS = ubi-utils mkfs.ubifs TARGETS = ftl_format flash_erase flash_eraseall nanddump doc_loadbios \ -@@ -17,6 +22,10 @@ +@@ -17,6 +22,10 @@ TARGETS = ftl_format flash_erase flash_e rfddump rfdformat \ serve_image recv_image \ sumtool #jffs2reader @@ -24,9 +23,8 @@ diff -urN mtd-20090505/Makefile mtd-20090505.new/Makefile SYMLINKS = -diff -urN mtd-20090505/include/cygwin/bits-byteswap.h mtd-20090505.new/include/cygwin/bits-byteswap.h ---- mtd-20090505/include/cygwin/bits-byteswap.h 1970-01-01 01:00:00.000000000 +0100 -+++ mtd-20090505.new/include/cygwin/bits-byteswap.h 2010-01-05 11:09:45.000000000 +0100 +--- /dev/null ++++ b/include/cygwin/bits-byteswap.h @@ -0,0 +1,132 @@ +/* Macros to swap the order of bytes in integer values. + Copyright (C) 1997, 1998, 2000, 2002 Free Software Foundation, Inc. @@ -160,9 +158,8 @@ diff -urN mtd-20090505/include/cygwin/bits-byteswap.h mtd-20090505.new/include/c +#endif + +#endif /* _BITS_BYTESWAP_H */ -diff -urN mtd-20090505/include/cygwin/byteswap.h mtd-20090505.new/include/cygwin/byteswap.h ---- mtd-20090505/include/cygwin/byteswap.h 1970-01-01 01:00:00.000000000 +0100 -+++ mtd-20090505.new/include/cygwin/byteswap.h 2010-01-05 11:09:45.000000000 +0100 +--- /dev/null ++++ b/include/cygwin/byteswap.h @@ -0,0 +1,40 @@ +/* Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. @@ -204,9 +201,8 @@ diff -urN mtd-20090505/include/cygwin/byteswap.h mtd-20090505.new/include/cygwin +#endif + +#endif /* byteswap.h */ -diff -urN mtd-20090505/include/cygwin/endian.h mtd-20090505.new/include/cygwin/endian.h ---- mtd-20090505/include/cygwin/endian.h 1970-01-01 01:00:00.000000000 +0100 -+++ mtd-20090505.new/include/cygwin/endian.h 2010-01-05 11:43:10.000000000 +0100 +--- /dev/null ++++ b/include/cygwin/endian.h @@ -0,0 +1,26 @@ +#ifndef _CYGENDIAN_H_ +#define _CYGENDIAN_H_ @@ -234,9 +230,8 @@ diff -urN mtd-20090505/include/cygwin/endian.h mtd-20090505.new/include/cygwin/e +#endif /* __CYGWIN__ */ + +#endif /* _CYGENDIAN_H_ */ -diff -urN mtd-20090505/include/cygwin/ioctl.h mtd-20090505.new/include/cygwin/ioctl.h ---- mtd-20090505/include/cygwin/ioctl.h 1970-01-01 01:00:00.000000000 +0100 -+++ mtd-20090505.new/include/cygwin/ioctl.h 2010-01-05 11:09:45.000000000 +0100 +--- /dev/null ++++ b/include/cygwin/ioctl.h @@ -0,0 +1,38 @@ +#ifndef _CYGIOCTL_H_ +#define _CYGIOCTL_H_ @@ -276,9 +271,8 @@ diff -urN mtd-20090505/include/cygwin/ioctl.h mtd-20090505.new/include/cygwin/io +#endif /* __CYGWIN__ */ + +#endif /* _CYGIOCTL_H_ */ -diff -urN mtd-20090505/include/cygwin/pread.c mtd-20090505.new/include/cygwin/pread.c ---- mtd-20090505/include/cygwin/pread.c 1970-01-01 01:00:00.000000000 +0100 -+++ mtd-20090505.new/include/cygwin/pread.c 2010-01-05 11:09:45.000000000 +0100 +--- /dev/null ++++ b/include/cygwin/pread.c @@ -0,0 +1,41 @@ +#ifdef __CYGWIN__ + @@ -321,9 +315,8 @@ diff -urN mtd-20090505/include/cygwin/pread.c mtd-20090505.new/include/cygwin/pr +} + +#endif /* __CYGWIN__ */ -diff -urN mtd-20090505/lnconf.sh mtd-20090505.new/lnconf.sh ---- mtd-20090505/lnconf.sh 1970-01-01 01:00:00.000000000 +0100 -+++ mtd-20090505.new/lnconf.sh 2010-01-05 11:09:45.000000000 +0100 +--- /dev/null ++++ b/lnconf.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# @@ -378,9 +371,8 @@ diff -urN mtd-20090505/lnconf.sh mtd-20090505.new/lnconf.sh + +lndir "$tdir" + -diff -urN mtd-20090505/mkfs.jffs2.c mtd-20090505.new/mkfs.jffs2.c ---- mtd-20090505/mkfs.jffs2.c 2009-06-05 16:59:08.000000000 +0200 -+++ mtd-20090505.new/mkfs.jffs2.c 2010-01-05 11:25:52.000000000 +0100 +--- a/mkfs.jffs2.c ++++ b/mkfs.jffs2.c @@ -75,6 +75,14 @@ #include "crc32.h" #include "rbtree.h" @@ -396,7 +388,7 @@ diff -urN mtd-20090505/mkfs.jffs2.c mtd-20090505.new/mkfs.jffs2.c /* Do not use the weird XPG version of basename */ #undef basename -@@ -474,7 +482,7 @@ +@@ -474,7 +482,7 @@ static struct filesystem_entry *recursiv the following macros use it if available or use a hacky workaround... */ @@ -405,7 +397,7 @@ diff -urN mtd-20090505/mkfs.jffs2.c mtd-20090505.new/mkfs.jffs2.c #define SCANF_PREFIX "a" #define SCANF_STRING(s) (&s) #define GETCWD_SIZE 0 -@@ -557,6 +565,14 @@ +@@ -557,6 +565,14 @@ static int interpret_table_entry(struct } entry = find_filesystem_entry(root, name, mode); if (entry) { @@ -420,7 +412,7 @@ diff -urN mtd-20090505/mkfs.jffs2.c mtd-20090505.new/mkfs.jffs2.c /* Ok, we just need to fixup the existing entry * and we will be all done... */ entry->sb.st_uid = uid; -@@ -566,11 +582,21 @@ +@@ -566,11 +582,21 @@ static int interpret_table_entry(struct entry->sb.st_rdev = makedev(major, minor); } } else { @@ -443,7 +435,7 @@ diff -urN mtd-20090505/mkfs.jffs2.c mtd-20090505.new/mkfs.jffs2.c free(tmp); if (parent == NULL) { error_msg ("skipping device_table entry '%s': no parent directory!", name); -@@ -584,6 +610,7 @@ +@@ -584,6 +610,7 @@ static int interpret_table_entry(struct add_host_filesystem_entry(name, hostpath, uid, gid, mode, 0, parent); break; case 'f': @@ -451,9 +443,8 @@ diff -urN mtd-20090505/mkfs.jffs2.c mtd-20090505.new/mkfs.jffs2.c add_host_filesystem_entry(name, hostpath, uid, gid, mode, 0, parent); break; case 'p': -diff -urN mtd-20090505/ubi-utils/src/libubi.c mtd-20090505.new/ubi-utils/src/libubi.c ---- mtd-20090505/ubi-utils/src/libubi.c 2009-06-05 16:59:08.000000000 +0200 -+++ mtd-20090505.new/ubi-utils/src/libubi.c 2010-01-05 11:46:24.000000000 +0100 +--- a/ubi-utils/src/libubi.c ++++ b/ubi-utils/src/libubi.c @@ -30,6 +30,9 @@ #include #include From c3204b544a9c7009d0148a8c2a2e4c7eb7ed35ee Mon Sep 17 00:00:00 2001 From: cshore Date: Sat, 16 Jan 2010 03:13:56 +0000 Subject: [PATCH 027/210] Fix typo in AGPF_S0 reset button definition git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19160 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../brcm63xx/files/arch/mips/bcm63xx/boards/board_bcm963xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/brcm63xx/files/arch/mips/bcm63xx/boards/board_bcm963xx.c b/target/linux/brcm63xx/files/arch/mips/bcm63xx/boards/board_bcm963xx.c index ba5719045..d2ecc8486 100644 --- a/target/linux/brcm63xx/files/arch/mips/bcm63xx/boards/board_bcm963xx.c +++ b/target/linux/brcm63xx/files/arch/mips/bcm63xx/boards/board_bcm963xx.c @@ -606,7 +606,7 @@ static struct board_info __initdata board_AGPFS0 = { }, }, - .reset_btn = 37; /* sw2 */ + .reset_btn = 37, /* sw2 */ /* sw1 is connected to gpio34*/ }; From 3e2d3da760137386b4051b13125e36d25de5aff5 Mon Sep 17 00:00:00 2001 From: jow Date: Sat, 16 Jan 2010 13:36:27 +0000 Subject: [PATCH 028/210] [orion] add sysupgrade support for the Netgear WNR854T and Linksys WRT350N v2 - thanks Matthias Buecher git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19166 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../orion/base-files/lib/upgrade/platform.sh | 23 ++++++++++++++ .../patches/100-openwrt_partition_map.patch | 31 ++++++++++++------- .../patches/101-wnr854t_partition_map.patch | 13 ++++++++ 3 files changed, 55 insertions(+), 12 deletions(-) create mode 100644 target/linux/orion/base-files/lib/upgrade/platform.sh create mode 100644 target/linux/orion/patches/101-wnr854t_partition_map.patch diff --git a/target/linux/orion/base-files/lib/upgrade/platform.sh b/target/linux/orion/base-files/lib/upgrade/platform.sh new file mode 100644 index 000000000..def241d4b --- /dev/null +++ b/target/linux/orion/base-files/lib/upgrade/platform.sh @@ -0,0 +1,23 @@ +# use default "image" for PART_NAME +# use default for platform_do_upgrade() + +platform_check_image() { + [ "${ARGC}" -gt 1 ] && { echo 'Too many arguments. Only flash file expected.'; return 1; } + + local hardware=`sed -n /Hardware/s/.*:.//p /proc/cpuinfo` + local magic="$(get_magic_word "$1")" + + case "${hardware}" in + # hardware with padded uImage + padded rootfs + 'Netgear WNR854T' | 'Linksys WRT350N v2') + [ "${magic}" != '2705' ] && { + echo "Invalid image type ${magic}." + return 1 + } + return 0 + ;; + esac + + echo "Sysupgrade is not yet supported on ${hardware}." + return 1 +} diff --git a/target/linux/orion/patches/100-openwrt_partition_map.patch b/target/linux/orion/patches/100-openwrt_partition_map.patch index 1fd4652b0..bef4a54e8 100644 --- a/target/linux/orion/patches/100-openwrt_partition_map.patch +++ b/target/linux/orion/patches/100-openwrt_partition_map.patch @@ -1,25 +1,32 @@ --- a/arch/arm/mach-orion5x/wrt350n-v2-setup.c +++ b/arch/arm/mach-orion5x/wrt350n-v2-setup.c -@@ -58,19 +58,11 @@ static struct mtd_partition wrt350n_v2_n +@@ -58,11 +58,11 @@ static struct mtd_partition wrt350n_v2_nor_flash_partitions { .name = "kernel", .offset = 0x00000000, - .size = 0x00760000, -+ .size = 0x00100000, ++ .size = 0x00100000, // change to kernel mtd size here (1/3) }, { .name = "rootfs", - .offset = 0x001a0000, ++ .offset = 0x00100000, // change to kernel mtd size here (2/3) - .size = 0x005c0000, -- }, { -- .name = "lang", -- .offset = 0x00760000, -- .size = 0x00040000, -- }, { -- .name = "nvram", -- .offset = 0x007a0000, -- .size = 0x00020000, -+ .offset = 0x00100000, -+ .size = 0x00650000, ++ .size = 0x00650000, // adopt to kernel mtd size here (3/3) = 0x00750000 - }, { + .name = "lang", + .offset = 0x00760000, +@@ -75,6 +79,14 @@ static struct mtd_partition wrt350n_v2_nor_flash_partitions .name = "u-boot", .offset = 0x007c0000, + .size = 0x00040000, ++ }, { ++ .name = "eRcOmM_do_not_touch", ++ .offset = 0x00750000, ++ .size = 0x00010000, // erasesize ++ }, { ++ .name = "image", // for sysupgrade ++ .offset = 0x00000000, ++ .size = 0x00750000, + }, + }; + diff --git a/target/linux/orion/patches/101-wnr854t_partition_map.patch b/target/linux/orion/patches/101-wnr854t_partition_map.patch new file mode 100644 index 000000000..4e96038ed --- /dev/null +++ b/target/linux/orion/patches/101-wnr854t_partition_map.patch @@ -0,0 +1,13 @@ +--- a/arch/arm/mach-orion5x/wnr854t-setup.c ++++ b/arch/arm/mach-orion5x/wnr854t-setup.c +@@ -67,6 +67,10 @@ static struct mtd_partition wnr854t_nor_flash_partitions + .name = "uboot", + .offset = 0x00760000, + .size = 0x00040000, ++ }, { ++ .name = "image", // for sysupgrade ++ .offset = 0x00000000, ++ .size = 0x00760000, + }, + }; + From 89a382a252649c78cb9fa9246818549a0a29143f Mon Sep 17 00:00:00 2001 From: jow Date: Sat, 16 Jan 2010 13:39:13 +0000 Subject: [PATCH 029/210] [package] base-files: sysupgade library coomon.sh has "bug" in glibc enviorement. For some reason ld-linux.so.3 is not installed at ramfs and sysupgrade always fails. Signed-off-by: Zintis Petersons git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19167 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/Makefile | 2 +- package/base-files/files/lib/upgrade/common.sh | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/package/base-files/Makefile b/package/base-files/Makefile index 67837120b..ea2b5a47f 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=base-files -PKG_RELEASE:=34 +PKG_RELEASE:=35 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh index ff3012bcc..3beb6484d 100644 --- a/package/base-files/files/lib/upgrade/common.sh +++ b/package/base-files/files/lib/upgrade/common.sh @@ -21,6 +21,9 @@ install_bin() { # [ ... ] files=$1 [ -x "$src" ] && files="$src $(libs $src)" install_file $files + [ -e /lib/ld-linux.so.3 ] && { + install_file /lib/ld-linux.so.3 + } shift for link in "$@"; do { dest="$RAM_ROOT/$link" From 936e9b5f26b3790589f58615cd782a1acbb3d1a3 Mon Sep 17 00:00:00 2001 From: jow Date: Sat, 16 Jan 2010 15:11:52 +0000 Subject: [PATCH 030/210] [brcm-2.4] fix serial flash support (#6442) git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19171 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../arch/mips/bcm947xx/include/bcmutils.h | 589 ++++++++++++++ .../files/arch/mips/bcm947xx/sflash.c | 508 ++++++++++++ .../files/drivers/mtd/devices/sflash.c | 729 ++++++------------ target/linux/brcm-2.4/patches/004-flash.patch | 10 + 4 files changed, 1358 insertions(+), 478 deletions(-) create mode 100644 target/linux/brcm-2.4/files/arch/mips/bcm947xx/include/bcmutils.h create mode 100644 target/linux/brcm-2.4/files/arch/mips/bcm947xx/sflash.c diff --git a/target/linux/brcm-2.4/files/arch/mips/bcm947xx/include/bcmutils.h b/target/linux/brcm-2.4/files/arch/mips/bcm947xx/include/bcmutils.h new file mode 100644 index 000000000..4c4986ce6 --- /dev/null +++ b/target/linux/brcm-2.4/files/arch/mips/bcm947xx/include/bcmutils.h @@ -0,0 +1,589 @@ +/* + * Misc useful os-independent macros and functions. + * + * Copyright 2007, Broadcom Corporation + * All Rights Reserved. + * + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. + * $Id$ + */ + +#ifndef _bcmutils_h_ +#define _bcmutils_h_ + +/* ctype replacement */ +#define _BCM_U 0x01 /* upper */ +#define _BCM_L 0x02 /* lower */ +#define _BCM_D 0x04 /* digit */ +#define _BCM_C 0x08 /* cntrl */ +#define _BCM_P 0x10 /* punct */ +#define _BCM_S 0x20 /* white space (space/lf/tab) */ +#define _BCM_X 0x40 /* hex digit */ +#define _BCM_SP 0x80 /* hard space (0x20) */ + +extern const unsigned char bcm_ctype[]; +#define bcm_ismask(x) (bcm_ctype[(int)(unsigned char)(x)]) + +#define bcm_isalnum(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L|_BCM_D)) != 0) +#define bcm_isalpha(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L)) != 0) +#define bcm_iscntrl(c) ((bcm_ismask(c)&(_BCM_C)) != 0) +#define bcm_isdigit(c) ((bcm_ismask(c)&(_BCM_D)) != 0) +#define bcm_isgraph(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D)) != 0) +#define bcm_islower(c) ((bcm_ismask(c)&(_BCM_L)) != 0) +#define bcm_isprint(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D|_BCM_SP)) != 0) +#define bcm_ispunct(c) ((bcm_ismask(c)&(_BCM_P)) != 0) +#define bcm_isspace(c) ((bcm_ismask(c)&(_BCM_S)) != 0) +#define bcm_isupper(c) ((bcm_ismask(c)&(_BCM_U)) != 0) +#define bcm_isxdigit(c) ((bcm_ismask(c)&(_BCM_D|_BCM_X)) != 0) +#define bcm_tolower(c) (bcm_isupper((c)) ? ((c) + 'a' - 'A') : (c)) +#define bcm_toupper(c) (bcm_islower((c)) ? ((c) + 'A' - 'a') : (c)) + +/* Buffer structure for collecting string-formatted data +* using bcm_bprintf() API. +* Use bcm_binit() to initialize before use +*/ + +struct bcmstrbuf { + char *buf; /* pointer to current position in origbuf */ + unsigned int size; /* current (residual) size in bytes */ + char *origbuf; /* unmodified pointer to orignal buffer */ + unsigned int origsize; /* unmodified orignal buffer size in bytes */ +}; + +/* ** driver-only section ** */ +#ifdef BCMDRIVER +#include + +#define GPIO_PIN_NOTDEFINED 0x20 /* Pin not defined */ + +/* + * Spin at most 'us' microseconds while 'exp' is true. + * Caller should explicitly test 'exp' when this completes + * and take appropriate error action if 'exp' is still true. + */ +#define SPINWAIT(exp, us) { \ + uint countdown = (us) + 9; \ + while ((exp) && (countdown >= 10)) {\ + OSL_DELAY(10); \ + countdown -= 10; \ + } \ +} + + +/* osl multi-precedence packet queue */ +#ifndef PKTQ_LEN_DEFAULT +#define PKTQ_LEN_DEFAULT 128 /* Max 128 packets */ +#endif +#ifndef PKTQ_MAX_PREC +#define PKTQ_MAX_PREC 16 /* Maximum precedence levels */ +#endif + +typedef struct pktq_prec { + void *head; /* first packet to dequeue */ + void *tail; /* last packet to dequeue */ + uint16 len; /* number of queued packets */ + uint16 max; /* maximum number of queued packets */ +} pktq_prec_t; + + +/* multi-priority pkt queue */ +struct pktq { + uint16 num_prec; /* number of precedences in use */ + uint16 hi_prec; /* rapid dequeue hint (>= highest non-empty prec) */ + uint16 max; /* total max packets */ + uint16 len; /* total number of packets */ + /* q array must be last since # of elements can be either PKTQ_MAX_PREC or 1 */ + struct pktq_prec q[PKTQ_MAX_PREC]; +}; + +/* simple, non-priority pkt queue */ +struct spktq { + uint16 num_prec; /* number of precedences in use (always 1) */ + uint16 hi_prec; /* rapid dequeue hint (>= highest non-empty prec) */ + uint16 max; /* total max packets */ + uint16 len; /* total number of packets */ + /* q array must be last since # of elements can be either PKTQ_MAX_PREC or 1 */ + struct pktq_prec q[1]; +}; + +#define PKTQ_PREC_ITER(pq, prec) for (prec = (pq)->num_prec - 1; prec >= 0; prec--) + +/* forward definition of ether_addr structure used by some function prototypes */ + +struct ether_addr; + +/* operations on a specific precedence in packet queue */ + +#define pktq_psetmax(pq, prec, _max) ((pq)->q[prec].max = (_max)) +#define pktq_plen(pq, prec) ((pq)->q[prec].len) +#define pktq_pavail(pq, prec) ((pq)->q[prec].max - (pq)->q[prec].len) +#define pktq_pfull(pq, prec) ((pq)->q[prec].len >= (pq)->q[prec].max) +#define pktq_pempty(pq, prec) ((pq)->q[prec].len == 0) + +#define pktq_ppeek(pq, prec) ((pq)->q[prec].head) +#define pktq_ppeek_tail(pq, prec) ((pq)->q[prec].tail) + +extern void *pktq_penq(struct pktq *pq, int prec, void *p); +extern void *pktq_penq_head(struct pktq *pq, int prec, void *p); +extern void *pktq_pdeq(struct pktq *pq, int prec); +extern void *pktq_pdeq_tail(struct pktq *pq, int prec); +/* Empty the queue at particular precedence level */ +extern void pktq_pflush(osl_t *osh, struct pktq *pq, int prec, bool dir); +/* Remove a specified packet from its queue */ +extern bool pktq_pdel(struct pktq *pq, void *p, int prec); + +/* operations on a set of precedences in packet queue */ + +extern int pktq_mlen(struct pktq *pq, uint prec_bmp); +extern void *pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out); + +/* operations on packet queue as a whole */ + +#define pktq_len(pq) ((int)(pq)->len) +#define pktq_max(pq) ((int)(pq)->max) +#define pktq_avail(pq) ((int)((pq)->max - (pq)->len)) +#define pktq_full(pq) ((pq)->len >= (pq)->max) +#define pktq_empty(pq) ((pq)->len == 0) + +/* operations for single precedence queues */ +#define pktenq(pq, p) pktq_penq(((struct pktq *)pq), 0, (p)) +#define pktenq_head(pq, p) pktq_penq_head(((struct pktq *)pq), 0, (p)) +#define pktdeq(pq) pktq_pdeq(((struct pktq *)pq), 0) +#define pktdeq_tail(pq) pktq_pdeq_tail(((struct pktq *)pq), 0) +#define pktqinit(pq, len) pktq_init(((struct pktq *)pq), 1, len) + +extern void pktq_init(struct pktq *pq, int num_prec, int max_len); +/* prec_out may be NULL if caller is not interested in return value */ +extern void *pktq_deq(struct pktq *pq, int *prec_out); +extern void *pktq_deq_tail(struct pktq *pq, int *prec_out); +extern void *pktq_peek(struct pktq *pq, int *prec_out); +extern void *pktq_peek_tail(struct pktq *pq, int *prec_out); +extern void pktq_flush(osl_t *osh, struct pktq *pq, bool dir); /* Empty the entire queue */ +extern int pktq_setmax(struct pktq *pq, int max_len); + +/* externs */ +/* packet */ +extern uint pktcopy(osl_t *osh, void *p, uint offset, int len, uchar *buf); +extern uint pkttotlen(osl_t *osh, void *p); +extern void *pktlast(osl_t *osh, void *p); + +/* Get priority from a packet and pass it back in scb (or equiv) */ +extern uint pktsetprio(void *pkt, bool update_vtag); +#define PKTPRIO_VDSCP 0x100 /* DSCP prio found after VLAN tag */ +#define PKTPRIO_VLAN 0x200 /* VLAN prio found */ +#define PKTPRIO_UPD 0x400 /* DSCP used to update VLAN prio */ +#define PKTPRIO_DSCP 0x800 /* DSCP prio found */ + +/* string */ +extern int BCMROMFN(bcm_atoi)(char *s); +extern ulong BCMROMFN(bcm_strtoul)(char *cp, char **endp, uint base); +extern char *BCMROMFN(bcmstrstr)(char *haystack, char *needle); +extern char *BCMROMFN(bcmstrcat)(char *dest, const char *src); +extern char *BCMROMFN(bcmstrncat)(char *dest, const char *src, uint size); +extern ulong wchar2ascii(char *abuf, ushort *wbuf, ushort wbuflen, ulong abuflen); +/* ethernet address */ +extern char *bcm_ether_ntoa(struct ether_addr *ea, char *buf); +extern int BCMROMFN(bcm_ether_atoe)(char *p, struct ether_addr *ea); + +/* ip address */ +struct ipv4_addr; +extern char *bcm_ip_ntoa(struct ipv4_addr *ia, char *buf); + +/* delay */ +extern void bcm_mdelay(uint ms); +/* variable access */ +extern char *getvar(char *vars, const char *name); +extern int getintvar(char *vars, const char *name); +extern uint getgpiopin(char *vars, char *pin_name, uint def_pin); +#ifdef BCMPERFSTATS +extern void bcm_perf_enable(void); +extern void bcmstats(char *fmt); +extern void bcmlog(char *fmt, uint a1, uint a2); +extern void bcmdumplog(char *buf, int size); +extern int bcmdumplogent(char *buf, uint idx); +#else +#define bcm_perf_enable() +#define bcmstats(fmt) +#define bcmlog(fmt, a1, a2) +#define bcmdumplog(buf, size) *buf = '\0' +#define bcmdumplogent(buf, idx) -1 +#endif /* BCMPERFSTATS */ +extern char *bcm_nvram_vars(uint *length); +extern int bcm_nvram_cache(void *sbh); + +/* Support for sharing code across in-driver iovar implementations. + * The intent is that a driver use this structure to map iovar names + * to its (private) iovar identifiers, and the lookup function to + * find the entry. Macros are provided to map ids and get/set actions + * into a single number space for a switch statement. + */ + +/* iovar structure */ +typedef struct bcm_iovar { + const char *name; /* name for lookup and display */ + uint16 varid; /* id for switch */ + uint16 flags; /* driver-specific flag bits */ + uint16 type; /* base type of argument */ + uint16 minlen; /* min length for buffer vars */ +} bcm_iovar_t; + +/* varid definitions are per-driver, may use these get/set bits */ + +/* IOVar action bits for id mapping */ +#define IOV_GET 0 /* Get an iovar */ +#define IOV_SET 1 /* Set an iovar */ + +/* Varid to actionid mapping */ +#define IOV_GVAL(id) ((id)*2) +#define IOV_SVAL(id) (((id)*2)+IOV_SET) +#define IOV_ISSET(actionid) ((actionid & IOV_SET) == IOV_SET) + +/* flags are per-driver based on driver attributes */ + +extern const bcm_iovar_t *bcm_iovar_lookup(const bcm_iovar_t *table, const char *name); +extern int bcm_iovar_lencheck(const bcm_iovar_t *table, void *arg, int len, bool set); + +#endif /* BCMDRIVER */ + +/* Base type definitions */ +#define IOVT_VOID 0 /* no value (implictly set only) */ +#define IOVT_BOOL 1 /* any value ok (zero/nonzero) */ +#define IOVT_INT8 2 /* integer values are range-checked */ +#define IOVT_UINT8 3 /* unsigned int 8 bits */ +#define IOVT_INT16 4 /* int 16 bits */ +#define IOVT_UINT16 5 /* unsigned int 16 bits */ +#define IOVT_INT32 6 /* int 32 bits */ +#define IOVT_UINT32 7 /* unsigned int 32 bits */ +#define IOVT_BUFFER 8 /* buffer is size-checked as per minlen */ +#define BCM_IOVT_VALID(type) (((unsigned int)(type)) <= IOVT_BUFFER) + +/* Initializer for IOV type strings */ +#define BCM_IOV_TYPE_INIT { \ + "void", \ + "bool", \ + "int8", \ + "uint8", \ + "int16", \ + "uint16", \ + "int32", \ + "uint32", \ + "buffer", \ + "" } + +#define BCM_IOVT_IS_INT(type) (\ + (type == IOVT_BOOL) || \ + (type == IOVT_INT8) || \ + (type == IOVT_UINT8) || \ + (type == IOVT_INT16) || \ + (type == IOVT_UINT16) || \ + (type == IOVT_INT32) || \ + (type == IOVT_UINT32)) + +/* ** driver/apps-shared section ** */ + +#define BCME_STRLEN 64 /* Max string length for BCM errors */ +#define VALID_BCMERROR(e) ((e <= 0) && (e >= BCME_LAST)) + + +/* + * error codes could be added but the defined ones shouldn't be changed/deleted + * these error codes are exposed to the user code + * when ever a new error code is added to this list + * please update errorstring table with the related error string and + * update osl files with os specific errorcode map +*/ + +#define BCME_OK 0 /* Success */ +#define BCME_ERROR -1 /* Error generic */ +#define BCME_BADARG -2 /* Bad Argument */ +#define BCME_BADOPTION -3 /* Bad option */ +#define BCME_NOTUP -4 /* Not up */ +#define BCME_NOTDOWN -5 /* Not down */ +#define BCME_NOTAP -6 /* Not AP */ +#define BCME_NOTSTA -7 /* Not STA */ +#define BCME_BADKEYIDX -8 /* BAD Key Index */ +#define BCME_RADIOOFF -9 /* Radio Off */ +#define BCME_NOTBANDLOCKED -10 /* Not band locked */ +#define BCME_NOCLK -11 /* No Clock */ +#define BCME_BADRATESET -12 /* BAD Rate valueset */ +#define BCME_BADBAND -13 /* BAD Band */ +#define BCME_BUFTOOSHORT -14 /* Buffer too short */ +#define BCME_BUFTOOLONG -15 /* Buffer too long */ +#define BCME_BUSY -16 /* Busy */ +#define BCME_NOTASSOCIATED -17 /* Not Associated */ +#define BCME_BADSSIDLEN -18 /* Bad SSID len */ +#define BCME_OUTOFRANGECHAN -19 /* Out of Range Channel */ +#define BCME_BADCHAN -20 /* Bad Channel */ +#define BCME_BADADDR -21 /* Bad Address */ +#define BCME_NORESOURCE -22 /* Not Enough Resources */ +#define BCME_UNSUPPORTED -23 /* Unsupported */ +#define BCME_BADLEN -24 /* Bad length */ +#define BCME_NOTREADY -25 /* Not Ready */ +#define BCME_EPERM -26 /* Not Permitted */ +#define BCME_NOMEM -27 /* No Memory */ +#define BCME_ASSOCIATED -28 /* Associated */ +#define BCME_RANGE -29 /* Not In Range */ +#define BCME_NOTFOUND -30 /* Not Found */ +#define BCME_WME_NOT_ENABLED -31 /* WME Not Enabled */ +#define BCME_TSPEC_NOTFOUND -32 /* TSPEC Not Found */ +#define BCME_ACM_NOTSUPPORTED -33 /* ACM Not Supported */ +#define BCME_NOT_WME_ASSOCIATION -34 /* Not WME Association */ +#define BCME_SDIO_ERROR -35 /* SDIO Bus Error */ +#define BCME_DONGLE_DOWN -36 /* Dongle Not Accessible */ +#define BCME_VERSION -37 /* Incorrect version */ +#define BCME_LAST BCME_VERSION + +/* These are collection of BCME Error strings */ +#define BCMERRSTRINGTABLE { \ + "OK", \ + "Undefined error", \ + "Bad Argument", \ + "Bad Option", \ + "Not up", \ + "Not down", \ + "Not AP", \ + "Not STA", \ + "Bad Key Index", \ + "Radio Off", \ + "Not band locked", \ + "No clock", \ + "Bad Rate valueset", \ + "Bad Band", \ + "Buffer too short", \ + "Buffer too long", \ + "Busy", \ + "Not Associated", \ + "Bad SSID len", \ + "Out of Range Channel", \ + "Bad Channel", \ + "Bad Address", \ + "Not Enough Resources", \ + "Unsupported", \ + "Bad length", \ + "Not Ready", \ + "Not Permitted", \ + "No Memory", \ + "Associated", \ + "Not In Range", \ + "Not Found", \ + "WME Not Enabled", \ + "TSPEC Not Found", \ + "ACM Not Supported", \ + "Not WME Association", \ + "SDIO Bus Error", \ + "Dongle Not Accessible", \ + "Incorrect version" \ +} + +#ifndef ABS +#define ABS(a) (((a) < 0)?-(a):(a)) +#endif /* ABS */ + +#ifndef MIN +#define MIN(a, b) (((a) < (b))?(a):(b)) +#endif /* MIN */ + +#ifndef MAX +#define MAX(a, b) (((a) > (b))?(a):(b)) +#endif /* MAX */ + +#define CEIL(x, y) (((x) + ((y)-1)) / (y)) +#define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y)) +#define ISALIGNED(a, x) (((a) & ((x)-1)) == 0) +#define ISPOWEROF2(x) ((((x)-1)&(x)) == 0) +#define VALID_MASK(mask) !((mask) & ((mask) + 1)) +#ifndef OFFSETOF +#define OFFSETOF(type, member) ((uint)(uintptr)&((type *)0)->member) +#endif /* OFFSETOF */ +#ifndef ARRAYSIZE +#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) +#endif + +/* bit map related macros */ +#ifndef setbit +#ifndef NBBY /* the BSD family defines NBBY */ +#define NBBY 8 /* 8 bits per byte */ +#endif /* #ifndef NBBY */ +#define setbit(a, i) (((uint8 *)a)[(i)/NBBY] |= 1<<((i)%NBBY)) +#define clrbit(a, i) (((uint8 *)a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) +#define isset(a, i) (((const uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) +#define isclr(a, i) ((((const uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) +#endif /* setbit */ + +#define NBITS(type) (sizeof(type) * 8) +#define NBITVAL(nbits) (1 << (nbits)) +#define MAXBITVAL(nbits) ((1 << (nbits)) - 1) +#define NBITMASK(nbits) MAXBITVAL(nbits) +#define MAXNBVAL(nbyte) MAXBITVAL((nbyte) * 8) + +/* basic mux operation - can be optimized on several architectures */ +#define MUX(pred, true, false) ((pred) ? (true) : (false)) + +/* modulo inc/dec - assumes x E [0, bound - 1] */ +#define MODDEC(x, bound) MUX((x) == 0, (bound) - 1, (x) - 1) +#define MODINC(x, bound) MUX((x) == (bound) - 1, 0, (x) + 1) + +/* modulo inc/dec, bound = 2^k */ +#define MODDEC_POW2(x, bound) (((x) - 1) & ((bound) - 1)) +#define MODINC_POW2(x, bound) (((x) + 1) & ((bound) - 1)) + +/* modulo add/sub - assumes x, y E [0, bound - 1] */ +#define MODADD(x, y, bound) \ + MUX((x) + (y) >= (bound), (x) + (y) - (bound), (x) + (y)) +#define MODSUB(x, y, bound) \ + MUX(((int)(x)) - ((int)(y)) < 0, (x) - (y) + (bound), (x) - (y)) + +/* module add/sub, bound = 2^k */ +#define MODADD_POW2(x, y, bound) (((x) + (y)) & ((bound) - 1)) +#define MODSUB_POW2(x, y, bound) (((x) - (y)) & ((bound) - 1)) + +/* crc defines */ +#define CRC8_INIT_VALUE 0xff /* Initial CRC8 checksum value */ +#define CRC8_GOOD_VALUE 0x9f /* Good final CRC8 checksum value */ +#define CRC16_INIT_VALUE 0xffff /* Initial CRC16 checksum value */ +#define CRC16_GOOD_VALUE 0xf0b8 /* Good final CRC16 checksum value */ +#define CRC32_INIT_VALUE 0xffffffff /* Initial CRC32 checksum value */ +#define CRC32_GOOD_VALUE 0xdebb20e3 /* Good final CRC32 checksum value */ + +/* bcm_format_flags() bit description structure */ +typedef struct bcm_bit_desc { + uint32 bit; + const char* name; +} bcm_bit_desc_t; + +/* tag_ID/length/value_buffer tuple */ +typedef struct bcm_tlv { + uint8 id; + uint8 len; + uint8 data[1]; +} bcm_tlv_t; + +/* Check that bcm_tlv_t fits into the given buflen */ +#define bcm_valid_tlv(elt, buflen) ((buflen) >= 2 && (int)(buflen) >= (int)(2 + (elt)->len)) + +/* buffer length for ethernet address from bcm_ether_ntoa() */ +#define ETHER_ADDR_STR_LEN 18 /* 18-bytes of Ethernet address buffer length */ + +/* unaligned load and store macros */ +#ifdef IL_BIGENDIAN +static INLINE uint32 +load32_ua(uint8 *a) +{ + return ((a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3]); +} + +static INLINE void +store32_ua(uint8 *a, uint32 v) +{ + a[0] = (v >> 24) & 0xff; + a[1] = (v >> 16) & 0xff; + a[2] = (v >> 8) & 0xff; + a[3] = v & 0xff; +} + +static INLINE uint16 +load16_ua(uint8 *a) +{ + return ((a[0] << 8) | a[1]); +} + +static INLINE void +store16_ua(uint8 *a, uint16 v) +{ + a[0] = (v >> 8) & 0xff; + a[1] = v & 0xff; +} + +#else /* IL_BIGENDIAN */ + +static INLINE uint32 +load32_ua(uint8 *a) +{ + return ((a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0]); +} + +static INLINE void +store32_ua(uint8 *a, uint32 v) +{ + a[3] = (v >> 24) & 0xff; + a[2] = (v >> 16) & 0xff; + a[1] = (v >> 8) & 0xff; + a[0] = v & 0xff; +} + +static INLINE uint16 +load16_ua(uint8 *a) +{ + return ((a[1] << 8) | a[0]); +} + +static INLINE void +store16_ua(uint8 *a, uint16 v) +{ + a[1] = (v >> 8) & 0xff; + a[0] = v & 0xff; +} + +#endif /* IL_BIGENDIAN */ + +/* externs */ +/* crc */ +extern uint8 BCMROMFN(hndcrc8)(uint8 *p, uint nbytes, uint8 crc); +extern uint16 BCMROMFN(hndcrc16)(uint8 *p, uint nbytes, uint16 crc); +extern uint32 BCMROMFN(hndcrc32)(uint8 *p, uint nbytes, uint32 crc); +/* format/print */ +extern char *bcm_brev_str(uint16 brev, char *buf); +extern void printfbig(char *buf); + +/* IE parsing */ +extern bcm_tlv_t *BCMROMFN(bcm_next_tlv)(bcm_tlv_t *elt, int *buflen); +extern bcm_tlv_t *BCMROMFN(bcm_parse_tlvs)(void *buf, int buflen, uint key); +extern bcm_tlv_t *BCMROMFN(bcm_parse_ordered_tlvs)(void *buf, int buflen, uint key); + +/* bcmerror */ +extern const char *bcmerrorstr(int bcmerror); + +/* multi-bool data type: set of bools, mbool is true if any is set */ +typedef uint32 mbool; +#define mboolset(mb, bit) ((mb) |= (bit)) /* set one bool */ +#define mboolclr(mb, bit) ((mb) &= ~(bit)) /* clear one bool */ +#define mboolisset(mb, bit) (((mb) & (bit)) != 0) /* TRUE if one bool is set */ +#define mboolmaskset(mb, mask, val) ((mb) = (((mb) & ~(mask)) | (val))) + +/* power conversion */ +extern uint16 BCMROMFN(bcm_qdbm_to_mw)(uint8 qdbm); +extern uint8 BCMROMFN(bcm_mw_to_qdbm)(uint16 mw); + +/* generic datastruct to help dump routines */ +struct fielddesc { + const char *nameandfmt; + uint32 offset; + uint32 len; +}; + +extern void bcm_binit(struct bcmstrbuf *b, char *buf, uint size); +extern int bcm_bprintf(struct bcmstrbuf *b, const char *fmt, ...); + +typedef uint32 (*readreg_rtn)(void *arg0, void *arg1, uint32 offset); +extern uint bcmdumpfields(readreg_rtn func_ptr, void *arg0, void *arg1, struct fielddesc *str, + char *buf, uint32 bufsize); + +extern uint bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint len); +extern uint BCMROMFN(bcm_bitcount)(uint8 *bitmap, uint bytelength); + +#ifdef BCMDBG_PKT /* pkt logging for debugging */ +#define PKTLIST_SIZE 1000 +typedef struct { + void *list[PKTLIST_SIZE]; /* List of pointers to packets */ + uint count; /* Total count of the packets */ +} pktlist_info_t; + +extern void pktlist_add(pktlist_info_t *pktlist, void *p); +extern void pktlist_remove(pktlist_info_t *pktlist, void *p); +extern char* pktlist_dump(pktlist_info_t *pktlist, char *buf); +#endif /* BCMDBG_PKT */ + +#endif /* _bcmutils_h_ */ diff --git a/target/linux/brcm-2.4/files/arch/mips/bcm947xx/sflash.c b/target/linux/brcm-2.4/files/arch/mips/bcm947xx/sflash.c new file mode 100644 index 000000000..9bfb8b42a --- /dev/null +++ b/target/linux/brcm-2.4/files/arch/mips/bcm947xx/sflash.c @@ -0,0 +1,508 @@ +/* + * Broadcom SiliconBackplane chipcommon serial flash interface + * + * Copyright 2007, Broadcom Corporation + * All Rights Reserved. + * + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. + * + * $Id$ + */ + +#include +#include +#include "include/bcmutils.h" +#include +#include +#include +#include +#include + +/* Private global state */ +static struct sflash sflash; + +/* Issue a serial flash command */ +static INLINE void +sflash_cmd(osl_t *osh, chipcregs_t *cc, uint opcode) +{ + W_REG(osh, &cc->flashcontrol, SFLASH_START | opcode); + while (R_REG(osh, &cc->flashcontrol) & SFLASH_BUSY); +} + +/* Initialize serial flash access */ +struct sflash * +sflash_init(sb_t *sbh, chipcregs_t *cc) +{ + uint32 id, id2; + osl_t *osh; + + ASSERT(sbh); + + osh = sb_osh(sbh); + + bzero(&sflash, sizeof(sflash)); + + sflash.type = sbh->cccaps & CC_CAP_FLASH_MASK; + + switch (sflash.type) { + case SFLASH_ST: + /* Probe for ST chips */ + sflash_cmd(osh, cc, SFLASH_ST_DP); + sflash_cmd(osh, cc, SFLASH_ST_RES); + id = R_REG(osh, &cc->flashdata); + switch (id) { + case 0x11: + /* ST M25P20 2 Mbit Serial Flash */ + sflash.blocksize = 64 * 1024; + sflash.numblocks = 4; + break; + case 0x12: + /* ST M25P40 4 Mbit Serial Flash */ + sflash.blocksize = 64 * 1024; + sflash.numblocks = 8; + break; + case 0x13: + /* ST M25P80 8 Mbit Serial Flash */ + sflash.blocksize = 64 * 1024; + sflash.numblocks = 16; + break; + case 0x14: + /* ST M25P16 16 Mbit Serial Flash */ + sflash.blocksize = 64 * 1024; + sflash.numblocks = 32; + break; + case 0x15: + /* ST M25P32 32 Mbit Serial Flash */ + sflash.blocksize = 64 * 1024; + sflash.numblocks = 64; + break; + case 0x16: + /* ST M25P64 64 Mbit Serial Flash */ + sflash.blocksize = 64 * 1024; + sflash.numblocks = 128; + break; + case 0xbf: + W_REG(osh, &cc->flashaddress, 1); + sflash_cmd(osh, cc, SFLASH_ST_RES); + id2 = R_REG(osh, &cc->flashdata); + if (id2 == 0x44) { + /* SST M25VF80 4 Mbit Serial Flash */ + sflash.blocksize = 64 * 1024; + sflash.numblocks = 8; + } + break; + } + break; + + case SFLASH_AT: + /* Probe for Atmel chips */ + sflash_cmd(osh, cc, SFLASH_AT_STATUS); + id = R_REG(osh, &cc->flashdata) & 0x3c; + switch (id) { + case 0xc: + /* Atmel AT45DB011 1Mbit Serial Flash */ + sflash.blocksize = 256; + sflash.numblocks = 512; + break; + case 0x14: + /* Atmel AT45DB021 2Mbit Serial Flash */ + sflash.blocksize = 256; + sflash.numblocks = 1024; + break; + case 0x1c: + /* Atmel AT45DB041 4Mbit Serial Flash */ + sflash.blocksize = 256; + sflash.numblocks = 2048; + break; + case 0x24: + /* Atmel AT45DB081 8Mbit Serial Flash */ + sflash.blocksize = 256; + sflash.numblocks = 4096; + break; + case 0x2c: + /* Atmel AT45DB161 16Mbit Serial Flash */ + sflash.blocksize = 512; + sflash.numblocks = 4096; + break; + case 0x34: + /* Atmel AT45DB321 32Mbit Serial Flash */ + sflash.blocksize = 512; + sflash.numblocks = 8192; + break; + case 0x3c: + /* Atmel AT45DB642 64Mbit Serial Flash */ + sflash.blocksize = 1024; + sflash.numblocks = 8192; + break; + } + break; + } + + sflash.size = sflash.blocksize * sflash.numblocks; + return sflash.size ? &sflash : NULL; +} + +/* Read len bytes starting at offset into buf. Returns number of bytes read. */ +int +sflash_read(sb_t *sbh, chipcregs_t *cc, uint offset, uint len, uchar *buf) +{ + uint8 *from, *to; + int cnt, i; + osl_t *osh; + + ASSERT(sbh); + + if (!len) + return 0; + + if ((offset + len) > sflash.size) + return -22; + + if ((len >= 4) && (offset & 3)) + cnt = 4 - (offset & 3); + else if ((len >= 4) && ((uintptr)buf & 3)) + cnt = 4 - ((uintptr)buf & 3); + else + cnt = len; + + osh = sb_osh(sbh); + + from = (uint8 *)(uintptr)OSL_UNCACHED(SB_FLASH2 + offset); + to = (uint8 *)buf; + + if (cnt < 4) { + for (i = 0; i < cnt; i ++) { + *to = R_REG(osh, from); + from ++; + to ++; + } + return cnt; + } + + while (cnt >= 4) { + *(uint32 *)to = R_REG(osh, (uint32 *)from); + from += 4; + to += 4; + cnt -= 4; + } + + return (len - cnt); +} + +/* Poll for command completion. Returns zero when complete. */ +int +sflash_poll(sb_t *sbh, chipcregs_t *cc, uint offset) +{ + osl_t *osh; + + ASSERT(sbh); + + osh = sb_osh(sbh); + + if (offset >= sflash.size) + return -22; + + switch (sflash.type) { + case SFLASH_ST: + /* Check for ST Write In Progress bit */ + sflash_cmd(osh, cc, SFLASH_ST_RDSR); + return R_REG(osh, &cc->flashdata) & SFLASH_ST_WIP; + case SFLASH_AT: + /* Check for Atmel Ready bit */ + sflash_cmd(osh, cc, SFLASH_AT_STATUS); + return !(R_REG(osh, &cc->flashdata) & SFLASH_AT_READY); + } + + return 0; +} + +/* Write len bytes starting at offset into buf. Returns number of bytes + * written. Caller should poll for completion. + */ +int +sflash_write(sb_t *sbh, chipcregs_t *cc, uint offset, uint len, const uchar *buf) +{ + struct sflash *sfl; + int ret = 0; + bool is4712b0; + uint32 page, byte, mask; + osl_t *osh; + + ASSERT(sbh); + + osh = sb_osh(sbh); + + if (!len) + return 0; + + if ((offset + len) > sflash.size) + return -22; + + sfl = &sflash; + switch (sfl->type) { + case SFLASH_ST: + is4712b0 = (sbh->chip == BCM4712_CHIP_ID) && (sbh->chiprev == 3); + /* Enable writes */ + sflash_cmd(osh, cc, SFLASH_ST_WREN); + if (is4712b0) { + mask = 1 << 14; + W_REG(osh, &cc->flashaddress, offset); + W_REG(osh, &cc->flashdata, *buf++); + /* Set chip select */ + OR_REG(osh, &cc->gpioout, mask); + /* Issue a page program with the first byte */ + sflash_cmd(osh, cc, SFLASH_ST_PP); + ret = 1; + offset++; + len--; + while (len > 0) { + if ((offset & 255) == 0) { + /* Page boundary, drop cs and return */ + AND_REG(osh, &cc->gpioout, ~mask); + if (!sflash_poll(sbh, cc, offset)) { + /* Flash rejected command */ + return -11; + } + return ret; + } else { + /* Write single byte */ + sflash_cmd(osh, cc, *buf++); + } + ret++; + offset++; + len--; + } + /* All done, drop cs if needed */ + if ((offset & 255) != 1) { + /* Drop cs */ + AND_REG(osh, &cc->gpioout, ~mask); + if (!sflash_poll(sbh, cc, offset)) { + /* Flash rejected command */ + return -12; + } + } + } else if ( (sbh->ccrev >= 20) && (len != 1) ) { + //} else if ( sbh->ccrev >= 20 ) { /* foxconn modified by EricHuang, 05/24/2007 */ + W_REG(NULL, &cc->flashaddress, offset); + W_REG(NULL, &cc->flashdata, *buf++); + /* Issue a page program with CSA bit set */ + sflash_cmd(osh, cc, SFLASH_ST_CSA | SFLASH_ST_PP); + ret = 1; + offset++; + len--; + while (len > 0) { + if ((offset & 255) == 0) { + /* Page boundary, poll droping cs and return */ + W_REG(NULL, &cc->flashcontrol, 0); + /* wklin added start, 06/08/2007 */ + W_REG(NULL, &cc->flashcontrol, 0); + OSL_DELAY(1); + /* wklin added end, 06/08/2007 */ + /* wklin rmeoved start, 06/08/2007 */ +#if 0 + if (!sflash_poll(sbh, cc, offset)) { + /* Flash rejected command */ + return -11; + } +#endif + /* wklin removed end, 06/08/2007 */ + return ret; + } else { + /* Write single byte */ + sflash_cmd(osh, cc, SFLASH_ST_CSA | *buf++); + } + ret++; + offset++; + len--; + } + /* All done, drop cs if needed */ + if ((offset & 255) != 1) { + /* Drop cs, poll */ + W_REG(NULL, &cc->flashcontrol, 0); + /* wklin added start, 06/08/2007 */ + W_REG(NULL, &cc->flashcontrol, 0); + OSL_DELAY(1); + /* wklin added end, 06/08/2007 */ + /* wklin removed start, 06/08/2007 */ +#if 0 + if (!sflash_poll(sbh, cc, offset)) { + /* Flash rejected command */ + return -12; + } +#endif + /* wklin removed end, 06/08/2007 */ + } + } else { + ret = 1; + W_REG(osh, &cc->flashaddress, offset); + W_REG(osh, &cc->flashdata, *buf); + /* Page program */ + sflash_cmd(osh, cc, SFLASH_ST_PP); + } + break; + case SFLASH_AT: + mask = sfl->blocksize - 1; + page = (offset & ~mask) << 1; + byte = offset & mask; + /* Read main memory page into buffer 1 */ + if (byte || (len < sfl->blocksize)) { + W_REG(osh, &cc->flashaddress, page); + sflash_cmd(osh, cc, SFLASH_AT_BUF1_LOAD); + /* 250 us for AT45DB321B */ + SPINWAIT(sflash_poll(sbh, cc, offset), 1000); + ASSERT(!sflash_poll(sbh, cc, offset)); + } + /* Write into buffer 1 */ + for (ret = 0; (ret < (int)len) && (byte < sfl->blocksize); ret++) { + W_REG(osh, &cc->flashaddress, byte++); + W_REG(osh, &cc->flashdata, *buf++); + sflash_cmd(osh, cc, SFLASH_AT_BUF1_WRITE); + } + /* Write buffer 1 into main memory page */ + W_REG(osh, &cc->flashaddress, page); + sflash_cmd(osh, cc, SFLASH_AT_BUF1_PROGRAM); + break; + } + + return ret; +} + +/* Erase a region. Returns number of bytes scheduled for erasure. + * Caller should poll for completion. + */ +int +sflash_erase(sb_t *sbh, chipcregs_t *cc, uint offset) +{ + struct sflash *sfl; + osl_t *osh; + + ASSERT(sbh); + + osh = sb_osh(sbh); + + if (offset >= sflash.size) + return -22; + + sfl = &sflash; + switch (sfl->type) { + case SFLASH_ST: + sflash_cmd(osh, cc, SFLASH_ST_WREN); + W_REG(osh, &cc->flashaddress, offset); + sflash_cmd(osh, cc, SFLASH_ST_SE); + return sfl->blocksize; + case SFLASH_AT: + W_REG(osh, &cc->flashaddress, offset << 1); + sflash_cmd(osh, cc, SFLASH_AT_PAGE_ERASE); + return sfl->blocksize; + } + + return 0; +} + +/* + * writes the appropriate range of flash, a NULL buf simply erases + * the region of flash + */ +int +sflash_commit(sb_t *sbh, chipcregs_t *cc, uint offset, uint len, const uchar *buf) +{ + struct sflash *sfl; + uchar *block = NULL, *cur_ptr, *blk_ptr; + uint blocksize = 0, mask, cur_offset, cur_length, cur_retlen, remainder; + uint blk_offset, blk_len, copied; + int bytes, ret = 0; + osl_t *osh; + + ASSERT(sbh); + + osh = sb_osh(sbh); + + /* Check address range */ + if (len <= 0) + return 0; + + sfl = &sflash; + if ((offset + len) > sfl->size) + return -1; + + blocksize = sfl->blocksize; + mask = blocksize - 1; + + /* Allocate a block of mem */ + if (!(block = MALLOC(osh, blocksize))) + return -1; + + while (len) { + /* Align offset */ + cur_offset = offset & ~mask; + cur_length = blocksize; + cur_ptr = block; + + remainder = blocksize - (offset & mask); + if (len < remainder) + cur_retlen = len; + else + cur_retlen = remainder; + + /* buf == NULL means erase only */ + if (buf) { + /* Copy existing data into holding block if necessary */ + if ((offset & mask) || (len < blocksize)) { + blk_offset = cur_offset; + blk_len = cur_length; + blk_ptr = cur_ptr; + + /* Copy entire block */ + while (blk_len) { + copied = sflash_read(sbh, cc, blk_offset, blk_len, blk_ptr); + blk_offset += copied; + blk_len -= copied; + blk_ptr += copied; + } + } + + /* Copy input data into holding block */ + memcpy(cur_ptr + (offset & mask), buf, cur_retlen); + } + + /* Erase block */ + if ((ret = sflash_erase(sbh, cc, (uint) cur_offset)) < 0) + goto done; + while (sflash_poll(sbh, cc, (uint) cur_offset)); + + /* buf == NULL means erase only */ + if (!buf) { + offset += cur_retlen; + len -= cur_retlen; + continue; + } + + /* Write holding block */ + while (cur_length > 0) { + if ((bytes = sflash_write(sbh, cc, + (uint) cur_offset, + (uint) cur_length, + (uchar *) cur_ptr)) < 0) { + ret = bytes; + goto done; + } + while (sflash_poll(sbh, cc, (uint) cur_offset)); + cur_offset += bytes; + cur_length -= bytes; + cur_ptr += bytes; + } + + offset += cur_retlen; + len -= cur_retlen; + buf += cur_retlen; + } + + ret = len; +done: + if (block) + MFREE(osh, block, blocksize); + return ret; +} diff --git a/target/linux/brcm-2.4/files/drivers/mtd/devices/sflash.c b/target/linux/brcm-2.4/files/drivers/mtd/devices/sflash.c index 7ffb00478..a8aab7bd9 100644 --- a/target/linux/brcm-2.4/files/drivers/mtd/devices/sflash.c +++ b/target/linux/brcm-2.4/files/drivers/mtd/devices/sflash.c @@ -1,530 +1,303 @@ /* * Broadcom SiliconBackplane chipcommon serial flash interface * - * Copyright 2007, Broadcom Corporation - * All Rights Reserved. - * - * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY - * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM - * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. + * Copyright 2006, Broadcom Corporation + * All Rights Reserved. + * + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. * + * $Id$ */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include +// #include +#include +#include #include #include #include -#include #include +#ifdef CONFIG_MTD_PARTITIONS +extern struct mtd_partition * init_mtd_partitions(struct mtd_info *mtd, size_t size); +#endif + +struct sflash_mtd { + sb_t *sbh; + chipcregs_t *cc; + struct semaphore lock; + struct mtd_info mtd; + struct mtd_erase_region_info region; +}; + /* Private global state */ -static struct sflash sflash; +static struct sflash_mtd sflash; -/* Issue a serial flash command */ -static INLINE void -sflash_cmd (osl_t * osh, chipcregs_t * cc, uint opcode) +static int +sflash_mtd_poll(struct sflash_mtd *sflash, unsigned int offset, int timeout) { - W_REG (osh, &cc->flashcontrol, SFLASH_START | opcode); - while (R_REG (osh, &cc->flashcontrol) & SFLASH_BUSY); + int now = jiffies; + int ret = 0; + + for (;;) { + if (!sflash_poll(sflash->sbh, sflash->cc, offset)) { + ret = 0; + break; + } + if (time_after(jiffies, now + timeout)) { + printk(KERN_ERR "sflash: timeout\n"); + ret = -ETIMEDOUT; + break; + } + if (current->need_resched) { + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(timeout / 10); + } else + udelay(1); + } + + return ret; } -/* Initialize serial flash access */ -struct sflash * -sflash_init (sb_t * sbh, chipcregs_t * cc) +static int +sflash_mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) { - uint32 id, id2; - osl_t *osh; + struct sflash_mtd *sflash = (struct sflash_mtd *) mtd->priv; + int bytes, ret = 0; - ASSERT (sbh); + /* Check address range */ + if (len == 0){ + *retlen = 0; + return 0; + } + if (!len) + return 0; + if ((from + len) > mtd->size) + return -EINVAL; + + down(&sflash->lock); - osh = sb_osh (sbh); - - bzero (&sflash, sizeof (sflash)); - - sflash.type = sbh->cccaps & CC_CAP_FLASH_MASK; - - switch (sflash.type) - { - case SFLASH_ST: - /* Probe for ST chips */ - sflash_cmd (osh, cc, SFLASH_ST_DP); - sflash_cmd (osh, cc, SFLASH_ST_RES); - id = R_REG (osh, &cc->flashdata); - switch (id) - { - case 0x11: - /* ST M25P20 2 Mbit Serial Flash */ - sflash.blocksize = 64 * 1024; - sflash.numblocks = 4; - break; - case 0x12: - /* ST M25P40 4 Mbit Serial Flash */ - sflash.blocksize = 64 * 1024; - sflash.numblocks = 8; - break; - case 0x13: - /* ST M25P80 8 Mbit Serial Flash */ - sflash.blocksize = 64 * 1024; - sflash.numblocks = 16; - break; - case 0x14: - /* ST M25P16 16 Mbit Serial Flash */ - sflash.blocksize = 64 * 1024; - sflash.numblocks = 32; - break; - case 0x15: - /* ST M25P32 32 Mbit Serial Flash */ - sflash.blocksize = 64 * 1024; - sflash.numblocks = 64; - break; - case 0x16: - /* ST M25P64 64 Mbit Serial Flash */ - sflash.blocksize = 64 * 1024; - sflash.numblocks = 128; - break; - case 0xbf: - W_REG (osh, &cc->flashaddress, 1); - sflash_cmd (osh, cc, SFLASH_ST_RES); - id2 = R_REG (osh, &cc->flashdata); - if (id2 == 0x44) - { - /* SST M25VF80 4 Mbit Serial Flash */ - sflash.blocksize = 64 * 1024; - sflash.numblocks = 8; - } - break; + *retlen = 0; + while (len) { + if ((bytes = sflash_read(sflash->sbh, sflash->cc, (uint) from, len, buf)) < 0) { + ret = bytes; + break; + } + from += (loff_t) bytes; + len -= bytes; + buf += bytes; + *retlen += bytes; } - break; - case SFLASH_AT: - /* Probe for Atmel chips */ - sflash_cmd (osh, cc, SFLASH_AT_STATUS); - id = R_REG (osh, &cc->flashdata) & 0x3c; - switch (id) - { - case 0xc: - /* Atmel AT45DB011 1Mbit Serial Flash */ - sflash.blocksize = 256; - sflash.numblocks = 512; - break; - case 0x14: - /* Atmel AT45DB021 2Mbit Serial Flash */ - sflash.blocksize = 256; - sflash.numblocks = 1024; - break; - case 0x1c: - /* Atmel AT45DB041 4Mbit Serial Flash */ - sflash.blocksize = 256; - sflash.numblocks = 2048; - break; - case 0x24: - /* Atmel AT45DB081 8Mbit Serial Flash */ - sflash.blocksize = 256; - sflash.numblocks = 4096; - break; - case 0x2c: - /* Atmel AT45DB161 16Mbit Serial Flash */ - sflash.blocksize = 512; - sflash.numblocks = 4096; - break; - case 0x34: - /* Atmel AT45DB321 32Mbit Serial Flash */ - sflash.blocksize = 512; - sflash.numblocks = 8192; - break; - case 0x3c: - /* Atmel AT45DB642 64Mbit Serial Flash */ - sflash.blocksize = 1024; - sflash.numblocks = 8192; - break; - } - break; - } + up(&sflash->lock); - sflash.size = sflash.blocksize * sflash.numblocks; - return sflash.size ? &sflash : NULL; + return ret; } -/* Read len bytes starting at offset into buf. Returns number of bytes read. */ -int -sflash_read (sb_t * sbh, chipcregs_t * cc, uint offset, uint len, uchar * buf) +static int +sflash_mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) { - uint8 *from, *to; - int cnt, i; - osl_t *osh; + struct sflash_mtd *sflash = (struct sflash_mtd *) mtd->priv; + int bytes, ret = 0; - ASSERT (sbh); + /* Check address range */ + if (len == 0){ + *retlen = 0; + return 0; + } + if (!len) + return 0; + if ((to + len) > mtd->size) + return -EINVAL; - if (!len) - return 0; + down(&sflash->lock); - if ((offset + len) > sflash.size) - return -22; - - if ((len >= 4) && (offset & 3)) - cnt = 4 - (offset & 3); - else if ((len >= 4) && ((uintptr) buf & 3)) - cnt = 4 - ((uintptr) buf & 3); - else - cnt = len; - - osh = sb_osh (sbh); - - from = (uint8 *) (uintptr) OSL_UNCACHED (SB_FLASH2 + offset); - to = (uint8 *) buf; - - if (cnt < 4) - { - for (i = 0; i < cnt; i++) - { - *to = R_REG (osh, from); - from++; - to++; + *retlen = 0; + while (len) { + if ((bytes = sflash_write(sflash->sbh, sflash->cc, (uint)to, (uint)len, buf)) < 0) { + ret = bytes; + break; + } + if ((ret = sflash_mtd_poll(sflash, (unsigned int) to, HZ / 10))) + break; + to += (loff_t) bytes; + len -= bytes; + buf += bytes; + *retlen += bytes; } - return cnt; - } - while (cnt >= 4) - { - *(uint32 *) to = R_REG (osh, (uint32 *) from); - from += 4; - to += 4; - cnt -= 4; - } + up(&sflash->lock); - return (len - cnt); + return ret; } -/* Poll for command completion. Returns zero when complete. */ -int -sflash_poll (sb_t * sbh, chipcregs_t * cc, uint offset) +static int +sflash_mtd_erase(struct mtd_info *mtd, struct erase_info *erase) { - osl_t *osh; + struct sflash_mtd *sflash = (struct sflash_mtd *) mtd->priv; + int i, j, ret = 0; + unsigned int addr, len; - ASSERT (sbh); + /* Check address range */ + if (!erase->len) + return 0; + if ((erase->addr + erase->len) > mtd->size) + return -EINVAL; - osh = sb_osh (sbh); + addr = erase->addr; + len = erase->len; - if (offset >= sflash.size) - return -22; + down(&sflash->lock); - switch (sflash.type) - { - case SFLASH_ST: - /* Check for ST Write In Progress bit */ - sflash_cmd (osh, cc, SFLASH_ST_RDSR); - return R_REG (osh, &cc->flashdata) & SFLASH_ST_WIP; - case SFLASH_AT: - /* Check for Atmel Ready bit */ - sflash_cmd (osh, cc, SFLASH_AT_STATUS); - return !(R_REG (osh, &cc->flashdata) & SFLASH_AT_READY); - } + /* Ensure that requested region is aligned */ + for (i = 0; i < mtd->numeraseregions; i++) { + for (j = 0; j < mtd->eraseregions[i].numblocks; j++) { + if (addr == mtd->eraseregions[i].offset + mtd->eraseregions[i].erasesize * j && + len >= mtd->eraseregions[i].erasesize) { + if ((ret = sflash_erase(sflash->sbh, sflash->cc, addr)) < 0) + break; + if ((ret = sflash_mtd_poll(sflash, addr, 10 * HZ))) + break; + addr += mtd->eraseregions[i].erasesize; + len -= mtd->eraseregions[i].erasesize; + } + } + if (ret) + break; + } - return 0; + up(&sflash->lock); + + /* Set erase status */ + if (ret) + erase->state = MTD_ERASE_FAILED; + else + erase->state = MTD_ERASE_DONE; + + /* Call erase callback */ + if (erase->callback) + erase->callback(erase); + + return ret; } -/* Write len bytes starting at offset into buf. Returns number of bytes - * written. Caller should poll for completion. - */ -int -sflash_write (sb_t * sbh, chipcregs_t * cc, uint offset, uint len, - const uchar * buf) +#if LINUX_VERSION_CODE < 0x20212 && defined(MODULE) +#define sflash_mtd_init init_module +#define sflash_mtd_exit cleanup_module +#endif + +mod_init_t +sflash_mtd_init(void) { - struct sflash *sfl; - int ret = 0; - bool is4712b0; - uint32 page, byte, mask; - osl_t *osh; + struct pci_dev *pdev; + int ret = 0; + struct sflash *info; + uint i; +#ifdef CONFIG_MTD_PARTITIONS + struct mtd_partition *parts; +#endif - ASSERT (sbh); - - osh = sb_osh (sbh); - - if (!len) - return 0; - - if ((offset + len) > sflash.size) - return -22; - - sfl = &sflash; - switch (sfl->type) - { - case SFLASH_ST: - is4712b0 = (sbh->chip == BCM4712_CHIP_ID) && (sbh->chiprev == 3); - /* Enable writes */ - sflash_cmd (osh, cc, SFLASH_ST_WREN); - if (is4712b0) - { - mask = 1 << 14; - W_REG (osh, &cc->flashaddress, offset); - W_REG (osh, &cc->flashdata, *buf++); - /* Set chip select */ - OR_REG (osh, &cc->gpioout, mask); - /* Issue a page program with the first byte */ - sflash_cmd (osh, cc, SFLASH_ST_PP); - ret = 1; - offset++; - len--; - while (len > 0) - { - if ((offset & 255) == 0) - { - /* Page boundary, drop cs and return */ - AND_REG (osh, &cc->gpioout, ~mask); - if (!sflash_poll (sbh, cc, offset)) - { - /* Flash rejected command */ - return -11; - } - return ret; - } - else - { - /* Write single byte */ - sflash_cmd (osh, cc, *buf++); - } - ret++; - offset++; - len--; - } - /* All done, drop cs if needed */ - if ((offset & 255) != 1) - { - /* Drop cs */ - AND_REG (osh, &cc->gpioout, ~mask); - if (!sflash_poll (sbh, cc, offset)) - { - /* Flash rejected command */ - return -12; - } - } + if (!(pdev = pci_find_device(VENDOR_BROADCOM, SB_CC, NULL))) { + printk(KERN_ERR "sflash: chipcommon not found\n"); + return -ENODEV; } - else if (sbh->ccrev >= 20) - { - W_REG (NULL, &cc->flashaddress, offset); - W_REG (NULL, &cc->flashdata, *buf++); - /* Issue a page program with CSA bit set */ - sflash_cmd (osh, cc, SFLASH_ST_CSA | SFLASH_ST_PP); - ret = 1; - offset++; - len--; - while (len > 0) - { - if ((offset & 255) == 0) - { - /* Page boundary, poll droping cs and return */ - W_REG (NULL, &cc->flashcontrol, 0); - if (!sflash_poll (sbh, cc, offset)) - { - /* Flash rejected command */ - return -11; - } - return ret; - } - else - { - /* Write single byte */ - sflash_cmd (osh, cc, SFLASH_ST_CSA | *buf++); - } - ret++; - offset++; - len--; - } - /* All done, drop cs if needed */ - if ((offset & 255) != 1) - { - /* Drop cs, poll */ - W_REG (NULL, &cc->flashcontrol, 0); - if (!sflash_poll (sbh, cc, offset)) - { - /* Flash rejected command */ - return -12; - } - } - } - else - { - ret = 1; - W_REG (osh, &cc->flashaddress, offset); - W_REG (osh, &cc->flashdata, *buf); - /* Page program */ - sflash_cmd (osh, cc, SFLASH_ST_PP); - } - break; - case SFLASH_AT: - mask = sfl->blocksize - 1; - page = (offset & ~mask) << 1; - byte = offset & mask; - /* Read main memory page into buffer 1 */ - if (byte || (len < sfl->blocksize)) - { - W_REG (osh, &cc->flashaddress, page); - sflash_cmd (osh, cc, SFLASH_AT_BUF1_LOAD); - /* 250 us for AT45DB321B */ - SPINWAIT (sflash_poll (sbh, cc, offset), 1000); - ASSERT (!sflash_poll (sbh, cc, offset)); - } - /* Write into buffer 1 */ - for (ret = 0; (ret < (int) len) && (byte < sfl->blocksize); ret++) - { - W_REG (osh, &cc->flashaddress, byte++); - W_REG (osh, &cc->flashdata, *buf++); - sflash_cmd (osh, cc, SFLASH_AT_BUF1_WRITE); - } - /* Write buffer 1 into main memory page */ - W_REG (osh, &cc->flashaddress, page); - sflash_cmd (osh, cc, SFLASH_AT_BUF1_PROGRAM); - break; - } - return ret; + memset(&sflash, 0, sizeof(struct sflash_mtd)); + init_MUTEX(&sflash.lock); + + /* attach to the backplane */ + if (!(sflash.sbh = sb_kattach(SB_OSH))) { + printk(KERN_ERR "sflash: error attaching to backplane\n"); + ret = -EIO; + goto fail; + } + + /* Map registers and flash base */ + if (!(sflash.cc = ioremap_nocache(pci_resource_start(pdev, 0), + pci_resource_len(pdev, 0)))) { + printk(KERN_ERR "sflash: error mapping registers\n"); + ret = -EIO; + goto fail; + } + + /* Initialize serial flash access */ + if (!(info = sflash_init(sflash.sbh, sflash.cc))) { + printk(KERN_ERR "sflash: found no supported devices\n"); + ret = -ENODEV; + goto fail; + } + + printk(KERN_INFO "sflash: found serial flash; blocksize=%dKB, numblocks=%d, size=%dKB\n",info->blocksize/1024,info->numblocks,info->size/1024); + + /* Setup region info */ + sflash.region.offset = 0; + sflash.region.erasesize = info->blocksize; + sflash.region.numblocks = info->numblocks; + if (sflash.region.erasesize > sflash.mtd.erasesize) + sflash.mtd.erasesize = sflash.region.erasesize; + sflash.mtd.size = info->size; + sflash.mtd.numeraseregions = 1; + + /* Register with MTD */ + sflash.mtd.name = "sflash"; + sflash.mtd.type = MTD_NORFLASH; + sflash.mtd.flags = MTD_CAP_NORFLASH; + sflash.mtd.eraseregions = &sflash.region; + sflash.mtd.module = THIS_MODULE; + sflash.mtd.erase = sflash_mtd_erase; + sflash.mtd.read = sflash_mtd_read; + sflash.mtd.write = sflash_mtd_write; + sflash.mtd.priv = &sflash; + +#ifdef CONFIG_MTD_PARTITIONS + parts = init_mtd_partitions(&sflash.mtd, sflash.mtd.size); + for (i = 0; parts[i].name; i++); + ret = add_mtd_partitions(&sflash.mtd, parts, i); +#else + ret = add_mtd_device(&sflash.mtd); +#endif + if (ret) { + printk(KERN_ERR "sflash: add_mtd failed\n"); + goto fail; + } + + return 0; + + fail: + if (sflash.cc) + iounmap((void *) sflash.cc); + if (sflash.sbh) + sb_detach(sflash.sbh); + return ret; } -/* Erase a region. Returns number of bytes scheduled for erasure. - * Caller should poll for completion. - */ -int -sflash_erase (sb_t * sbh, chipcregs_t * cc, uint offset) +mod_exit_t +sflash_mtd_exit(void) { - struct sflash *sfl; - osl_t *osh; - - ASSERT (sbh); - - osh = sb_osh (sbh); - - if (offset >= sflash.size) - return -22; - - sfl = &sflash; - switch (sfl->type) - { - case SFLASH_ST: - sflash_cmd (osh, cc, SFLASH_ST_WREN); - W_REG (osh, &cc->flashaddress, offset); - sflash_cmd (osh, cc, SFLASH_ST_SE); - return sfl->blocksize; - case SFLASH_AT: - W_REG (osh, &cc->flashaddress, offset << 1); - sflash_cmd (osh, cc, SFLASH_AT_PAGE_ERASE); - return sfl->blocksize; - } - - return 0; +#ifdef CONFIG_MTD_PARTITIONS + del_mtd_partitions(&sflash.mtd); +#else + del_mtd_device(&sflash.mtd); +#endif + iounmap((void *) sflash.cc); + sb_detach(sflash.sbh); } -/* - * writes the appropriate range of flash, a NULL buf simply erases - * the region of flash - */ -int -sflash_commit (sb_t * sbh, chipcregs_t * cc, uint offset, uint len, - const uchar * buf) -{ - struct sflash *sfl; - uchar *block = NULL, *cur_ptr, *blk_ptr; - uint blocksize = 0, mask, cur_offset, cur_length, cur_retlen, remainder; - uint blk_offset, blk_len, copied; - int bytes, ret = 0; - osl_t *osh; - - ASSERT (sbh); - - osh = sb_osh (sbh); - - /* Check address range */ - if (len <= 0) - return 0; - - sfl = &sflash; - if ((offset + len) > sfl->size) - return -1; - - blocksize = sfl->blocksize; - mask = blocksize - 1; - - /* Allocate a block of mem */ - if (!(block = MALLOC (osh, blocksize))) - return -1; - - while (len) - { - /* Align offset */ - cur_offset = offset & ~mask; - cur_length = blocksize; - cur_ptr = block; - - remainder = blocksize - (offset & mask); - if (len < remainder) - cur_retlen = len; - else - cur_retlen = remainder; - - /* buf == NULL means erase only */ - if (buf) - { - /* Copy existing data into holding block if necessary */ - if ((offset & mask) || (len < blocksize)) - { - blk_offset = cur_offset; - blk_len = cur_length; - blk_ptr = cur_ptr; - - /* Copy entire block */ - while (blk_len) - { - copied = - sflash_read (sbh, cc, blk_offset, blk_len, blk_ptr); - blk_offset += copied; - blk_len -= copied; - blk_ptr += copied; - } - } - - /* Copy input data into holding block */ - memcpy (cur_ptr + (offset & mask), buf, cur_retlen); - } - - /* Erase block */ - if ((ret = sflash_erase (sbh, cc, (uint) cur_offset)) < 0) - goto done; - while (sflash_poll (sbh, cc, (uint) cur_offset)); - - /* buf == NULL means erase only */ - if (!buf) - { - offset += cur_retlen; - len -= cur_retlen; - continue; - } - - /* Write holding block */ - while (cur_length > 0) - { - if ((bytes = sflash_write (sbh, cc, - (uint) cur_offset, - (uint) cur_length, - (uchar *) cur_ptr)) < 0) - { - ret = bytes; - goto done; - } - while (sflash_poll (sbh, cc, (uint) cur_offset)); - cur_offset += bytes; - cur_length -= bytes; - cur_ptr += bytes; - } - - offset += cur_retlen; - len -= cur_retlen; - buf += cur_retlen; - } - - ret = len; -done: - if (block) - MFREE (osh, block, blocksize); - return ret; -} +module_init(sflash_mtd_init); +module_exit(sflash_mtd_exit); diff --git a/target/linux/brcm-2.4/patches/004-flash.patch b/target/linux/brcm-2.4/patches/004-flash.patch index f34efb014..7de8a82eb 100644 --- a/target/linux/brcm-2.4/patches/004-flash.patch +++ b/target/linux/brcm-2.4/patches/004-flash.patch @@ -1,3 +1,13 @@ +--- a/arch/mips/bcm947xx/Makefile ++++ b/arch/mips/bcm947xx/Makefile +@@ -11,6 +11,7 @@ + obj-y := prom.o setup.o time.o sbmips.o gpio.o + obj-y += nvram.o nvram_linux.o cfe_env.o hndpmu.o + obj-y += sbutils.o utils.o bcmsrom.o hndchipc.o ++obj-y += sflash.o + obj-$(CONFIG_PCI) += sbpci.o pcibios.o + obj-y += export.o + --- a/drivers/mtd/devices/Config.in +++ b/drivers/mtd/devices/Config.in @@ -5,6 +5,7 @@ From 79418f0733a44b5f592a359e44696f5a112c9ca5 Mon Sep 17 00:00:00 2001 From: jow Date: Sat, 16 Jan 2010 15:45:12 +0000 Subject: [PATCH 031/210] [package] add broadcom-sdhc - successor of broadcom-mmc (#6343) git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19172 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/broadcom-sdhc/Makefile | 57 ++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 package/broadcom-sdhc/Makefile diff --git a/package/broadcom-sdhc/Makefile b/package/broadcom-sdhc/Makefile new file mode 100644 index 000000000..1bafac926 --- /dev/null +++ b/package/broadcom-sdhc/Makefile @@ -0,0 +1,57 @@ +# +# High Capacity Media card driver. Handles high capacity and standard multimedia +# and secure digital cards +# +# This makefile is compatible for building under the kamikaze 8.09 branch +# + +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_NAME:=broadcom-sdhc +PKG_VERSION:=2.0.2 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://www.4mul8.ca/openwrt/source/broadcom-sdhc-2.0.2 +PKG_MD5SUM:=6238463bce27e64829eda1d88f1a7edd +PKG_CAT:=zcat + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) + +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/broadcom-sdhc + SUBMENU:=Other modules + DEPENDS:=@TARGET_brcm_2_4 + TITLE:= MMHC/SDHC card driver - Linksys WRT54G/GS/GL + VERSION:=$(LINUX_VERSION)-$(BOARD)-$(PKG_VERSION)-$(PKG_RELEASE) + FILES:=\ + $(PKG_BUILD_DIR)/sdhc.$(LINUX_KMOD_SUFFIX)\ + $(PKG_BUILD_DIR)/sdhcd.$(LINUX_KMOD_SUFFIX) + URL:=http://www.4mul8.ca/openwrt +endef + +define KernelPackage/broadcom-sdhc/description + Driver for Linksys WRT54G/GS/GL MM/SD card modification. + Supports standard and high capacity cards. + May work for other broadcom based routers (Buffalo, etc). +endef + +define Build/Compile + $(MAKE) -C "$(LINUX_DIR)" \ + CROSS_COMPILE="$(TARGET_CROSS)" \ + ARCH="$(LINUX_KARCH)" \ + SUBDIRS="$(PKG_BUILD_DIR)" \ + modules +endef + +define KernelPackage/broadcom-sdhc/install + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) $(PKG_BUILD_DIR)/sdcard $(1)/etc/init.d/sdcard + $(INSTALL_DATA) $(PKG_BUILD_DIR)/sdcard.conf $(1)/etc/sdcard.conf + $(CP) $(PKG_BUILD_DIR)/sdhc.o $(1)/lib/modules/$(LINUX_VERSION)/ + $(CP) $(PKG_BUILD_DIR)/sdhcd.o $(1)/lib/modules/$(LINUX_VERSION)/ +endef + +$(eval $(call KernelPackage,broadcom-sdhc)) From 82a38de19fed036d2087a08dcb03d604a1ec0eb5 Mon Sep 17 00:00:00 2001 From: jow Date: Sat, 16 Jan 2010 15:46:43 +0000 Subject: [PATCH 032/210] [package] remove broadcom-mmc, superseded by broadcom-sdhc git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19173 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/broadcom-mmc/Makefile | 46 -- package/broadcom-mmc/src/Makefile | 7 - package/broadcom-mmc/src/mmc.c | 676 ------------------------------ 3 files changed, 729 deletions(-) delete mode 100644 package/broadcom-mmc/Makefile delete mode 100644 package/broadcom-mmc/src/Makefile delete mode 100644 package/broadcom-mmc/src/mmc.c diff --git a/package/broadcom-mmc/Makefile b/package/broadcom-mmc/Makefile deleted file mode 100644 index 509e993c4..000000000 --- a/package/broadcom-mmc/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -# -# Copyright (C) 2007 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)/kernel.mk - -PKG_NAME:=broadcom-mmc -PKG_VERSION:=0.1 -PKG_RELEASE:=1 - -include $(INCLUDE_DIR)/package.mk - -MAKEFLAGS_KMOD:= -C "$(LINUX_DIR)" \ - CROSS_COMPILE="$(TARGET_CROSS)" \ - ARCH="$(LINUX_KARCH)" \ - PATH="$(TARGET_PATH)" \ - SUBDIRS="$(PKG_BUILD_DIR)" - -define KernelPackage/broadcom-mmc - SUBMENU:=Other modules - DEPENDS:=@TARGET_brcm_2_4 - TITLE:=Kernel driver for the Linksys WRT54G MM/SD-Card Mod - URL:=http://kiel.kool.dk/ - FILES:=$(PKG_BUILD_DIR)/mmc.$(LINUX_KMOD_SUFFIX) - AUTOLOAD:=$(call AutoLoad,80,mmc) -endef - -define KernelPackage/broadcom-mmc/description - Kernel driver for the Linksys WRT54G MM/SD-Card Mod -endef - -define Build/Prepare - mkdir -p $(PKG_BUILD_DIR) - $(CP) ./src/* $(PKG_BUILD_DIR)/ -endef - -define Build/Compile - $(MAKE) $(MAKEFLAGS_KMOD) \ - modules -endef - -$(eval $(call KernelPackage,broadcom-mmc)) diff --git a/package/broadcom-mmc/src/Makefile b/package/broadcom-mmc/src/Makefile deleted file mode 100644 index ccf07b169..000000000 --- a/package/broadcom-mmc/src/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -obj-m := mmc.o - -ifeq ($(MAKING_MODULES),1) - --include $(TOPDIR)/Rules.make -endif - diff --git a/package/broadcom-mmc/src/mmc.c b/package/broadcom-mmc/src/mmc.c deleted file mode 100644 index 64cb8d97b..000000000 --- a/package/broadcom-mmc/src/mmc.c +++ /dev/null @@ -1,676 +0,0 @@ -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEVICE_NAME "mmc" -#define DEVICE_NR(device) (MINOR(device)) -#define DEVICE_ON(device) -#define DEVICE_OFF(device) -#define MAJOR_NR 121 - -#include - -MODULE_AUTHOR("Madsuk/Rohde"); -MODULE_DESCRIPTION("Driver MMC/SD-Cards"); -MODULE_SUPPORTED_DEVICE("WRT54G"); -MODULE_LICENSE("GPL"); - -#define SD_DI 0x20 -#define SD_DO 0x10 -#define SD_CLK 0x08 -#define SD_CS 0x80 - -/* we have only one device */ -static int hd_sizes[1<<6]; -static int hd_blocksizes[1<<6]; -static int hd_hardsectsizes[1<<6]; -static int hd_maxsect[1<<6]; -static struct hd_struct hd[1<<6]; - -static struct timer_list mmc_timer; -static int mmc_media_detect = 0; -static int mmc_media_changed = 1; - -typedef unsigned int uint32; - -static unsigned char port_state = 0x00; -static volatile uint32 *gpioaddr_input = (uint32 *)0xb8000060; -static volatile uint32 *gpioaddr_output = (uint32 *)0xb8000064; -static volatile uint32 *gpioaddr_enable = (uint32 *)0xb8000068; -static volatile uint32 *gpioaddr_control = (uint32 *)0xb800006c; - -static void mmc_spi_cs_low(void) -{ - port_state &= ~(SD_CS); - *gpioaddr_output = port_state; -} - -static void mmc_spi_cs_high(void) -{ - port_state |= SD_CS; - *gpioaddr_output = port_state; -} - -static unsigned char mmc_spi_io(unsigned char data_out) -{ - int i; - unsigned char result = 0, tmp_data = 0; - - for(i=0; i<8; i++) { - if(data_out & (0x01 << (7-i))) - port_state |= SD_DI; - else - port_state &= ~SD_DI; - - *gpioaddr_output = port_state; - port_state |= SD_CLK; - *gpioaddr_output = port_state; - - tmp_data = *gpioaddr_input; - - port_state &= ~SD_CLK; - *gpioaddr_output = port_state; - - result <<= 1; - - if(tmp_data & SD_DO) - result |= 1; - } - - return(result); -} - -static int mmc_write_block(unsigned int dest_addr, unsigned char *data) -{ - unsigned int address; - unsigned char r = 0; - unsigned char ab0, ab1, ab2, ab3; - int i; - - address = dest_addr; - - ab3 = 0xff & (address >> 24); - ab2 = 0xff & (address >> 16); - ab1 = 0xff & (address >> 8); - ab0 = 0xff & address; - mmc_spi_cs_low(); - for (i = 0; i < 4; i++) mmc_spi_io(0xff); - mmc_spi_io(0x58); - mmc_spi_io(ab3); /* msb */ - mmc_spi_io(ab2); - mmc_spi_io(ab1); - mmc_spi_io(ab0); /* lsb */ - mmc_spi_io(0xff); - for (i = 0; i < 8; i++) - { - r = mmc_spi_io(0xff); - if (r == 0x00) break; - } - if (r != 0x00) - { - mmc_spi_cs_high(); - mmc_spi_io(0xff); - return(1); - } - - mmc_spi_io(0xfe); - for (i = 0; i < 512; i++) mmc_spi_io(data[i]); - for (i = 0; i < 2; i++) mmc_spi_io(0xff); - - for (i = 0; i < 1000000; i++) - { - r = mmc_spi_io(0xff); - if (r == 0xff) break; - } - if (r != 0xff) - { - mmc_spi_cs_high(); - mmc_spi_io(0xff); - return(3); - } - mmc_spi_cs_high(); - mmc_spi_io(0xff); - return(0); -} - -static int mmc_read_block(unsigned char *data, unsigned int src_addr) -{ - unsigned int address; - unsigned char r = 0; - unsigned char ab0, ab1, ab2, ab3; - int i; - - address = src_addr; - - ab3 = 0xff & (address >> 24); - ab2 = 0xff & (address >> 16); - ab1 = 0xff & (address >> 8); - ab0 = 0xff & address; - - mmc_spi_cs_low(); - for (i = 0; i < 4; i++) mmc_spi_io(0xff); - mmc_spi_io(0x51); - mmc_spi_io(ab3); /* msb */ - mmc_spi_io(ab2); - mmc_spi_io(ab1); - mmc_spi_io(ab0); /* lsb */ - - mmc_spi_io(0xff); - for (i = 0; i < 8; i++) - { - r = mmc_spi_io(0xff); - if (r == 0x00) break; - } - if (r != 0x00) - { - mmc_spi_cs_high(); - mmc_spi_io(0xff); - return(1); - } - for (i = 0; i < 100000; i++) - { - r = mmc_spi_io(0xff); - if (r == 0xfe) break; - } - if (r != 0xfe) - { - mmc_spi_cs_high(); - mmc_spi_io(0xff); - return(2); - } - for (i = 0; i < 512; i++) - { - r = mmc_spi_io(0xff); - data[i] = r; - } - for (i = 0; i < 2; i++) - { - r = mmc_spi_io(0xff); - } - mmc_spi_cs_high(); - mmc_spi_io(0xff); - - return(0); -} - -static void mmc_request(request_queue_t *q) -{ - unsigned int mmc_address; - unsigned char *buffer_address; - int nr_sectors; - int i; - int cmd; - int rc, code; - - (void)q; - while (1) - { - code = 1; // Default is success - INIT_REQUEST; - mmc_address = (CURRENT->sector + hd[MINOR(CURRENT->rq_dev)].start_sect) * hd_hardsectsizes[0]; - buffer_address = CURRENT->buffer; - nr_sectors = CURRENT->current_nr_sectors; - cmd = CURRENT->cmd; - if (((CURRENT->sector + CURRENT->current_nr_sectors + hd[MINOR(CURRENT->rq_dev)].start_sect) > hd[0].nr_sects) || (mmc_media_detect == 0)) - { - code = 0; - } - else if (cmd == READ) - { - spin_unlock_irq(&io_request_lock); - for (i = 0; i < nr_sectors; i++) - { - rc = mmc_read_block(buffer_address, mmc_address); - if (rc != 0) - { - printk("mmc: error in mmc_read_block (%d)\n", rc); - code = 0; - break; - } - else - { - mmc_address += hd_hardsectsizes[0]; - buffer_address += hd_hardsectsizes[0]; - } - } - spin_lock_irq(&io_request_lock); - } - else if (cmd == WRITE) - { - spin_unlock_irq(&io_request_lock); - for (i = 0; i < nr_sectors; i++) - { - rc = mmc_write_block(mmc_address, buffer_address); - if (rc != 0) - { - printk("mmc: error in mmc_write_block (%d)\n", rc); - code = 0; - break; - } - else - { - mmc_address += hd_hardsectsizes[0]; - buffer_address += hd_hardsectsizes[0]; - } - } - spin_lock_irq(&io_request_lock); - } - else - { - code = 0; - } - end_request(code); - } -} - - -static int mmc_open(struct inode *inode, struct file *filp) -{ - int device; - (void)filp; - - if (mmc_media_detect == 0) return -ENODEV; - -#if defined(MODULE) - MOD_INC_USE_COUNT; -#endif - return 0; -} - -static int mmc_release(struct inode *inode, struct file *filp) -{ - (void)filp; - fsync_dev(inode->i_rdev); - invalidate_buffers(inode->i_rdev); - -#if defined(MODULE) - MOD_DEC_USE_COUNT; -#endif - return 0; -} - -extern struct gendisk hd_gendisk; -static int mmc_revalidate(kdev_t dev) -{ - int target, max_p, start, i; - if (mmc_media_detect == 0) return -ENODEV; - - target = DEVICE_NR(dev); - - max_p = hd_gendisk.max_p; - start = target << 6; - for (i = max_p - 1; i >= 0; i--) { - int minor = start + i; - invalidate_device(MKDEV(MAJOR_NR, minor), 1); - hd_gendisk.part[minor].start_sect = 0; - hd_gendisk.part[minor].nr_sects = 0; - } - - grok_partitions(&hd_gendisk, target, 1 << 6, - hd_sizes[0] * 2); - - return 0; -} - -static int mmc_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) -{ - if (!inode || !inode->i_rdev) - return -EINVAL; - - switch(cmd) { - case BLKGETSIZE: - return put_user(hd[MINOR(inode->i_rdev)].nr_sects, (unsigned long *)arg); - case BLKGETSIZE64: - return put_user((u64)hd[MINOR(inode->i_rdev)]. - nr_sects, (u64 *) arg); - case BLKRRPART: - if (!capable(CAP_SYS_ADMIN)) - return -EACCES; - - return mmc_revalidate(inode->i_rdev); - case HDIO_GETGEO: - { - struct hd_geometry *loc, g; - loc = (struct hd_geometry *) arg; - if (!loc) - return -EINVAL; - g.heads = 4; - g.sectors = 16; - g.cylinders = hd[0].nr_sects / (4 * 16); - g.start = hd[MINOR(inode->i_rdev)].start_sect; - return copy_to_user(loc, &g, sizeof(g)) ? -EFAULT : 0; - } - default: - return blk_ioctl(inode->i_rdev, cmd, arg); - } -} - -static int mmc_card_init(void) -{ - unsigned char r = 0; - short i, j; - unsigned long flags; - - save_flags(flags); - cli(); - - printk("mmc Card init\n"); - mmc_spi_cs_high(); - for (i = 0; i < 20; i++) mmc_spi_io(0xff); - - mmc_spi_cs_low(); - - mmc_spi_io(0x40); - for (i = 0; i < 4; i++) mmc_spi_io(0x00); - mmc_spi_io(0x95); - for (i = 0; i < 8; i++) - { - r = mmc_spi_io(0xff); - if (r == 0x01) break; - } - mmc_spi_cs_high(); - mmc_spi_io(0xff); - if (r != 0x01) - { - restore_flags(flags); - return(1); - } - - printk("mmc Card init *1*\n"); - for (j = 0; j < 10000; j++) - { - mmc_spi_cs_low(); - - mmc_spi_io(0x41); - for (i = 0; i < 4; i++) mmc_spi_io(0x00); - mmc_spi_io(0xff); - for (i = 0; i < 8; i++) - { - r = mmc_spi_io(0xff); - if (r == 0x00) break; - } - mmc_spi_cs_high(); - mmc_spi_io(0xff); - if (r == 0x00) - { - restore_flags(flags); - printk("mmc Card init *2*\n"); - return(0); - } - } - restore_flags(flags); - - return(2); -} - -static int mmc_card_config(void) -{ - unsigned char r = 0; - short i; - unsigned char csd[32]; - unsigned int c_size; - unsigned int c_size_mult; - unsigned int mult; - unsigned int read_bl_len; - unsigned int blocknr = 0; - unsigned int block_len = 0; - unsigned int size = 0; - - mmc_spi_cs_low(); - for (i = 0; i < 4; i++) mmc_spi_io(0xff); - mmc_spi_io(0x49); - for (i = 0; i < 4; i++) mmc_spi_io(0x00); - mmc_spi_io(0xff); - for (i = 0; i < 8; i++) - { - r = mmc_spi_io(0xff); - if (r == 0x00) break; - } - if (r != 0x00) - { - mmc_spi_cs_high(); - mmc_spi_io(0xff); - return(1); - } - for (i = 0; i < 8; i++) - { - r = mmc_spi_io(0xff); - if (r == 0xfe) break; - } - if (r != 0xfe) - { - mmc_spi_cs_high(); - mmc_spi_io(0xff); - return(2); - } - for (i = 0; i < 16; i++) - { - r = mmc_spi_io(0xff); - csd[i] = r; - } - for (i = 0; i < 2; i++) - { - r = mmc_spi_io(0xff); - } - mmc_spi_cs_high(); - mmc_spi_io(0xff); - if (r == 0x00) return(3); - - c_size = csd[8] + csd[7] * 256 + (csd[6] & 0x03) * 256 * 256; - c_size >>= 6; - c_size_mult = csd[10] + (csd[9] & 0x03) * 256; - c_size_mult >>= 7; - read_bl_len = csd[5] & 0x0f; - mult = 1; - mult <<= c_size_mult + 2; - blocknr = (c_size + 1) * mult; - block_len = 1; - block_len <<= read_bl_len; - size = block_len * blocknr; - size >>= 10; - - for(i=0; i<(1<<6); i++) { - hd_blocksizes[i] = 1024; - hd_hardsectsizes[i] = block_len; - hd_maxsect[i] = 256; - } - hd_sizes[0] = size; - hd[0].nr_sects = blocknr; - - - printk("Size = %d, hardsectsize = %d, sectors = %d\n", - size, block_len, blocknr); - - return 0; -} - -static int mmc_hardware_init(void) -{ - unsigned char gpio_outen; - - // Set inputs/outputs here - printk("mmc Hardware init\n"); - gpio_outen = *gpioaddr_enable; - - gpio_outen = (gpio_outen | SD_DI | SD_CLK | SD_CS) & ~SD_DO; - *gpioaddr_enable = gpio_outen; - - port_state = *gpioaddr_input; - - // Clock low - port_state &= ~(SD_CLK | SD_DI | SD_CS); - *gpioaddr_output = port_state; - - return 0; -} - -static int mmc_check_media_change(kdev_t dev) -{ - (void)dev; - if (mmc_media_changed == 1) - { - mmc_media_changed = 0; - return 1; - } - else return 0; -} - -static struct block_device_operations mmc_bdops = -{ - open: mmc_open, - release: mmc_release, - ioctl: mmc_ioctl, -#if 0 - check_media_change: mmc_check_media_change, - revalidate: mmc_revalidate, -#endif -}; - -static struct gendisk hd_gendisk = { - major: MAJOR_NR, - major_name: DEVICE_NAME, - minor_shift: 6, - max_p: 1 << 6, - part: hd, - sizes: hd_sizes, - fops: &mmc_bdops, -}; - -static int mmc_init(void) -{ - int rc; - - rc = mmc_hardware_init(); - - if ( rc != 0) - { - printk("mmc: error in mmc_hardware_init (%d)\n", rc); - return -1; - } - - rc = mmc_card_init(); - if ( rc != 0) - { - // Give it an extra shot - rc = mmc_card_init(); - if ( rc != 0) - { - printk("mmc: error in mmc_card_init (%d)\n", rc); - return -1; - } - } - - memset(hd_sizes, 0, sizeof(hd_sizes)); - rc = mmc_card_config(); - if ( rc != 0) - { - printk("mmc: error in mmc_card_config (%d)\n", rc); - return -1; - } - - - blk_size[MAJOR_NR] = hd_sizes; - - memset(hd, 0, sizeof(hd)); - hd[0].nr_sects = hd_sizes[0]*2; - - blksize_size[MAJOR_NR] = hd_blocksizes; - hardsect_size[MAJOR_NR] = hd_hardsectsizes; - max_sectors[MAJOR_NR] = hd_maxsect; - - hd_gendisk.nr_real = 1; - - register_disk(&hd_gendisk, MKDEV(MAJOR_NR,0), 1<<6, - &mmc_bdops, hd_sizes[0]*2); - - return 0; -} - -static void mmc_exit(void) -{ - blk_size[MAJOR_NR] = NULL; - blksize_size[MAJOR_NR] = NULL; - hardsect_size[MAJOR_NR] = NULL; - max_sectors[MAJOR_NR] = NULL; - hd[0].nr_sects = 0; -} - -static void mmc_check_media(void) -{ - int old_state; - int rc; - - old_state = mmc_media_detect; - - // TODO: Add card detection here - mmc_media_detect = 1; - if (old_state != mmc_media_detect) - { - mmc_media_changed = 1; - if (mmc_media_detect == 1) - { - rc = mmc_init(); - if (rc != 0) printk("mmc: error in mmc_init (%d)\n", rc); - } - else - { - mmc_exit(); - } - } - - /* del_timer(&mmc_timer); - mmc_timer.expires = jiffies + 10*HZ; - add_timer(&mmc_timer); */ -} - -static int __init mmc_driver_init(void) -{ - int rc; - - rc = devfs_register_blkdev(MAJOR_NR, DEVICE_NAME, &mmc_bdops); - if (rc < 0) - { - printk(KERN_WARNING "mmc: can't get major %d\n", MAJOR_NR); - return rc; - } - - blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), mmc_request); - - read_ahead[MAJOR_NR] = 8; - add_gendisk(&hd_gendisk); - - mmc_check_media(); - - /*init_timer(&mmc_timer); - mmc_timer.expires = jiffies + HZ; - mmc_timer.function = (void *)mmc_check_media; - add_timer(&mmc_timer);*/ - - return 0; -} - -static void __exit mmc_driver_exit(void) -{ - int i; - del_timer(&mmc_timer); - - for (i = 0; i < (1 << 6); i++) - fsync_dev(MKDEV(MAJOR_NR, i)); - - blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR)); - del_gendisk(&hd_gendisk); - devfs_unregister_blkdev(MAJOR_NR, DEVICE_NAME); - mmc_exit(); -} - -module_init(mmc_driver_init); -module_exit(mmc_driver_exit); From 5231eb95d671f6da18dace18e37ff6943d5cbd4d Mon Sep 17 00:00:00 2001 From: nbd Date: Sat, 16 Jan 2010 22:18:56 +0000 Subject: [PATCH 033/210] make sure that processed directories are printed on make V=99 git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19174 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- include/verbose.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/verbose.mk b/include/verbose.mk index 620c2b3f0..f795e2804 100644 --- a/include/verbose.mk +++ b/include/verbose.mk @@ -49,7 +49,7 @@ ifneq ($(KBUILD_VERBOSE),99) .SILENT: $(MAKECMDGOALS) else - SUBMAKE=$(MAKE) + SUBMAKE=$(MAKE) -w define MESSAGE printf "%s\n" "$(1)" endef From 682557cca159feecf97ec8cfa025954b4f56b5a0 Mon Sep 17 00:00:00 2001 From: nbd Date: Sun, 17 Jan 2010 01:07:18 +0000 Subject: [PATCH 034/210] ar71xx: the lack of DQ* flash status checking for cfi cmdset 0002 does not only apply to erase commands, it also affects writes. extend the workaround to cover writes commands as well git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19175 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- ...x_cfi_cmdset_0002_erase_status_check.patch | 20 ------ ...mtd_fix_cfi_cmdset_0002_status_check.patch | 71 +++++++++++++++++++ 2 files changed, 71 insertions(+), 20 deletions(-) delete mode 100644 target/linux/ar71xx/patches-2.6.30/108-mtd_fix_cfi_cmdset_0002_erase_status_check.patch create mode 100644 target/linux/ar71xx/patches-2.6.30/108-mtd_fix_cfi_cmdset_0002_status_check.patch diff --git a/target/linux/ar71xx/patches-2.6.30/108-mtd_fix_cfi_cmdset_0002_erase_status_check.patch b/target/linux/ar71xx/patches-2.6.30/108-mtd_fix_cfi_cmdset_0002_erase_status_check.patch deleted file mode 100644 index 3f25b61dd..000000000 --- a/target/linux/ar71xx/patches-2.6.30/108-mtd_fix_cfi_cmdset_0002_erase_status_check.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/drivers/mtd/chips/cfi_cmdset_0002.c -+++ b/drivers/mtd/chips/cfi_cmdset_0002.c -@@ -1579,7 +1579,7 @@ static int __xipram do_erase_chip(struct - chip->erase_suspended = 0; - } - -- if (chip_ready(map, adr)) -+ if (chip_good(map, adr, map_word_ff(map))) - break; - - if (time_after(jiffies, timeo)) { -@@ -1667,7 +1667,7 @@ static int __xipram do_erase_oneblock(st - chip->erase_suspended = 0; - } - -- if (chip_ready(map, adr)) { -+ if (chip_good(map, adr, map_word_ff(map))) { - xip_enable(map, chip, adr); - break; - } diff --git a/target/linux/ar71xx/patches-2.6.30/108-mtd_fix_cfi_cmdset_0002_status_check.patch b/target/linux/ar71xx/patches-2.6.30/108-mtd_fix_cfi_cmdset_0002_status_check.patch new file mode 100644 index 000000000..6c49fd4ea --- /dev/null +++ b/target/linux/ar71xx/patches-2.6.30/108-mtd_fix_cfi_cmdset_0002_status_check.patch @@ -0,0 +1,71 @@ +--- a/drivers/mtd/chips/cfi_cmdset_0002.c ++++ b/drivers/mtd/chips/cfi_cmdset_0002.c +@@ -39,7 +39,7 @@ + #include + + #define AMD_BOOTLOC_BUG +-#define FORCE_WORD_WRITE 0 ++#define FORCE_WORD_WRITE 1 + + #define MAX_WORD_RETRIES 3 + +@@ -190,6 +190,7 @@ static void fixup_amd_bootblock(struct m + } + #endif + ++#if !FORCE_WORD_WRITE + static void fixup_use_write_buffers(struct mtd_info *mtd, void *param) + { + struct map_info *map = mtd->priv; +@@ -199,6 +200,7 @@ static void fixup_use_write_buffers(stru + mtd->write = cfi_amdstd_write_buffers; + } + } ++#endif + + /* Atmel chips don't use the same PRI format as AMD chips */ + static void fixup_convert_atmel_pri(struct mtd_info *mtd, void *param) +@@ -1152,7 +1154,7 @@ static int __xipram do_write_oneword(str + break; + } + +- if (chip_ready(map, adr)) ++ if (chip_good(map, adr, datum)) + break; + + /* Latency issues. Drop the lock, wait a while and retry */ +@@ -1436,6 +1438,7 @@ static int __xipram do_write_buffer(stru + } + + ++#if !FORCE_WORD_WRITE + static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len, + size_t *retlen, const u_char *buf) + { +@@ -1514,7 +1517,7 @@ static int cfi_amdstd_write_buffers(stru + + return 0; + } +- ++#endif + + /* + * Handle devices with one erase region, that only implement +@@ -1579,7 +1582,7 @@ static int __xipram do_erase_chip(struct + chip->erase_suspended = 0; + } + +- if (chip_ready(map, adr)) ++ if (chip_good(map, adr, map_word_ff(map))) + break; + + if (time_after(jiffies, timeo)) { +@@ -1667,7 +1670,7 @@ static int __xipram do_erase_oneblock(st + chip->erase_suspended = 0; + } + +- if (chip_ready(map, adr)) { ++ if (chip_good(map, adr, map_word_ff(map))) { + xip_enable(map, chip, adr); + break; + } From 9e219ca63654c28f0f63378a4f176fb8da6d5b5e Mon Sep 17 00:00:00 2001 From: nbd Date: Sun, 17 Jan 2010 01:38:07 +0000 Subject: [PATCH 035/210] mac80211: upgrade to compat-wireless 2010-01-15 git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19176 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/mac80211/Makefile | 7 +- .../mac80211/patches/020-fix_compat_h.patch | 4 +- .../patches/021-fix_missing_ifdefs.patch | 18 -- .../patches/300-ath9k_fix_init_crash.patch | 35 --- .../patches/301-mac80211_tx_queue_wake.patch | 15 -- .../patches/302-mac80211_pwr_mgmt_fix.patch | 6 +- ...h9k-fix-invalid-mac-address-handling.patch | 2 +- ...ROM-only-if-no-platform-data-present.patch | 2 +- ...rride-mac-address-from-platform-data.patch | 2 +- .../408-ath9k_tweak_rx_intr_mitigation.patch | 2 +- ..._cts.patch => 540-ath9k_fix_rts_cts.patch} | 0 .../patches/540-short_slot_handling.patch | 27 --- ...=> 550-ath9k_ack_timeout_workaround.patch} | 0 .../550-ath9k_clean_up_timing_handling.patch | 229 ------------------ .../patches/560-ath9k_coverage_class.patch | 60 ----- 15 files changed, 13 insertions(+), 396 deletions(-) delete mode 100644 package/mac80211/patches/021-fix_missing_ifdefs.patch delete mode 100644 package/mac80211/patches/300-ath9k_fix_init_crash.patch delete mode 100644 package/mac80211/patches/301-mac80211_tx_queue_wake.patch rename package/mac80211/patches/{570-ath9k_fix_rts_cts.patch => 540-ath9k_fix_rts_cts.patch} (100%) delete mode 100644 package/mac80211/patches/540-short_slot_handling.patch rename package/mac80211/patches/{580-ath9k_ack_timeout_workaround.patch => 550-ath9k_ack_timeout_workaround.patch} (100%) delete mode 100644 package/mac80211/patches/550-ath9k_clean_up_timing_handling.patch delete mode 100644 package/mac80211/patches/560-ath9k_coverage_class.patch diff --git a/package/mac80211/Makefile b/package/mac80211/Makefile index b173300db..0d0e975b9 100644 --- a/package/mac80211/Makefile +++ b/package/mac80211/Makefile @@ -10,12 +10,12 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=mac80211 -PKG_VERSION:=2010-01-13 +PKG_VERSION:=2010-01-15 PKG_RELEASE:=1 PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources # http://www.orbit-lab.org/kernel/compat-wireless-2.6/2010/11 \ # http://wireless.kernel.org/download/compat-wireless-2.6 -PKG_MD5SUM:=b773266f141a1a6349b6e09b84948f02 +PKG_MD5SUM:=aa6f80ad3fcc2b663e62c7b80d37abd3 PKG_SOURCE:=compat-wireless-$(PKG_VERSION).tar.bz2 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/compat-wireless-$(PKG_VERSION) @@ -42,9 +42,10 @@ define KernelPackage/mac80211 DEPENDS+= +kmod-crypto-arc4 +kmod-crypto-aes +wireless-tools +iw @!LINUX_2_6_21 @!LINUX_2_6_25 FILES:= \ $(PKG_BUILD_DIR)/compat/compat.$(LINUX_KMOD_SUFFIX) \ + $(PKG_BUILD_DIR)/compat/compat_firmware_class.$(LINUX_KMOD_SUFFIX) \ $(PKG_BUILD_DIR)/net/mac80211/mac80211.$(LINUX_KMOD_SUFFIX) \ $(PKG_BUILD_DIR)/net/wireless/cfg80211.$(LINUX_KMOD_SUFFIX) - AUTOLOAD:=$(call AutoLoad,20,compat cfg80211 mac80211) + AUTOLOAD:=$(call AutoLoad,20,compat compat_firmware_class cfg80211 mac80211) endef define KernelPackage/mac80211/config diff --git a/package/mac80211/patches/020-fix_compat_h.patch b/package/mac80211/patches/020-fix_compat_h.patch index 7f90cf4dc..b001cf2ed 100644 --- a/package/mac80211/patches/020-fix_compat_h.patch +++ b/package/mac80211/patches/020-fix_compat_h.patch @@ -1,6 +1,6 @@ --- a/include/linux/compat-2.6.32.h +++ b/include/linux/compat-2.6.32.h -@@ -7,7 +7,7 @@ +@@ -6,7 +6,7 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) #include @@ -8,4 +8,4 @@ +#include #include #include - + #include diff --git a/package/mac80211/patches/021-fix_missing_ifdefs.patch b/package/mac80211/patches/021-fix_missing_ifdefs.patch deleted file mode 100644 index 2c838ebac..000000000 --- a/package/mac80211/patches/021-fix_missing_ifdefs.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/compat/compat-2.6.33.c -+++ b/compat/compat-2.6.33.c -@@ -12,6 +12,7 @@ - - #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) - -+#ifdef CONFIG_PCCARD - - /** - * pccard_loop_tuple() - loop over tuples in the CIS -@@ -125,6 +126,7 @@ int pcmcia_loop_tuple(struct pcmcia_devi - EXPORT_SYMBOL(pcmcia_loop_tuple); - /* Source: drivers/pcmcia/pcmcia_resource.c */ - -+#endif - - #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */ - diff --git a/package/mac80211/patches/300-ath9k_fix_init_crash.patch b/package/mac80211/patches/300-ath9k_fix_init_crash.patch deleted file mode 100644 index 8f3540b5d..000000000 --- a/package/mac80211/patches/300-ath9k_fix_init_crash.patch +++ /dev/null @@ -1,35 +0,0 @@ ---- a/drivers/net/wireless/ath/ath9k/ahb.c -+++ b/drivers/net/wireless/ath/ath9k/ahb.c -@@ -121,6 +121,9 @@ static int ath_ahb_probe(struct platform - sc->mem = mem; - sc->irq = irq; - -+ /* Will be cleared in ath9k_start() */ -+ sc->sc_flags |= SC_OP_INVALID; -+ - ret = request_irq(irq, ath_isr, IRQF_SHARED, "ath9k", sc); - if (ret) { - dev_err(&pdev->dev, "request_irq failed\n"); ---- a/drivers/net/wireless/ath/ath9k/init.c -+++ b/drivers/net/wireless/ath/ath9k/init.c -@@ -534,8 +534,6 @@ static int ath9k_init_softc(u16 devid, s - int ret = 0, i; - int csz = 0; - -- sc->sc_flags |= SC_OP_INVALID; -- - ah = kzalloc(sizeof(struct ath_hw), GFP_KERNEL); - if (!ah) - return -ENOMEM; ---- a/drivers/net/wireless/ath/ath9k/pci.c -+++ b/drivers/net/wireless/ath/ath9k/pci.c -@@ -202,6 +202,9 @@ static int ath_pci_probe(struct pci_dev - sc->dev = &pdev->dev; - sc->mem = mem; - -+ /* Will be cleared in ath9k_start() */ -+ sc->sc_flags |= SC_OP_INVALID; -+ - ret = request_irq(pdev->irq, ath_isr, IRQF_SHARED, "ath9k", sc); - if (ret) { - dev_err(&pdev->dev, "request_irq failed\n"); diff --git a/package/mac80211/patches/301-mac80211_tx_queue_wake.patch b/package/mac80211/patches/301-mac80211_tx_queue_wake.patch deleted file mode 100644 index 1934fccac..000000000 --- a/package/mac80211/patches/301-mac80211_tx_queue_wake.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/mac80211/offchannel.c -+++ b/net/mac80211/offchannel.c -@@ -153,9 +153,11 @@ void ieee80211_offchannel_return(struct - if (sdata->vif.type == NL80211_IFTYPE_STATION) { - if (sdata->u.mgd.associated) - ieee80211_offchannel_ps_disable(sdata); -- netif_tx_wake_all_queues(sdata->dev); - } - -+ if (sdata->vif.type != NL80211_IFTYPE_MONITOR) -+ netif_tx_wake_all_queues(sdata->dev); -+ - /* re-enable beaconing */ - if (enable_beaconing && - (sdata->vif.type == NL80211_IFTYPE_AP || diff --git a/package/mac80211/patches/302-mac80211_pwr_mgmt_fix.patch b/package/mac80211/patches/302-mac80211_pwr_mgmt_fix.patch index 628fc1d20..30a91840e 100644 --- a/package/mac80211/patches/302-mac80211_pwr_mgmt_fix.patch +++ b/package/mac80211/patches/302-mac80211_pwr_mgmt_fix.patch @@ -1,8 +1,8 @@ --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c -@@ -1384,6 +1384,9 @@ static int ieee80211_set_power_mgmt(stru - struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); - struct ieee80211_conf *conf = &local->hw.conf; +@@ -1394,6 +1394,9 @@ static int ieee80211_set_power_mgmt(stru + if (sdata->vif.type != NL80211_IFTYPE_STATION) + return -EOPNOTSUPP; + if (sdata->vif.type != NL80211_IFTYPE_STATION) + return 0; diff --git a/package/mac80211/patches/403-ath9k-fix-invalid-mac-address-handling.patch b/package/mac80211/patches/403-ath9k-fix-invalid-mac-address-handling.patch index 63cb3d979..c41495175 100644 --- a/package/mac80211/patches/403-ath9k-fix-invalid-mac-address-handling.patch +++ b/package/mac80211/patches/403-ath9k-fix-invalid-mac-address-handling.patch @@ -8,7 +8,7 @@ #include #include "hw.h" -@@ -461,8 +462,18 @@ static int ath9k_hw_init_macaddr(struct +@@ -437,8 +438,18 @@ static int ath9k_hw_init_macaddr(struct common->macaddr[2 * i] = eeval >> 8; common->macaddr[2 * i + 1] = eeval & 0xff; } diff --git a/package/mac80211/patches/406-ath9k-set-AH_USE_EEPROM-only-if-no-platform-data-present.patch b/package/mac80211/patches/406-ath9k-set-AH_USE_EEPROM-only-if-no-platform-data-present.patch index c09935ee7..a83242f91 100644 --- a/package/mac80211/patches/406-ath9k-set-AH_USE_EEPROM-only-if-no-platform-data-present.patch +++ b/package/mac80211/patches/406-ath9k-set-AH_USE_EEPROM-only-if-no-platform-data-present.patch @@ -1,6 +1,6 @@ --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c -@@ -403,11 +403,8 @@ static void ath9k_hw_init_defaults(struc +@@ -381,11 +381,8 @@ static void ath9k_hw_init_defaults(struc ah->hw_version.magic = AR5416_MAGIC; ah->hw_version.subvendorid = 0; diff --git a/package/mac80211/patches/407-ath9k-override-mac-address-from-platform-data.patch b/package/mac80211/patches/407-ath9k-override-mac-address-from-platform-data.patch index 615de77a5..dae663dd7 100644 --- a/package/mac80211/patches/407-ath9k-override-mac-address-from-platform-data.patch +++ b/package/mac80211/patches/407-ath9k-override-mac-address-from-platform-data.patch @@ -11,7 +11,7 @@ #include "hw.h" #include "rc.h" #include "initvals.h" -@@ -448,17 +450,23 @@ static int ath9k_hw_rf_claim(struct ath_ +@@ -424,17 +426,23 @@ static int ath9k_hw_rf_claim(struct ath_ static int ath9k_hw_init_macaddr(struct ath_hw *ah) { struct ath_common *common = ath9k_hw_common(ah); diff --git a/package/mac80211/patches/408-ath9k_tweak_rx_intr_mitigation.patch b/package/mac80211/patches/408-ath9k_tweak_rx_intr_mitigation.patch index b900f411f..e3df0ad14 100644 --- a/package/mac80211/patches/408-ath9k_tweak_rx_intr_mitigation.patch +++ b/package/mac80211/patches/408-ath9k_tweak_rx_intr_mitigation.patch @@ -1,6 +1,6 @@ --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c -@@ -2109,7 +2109,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st +@@ -2088,7 +2088,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st if (ah->config.rx_intr_mitigation) { REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_LAST, 500); diff --git a/package/mac80211/patches/570-ath9k_fix_rts_cts.patch b/package/mac80211/patches/540-ath9k_fix_rts_cts.patch similarity index 100% rename from package/mac80211/patches/570-ath9k_fix_rts_cts.patch rename to package/mac80211/patches/540-ath9k_fix_rts_cts.patch diff --git a/package/mac80211/patches/540-short_slot_handling.patch b/package/mac80211/patches/540-short_slot_handling.patch deleted file mode 100644 index 70341473e..000000000 --- a/package/mac80211/patches/540-short_slot_handling.patch +++ /dev/null @@ -1,27 +0,0 @@ ---- a/net/mac80211/mlme.c -+++ b/net/mac80211/mlme.c -@@ -670,6 +670,8 @@ static u32 ieee80211_handle_bss_capabili - } - - use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME); -+ if (sdata->local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) -+ use_short_slot = true; - - if (use_protection != bss_conf->use_cts_prot) { - bss_conf->use_cts_prot = use_protection; ---- a/net/mac80211/cfg.c -+++ b/net/mac80211/cfg.c -@@ -1087,6 +1087,13 @@ static int ieee80211_change_bss(struct w - params->use_short_preamble; - changed |= BSS_CHANGED_ERP_PREAMBLE; - } -+ -+ if (!sdata->vif.bss_conf.use_short_slot && -+ sdata->local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) { -+ sdata->vif.bss_conf.use_short_slot = true; -+ changed |= BSS_CHANGED_ERP_SLOT; -+ } -+ - if (params->use_short_slot_time >= 0) { - sdata->vif.bss_conf.use_short_slot = - params->use_short_slot_time; diff --git a/package/mac80211/patches/580-ath9k_ack_timeout_workaround.patch b/package/mac80211/patches/550-ath9k_ack_timeout_workaround.patch similarity index 100% rename from package/mac80211/patches/580-ath9k_ack_timeout_workaround.patch rename to package/mac80211/patches/550-ath9k_ack_timeout_workaround.patch diff --git a/package/mac80211/patches/550-ath9k_clean_up_timing_handling.patch b/package/mac80211/patches/550-ath9k_clean_up_timing_handling.patch deleted file mode 100644 index dc6502274..000000000 --- a/package/mac80211/patches/550-ath9k_clean_up_timing_handling.patch +++ /dev/null @@ -1,229 +0,0 @@ ---- a/drivers/net/wireless/ath/ath9k/main.c -+++ b/drivers/net/wireless/ath/ath9k/main.c -@@ -1790,6 +1790,7 @@ static void ath9k_bss_info_changed(struc - struct ath_hw *ah = sc->sc_ah; - struct ath_common *common = ath9k_hw_common(ah); - struct ath_vif *avp = (void *)vif->drv_priv; -+ int slottime; - int error; - - mutex_lock(&sc->mutex); -@@ -1825,6 +1826,25 @@ static void ath9k_bss_info_changed(struc - ath_beacon_config(sc, vif); - } - -+ if (changed & BSS_CHANGED_ERP_SLOT) { -+ if (bss_conf->use_short_slot) -+ slottime = 9; -+ else -+ slottime = 20; -+ if (vif->type == NL80211_IFTYPE_AP) { -+ /* -+ * Defer update, so that connected stations can adjust -+ * their settings at the same time. -+ * See beacon.c for more details -+ */ -+ sc->beacon.slottime = slottime; -+ sc->beacon.updateslot = UPDATE; -+ } else { -+ ah->slottime = slottime; -+ ath9k_hw_init_global_settings(ah); -+ } -+ } -+ - /* Disable transmission of beacons */ - if ((changed & BSS_CHANGED_BEACON_ENABLED) && !bss_conf->enable_beacon) - ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq); ---- a/drivers/net/wireless/ath/ath9k/hw.c -+++ b/drivers/net/wireless/ath/ath9k/hw.c -@@ -55,28 +55,6 @@ module_exit(ath9k_exit); - /* Helper Functions */ - /********************/ - --static u32 ath9k_hw_mac_usec(struct ath_hw *ah, u32 clks) --{ -- struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf; -- -- if (!ah->curchan) /* should really check for CCK instead */ -- return clks / ATH9K_CLOCK_RATE_CCK; -- if (conf->channel->band == IEEE80211_BAND_2GHZ) -- return clks / ATH9K_CLOCK_RATE_2GHZ_OFDM; -- -- return clks / ATH9K_CLOCK_RATE_5GHZ_OFDM; --} -- --static u32 ath9k_hw_mac_to_usec(struct ath_hw *ah, u32 clks) --{ -- struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf; -- -- if (conf_is_ht40(conf)) -- return ath9k_hw_mac_usec(ah, clks) / 2; -- else -- return ath9k_hw_mac_usec(ah, clks); --} -- - static u32 ath9k_hw_mac_clks(struct ath_hw *ah, u32 usecs) - { - struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf; -@@ -413,8 +391,6 @@ static void ath9k_hw_init_defaults(struc - ah->beacon_interval = 100; - ah->enable_32kHz_clock = DONT_USE_32KHZ; - ah->slottime = (u32) -1; -- ah->acktimeout = (u32) -1; -- ah->ctstimeout = (u32) -1; - ah->globaltxtimeout = (u32) -1; - ah->power_mode = ATH9K_PM_UNDEFINED; - } -@@ -1196,34 +1172,25 @@ static void ath9k_hw_init_interrupt_mask - } - } - --static bool ath9k_hw_set_ack_timeout(struct ath_hw *ah, u32 us) -+static void ath9k_hw_setslottime(struct ath_hw *ah, u32 us) - { -- if (us > ath9k_hw_mac_to_usec(ah, MS(0xffffffff, AR_TIME_OUT_ACK))) { -- ath_print(ath9k_hw_common(ah), ATH_DBG_RESET, -- "bad ack timeout %u\n", us); -- ah->acktimeout = (u32) -1; -- return false; -- } else { -- REG_RMW_FIELD(ah, AR_TIME_OUT, -- AR_TIME_OUT_ACK, ath9k_hw_mac_to_clks(ah, us)); -- ah->acktimeout = us; -- return true; -- } -+ u32 val = ath9k_hw_mac_to_clks(ah, us); -+ val = min(val, (u32) 0xFFFF); -+ REG_WRITE(ah, AR_D_GBL_IFS_SLOT, val); - } - --static bool ath9k_hw_set_cts_timeout(struct ath_hw *ah, u32 us) -+static void ath9k_hw_set_ack_timeout(struct ath_hw *ah, u32 us) - { -- if (us > ath9k_hw_mac_to_usec(ah, MS(0xffffffff, AR_TIME_OUT_CTS))) { -- ath_print(ath9k_hw_common(ah), ATH_DBG_RESET, -- "bad cts timeout %u\n", us); -- ah->ctstimeout = (u32) -1; -- return false; -- } else { -- REG_RMW_FIELD(ah, AR_TIME_OUT, -- AR_TIME_OUT_CTS, ath9k_hw_mac_to_clks(ah, us)); -- ah->ctstimeout = us; -- return true; -- } -+ u32 val = ath9k_hw_mac_to_clks(ah, us); -+ val = min(val, (u32) MS(0xFFFFFFFF, AR_TIME_OUT_ACK)); -+ REG_RMW_FIELD(ah, AR_TIME_OUT, AR_TIME_OUT_ACK, val); -+} -+ -+static void ath9k_hw_set_cts_timeout(struct ath_hw *ah, u32 us) -+{ -+ u32 val = ath9k_hw_mac_to_clks(ah, us); -+ val = min(val, (u32) MS(0xFFFFFFFF, AR_TIME_OUT_CTS)); -+ REG_RMW_FIELD(ah, AR_TIME_OUT, AR_TIME_OUT_CTS, val); - } - - static bool ath9k_hw_set_global_txtimeout(struct ath_hw *ah, u32 tu) -@@ -1240,23 +1207,32 @@ static bool ath9k_hw_set_global_txtimeou - } - } - --static void ath9k_hw_init_user_settings(struct ath_hw *ah) -+void ath9k_hw_init_global_settings(struct ath_hw *ah) - { -+ struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf; -+ int acktimeout; -+ int sifstime; -+ - ath_print(ath9k_hw_common(ah), ATH_DBG_RESET, "ah->misc_mode 0x%x\n", - ah->misc_mode); - - if (ah->misc_mode != 0) - REG_WRITE(ah, AR_PCU_MISC, - REG_READ(ah, AR_PCU_MISC) | ah->misc_mode); -- if (ah->slottime != (u32) -1) -- ath9k_hw_setslottime(ah, ah->slottime); -- if (ah->acktimeout != (u32) -1) -- ath9k_hw_set_ack_timeout(ah, ah->acktimeout); -- if (ah->ctstimeout != (u32) -1) -- ath9k_hw_set_cts_timeout(ah, ah->ctstimeout); -+ -+ if (conf->channel && conf->channel->band == IEEE80211_BAND_5GHZ) -+ sifstime = 16; -+ else -+ sifstime = 10; -+ -+ acktimeout = ah->slottime + sifstime; -+ ath9k_hw_setslottime(ah, ah->slottime); -+ ath9k_hw_set_ack_timeout(ah, acktimeout); -+ ath9k_hw_set_cts_timeout(ah, acktimeout); - if (ah->globaltxtimeout != (u32) -1) - ath9k_hw_set_global_txtimeout(ah, ah->globaltxtimeout); - } -+EXPORT_SYMBOL(ath9k_hw_init_global_settings); - - void ath9k_hw_deinit(struct ath_hw *ah) - { -@@ -2077,7 +2053,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st - if (ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT) - ath9k_enable_rfkill(ah); - -- ath9k_hw_init_user_settings(ah); -+ ath9k_hw_init_global_settings(ah); - - if (AR_SREV_9287_12_OR_LATER(ah)) { - REG_WRITE(ah, AR_D_GBL_IFS_SIFS, -@@ -3674,21 +3650,6 @@ u64 ath9k_hw_extend_tsf(struct ath_hw *a - } - EXPORT_SYMBOL(ath9k_hw_extend_tsf); - --bool ath9k_hw_setslottime(struct ath_hw *ah, u32 us) --{ -- if (us < ATH9K_SLOT_TIME_9 || us > ath9k_hw_mac_to_usec(ah, 0xffff)) { -- ath_print(ath9k_hw_common(ah), ATH_DBG_RESET, -- "bad slot time %u\n", us); -- ah->slottime = (u32) -1; -- return false; -- } else { -- REG_WRITE(ah, AR_D_GBL_IFS_SLOT, ath9k_hw_mac_to_clks(ah, us)); -- ah->slottime = us; -- return true; -- } --} --EXPORT_SYMBOL(ath9k_hw_setslottime); -- - void ath9k_hw_set11nmac2040(struct ath_hw *ah) - { - struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf; ---- a/drivers/net/wireless/ath/ath9k/hw.h -+++ b/drivers/net/wireless/ath/ath9k/hw.h -@@ -553,8 +553,6 @@ struct ath_hw { - int16_t txpower_indexoffset; - u32 beacon_interval; - u32 slottime; -- u32 acktimeout; -- u32 ctstimeout; - u32 globaltxtimeout; - - /* ANI */ -@@ -668,7 +666,7 @@ void ath9k_hw_settsf64(struct ath_hw *ah - void ath9k_hw_reset_tsf(struct ath_hw *ah); - void ath9k_hw_set_tsfadjust(struct ath_hw *ah, u32 setting); - u64 ath9k_hw_extend_tsf(struct ath_hw *ah, u32 rstamp); --bool ath9k_hw_setslottime(struct ath_hw *ah, u32 us); -+void ath9k_hw_init_global_settings(struct ath_hw *ah); - void ath9k_hw_set11nmac2040(struct ath_hw *ah); - void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period); - void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah, ---- a/drivers/net/wireless/ath/ath9k/beacon.c -+++ b/drivers/net/wireless/ath/ath9k/beacon.c -@@ -480,7 +480,8 @@ void ath_beacon_tasklet(unsigned long da - sc->beacon.updateslot = COMMIT; /* commit next beacon */ - sc->beacon.slotupdate = slot; - } else if (sc->beacon.updateslot == COMMIT && sc->beacon.slotupdate == slot) { -- ath9k_hw_setslottime(sc->sc_ah, sc->beacon.slottime); -+ ah->slottime = sc->beacon.slottime; -+ ath9k_hw_init_global_settings(ah); - sc->beacon.updateslot = OK; - } - if (bfaddr != 0) { diff --git a/package/mac80211/patches/560-ath9k_coverage_class.patch b/package/mac80211/patches/560-ath9k_coverage_class.patch deleted file mode 100644 index 035eabb1f..000000000 --- a/package/mac80211/patches/560-ath9k_coverage_class.patch +++ /dev/null @@ -1,60 +0,0 @@ ---- a/drivers/net/wireless/ath/ath9k/hw.c -+++ b/drivers/net/wireless/ath/ath9k/hw.c -@@ -1211,6 +1211,7 @@ void ath9k_hw_init_global_settings(struc - { - struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf; - int acktimeout; -+ int slottime; - int sifstime; - - ath_print(ath9k_hw_common(ah), ATH_DBG_RESET, "ah->misc_mode 0x%x\n", -@@ -1225,8 +1226,10 @@ void ath9k_hw_init_global_settings(struc - else - sifstime = 10; - -- acktimeout = ah->slottime + sifstime; -- ath9k_hw_setslottime(ah, ah->slottime); -+ /* As defined by IEEE 802.11-2007 17.3.8.6 */ -+ slottime = ah->slottime + 3 * ah->coverage_class; -+ acktimeout = slottime + sifstime; -+ ath9k_hw_setslottime(ah, slottime); - ath9k_hw_set_ack_timeout(ah, acktimeout); - ath9k_hw_set_cts_timeout(ah, acktimeout); - if (ah->globaltxtimeout != (u32) -1) ---- a/drivers/net/wireless/ath/ath9k/hw.h -+++ b/drivers/net/wireless/ath/ath9k/hw.h -@@ -551,6 +551,7 @@ struct ath_hw { - u32 *bank6Temp; - - int16_t txpower_indexoffset; -+ int coverage_class; - u32 beacon_interval; - u32 slottime; - u32 globaltxtimeout; ---- a/drivers/net/wireless/ath/ath9k/main.c -+++ b/drivers/net/wireless/ath/ath9k/main.c -@@ -2015,6 +2015,18 @@ static void ath9k_sw_scan_complete(struc - mutex_unlock(&sc->mutex); - } - -+static void ath9k_set_coverage_class(struct ieee80211_hw *hw, u8 coverage_class) -+{ -+ struct ath_wiphy *aphy = hw->priv; -+ struct ath_softc *sc = aphy->sc; -+ struct ath_hw *ah = sc->sc_ah; -+ -+ mutex_lock(&sc->mutex); -+ ah->coverage_class = coverage_class; -+ ath9k_hw_init_global_settings(ah); -+ mutex_unlock(&sc->mutex); -+} -+ - struct ieee80211_ops ath9k_ops = { - .tx = ath9k_tx, - .start = ath9k_start, -@@ -2034,4 +2046,5 @@ struct ieee80211_ops ath9k_ops = { - .sw_scan_start = ath9k_sw_scan_start, - .sw_scan_complete = ath9k_sw_scan_complete, - .rfkill_poll = ath9k_rfkill_poll_state, -+ .set_coverage_class = ath9k_set_coverage_class, - }; From d9d6100edd9b4229398ffc177bd3aff826308377 Mon Sep 17 00:00:00 2001 From: nbd Date: Sun, 17 Jan 2010 01:52:45 +0000 Subject: [PATCH 036/210] mac80211: fix mac address handling for multiple phy/vif git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19177 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/mac80211/files/lib/wifi/mac80211.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package/mac80211/files/lib/wifi/mac80211.sh b/package/mac80211/files/lib/wifi/mac80211.sh index 82ff95822..dea57223b 100644 --- a/package/mac80211/files/lib/wifi/mac80211.sh +++ b/package/mac80211/files/lib/wifi/mac80211.sh @@ -81,6 +81,7 @@ enable_mac80211() { find_mac80211_phy "$device" || return 0 config_get phy "$device" phy local i=0 + local macidx=0 fixed="" [ -n "$country" ] && iw reg set "$country" @@ -147,12 +148,13 @@ enable_mac80211() { config_get vif_mac "$vif" macaddr [ -n "$vif_mac" ] || { - if [ "$i" -gt 0 ]; then - offset="$(( 2 + $i * 4 ))" + if [ "$macidx" -gt 0 ]; then + offset="$(( 2 + $macidx * 4 ))" else offset="0" fi vif_mac="$( printf %02x $((0x$mac_1 + $offset)) ):$mac_2" + macidx="$(($macidx + 1))" } ifconfig "$ifname" hw ether "$vif_mac" From b3eea0e9a17679a580b13bf586018cb07f0f9b29 Mon Sep 17 00:00:00 2001 From: nbd Date: Sun, 17 Jan 2010 03:07:51 +0000 Subject: [PATCH 037/210] mac80211: allow user space to query the current operating frequency git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19178 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../patches/560-nl80211_get_freq.patch | 47 +++++++++++++++++++ .../patches/570-mac80211_get_freq.patch | 29 ++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 package/mac80211/patches/560-nl80211_get_freq.patch create mode 100644 package/mac80211/patches/570-mac80211_get_freq.patch diff --git a/package/mac80211/patches/560-nl80211_get_freq.patch b/package/mac80211/patches/560-nl80211_get_freq.patch new file mode 100644 index 000000000..25d915473 --- /dev/null +++ b/package/mac80211/patches/560-nl80211_get_freq.patch @@ -0,0 +1,47 @@ +--- a/include/net/cfg80211.h ++++ b/include/net/cfg80211.h +@@ -954,6 +954,8 @@ struct cfg80211_pmksa { + * + * @set_txq_params: Set TX queue parameters + * ++ * @get_channel: Get operating channel ++ * + * @set_channel: Set channel + * + * @scan: Request to do a scan. If returning zero, the scan request is given +@@ -1079,6 +1081,10 @@ struct cfg80211_ops { + int (*set_txq_params)(struct wiphy *wiphy, + struct ieee80211_txq_params *params); + ++ int (*get_channel)(struct wiphy *wiphy, ++ struct ieee80211_channel **chan, ++ enum nl80211_channel_type *channel_type); ++ + int (*set_channel)(struct wiphy *wiphy, + struct ieee80211_channel *chan, + enum nl80211_channel_type channel_type); +--- a/net/wireless/nl80211.c ++++ b/net/wireless/nl80211.c +@@ -427,7 +427,8 @@ static int nl80211_send_wiphy(struct sk_ + struct nlattr *nl_modes; + struct nlattr *nl_cmds; + enum ieee80211_band band; +- struct ieee80211_channel *chan; ++ struct ieee80211_channel *chan = NULL; ++ enum nl80211_channel_type chan_type; + struct ieee80211_rate *rate; + int i; + u16 ifmodes = dev->wiphy.interface_modes; +@@ -465,6 +466,12 @@ static int nl80211_send_wiphy(struct sk_ + NLA_PUT_U8(msg, NL80211_ATTR_MAX_NUM_PMKIDS, + dev->wiphy.max_num_pmkids); + ++ if (dev->ops->get_channel && ++ dev->ops->get_channel(&dev->wiphy, &chan, &chan_type) == 0) { ++ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, chan->center_freq); ++ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, chan_type); ++ } ++ + nl_modes = nla_nest_start(msg, NL80211_ATTR_SUPPORTED_IFTYPES); + if (!nl_modes) + goto nla_put_failure; diff --git a/package/mac80211/patches/570-mac80211_get_freq.patch b/package/mac80211/patches/570-mac80211_get_freq.patch new file mode 100644 index 000000000..073fe6386 --- /dev/null +++ b/package/mac80211/patches/570-mac80211_get_freq.patch @@ -0,0 +1,29 @@ +--- a/net/mac80211/cfg.c ++++ b/net/mac80211/cfg.c +@@ -1154,6 +1154,18 @@ static int ieee80211_set_txq_params(stru + return 0; + } + ++static int ieee80211_get_oper_channel(struct wiphy *wiphy, ++ struct ieee80211_channel **chan, ++ enum nl80211_channel_type *channel_type) ++{ ++ struct ieee80211_local *local = wiphy_priv(wiphy); ++ ++ *chan = local->oper_channel; ++ *channel_type = local->oper_channel_type; ++ ++ return 0; ++} ++ + static int ieee80211_set_channel(struct wiphy *wiphy, + struct ieee80211_channel *chan, + enum nl80211_channel_type channel_type) +@@ -1494,6 +1506,7 @@ struct cfg80211_ops mac80211_config_ops + #endif + .change_bss = ieee80211_change_bss, + .set_txq_params = ieee80211_set_txq_params, ++ .get_channel = ieee80211_get_oper_channel, + .set_channel = ieee80211_set_channel, + .suspend = ieee80211_suspend, + .resume = ieee80211_resume, From 40f5a41eaedcacd4435e3bd7b7f2e9b9163efe18 Mon Sep 17 00:00:00 2001 From: nbd Date: Sun, 17 Jan 2010 03:07:55 +0000 Subject: [PATCH 038/210] iw: print the current operating frequency in the phy info git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19179 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/iw/patches/110-freq.patch | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 package/iw/patches/110-freq.patch diff --git a/package/iw/patches/110-freq.patch b/package/iw/patches/110-freq.patch new file mode 100644 index 000000000..9a00a65e3 --- /dev/null +++ b/package/iw/patches/110-freq.patch @@ -0,0 +1,30 @@ +--- a/info.c ++++ b/info.c +@@ -62,6 +62,27 @@ static int print_phy_handler(struct nl_m + if (tb_msg[NL80211_ATTR_WIPHY_NAME]) + printf("Wiphy %s\n", nla_get_string(tb_msg[NL80211_ATTR_WIPHY_NAME])); + ++ if (tb_msg[NL80211_ATTR_WIPHY_FREQ]) { ++ const char *mode; ++ ++ if (tb_msg[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) ++ switch(nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_CHANNEL_TYPE])) { ++ case NL80211_CHAN_HT20: ++ mode = "HT20"; ++ break; ++ case NL80211_CHAN_HT40PLUS: ++ mode = "HT40+"; ++ break; ++ case NL80211_CHAN_HT40MINUS: ++ mode = "HT40-"; ++ break; ++ default: ++ mode = ""; ++ } ++ ++ printf("\tCurrent frequency: %d MHz %s\n", nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_FREQ]), mode); ++ } ++ + nla_for_each_nested(nl_band, tb_msg[NL80211_ATTR_WIPHY_BANDS], rem_band) { + printf("\tBand %d:\n", bandidx); + bandidx++; From 71e22385411d263e0de17ddccd26c3af9b3353bd Mon Sep 17 00:00:00 2001 From: jow Date: Sun, 17 Jan 2010 13:50:10 +0000 Subject: [PATCH 039/210] [PATCH] missing prerequisite for Orion images Webupgrade image building for WRT350Nv2 needs zip package. Copy command for WRT350Nv2 recovery image overrides error code of webupgrade builder, moved behind brackets. Removed indention of comments to avoid output in log. Signed-off by: Matthias Buecher git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19183 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/orion/image/Makefile | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/target/linux/orion/image/Makefile b/target/linux/orion/image/Makefile index 338af419d..c6c790ffb 100644 --- a/target/linux/orion/image/Makefile +++ b/target/linux/orion/image/Makefile @@ -49,24 +49,26 @@ define Image/Build/Netgear endef define Image/Build/Linksys - # WRT350N v2 sysupgrade image +# WRT350N v2 images +# sysupgrade image ( \ dd if="${KDIR}/$2-uImage" bs=$5 conv=sync; \ dd if="${KDIR}/root.$1" bs=64k conv=sync; \ ) > "${BIN_DIR}/openwrt-$2-$1.img" - # WRT350N v2 webupgrade image for stock firmware +# recovery image and webupgrade image for stock firmware rm -rf "${TMP_DIR}/$2_webupgrade" mkdir "${TMP_DIR}/$2_webupgrade" - # create parameter file +# create parameter file echo ":kernel $5 ${BIN_DIR}/openwrt-$2-uImage" >"${TMP_DIR}/$2_webupgrade/$2.par" echo ":rootfs 0 ${KDIR}/root.$1" >>"${TMP_DIR}/$2_webupgrade/$2.par" - # create webupgrade file +# create webupgrade image ( cd "${TMP_DIR}/$2_webupgrade"; \ "${STAGING_DIR_HOST}/bin/$2-builder" \ -v "${TMP_DIR}/$2_webupgrade/$2.par" \ - "${BIN_DIR}/openwrt-$2-$(1)-webupgrade.img"; \ - $(CP) openwrt-$2-$(1)-webupgrade.bin $(BIN_DIR)/openwrt-$2-$(1)-recovery.bin; \ + "${BIN_DIR}/openwrt-$2-$1-webupgrade.img"; \ ) +# copy bin file as recovery image + $(CP) "${TMP_DIR}/$2_webupgrade/openwrt-$2-$1-webupgrade.bin" "$(BIN_DIR)/openwrt-$2-$1-recovery.bin" rm -rf "${TMP_DIR}/$2_webupgrade" endef @@ -96,3 +98,8 @@ define Image/Build/squashfs endef $(eval $(call BuildImage)) + +# Dependency for WRT350N v2 webupgrade image +$(eval $(call RequireCommand,zip, \ + Please install zip. \ +)) From 8ab163d2045aaa3eeb10726798609a31c02087f0 Mon Sep 17 00:00:00 2001 From: juhosg Date: Sun, 17 Jan 2010 14:33:23 +0000 Subject: [PATCH 040/210] Fix Routerboard 411ar on board wireless This patch adds the appropriate interrupt for slot 0 pin 1 of the Routerboard 411ar (RB411 with on board Atheros wireless). Signed-off-by: Andrew Bates abates@omeganetserv.com git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19184 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb-4xx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb-4xx.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb-4xx.c index 2392c3dc6..5598c235f 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb-4xx.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb-4xx.c @@ -56,6 +56,10 @@ static struct platform_device rb4xx_nand_device = { static struct ar71xx_pci_irq rb4xx_pci_irqs[] __initdata = { { + .slot = 0, + .pin = 1, + .irq = AR71XX_PCI_IRQ_DEV2, + }, { .slot = 1, .pin = 1, .irq = AR71XX_PCI_IRQ_DEV0, From 9899a873bf6d990fd2ea96ee9dae349c0a242054 Mon Sep 17 00:00:00 2001 From: juhosg Date: Sun, 17 Jan 2010 14:33:26 +0000 Subject: [PATCH 041/210] ar71xx: fix phy interface selection for the RB-450G Patch from: https://forum.openwrt.org/viewtopic.php?pid=95865#p95865 git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19185 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb-4xx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb-4xx.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb-4xx.c index 5598c235f..bf1a39f3b 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb-4xx.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb-4xx.c @@ -248,12 +248,12 @@ static void __init rb450_generic_setup(int gige) ar71xx_add_device_mdio(0xffffffe0); - ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII; + ar71xx_eth0_data.phy_if_mode = (gige) ? PHY_INTERFACE_MODE_RGMII : PHY_INTERFACE_MODE_MII; ar71xx_eth0_data.phy_mask = 0x0000000f; ar71xx_eth0_data.speed = (gige) ? SPEED_1000 : SPEED_100; ar71xx_eth0_data.duplex = DUPLEX_FULL; - ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; + ar71xx_eth1_data.phy_if_mode = (gige) ? PHY_INTERFACE_MODE_RGMII : PHY_INTERFACE_MODE_RMII; ar71xx_eth1_data.phy_mask = 0x00000010; ar71xx_add_device_eth(1); From db8cad940478c55888cc2e094352c1ce09baefb0 Mon Sep 17 00:00:00 2001 From: juhosg Date: Sun, 17 Jan 2010 14:33:29 +0000 Subject: [PATCH 042/210] ar71xx: add optimizations to the cfi cmdset 002 status checking git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19186 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- ...mtd_fix_cfi_cmdset_0002_status_check.patch | 48 +++++++++++++++---- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/target/linux/ar71xx/patches-2.6.30/108-mtd_fix_cfi_cmdset_0002_status_check.patch b/target/linux/ar71xx/patches-2.6.30/108-mtd_fix_cfi_cmdset_0002_status_check.patch index 6c49fd4ea..d3e8b7956 100644 --- a/target/linux/ar71xx/patches-2.6.30/108-mtd_fix_cfi_cmdset_0002_status_check.patch +++ b/target/linux/ar71xx/patches-2.6.30/108-mtd_fix_cfi_cmdset_0002_status_check.patch @@ -25,16 +25,27 @@ /* Atmel chips don't use the same PRI format as AMD chips */ static void fixup_convert_atmel_pri(struct mtd_info *mtd, void *param) -@@ -1152,7 +1154,7 @@ static int __xipram do_write_oneword(str +@@ -1152,8 +1154,8 @@ static int __xipram do_write_oneword(str break; } - if (chip_ready(map, adr)) +- break; + if (chip_good(map, adr, datum)) - break; ++ goto enable_xip; /* Latency issues. Drop the lock, wait a while and retry */ -@@ -1436,6 +1438,7 @@ static int __xipram do_write_buffer(stru + UDELAY(map, chip, adr, 1); +@@ -1169,6 +1171,8 @@ static int __xipram do_write_oneword(str + + ret = -EIO; + } ++ ++ enable_xip: + xip_enable(map, chip, adr); + op_done: + chip->state = FL_READY; +@@ -1436,6 +1440,7 @@ static int __xipram do_write_buffer(stru } @@ -42,7 +53,7 @@ static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) { -@@ -1514,7 +1517,7 @@ static int cfi_amdstd_write_buffers(stru +@@ -1514,7 +1519,7 @@ static int cfi_amdstd_write_buffers(stru return 0; } @@ -51,21 +62,42 @@ /* * Handle devices with one erase region, that only implement -@@ -1579,7 +1582,7 @@ static int __xipram do_erase_chip(struct +@@ -1579,8 +1584,8 @@ static int __xipram do_erase_chip(struct chip->erase_suspended = 0; } - if (chip_ready(map, adr)) +- break; + if (chip_good(map, adr, map_word_ff(map))) - break; ++ goto op_done; if (time_after(jiffies, timeo)) { -@@ -1667,7 +1670,7 @@ static int __xipram do_erase_oneblock(st + printk(KERN_WARNING "MTD %s(): software timeout\n", +@@ -1600,6 +1605,7 @@ static int __xipram do_erase_chip(struct + ret = -EIO; + } + ++ op_done: + chip->state = FL_READY; + xip_enable(map, chip, adr); + put_chip(map, chip, adr); +@@ -1667,9 +1673,9 @@ static int __xipram do_erase_oneblock(st chip->erase_suspended = 0; } - if (chip_ready(map, adr)) { + if (chip_good(map, adr, map_word_ff(map))) { xip_enable(map, chip, adr); - break; +- break; ++ goto op_done; } + + if (time_after(jiffies, timeo)) { +@@ -1691,6 +1697,7 @@ static int __xipram do_erase_oneblock(st + ret = -EIO; + } + ++ op_done: + chip->state = FL_READY; + put_chip(map, chip, adr); + spin_unlock(chip->mutex); From 8b7f45f807cef05ccf49478b16abc60e6cf93cb3 Mon Sep 17 00:00:00 2001 From: juhosg Date: Sun, 17 Jan 2010 14:33:32 +0000 Subject: [PATCH 043/210] ar71xx: move forcing of word write into a separate patch git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19187 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- ...mtd_fix_cfi_cmdset_0002_status_check.patch | 52 +++------------- ...mtd-cfi_cmdset_0002-force-word-write.patch | 61 +++++++++++++++++++ 2 files changed, 70 insertions(+), 43 deletions(-) create mode 100644 target/linux/ar71xx/patches-2.6.30/111-mtd-cfi_cmdset_0002-force-word-write.patch diff --git a/target/linux/ar71xx/patches-2.6.30/108-mtd_fix_cfi_cmdset_0002_status_check.patch b/target/linux/ar71xx/patches-2.6.30/108-mtd_fix_cfi_cmdset_0002_status_check.patch index d3e8b7956..2ddd0d3dd 100644 --- a/target/linux/ar71xx/patches-2.6.30/108-mtd_fix_cfi_cmdset_0002_status_check.patch +++ b/target/linux/ar71xx/patches-2.6.30/108-mtd_fix_cfi_cmdset_0002_status_check.patch @@ -1,31 +1,6 @@ --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c -@@ -39,7 +39,7 @@ - #include - - #define AMD_BOOTLOC_BUG --#define FORCE_WORD_WRITE 0 -+#define FORCE_WORD_WRITE 1 - - #define MAX_WORD_RETRIES 3 - -@@ -190,6 +190,7 @@ static void fixup_amd_bootblock(struct m - } - #endif - -+#if !FORCE_WORD_WRITE - static void fixup_use_write_buffers(struct mtd_info *mtd, void *param) - { - struct map_info *map = mtd->priv; -@@ -199,6 +200,7 @@ static void fixup_use_write_buffers(stru - mtd->write = cfi_amdstd_write_buffers; - } - } -+#endif - - /* Atmel chips don't use the same PRI format as AMD chips */ - static void fixup_convert_atmel_pri(struct mtd_info *mtd, void *param) -@@ -1152,8 +1154,8 @@ static int __xipram do_write_oneword(str +@@ -1152,8 +1152,8 @@ static int __xipram do_write_oneword(str break; } @@ -36,7 +11,7 @@ /* Latency issues. Drop the lock, wait a while and retry */ UDELAY(map, chip, adr, 1); -@@ -1169,6 +1171,8 @@ static int __xipram do_write_oneword(str +@@ -1169,6 +1169,8 @@ static int __xipram do_write_oneword(str ret = -EIO; } @@ -45,24 +20,15 @@ xip_enable(map, chip, adr); op_done: chip->state = FL_READY; -@@ -1436,6 +1440,7 @@ static int __xipram do_write_buffer(stru - } - - -+#if !FORCE_WORD_WRITE - static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len, - size_t *retlen, const u_char *buf) - { -@@ -1514,7 +1519,7 @@ static int cfi_amdstd_write_buffers(stru - +@@ -1515,7 +1517,6 @@ static int cfi_amdstd_write_buffers(stru return 0; } -- -+#endif +- /* * Handle devices with one erase region, that only implement -@@ -1579,8 +1584,8 @@ static int __xipram do_erase_chip(struct + * the chip erase command. +@@ -1579,8 +1580,8 @@ static int __xipram do_erase_chip(struct chip->erase_suspended = 0; } @@ -73,7 +39,7 @@ if (time_after(jiffies, timeo)) { printk(KERN_WARNING "MTD %s(): software timeout\n", -@@ -1600,6 +1605,7 @@ static int __xipram do_erase_chip(struct +@@ -1600,6 +1601,7 @@ static int __xipram do_erase_chip(struct ret = -EIO; } @@ -81,7 +47,7 @@ chip->state = FL_READY; xip_enable(map, chip, adr); put_chip(map, chip, adr); -@@ -1667,9 +1673,9 @@ static int __xipram do_erase_oneblock(st +@@ -1667,9 +1669,9 @@ static int __xipram do_erase_oneblock(st chip->erase_suspended = 0; } @@ -93,7 +59,7 @@ } if (time_after(jiffies, timeo)) { -@@ -1691,6 +1697,7 @@ static int __xipram do_erase_oneblock(st +@@ -1691,6 +1693,7 @@ static int __xipram do_erase_oneblock(st ret = -EIO; } diff --git a/target/linux/ar71xx/patches-2.6.30/111-mtd-cfi_cmdset_0002-force-word-write.patch b/target/linux/ar71xx/patches-2.6.30/111-mtd-cfi_cmdset_0002-force-word-write.patch new file mode 100644 index 000000000..8c966d272 --- /dev/null +++ b/target/linux/ar71xx/patches-2.6.30/111-mtd-cfi_cmdset_0002-force-word-write.patch @@ -0,0 +1,61 @@ +--- a/drivers/mtd/chips/cfi_cmdset_0002.c ++++ b/drivers/mtd/chips/cfi_cmdset_0002.c +@@ -39,7 +39,7 @@ + #include + + #define AMD_BOOTLOC_BUG +-#define FORCE_WORD_WRITE 0 ++#define FORCE_WORD_WRITE 1 + + #define MAX_WORD_RETRIES 3 + +@@ -55,7 +55,9 @@ + + static int cfi_amdstd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *); + static int cfi_amdstd_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); ++#if !FORCE_WORD_WRITE + static int cfi_amdstd_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); ++#endif + static int cfi_amdstd_erase_chip(struct mtd_info *, struct erase_info *); + static int cfi_amdstd_erase_varsize(struct mtd_info *, struct erase_info *); + static void cfi_amdstd_sync (struct mtd_info *); +@@ -190,6 +192,7 @@ static void fixup_amd_bootblock(struct m + } + #endif + ++#if !FORCE_WORD_WRITE + static void fixup_use_write_buffers(struct mtd_info *mtd, void *param) + { + struct map_info *map = mtd->priv; +@@ -199,6 +202,7 @@ static void fixup_use_write_buffers(stru + mtd->write = cfi_amdstd_write_buffers; + } + } ++#endif /* !FORCE_WORD_WRITE */ + + /* Atmel chips don't use the same PRI format as AMD chips */ + static void fixup_convert_atmel_pri(struct mtd_info *mtd, void *param) +@@ -1326,6 +1330,7 @@ static int cfi_amdstd_write_words(struct + /* + * FIXME: interleaved mode not tested, and probably not supported! + */ ++#if !FORCE_WORD_WRITE + static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, + unsigned long adr, const u_char *buf, + int len) +@@ -1437,7 +1442,6 @@ static int __xipram do_write_buffer(stru + return ret; + } + +- + static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len, + size_t *retlen, const u_char *buf) + { +@@ -1516,6 +1520,7 @@ static int cfi_amdstd_write_buffers(stru + + return 0; + } ++#endif /* !FORCE_WORD_WRITE */ + + /* + * Handle devices with one erase region, that only implement From d9878acef400bc24b1385fc4039f81aabcde2eb8 Mon Sep 17 00:00:00 2001 From: juhosg Date: Sun, 17 Jan 2010 14:33:35 +0000 Subject: [PATCH 044/210] ar71xx: update cfi patches for 2.6.3[12] as well git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19188 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- ...x_cfi_cmdset_0002_erase_status_check.patch | 20 ------ ...mtd_fix_cfi_cmdset_0002_status_check.patch | 69 +++++++++++++++++++ ...mtd-cfi_cmdset_0002-force-word-write.patch | 61 ++++++++++++++++ ...x_cfi_cmdset_0002_erase_status_check.patch | 20 ------ ...mtd_fix_cfi_cmdset_0002_status_check.patch | 69 +++++++++++++++++++ ...mtd-cfi_cmdset_0002-force-word-write.patch | 61 ++++++++++++++++ 6 files changed, 260 insertions(+), 40 deletions(-) delete mode 100644 target/linux/ar71xx/patches-2.6.31/108-mtd_fix_cfi_cmdset_0002_erase_status_check.patch create mode 100644 target/linux/ar71xx/patches-2.6.31/108-mtd_fix_cfi_cmdset_0002_status_check.patch create mode 100644 target/linux/ar71xx/patches-2.6.31/111-mtd-cfi_cmdset_0002-force-word-write.patch delete mode 100644 target/linux/ar71xx/patches-2.6.32/108-mtd_fix_cfi_cmdset_0002_erase_status_check.patch create mode 100644 target/linux/ar71xx/patches-2.6.32/108-mtd_fix_cfi_cmdset_0002_status_check.patch create mode 100644 target/linux/ar71xx/patches-2.6.32/111-mtd-cfi_cmdset_0002-force-word-write.patch diff --git a/target/linux/ar71xx/patches-2.6.31/108-mtd_fix_cfi_cmdset_0002_erase_status_check.patch b/target/linux/ar71xx/patches-2.6.31/108-mtd_fix_cfi_cmdset_0002_erase_status_check.patch deleted file mode 100644 index 22aefe0d4..000000000 --- a/target/linux/ar71xx/patches-2.6.31/108-mtd_fix_cfi_cmdset_0002_erase_status_check.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/drivers/mtd/chips/cfi_cmdset_0002.c -+++ b/drivers/mtd/chips/cfi_cmdset_0002.c -@@ -1568,7 +1568,7 @@ static int __xipram do_erase_chip(struct - chip->erase_suspended = 0; - } - -- if (chip_ready(map, adr)) -+ if (chip_good(map, adr, map_word_ff(map))) - break; - - if (time_after(jiffies, timeo)) { -@@ -1656,7 +1656,7 @@ static int __xipram do_erase_oneblock(st - chip->erase_suspended = 0; - } - -- if (chip_ready(map, adr)) { -+ if (chip_good(map, adr, map_word_ff(map))) { - xip_enable(map, chip, adr); - break; - } diff --git a/target/linux/ar71xx/patches-2.6.31/108-mtd_fix_cfi_cmdset_0002_status_check.patch b/target/linux/ar71xx/patches-2.6.31/108-mtd_fix_cfi_cmdset_0002_status_check.patch new file mode 100644 index 000000000..d4272ab1b --- /dev/null +++ b/target/linux/ar71xx/patches-2.6.31/108-mtd_fix_cfi_cmdset_0002_status_check.patch @@ -0,0 +1,69 @@ +--- a/drivers/mtd/chips/cfi_cmdset_0002.c ++++ b/drivers/mtd/chips/cfi_cmdset_0002.c +@@ -1141,8 +1141,8 @@ static int __xipram do_write_oneword(str + break; + } + +- if (chip_ready(map, adr)) +- break; ++ if (chip_good(map, adr, datum)) ++ goto enable_xip; + + /* Latency issues. Drop the lock, wait a while and retry */ + UDELAY(map, chip, adr, 1); +@@ -1158,6 +1158,8 @@ static int __xipram do_write_oneword(str + + ret = -EIO; + } ++ ++ enable_xip: + xip_enable(map, chip, adr); + op_done: + chip->state = FL_READY; +@@ -1504,7 +1506,6 @@ static int cfi_amdstd_write_buffers(stru + return 0; + } + +- + /* + * Handle devices with one erase region, that only implement + * the chip erase command. +@@ -1568,8 +1569,8 @@ static int __xipram do_erase_chip(struct + chip->erase_suspended = 0; + } + +- if (chip_ready(map, adr)) +- break; ++ if (chip_good(map, adr, map_word_ff(map))) ++ goto op_done; + + if (time_after(jiffies, timeo)) { + printk(KERN_WARNING "MTD %s(): software timeout\n", +@@ -1589,6 +1590,7 @@ static int __xipram do_erase_chip(struct + ret = -EIO; + } + ++ op_done: + chip->state = FL_READY; + xip_enable(map, chip, adr); + put_chip(map, chip, adr); +@@ -1656,9 +1658,9 @@ static int __xipram do_erase_oneblock(st + chip->erase_suspended = 0; + } + +- if (chip_ready(map, adr)) { ++ if (chip_good(map, adr, map_word_ff(map))) { + xip_enable(map, chip, adr); +- break; ++ goto op_done; + } + + if (time_after(jiffies, timeo)) { +@@ -1680,6 +1682,7 @@ static int __xipram do_erase_oneblock(st + ret = -EIO; + } + ++ op_done: + chip->state = FL_READY; + put_chip(map, chip, adr); + spin_unlock(chip->mutex); diff --git a/target/linux/ar71xx/patches-2.6.31/111-mtd-cfi_cmdset_0002-force-word-write.patch b/target/linux/ar71xx/patches-2.6.31/111-mtd-cfi_cmdset_0002-force-word-write.patch new file mode 100644 index 000000000..4be025d87 --- /dev/null +++ b/target/linux/ar71xx/patches-2.6.31/111-mtd-cfi_cmdset_0002-force-word-write.patch @@ -0,0 +1,61 @@ +--- a/drivers/mtd/chips/cfi_cmdset_0002.c ++++ b/drivers/mtd/chips/cfi_cmdset_0002.c +@@ -39,7 +39,7 @@ + #include + + #define AMD_BOOTLOC_BUG +-#define FORCE_WORD_WRITE 0 ++#define FORCE_WORD_WRITE 1 + + #define MAX_WORD_RETRIES 3 + +@@ -55,7 +55,9 @@ + + static int cfi_amdstd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *); + static int cfi_amdstd_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); ++#if !FORCE_WORD_WRITE + static int cfi_amdstd_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); ++#endif + static int cfi_amdstd_erase_chip(struct mtd_info *, struct erase_info *); + static int cfi_amdstd_erase_varsize(struct mtd_info *, struct erase_info *); + static void cfi_amdstd_sync (struct mtd_info *); +@@ -190,6 +192,7 @@ static void fixup_amd_bootblock(struct m + } + #endif + ++#if !FORCE_WORD_WRITE + static void fixup_use_write_buffers(struct mtd_info *mtd, void *param) + { + struct map_info *map = mtd->priv; +@@ -199,6 +202,7 @@ static void fixup_use_write_buffers(stru + mtd->write = cfi_amdstd_write_buffers; + } + } ++#endif /* !FORCE_WORD_WRITE */ + + /* Atmel chips don't use the same PRI format as AMD chips */ + static void fixup_convert_atmel_pri(struct mtd_info *mtd, void *param) +@@ -1315,6 +1319,7 @@ static int cfi_amdstd_write_words(struct + /* + * FIXME: interleaved mode not tested, and probably not supported! + */ ++#if !FORCE_WORD_WRITE + static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, + unsigned long adr, const u_char *buf, + int len) +@@ -1426,7 +1431,6 @@ static int __xipram do_write_buffer(stru + return ret; + } + +- + static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len, + size_t *retlen, const u_char *buf) + { +@@ -1505,6 +1509,7 @@ static int cfi_amdstd_write_buffers(stru + + return 0; + } ++#endif /* !FORCE_WORD_WRITE */ + + /* + * Handle devices with one erase region, that only implement diff --git a/target/linux/ar71xx/patches-2.6.32/108-mtd_fix_cfi_cmdset_0002_erase_status_check.patch b/target/linux/ar71xx/patches-2.6.32/108-mtd_fix_cfi_cmdset_0002_erase_status_check.patch deleted file mode 100644 index 22aefe0d4..000000000 --- a/target/linux/ar71xx/patches-2.6.32/108-mtd_fix_cfi_cmdset_0002_erase_status_check.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/drivers/mtd/chips/cfi_cmdset_0002.c -+++ b/drivers/mtd/chips/cfi_cmdset_0002.c -@@ -1568,7 +1568,7 @@ static int __xipram do_erase_chip(struct - chip->erase_suspended = 0; - } - -- if (chip_ready(map, adr)) -+ if (chip_good(map, adr, map_word_ff(map))) - break; - - if (time_after(jiffies, timeo)) { -@@ -1656,7 +1656,7 @@ static int __xipram do_erase_oneblock(st - chip->erase_suspended = 0; - } - -- if (chip_ready(map, adr)) { -+ if (chip_good(map, adr, map_word_ff(map))) { - xip_enable(map, chip, adr); - break; - } diff --git a/target/linux/ar71xx/patches-2.6.32/108-mtd_fix_cfi_cmdset_0002_status_check.patch b/target/linux/ar71xx/patches-2.6.32/108-mtd_fix_cfi_cmdset_0002_status_check.patch new file mode 100644 index 000000000..d4272ab1b --- /dev/null +++ b/target/linux/ar71xx/patches-2.6.32/108-mtd_fix_cfi_cmdset_0002_status_check.patch @@ -0,0 +1,69 @@ +--- a/drivers/mtd/chips/cfi_cmdset_0002.c ++++ b/drivers/mtd/chips/cfi_cmdset_0002.c +@@ -1141,8 +1141,8 @@ static int __xipram do_write_oneword(str + break; + } + +- if (chip_ready(map, adr)) +- break; ++ if (chip_good(map, adr, datum)) ++ goto enable_xip; + + /* Latency issues. Drop the lock, wait a while and retry */ + UDELAY(map, chip, adr, 1); +@@ -1158,6 +1158,8 @@ static int __xipram do_write_oneword(str + + ret = -EIO; + } ++ ++ enable_xip: + xip_enable(map, chip, adr); + op_done: + chip->state = FL_READY; +@@ -1504,7 +1506,6 @@ static int cfi_amdstd_write_buffers(stru + return 0; + } + +- + /* + * Handle devices with one erase region, that only implement + * the chip erase command. +@@ -1568,8 +1569,8 @@ static int __xipram do_erase_chip(struct + chip->erase_suspended = 0; + } + +- if (chip_ready(map, adr)) +- break; ++ if (chip_good(map, adr, map_word_ff(map))) ++ goto op_done; + + if (time_after(jiffies, timeo)) { + printk(KERN_WARNING "MTD %s(): software timeout\n", +@@ -1589,6 +1590,7 @@ static int __xipram do_erase_chip(struct + ret = -EIO; + } + ++ op_done: + chip->state = FL_READY; + xip_enable(map, chip, adr); + put_chip(map, chip, adr); +@@ -1656,9 +1658,9 @@ static int __xipram do_erase_oneblock(st + chip->erase_suspended = 0; + } + +- if (chip_ready(map, adr)) { ++ if (chip_good(map, adr, map_word_ff(map))) { + xip_enable(map, chip, adr); +- break; ++ goto op_done; + } + + if (time_after(jiffies, timeo)) { +@@ -1680,6 +1682,7 @@ static int __xipram do_erase_oneblock(st + ret = -EIO; + } + ++ op_done: + chip->state = FL_READY; + put_chip(map, chip, adr); + spin_unlock(chip->mutex); diff --git a/target/linux/ar71xx/patches-2.6.32/111-mtd-cfi_cmdset_0002-force-word-write.patch b/target/linux/ar71xx/patches-2.6.32/111-mtd-cfi_cmdset_0002-force-word-write.patch new file mode 100644 index 000000000..4be025d87 --- /dev/null +++ b/target/linux/ar71xx/patches-2.6.32/111-mtd-cfi_cmdset_0002-force-word-write.patch @@ -0,0 +1,61 @@ +--- a/drivers/mtd/chips/cfi_cmdset_0002.c ++++ b/drivers/mtd/chips/cfi_cmdset_0002.c +@@ -39,7 +39,7 @@ + #include + + #define AMD_BOOTLOC_BUG +-#define FORCE_WORD_WRITE 0 ++#define FORCE_WORD_WRITE 1 + + #define MAX_WORD_RETRIES 3 + +@@ -55,7 +55,9 @@ + + static int cfi_amdstd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *); + static int cfi_amdstd_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); ++#if !FORCE_WORD_WRITE + static int cfi_amdstd_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); ++#endif + static int cfi_amdstd_erase_chip(struct mtd_info *, struct erase_info *); + static int cfi_amdstd_erase_varsize(struct mtd_info *, struct erase_info *); + static void cfi_amdstd_sync (struct mtd_info *); +@@ -190,6 +192,7 @@ static void fixup_amd_bootblock(struct m + } + #endif + ++#if !FORCE_WORD_WRITE + static void fixup_use_write_buffers(struct mtd_info *mtd, void *param) + { + struct map_info *map = mtd->priv; +@@ -199,6 +202,7 @@ static void fixup_use_write_buffers(stru + mtd->write = cfi_amdstd_write_buffers; + } + } ++#endif /* !FORCE_WORD_WRITE */ + + /* Atmel chips don't use the same PRI format as AMD chips */ + static void fixup_convert_atmel_pri(struct mtd_info *mtd, void *param) +@@ -1315,6 +1319,7 @@ static int cfi_amdstd_write_words(struct + /* + * FIXME: interleaved mode not tested, and probably not supported! + */ ++#if !FORCE_WORD_WRITE + static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, + unsigned long adr, const u_char *buf, + int len) +@@ -1426,7 +1431,6 @@ static int __xipram do_write_buffer(stru + return ret; + } + +- + static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len, + size_t *retlen, const u_char *buf) + { +@@ -1505,6 +1509,7 @@ static int cfi_amdstd_write_buffers(stru + + return 0; + } ++#endif /* !FORCE_WORD_WRITE */ + + /* + * Handle devices with one erase region, that only implement From 7b293e59ef28b174d80a0e6b2e7a0b9e13d17720 Mon Sep 17 00:00:00 2001 From: juhosg Date: Sun, 17 Jan 2010 18:53:42 +0000 Subject: [PATCH 045/210] ar71xx: create sysupgrade file for the WZR-HP-G300NH git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19193 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/ar71xx/image/Makefile | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile index 4cc88d477..96611bb47 100644 --- a/target/linux/ar71xx/image/Makefile +++ b/target/linux/ar71xx/image/Makefile @@ -114,6 +114,24 @@ define Image/Build/DIR825B1 fi; fi endef +define Image/Build/WZRHPG300NH + $(call PatchKernelLzma,$(2),$(3)) + if [ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.lzma"` -gt 1048576 ]; then \ + echo "Warning: $(KDIR)/vmlinux-$(2).bin.lzma is too big"; \ + else if [ `stat -c%s $(KDIR)/root.$(1)` -gt 31850496 ]; then \ + echo "Warning: $(KDIR)/root.$(1) is too big"; \ + else \ + mkimage -A mips -O linux -T kernel -a 0x80060000 -C lzma -e \ + 0x80060000 \ + -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \ + -d $(KDIR)/vmlinux-$(2).bin.lzma $(KDIR)/vmlinux-$(2).uImage; \ + ( \ + dd if=$(KDIR)/vmlinux-$(2).uImage bs=1M conv=sync; \ + dd if=$(KDIR)/root.$(1) bs=128k conv=sync; \ + ) > $(call imgname,$(1),$(2))-sysupgrade.bin; \ + fi; fi +endef + cameo_mtdlayout=mtdparts=spi0.0:128k(u-boot)ro,64k(config)ro,896k(kernel),2880k(rootfs),64k(art)ro,3776k@0x30000(firmware) define Image/Build/Cameo $(call PatchKernelLzma,$(2),$(3) $(cameo_mtdlayout)) @@ -449,6 +467,10 @@ define Image/Build/Profile/WRT160NL $(call Image/Build/Template/64k/$(1),CyberTAN,wrt160nl,board=WRT160NL,1.00.01) endef +define Image/Build/Profile/WZRHPG300NH + $(call Image/Build/Template/128k/$(1),WZRHPG300NH,wzr-hp-g300nh,board=WZR-HP-G300NH) +endef + define Image/Build/Profile/Default $(call Image/Build/Profile/AP81,$(1)) $(call Image/Build/Profile/AP83,$(1)) @@ -473,6 +495,7 @@ define Image/Build/Profile/Default $(call Image/Build/Profile/WNDR3700,$(1)) $(call Image/Build/Profile/WRT400N,$(1)) $(call Image/Build/Profile/WRT160NL,$(1)) + $(call Image/Build/Profile/WZRHPG300NH,$(1)) endef define Image/Build/Profile/Madwifi From 66fdfcd51321caf82c263dcaedaa1010102443ce Mon Sep 17 00:00:00 2001 From: nbd Date: Sun, 17 Jan 2010 20:49:28 +0000 Subject: [PATCH 046/210] iw, mac80211: get the frequency info per-netdev instead of per-phy git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19194 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/iw/patches/110-freq.patch | 20 ++++---- .../patches/560-cfg80211_get_freq.patch | 34 ++++++++++++++ .../patches/560-nl80211_get_freq.patch | 47 ------------------- .../patches/570-mac80211_get_freq.patch | 29 ------------ 4 files changed, 44 insertions(+), 86 deletions(-) create mode 100644 package/mac80211/patches/560-cfg80211_get_freq.patch delete mode 100644 package/mac80211/patches/560-nl80211_get_freq.patch delete mode 100644 package/mac80211/patches/570-mac80211_get_freq.patch diff --git a/package/iw/patches/110-freq.patch b/package/iw/patches/110-freq.patch index 9a00a65e3..f73d303bb 100644 --- a/package/iw/patches/110-freq.patch +++ b/package/iw/patches/110-freq.patch @@ -1,9 +1,9 @@ ---- a/info.c -+++ b/info.c -@@ -62,6 +62,27 @@ static int print_phy_handler(struct nl_m - if (tb_msg[NL80211_ATTR_WIPHY_NAME]) - printf("Wiphy %s\n", nla_get_string(tb_msg[NL80211_ATTR_WIPHY_NAME])); - +--- a/interface.c ++++ b/interface.c +@@ -260,6 +260,27 @@ static int print_iface_handler(struct nl + printf("%s\tifindex %d\n", indent, nla_get_u32(tb_msg[NL80211_ATTR_IFINDEX])); + if (tb_msg[NL80211_ATTR_IFTYPE]) + printf("%s\ttype %s\n", indent, iftype_name(nla_get_u32(tb_msg[NL80211_ATTR_IFTYPE]))); + if (tb_msg[NL80211_ATTR_WIPHY_FREQ]) { + const char *mode; + @@ -22,9 +22,9 @@ + mode = ""; + } + -+ printf("\tCurrent frequency: %d MHz %s\n", nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_FREQ]), mode); ++ printf("%s\tfrequency %d MHz %s\n", indent, nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_FREQ]), mode); + } + - nla_for_each_nested(nl_band, tb_msg[NL80211_ATTR_WIPHY_BANDS], rem_band) { - printf("\tBand %d:\n", bandidx); - bandidx++; + + return NL_SKIP; + } diff --git a/package/mac80211/patches/560-cfg80211_get_freq.patch b/package/mac80211/patches/560-cfg80211_get_freq.patch new file mode 100644 index 000000000..93c9d6e5b --- /dev/null +++ b/package/mac80211/patches/560-cfg80211_get_freq.patch @@ -0,0 +1,34 @@ +--- a/net/wireless/core.h ++++ b/net/wireless/core.h +@@ -75,6 +75,7 @@ struct cfg80211_registered_device { + + /* current channel */ + struct ieee80211_channel *channel; ++ enum nl80211_channel_type channel_type; + + /* must be last because of the way we do wiphy_priv(), + * and it should at least be aligned to NETDEV_ALIGN */ +--- a/net/wireless/chan.c ++++ b/net/wireless/chan.c +@@ -97,6 +97,7 @@ int rdev_set_freq(struct cfg80211_regist + return result; + + rdev->channel = chan; ++ rdev->channel_type = channel_type; + + return 0; + } +--- a/net/wireless/nl80211.c ++++ b/net/wireless/nl80211.c +@@ -881,6 +881,11 @@ static int nl80211_send_iface(struct sk_ + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); + NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, dev->name); + NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, dev->ieee80211_ptr->iftype); ++ if (rdev->channel) { ++ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, rdev->channel->center_freq); ++ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, rdev->channel_type); ++ } ++ + + NLA_PUT_U32(msg, NL80211_ATTR_GENERATION, + rdev->devlist_generation ^ diff --git a/package/mac80211/patches/560-nl80211_get_freq.patch b/package/mac80211/patches/560-nl80211_get_freq.patch deleted file mode 100644 index 25d915473..000000000 --- a/package/mac80211/patches/560-nl80211_get_freq.patch +++ /dev/null @@ -1,47 +0,0 @@ ---- a/include/net/cfg80211.h -+++ b/include/net/cfg80211.h -@@ -954,6 +954,8 @@ struct cfg80211_pmksa { - * - * @set_txq_params: Set TX queue parameters - * -+ * @get_channel: Get operating channel -+ * - * @set_channel: Set channel - * - * @scan: Request to do a scan. If returning zero, the scan request is given -@@ -1079,6 +1081,10 @@ struct cfg80211_ops { - int (*set_txq_params)(struct wiphy *wiphy, - struct ieee80211_txq_params *params); - -+ int (*get_channel)(struct wiphy *wiphy, -+ struct ieee80211_channel **chan, -+ enum nl80211_channel_type *channel_type); -+ - int (*set_channel)(struct wiphy *wiphy, - struct ieee80211_channel *chan, - enum nl80211_channel_type channel_type); ---- a/net/wireless/nl80211.c -+++ b/net/wireless/nl80211.c -@@ -427,7 +427,8 @@ static int nl80211_send_wiphy(struct sk_ - struct nlattr *nl_modes; - struct nlattr *nl_cmds; - enum ieee80211_band band; -- struct ieee80211_channel *chan; -+ struct ieee80211_channel *chan = NULL; -+ enum nl80211_channel_type chan_type; - struct ieee80211_rate *rate; - int i; - u16 ifmodes = dev->wiphy.interface_modes; -@@ -465,6 +466,12 @@ static int nl80211_send_wiphy(struct sk_ - NLA_PUT_U8(msg, NL80211_ATTR_MAX_NUM_PMKIDS, - dev->wiphy.max_num_pmkids); - -+ if (dev->ops->get_channel && -+ dev->ops->get_channel(&dev->wiphy, &chan, &chan_type) == 0) { -+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, chan->center_freq); -+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, chan_type); -+ } -+ - nl_modes = nla_nest_start(msg, NL80211_ATTR_SUPPORTED_IFTYPES); - if (!nl_modes) - goto nla_put_failure; diff --git a/package/mac80211/patches/570-mac80211_get_freq.patch b/package/mac80211/patches/570-mac80211_get_freq.patch deleted file mode 100644 index 073fe6386..000000000 --- a/package/mac80211/patches/570-mac80211_get_freq.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/net/mac80211/cfg.c -+++ b/net/mac80211/cfg.c -@@ -1154,6 +1154,18 @@ static int ieee80211_set_txq_params(stru - return 0; - } - -+static int ieee80211_get_oper_channel(struct wiphy *wiphy, -+ struct ieee80211_channel **chan, -+ enum nl80211_channel_type *channel_type) -+{ -+ struct ieee80211_local *local = wiphy_priv(wiphy); -+ -+ *chan = local->oper_channel; -+ *channel_type = local->oper_channel_type; -+ -+ return 0; -+} -+ - static int ieee80211_set_channel(struct wiphy *wiphy, - struct ieee80211_channel *chan, - enum nl80211_channel_type channel_type) -@@ -1494,6 +1506,7 @@ struct cfg80211_ops mac80211_config_ops - #endif - .change_bss = ieee80211_change_bss, - .set_txq_params = ieee80211_set_txq_params, -+ .get_channel = ieee80211_get_oper_channel, - .set_channel = ieee80211_set_channel, - .suspend = ieee80211_suspend, - .resume = ieee80211_resume, From 2065e4c697016440ef3c2a02fd5127ce7bd63b36 Mon Sep 17 00:00:00 2001 From: nbd Date: Sun, 17 Jan 2010 20:49:33 +0000 Subject: [PATCH 047/210] mac80211: remove an obsolete patch git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19195 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../mac80211/patches/302-mac80211_pwr_mgmt_fix.patch | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 package/mac80211/patches/302-mac80211_pwr_mgmt_fix.patch diff --git a/package/mac80211/patches/302-mac80211_pwr_mgmt_fix.patch b/package/mac80211/patches/302-mac80211_pwr_mgmt_fix.patch deleted file mode 100644 index 30a91840e..000000000 --- a/package/mac80211/patches/302-mac80211_pwr_mgmt_fix.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/mac80211/cfg.c -+++ b/net/mac80211/cfg.c -@@ -1394,6 +1394,9 @@ static int ieee80211_set_power_mgmt(stru - if (sdata->vif.type != NL80211_IFTYPE_STATION) - return -EOPNOTSUPP; - -+ if (sdata->vif.type != NL80211_IFTYPE_STATION) -+ return 0; -+ - if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS)) - return -EOPNOTSUPP; - From 3d899911584f9a517ba057dc4dff97e4e69c8b66 Mon Sep 17 00:00:00 2001 From: juhosg Date: Sun, 17 Jan 2010 21:17:42 +0000 Subject: [PATCH 048/210] ar71xx: upgrade rtl8366_smi driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks to Antti SeppƤlƤ. Patch from https://forum.openwrt.org/viewtopic.php?pid=100150#p100150 git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19196 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../files/drivers/net/phy/rtl8366_smi.c | 1511 ++++++++++++++++- 1 file changed, 1435 insertions(+), 76 deletions(-) diff --git a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c index e43f8a2d0..f0f9a76c9 100644 --- a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c +++ b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c @@ -2,6 +2,7 @@ * Platform driver for the Realtek RTL8366 ethernet switch * * Copyright (C) 2009 Gabor Juhos + * Copyright (C) 2010 Antti SeppƤlƤ * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published @@ -16,48 +17,209 @@ #include #include #include +#include #include #include -//#define DEBUG 1 +/* #define DEBUG 1 */ + +#ifdef DEBUG +#include +#endif #define RTL8366_SMI_DRIVER_NAME "rtl8366-smi" #define RTL8366_SMI_DRIVER_DESC "Realtek RTL8366 switch driver" -#define RTL8366_SMI_DRIVER_VER "0.1.0" +#define RTL8366_SMI_DRIVER_VER "0.1.1" -#define RTL8366S_PHY_NO_MAX 4 -#define RTL8366S_PHY_PAGE_MAX 7 -#define RTL8366S_PHY_ADDR_MAX 31 +#define RTL8366S_PHY_NO_MAX 4 +#define RTL8366S_PHY_PAGE_MAX 7 +#define RTL8366S_PHY_ADDR_MAX 31 -#define RTL8366S_CHIP_VERSION_CTRL_REG 0x0104 -#define RTL8366S_CHIP_VERSION_MASK 0xf -#define RTL8366S_CHIP_ID_REG 0x0105 -#define RTL8366S_CHIP_ID_8366 0x8366 +#define RTL8366_CHIP_GLOBAL_CTRL_REG 0x0000 +#define RTL8366_CHIP_CTRL_VLAN (1 << 13) + +#define RTL8366_RESET_CTRL_REG 0x0100 +#define RTL8366_CHIP_CTRL_RESET_HW 1 +#define RTL8366_CHIP_CTRL_RESET_SW (1 << 1) + +#define RTL8366S_CHIP_VERSION_CTRL_REG 0x0104 +#define RTL8366S_CHIP_VERSION_MASK 0xf +#define RTL8366S_CHIP_ID_REG 0x0105 +#define RTL8366S_CHIP_ID_8366 0x8366 /* PHY registers control */ -#define RTL8366S_PHY_ACCESS_CTRL_REG 0x8028 -#define RTL8366S_PHY_ACCESS_DATA_REG 0x8029 +#define RTL8366S_PHY_ACCESS_CTRL_REG 0x8028 +#define RTL8366S_PHY_ACCESS_DATA_REG 0x8029 -#define RTL8366S_PHY_CTRL_READ 1 -#define RTL8366S_PHY_CTRL_WRITE 0 +#define RTL8366S_PHY_CTRL_READ 1 +#define RTL8366S_PHY_CTRL_WRITE 0 -#define RTL8366S_PHY_REG_MASK 0x1f -#define RTL8366S_PHY_PAGE_OFFSET 5 -#define RTL8366S_PHY_PAGE_MASK (0x7 << 5) -#define RTL8366S_PHY_NO_OFFSET 9 -#define RTL8366S_PHY_NO_MASK (0x1f << 9) +#define RTL8366S_PHY_REG_MASK 0x1f +#define RTL8366S_PHY_PAGE_OFFSET 5 +#define RTL8366S_PHY_PAGE_MASK (0x7 << 5) +#define RTL8366S_PHY_NO_OFFSET 9 +#define RTL8366S_PHY_NO_MASK (0x1f << 9) -#define RTL8366_SMI_ACK_RETRY_COUNT 5 -#define RTL8366_SMI_CLK_DELAY 10 /* nsec */ +#define RTL8366_SMI_ACK_RETRY_COUNT 5 +#define RTL8366_SMI_CLK_DELAY 10 /* nsec */ + +/* LED control registers */ +#define RTL8366_LED_BLINKRATE_REG 0x0420 +#define RTL8366_LED_BLINKRATE_BIT 0 +#define RTL8366_LED_BLINKRATE_MASK 0x0007 + +#define RTL8366_LED_CTRL_REG 0x0421 +#define RTL8366_LED_0_1_CTRL_REG 0x0422 +#define RTL8366_LED_2_3_CTRL_REG 0x0423 + +#define RTL8366S_MIB_COUNT 33 +#define RTL8366S_GLOBAL_MIB_COUNT 1 +#define RTL8366S_MIB_COUNTER_PORT_OFFSET 0x0040 +#define RTL8366S_MIB_COUNTER_BASE 0x1000 +#define RTL8366S_MIB_CTRL_REG 0x11F0 +#define RTL8366S_MIB_CTRL_USER_MASK 0x01FF +#define RTL8366S_MIB_CTRL_BUSY_MASK 0x0001 +#define RTL8366S_MIB_CTRL_RESET_MASK 0x0002 + +#define RTL8366S_MIB_CTRL_GLOBAL_RESET_MASK 0x0004 +#define RTL8366S_MIB_CTRL_PORT_RESET_BIT 0x0003 +#define RTL8366S_MIB_CTRL_PORT_RESET_MASK 0x01FC + + +#define RTL8366S_PORT_VLAN_CTRL_BASE 0x0058 +#define RTL8366S_VLAN_TABLE_READ_BASE 0x018B +#define RTL8366S_VLAN_TABLE_WRITE_BASE 0x0185 + +#define RTL8366S_VLAN_TB_CTRL_REG 0x010F + +#define RTL8366S_TABLE_ACCESS_CTRL_REG 0x0180 +#define RTL8366S_TABLE_VLAN_READ_CTRL 0x0E01 +#define RTL8366S_TABLE_VLAN_WRITE_CTRL 0x0F01 + +#define RTL8366S_VLAN_MEMCONF_BASE 0x0016 + + +#define RTL8366S_PORT_LINK_STATUS_BASE 0x0060 +#define RTL8366S_PORT_STATUS_SPEED_MASK 0x0003 +#define RTL8366S_PORT_STATUS_DUPLEX_MASK 0x0004 +#define RTL8366S_PORT_STATUS_LINK_MASK 0x0010 +#define RTL8366S_PORT_STATUS_TXPAUSE_MASK 0x0020 +#define RTL8366S_PORT_STATUS_RXPAUSE_MASK 0x0040 +#define RTL8366S_PORT_STATUS_AN_MASK 0x0080 + + +#define RTL8366_PORT_NUM_CPU 5 +#define RTL8366_NUM_PORTS 6 +#define RTL8366_NUM_VLANS 16 +#define RTL8366_NUM_LEDGROUPS 4 +#define RTL8366_NUM_VIDS 4096 +#define RTL8366S_PRIORITYMAX 7 +#define RTL8366S_FIDMAX 7 + + +#define RTL8366_PORT_1 (1 << 0) /* In userspace port 0 */ +#define RTL8366_PORT_2 (1 << 1) /* In userspace port 1 */ +#define RTL8366_PORT_3 (1 << 2) /* In userspace port 2 */ +#define RTL8366_PORT_4 (1 << 3) /* In userspace port 3 */ + +#define RTL8366_PORT_UNKNOWN (1 << 4) /* No known connection */ +#define RTL8366_PORT_CPU (1 << 5) /* CPU port */ + +#define RTL8366_PORT_ALL (RTL8366_PORT_1 | \ + RTL8366_PORT_2 | \ + RTL8366_PORT_3 | \ + RTL8366_PORT_4 | \ + RTL8366_PORT_UNKNOWN | \ + RTL8366_PORT_CPU) + +#define RTL8366_PORT_ALL_BUT_CPU (RTL8366_PORT_1 | \ + RTL8366_PORT_2 | \ + RTL8366_PORT_3 | \ + RTL8366_PORT_4 | \ + RTL8366_PORT_UNKNOWN) + +#define RTL8366_PORT_ALL_EXTERNAL (RTL8366_PORT_1 | \ + RTL8366_PORT_2 | \ + RTL8366_PORT_3 | \ + RTL8366_PORT_4) + +#define RTL8366_PORT_ALL_INTERNAL (RTL8366_PORT_UNKNOWN | \ + RTL8366_PORT_CPU) + +struct rtl8366s_vlanconfig { + u16 reserved2:1; + u16 priority:3; + u16 vid:12; + + u16 reserved1:1; + u16 fid:3; + u16 untag:6; + u16 member:6; +}; + +struct rtl8366s_vlan4kentry { + u16 reserved1:4; + u16 vid:12; + + u16 reserved2:1; + u16 fid:3; + u16 untag:6; + u16 member:6; +}; + +static const char *MIBCOUNTERS[] = { "IfInOctets ", + "EtherStatsOctets ", + "EtherStatsUnderSizePkts ", + "EtherFregament ", + "EtherStatsPkts64Octets ", + "EtherStatsPkts65to127Octets ", + "EtherStatsPkts128to255Octets ", + "EtherStatsPkts256to511Octets ", + "EtherStatsPkts512to1023Octets ", + "EtherStatsPkts1024to1518Octets ", + "EtherOversizeStats ", + "EtherStatsJabbers ", + "IfInUcastPkts ", + "EtherStatsMulticastPkts ", + "EtherStatsBroadcastPkts ", + "EtherStatsDropEvents ", + "Dot3StatsFCSErrors ", + "Dot3StatsSymbolErrors ", + "Dot3InPauseFrames ", + "Dot3ControlInUnknownOpcodes ", + "IfOutOctets ", + "Dot3StatsSingleCollisionFrames ", + "Dot3StatMultipleCollisionFrames ", + "Dot3sDeferredTransmissions ", + "Dot3StatsLateCollisions ", + "EtherStatsCollisions ", + "Dot3StatsExcessiveCollisions ", + "Dot3OutPauseFrames ", + "Dot1dBasePortDelayExceededDiscards", + "Dot1dTpPortInDiscards ", + "IfOutUcastPkts ", + "IfOutMulticastPkts ", + "IfOutBroadcastPkts ", + NULL }; struct rtl8366_smi { - struct platform_device *pdev; - struct rtl8366_smi_platform_data *pdata; - spinlock_t lock; - struct mii_bus *mii_bus; - int mii_irq[PHY_MAX_ADDR]; + struct platform_device *pdev; + struct rtl8366_smi_platform_data *pdata; + spinlock_t lock; + struct mii_bus *mii_bus; + struct switch_dev dev; + int mii_irq[PHY_MAX_ADDR]; +#ifdef DEBUG + struct dentry *debugfs_root; +#endif }; +#ifdef DEBUG +u16 g_dbg_reg; +#endif + +#define to_rtl8366(_dev) container_of(_dev, struct rtl8366_smi, dev) + static inline void rtl8366_smi_clk_delay(struct rtl8366_smi *smi) { ndelay(RTL8366_SMI_CLK_DELAY); @@ -370,43 +532,1213 @@ static int rtl8366_smi_write_phy_reg(struct rtl8366_smi *smi, return 0; } -#ifdef DEBUG -static void rtl8366_smi_dump_regs(struct rtl8366_smi *smi) +static int rtl8366_get_mib_counter(struct rtl8366_smi *smi, int counter, + int port, unsigned long long *val) { - u32 t; - int err; int i; + int err; + u32 addr, data, regoffset; + u64 mibvalue; - for (i = 0; i < 0x200; i++) { - err = rtl8366_smi_read_reg(smi, i, &t); + /* address offset to MIBs counter */ + const u16 mibLength[RTL8366S_MIB_COUNT] = {4, 4, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 4, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2}; + + if (port > RTL8366_NUM_PORTS || counter >= RTL8366S_MIB_COUNT) + return -EINVAL; + + i = 0; + regoffset = RTL8366S_MIB_COUNTER_PORT_OFFSET * (port); + + while (i < counter) { + regoffset += mibLength[i]; + i++; + } + + addr = RTL8366S_MIB_COUNTER_BASE + regoffset; + + + /* writing access counter address first */ + /* then ASIC will prepare 64bits counter wait for being retrived */ + data = 0;/* writing data will be discard by ASIC */ + err = rtl8366_smi_write_reg(smi, addr, data); + if (err) + return err; + + /* read MIB control register */ + err = rtl8366_smi_read_reg(smi, RTL8366S_MIB_CTRL_REG, &data); + if (err) + return err; + + if (data & RTL8366S_MIB_CTRL_BUSY_MASK) + return -EBUSY; + + if (data & RTL8366S_MIB_CTRL_RESET_MASK) + return -EIO; + + mibvalue = 0; + addr = addr + mibLength[counter] - 1; + i = mibLength[counter]; + + while (i) { + err = rtl8366_smi_read_reg(smi, addr, &data); + if (err) + return err; + + mibvalue = (mibvalue << 16) | (data & 0xFFFF); + + addr--; + i--; + } + + *val = mibvalue; + return 0; +} + +static int rtl8366s_get_vlan_4k_entry(struct rtl8366_smi *smi, + struct rtl8366s_vlan4kentry *vlan4k) +{ + int err; + u32 data; + u32 vid; + u16 *tableaddr; + + vid = vlan4k->vid; + + if (vid >= RTL8366_NUM_VIDS) + return -EINVAL; + + tableaddr = (u16 *)vlan4k; + + /* write VID */ + data = *tableaddr; + err = rtl8366_smi_write_reg(smi, RTL8366S_VLAN_TABLE_WRITE_BASE, data); + if (err) + return err; + + /* write table access control word */ + err = rtl8366_smi_write_reg(smi, RTL8366S_TABLE_ACCESS_CTRL_REG, + RTL8366S_TABLE_VLAN_READ_CTRL); + if (err) + return err; + + err = rtl8366_smi_read_reg(smi, RTL8366S_VLAN_TABLE_READ_BASE, &data); + if (err) + return err; + + *tableaddr = data; + tableaddr++; + + err = rtl8366_smi_read_reg(smi, RTL8366S_VLAN_TABLE_READ_BASE + 1, + &data); + if (err) + return err; + + *tableaddr = data; + vlan4k->vid = vid; + + return 0; +} + +static int rtl8366s_set_vlan_4k_entry(struct rtl8366_smi *smi, + const struct rtl8366s_vlan4kentry *vlan4k) +{ + int err; + u32 data; + u16 *tableaddr; + + if (vlan4k->vid >= RTL8366_NUM_VIDS || + vlan4k->member > RTL8366_PORT_ALL || + vlan4k->untag > RTL8366_PORT_ALL || + vlan4k->fid > RTL8366S_FIDMAX) + return -EINVAL; + + tableaddr = (u16 *)vlan4k; + + data = *tableaddr; + + err = rtl8366_smi_write_reg(smi, RTL8366S_VLAN_TABLE_WRITE_BASE, data); + if (err) + return err; + + tableaddr++; + + data = *tableaddr; + + rtl8366_smi_write_reg(smi, RTL8366S_VLAN_TABLE_WRITE_BASE + 1, data); + + + /* write table access control word */ + err = rtl8366_smi_write_reg(smi, RTL8366S_TABLE_ACCESS_CTRL_REG, + RTL8366S_TABLE_VLAN_WRITE_CTRL); + if (err) + return err; + + return 0; +} + +static int rtl8366s_get_vlan_member_config(struct rtl8366_smi *smi, u32 index, + struct rtl8366s_vlanconfig + *vlanmconf) +{ + int err; + u32 addr; + u32 data; + u16 *tableaddr; + + if (index >= RTL8366_NUM_VLANS) + return -EINVAL; + + tableaddr = (u16 *)vlanmconf; + + addr = RTL8366S_VLAN_MEMCONF_BASE + (index << 1); + + err = rtl8366_smi_read_reg(smi, addr, &data); + if (err) + return err; + + *tableaddr = data; + tableaddr++; + + addr = RTL8366S_VLAN_MEMCONF_BASE + 1 + (index << 1); + + err = rtl8366_smi_read_reg(smi, addr, &data); + if (err) + return err; + + *tableaddr = data; + + return 0; +} + +static int rtl8366s_set_vlan_member_config(struct rtl8366_smi *smi, u32 index, + const struct rtl8366s_vlanconfig + *vlanmconf) +{ + int err; + u32 addr; + u32 data; + u16 *tableaddr; + + if (index >= RTL8366_NUM_VLANS || + vlanmconf->vid >= RTL8366_NUM_VIDS || + vlanmconf->priority > RTL8366S_PRIORITYMAX || + vlanmconf->member > RTL8366_PORT_ALL || + vlanmconf->untag > RTL8366_PORT_ALL || + vlanmconf->fid > RTL8366S_FIDMAX) + return -EINVAL; + + addr = RTL8366S_VLAN_MEMCONF_BASE + (index << 1); + + + tableaddr = (u16 *)vlanmconf; + data = *tableaddr; + + err = rtl8366_smi_write_reg(smi, addr, data); + if (err) + return err; + + addr = RTL8366S_VLAN_MEMCONF_BASE + 1 + (index << 1); + + tableaddr++; + data = *tableaddr; + + err = rtl8366_smi_write_reg(smi, addr, data); + if (err) + return err; + + return 0; +} + +static int rtl8366_get_port_vlan_index(struct rtl8366_smi *smi, int port, + int *val) +{ + int err; + u32 addr; + u32 data; + + /* bits mapping to port vlan control register of port n */ + const u16 bits[RTL8366_NUM_PORTS] = { 0x000F, 0x00F0, 0x0F00, + 0xF000, 0x000F, 0x00F0 }; + /* bits offset to port vlan control register of port n */ + const u16 bitoffset[RTL8366_NUM_PORTS] = { 0, 4, 8, 12, 0, 4 }; + /* address offset to port vlan control register of port n */ + const u16 addroffset[RTL8366_NUM_PORTS] = { 0, 0, 0, 0, 1, 1 }; + + if (port >= RTL8366_NUM_PORTS) + return -EINVAL; + + addr = RTL8366S_PORT_VLAN_CTRL_BASE + addroffset[port]; + + err = rtl8366_smi_read_reg(smi, addr, &data); + if (err) + return err; + + *val = (data & bits[port]) >> bitoffset[port]; + + return 0; + +} + +static int rtl8366_get_vlan_port_pvid(struct rtl8366_smi *smi, int port, + int *val) +{ + int err; + int index; + struct rtl8366s_vlanconfig vlanMC; + + memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); + + err = rtl8366_get_port_vlan_index(smi, port, &index); + if (err) + return err; + + err = rtl8366s_get_vlan_member_config(smi, index, &vlanMC); + if (err) + return err; + + *val = vlanMC.vid; + return 0; +} + +static int rtl8366_set_port_vlan_index(struct rtl8366_smi *smi, int port, + int index) +{ + int err; + u32 addr; + u32 data; + u32 vlan_data; + u32 bits; + + /* bits mapping to port vlan control register of port n */ + const u16 bitmasks[6] = { 0x000F, 0x00F0, 0x0F00, + 0xF000, 0x000F, 0x00F0 }; + /* bits offset to port vlan control register of port n */ + const u16 bitOff[6] = { 0, 4, 8, 12, 0, 4 }; + /* address offset to port vlan control register of port n */ + const u16 addrOff[6] = { 0, 0, 0, 0, 1, 1 }; + + if (port >= RTL8366_NUM_PORTS || index >= RTL8366_NUM_VLANS) + return -EINVAL; + + addr = RTL8366S_PORT_VLAN_CTRL_BASE + addrOff[port]; + + bits = bitmasks[port]; + + data = (index << bitOff[port]) & bits; + + err = rtl8366_smi_read_reg(smi, addr, &vlan_data); + if (err) + return err; + + vlan_data &= ~(vlan_data & bits); + vlan_data |= data; + + err = rtl8366_smi_write_reg(smi, addr, vlan_data); + if (err) + return err; + + return 0; +} + +static int rtl8366_set_vlan_port_pvid(struct rtl8366_smi *smi, int port, + int val) +{ + int i; + struct rtl8366s_vlanconfig vlanMC; + struct rtl8366s_vlan4kentry vlan4K; + + if (port >= RTL8366_NUM_PORTS || val >= RTL8366_NUM_VIDS) + return -EINVAL; + + + + /* Updating the 4K entry; lookup it and change the port member set */ + memset(&vlan4K, '\0', sizeof(struct rtl8366s_vlan4kentry)); + vlan4K.vid = val; + rtl8366s_get_vlan_4k_entry(smi, &vlan4K); + vlan4K.member |= ((1 << port) | RTL8366_PORT_CPU); + vlan4K.untag = RTL8366_PORT_ALL_BUT_CPU; + rtl8366s_set_vlan_4k_entry(smi, &vlan4K); + + /* For the 16 entries more work needs to be done. First see if such + VID is already there and change it */ + for (i = 0; i < RTL8366_NUM_VLANS; ++i) { + memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); + rtl8366s_get_vlan_member_config(smi, i, &vlanMC); + + /* Try to find an existing vid and update port member set */ + if (val == vlanMC.vid) { + vlanMC.member |= ((1 << port) | RTL8366_PORT_CPU); + rtl8366s_set_vlan_member_config(smi, i, &vlanMC); + + /* Now update PVID register settings */ + rtl8366_set_port_vlan_index(smi, port, i); + + return 0; + } + } + + /* PVID could not be found from vlan table. Replace unused (one that + has no member ports) with new one */ + for (i = 0; i < RTL8366_NUM_VLANS; ++i) { + memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); + rtl8366s_get_vlan_member_config(smi, i, &vlanMC); + + /* See if this vlan member configuration is unused. It is + unused if member set contains no ports or CPU port only */ + if (!vlanMC.member || vlanMC.member == RTL8366_PORT_CPU) { + vlanMC.vid = val; + vlanMC.priority = 0; + vlanMC.untag = RTL8366_PORT_ALL_BUT_CPU; + vlanMC.member = ((1 << port) | RTL8366_PORT_CPU); + vlanMC.fid = 0; + + rtl8366s_set_vlan_member_config(smi, i, &vlanMC); + + /* Now update PVID register settings */ + rtl8366_set_port_vlan_index(smi, port, i); + + return 0; + } + } + + dev_err(&smi->pdev->dev, "All 16 vlan member configurations are in " + "use\n"); + return -EINVAL; +} + + +static int rtl8366_vlan_set_vlan(struct rtl8366_smi *smi, int enable) +{ + u32 data = 0; + rtl8366_smi_read_reg(smi, RTL8366_CHIP_GLOBAL_CTRL_REG, &data); + + data &= ~(data & RTL8366_CHIP_CTRL_VLAN); + if (enable) + data |= RTL8366_CHIP_CTRL_VLAN; + + return rtl8366_smi_write_reg(smi, RTL8366_CHIP_GLOBAL_CTRL_REG, data); +} + +static int rtl8366_vlan_set_4ktable(struct rtl8366_smi *smi, int enable) +{ + u32 data = 0; + rtl8366_smi_read_reg(smi, RTL8366S_VLAN_TB_CTRL_REG, &data); + + data &= ~(data & 1); + if (enable) + data |= 1; + + return rtl8366_smi_write_reg(smi, RTL8366S_VLAN_TB_CTRL_REG, data); +} + +static int rtl8366s_reset_vlan(struct rtl8366_smi *smi) +{ + int i; + struct rtl8366s_vlan4kentry vlan4K; + struct rtl8366s_vlanconfig vlanMC; + + /* clear 16 VLAN member configuration */ + for (i = 0; i < RTL8366_NUM_VLANS; i++) { + vlanMC.vid = 0; + vlanMC.priority = 0; + vlanMC.member = 0; + vlanMC.untag = 0; + vlanMC.fid = 0; + if (rtl8366s_set_vlan_member_config(smi, i, &vlanMC) != 0) + return -EIO; + } + + /* Set a default VLAN with vid 1 to 4K table for all ports */ + vlan4K.vid = 1; + vlan4K.member = RTL8366_PORT_ALL; + vlan4K.untag = RTL8366_PORT_ALL; + vlan4K.fid = 0; + if (rtl8366s_set_vlan_4k_entry(smi, &vlan4K) != 0) + return -EIO; + + /* Set all ports PVID to default VLAN */ + for (i = 0; i < RTL8366_NUM_PORTS; i++) { + if (rtl8366_set_vlan_port_pvid(smi, i, 0) != 0) + return -EIO; + } + + return 0; +} + +#ifdef DEBUG +static int rtl8366_debugfs_open(struct inode *inode, struct file *file) +{ + file->private_data = inode->i_private; + return 0; +} + +static ssize_t rtl8366_read_debugfs_mibs(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + char buf[4096]; + int i, j, len = 0; + struct rtl8366_smi *smi = (struct rtl8366_smi *)file->private_data; + + len += snprintf(buf + len, sizeof(buf) - len, "MIB Counters:\n"); + len += snprintf(buf + len, sizeof(buf) - len, "Counter" + " " + "Port 0 \t\t Port 1 \t\t Port 2 \t\t Port 3 \t\t " + "Port 4\n"); + + for (i = 0; i < 33; ++i) { + + len += snprintf(buf + len, sizeof(buf) - len, "%d:%s ", + i, MIBCOUNTERS[i]); + for (j = 0; j < RTL8366_NUM_PORTS; ++j) { + unsigned long long counter = 0; + + if (!rtl8366_get_mib_counter(smi, i, j, &counter)) + len += snprintf(buf + len, sizeof(buf) - len, + "[%llu]", counter); + else + len += snprintf(buf + len, sizeof(buf) - len, + "[error]"); + + if (j != RTL8366_NUM_PORTS - 1) { + if (counter < 100000) + len += snprintf(buf + len, + sizeof(buf) - len, + "\t"); + + len += snprintf(buf + len, sizeof(buf) - len, + "\t"); + } + } + len += snprintf(buf + len, sizeof(buf) - len, "\n"); + } + + len += snprintf(buf + len, sizeof(buf) - len, "\n"); + + return simple_read_from_buffer(user_buf, count, ppos, buf, len); +} + +static ssize_t rtl8366_read_debugfs_vlan(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + char buf[4096]; + int i, j, len = 0; + struct rtl8366_smi *smi = (struct rtl8366_smi *)file->private_data; + + len += snprintf(buf + len, sizeof(buf) - len, "VLAN Member Config:\n"); + len += snprintf(buf + len, sizeof(buf) - len, + "\t id \t vid \t prio \t member \t untag \t fid " + "\tports\n"); + + for (i = 0; i < RTL8366_NUM_VLANS; ++i) { + struct rtl8366s_vlanconfig vlanMC; + memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); + rtl8366s_get_vlan_member_config(smi, i, &vlanMC); + + len += snprintf(buf + len, sizeof(buf) - len, + "\t[%d] \t %d \t %d \t 0x%04x \t 0x%04x \t %d " + "\t", i, vlanMC.vid, vlanMC.priority, + vlanMC.member, vlanMC.untag, vlanMC.fid); + + for (j = 0; j < RTL8366_NUM_PORTS; ++j) { + int index = 0; + if (!rtl8366_get_port_vlan_index(smi, j, &index)) { + if (index == i) + len += snprintf(buf + len, + sizeof(buf) - len, + "%d", j); + } + } + len += snprintf(buf + len, sizeof(buf) - len, "\n"); + } + + return simple_read_from_buffer(user_buf, count, ppos, buf, len); +} + +static ssize_t rtl8366_read_debugfs_reg(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + u32 t, reg = g_dbg_reg; + int err, len = 0; + char buf[512]; + struct rtl8366_smi *smi = (struct rtl8366_smi *)file->private_data; + + memset(buf, '\0', sizeof(buf)); + + err = rtl8366_smi_read_reg(smi, reg, &t); + if (err) { + len += snprintf(buf, sizeof(buf), + "Read failed (reg: 0x%04x)\n", reg); + return simple_read_from_buffer(user_buf, count, ppos, buf, len); + } + + len += snprintf(buf, sizeof(buf), "reg = 0x%04x, val = 0x%04x\n", + reg, t); + + return simple_read_from_buffer(user_buf, count, ppos, buf, len); +} + +static ssize_t rtl8366_write_debugfs_reg(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + unsigned long data; + u32 reg = g_dbg_reg; + int err; + char buf[50]; + size_t len; + struct rtl8366_smi *smi = (struct rtl8366_smi *)file->private_data; + + len = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, len)) { + dev_err(&smi->pdev->dev, "copy from user failed\n"); + return -EFAULT; + } + + buf[len] = '\0'; + if (len > 0 && buf[len - 1] == '\n') + buf[len - 1] = '\0'; + + + if (strict_strtoul(buf, 16, &data)) { + dev_err(&smi->pdev->dev, "Invalid reg value %s\n", buf); + } else { + err = rtl8366_smi_write_reg(smi, reg, data); if (err) { dev_err(&smi->pdev->dev, - "unable to read register %04x\n", i); - return; + "writing reg 0x%04x val 0x%04lx failed\n", + reg, data); } - dev_info(&smi->pdev->dev, "reg %04x: %04x\n", i, t); } - for (i = 0; i <= RTL8366S_PHY_NO_MAX; i++) { - int j; + return count; +} - for (j = 0; j <= RTL8366S_PHY_ADDR_MAX; j++) { - err = rtl8366_smi_read_phy_reg(smi, i, 0, j, &t); - if (err) { - dev_err(&smi->pdev->dev, - "unable to read PHY%u:%02x register\n", - i, j); - return; - } - dev_info(&smi->pdev->dev, - "PHY%u:%02x: %04x\n", i, j, t); - } +static const struct file_operations fops_rtl8366_regs = { + .read = rtl8366_read_debugfs_reg, + .write = rtl8366_write_debugfs_reg, + .open = rtl8366_debugfs_open, + .owner = THIS_MODULE +}; + +static const struct file_operations fops_rtl8366_vlan = { + .read = rtl8366_read_debugfs_vlan, + .open = rtl8366_debugfs_open, + .owner = THIS_MODULE +}; + +static const struct file_operations fops_rtl8366_mibs = { + .read = rtl8366_read_debugfs_mibs, + .open = rtl8366_debugfs_open, + .owner = THIS_MODULE +}; + +static void rtl8366_debugfs_init(struct rtl8366_smi *smi) +{ + struct dentry *node; + struct dentry *root; + + if (!smi->debugfs_root) + smi->debugfs_root = debugfs_create_dir("rtl8366s", NULL); + + if (!smi->debugfs_root) { + dev_err(&smi->pdev->dev, "Unable to create debugfs dir\n"); + return; + } + root = smi->debugfs_root; + + node = debugfs_create_x16("reg", S_IRUGO | S_IWUSR, root, &g_dbg_reg); + if (!node) { + dev_err(&smi->pdev->dev, "Creating debugfs file reg failed\n"); + return; + } + + node = debugfs_create_file("val", S_IRUGO | S_IWUSR, root, smi, + &fops_rtl8366_regs); + if (!node) { + dev_err(&smi->pdev->dev, "Creating debugfs file val failed\n"); + return; + } + + node = debugfs_create_file("vlan", S_IRUSR, root, smi, + &fops_rtl8366_vlan); + if (!node) { + dev_err(&smi->pdev->dev, "Creating debugfs file vlan " + "failed\n"); + return; + } + + node = debugfs_create_file("mibs", S_IRUSR, root, smi, + &fops_rtl8366_mibs); + if (!node) { + dev_err(&smi->pdev->dev, "Creating debugfs file mibs " + "xfailed\n"); + return; } } + +static void rtl8366_debugfs_remove(struct rtl8366_smi *smi) +{ + if (smi->debugfs_root) { + debugfs_remove_recursive(smi->debugfs_root); + smi->debugfs_root = NULL; + } +} + #else -static inline void rtl8366_smi_dump_regs(struct rtl8366_smi *smi) {} +static inline void rtl8366_debugfs_init(struct rtl8366_smi *smi) {} +static inline void rtl8366_debugfs_remove(struct rtl8366_smi *smi) {} #endif +static int rtl8366_global_reset_mibs(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val) +{ + u32 data = 0; + struct rtl8366_smi *smi = to_rtl8366(dev); + + if (val->value.i == 1) { + rtl8366_smi_read_reg(smi, RTL8366S_MIB_CTRL_REG, &data); + data |= (1 << 2); + rtl8366_smi_write_reg(smi, RTL8366S_MIB_CTRL_REG, data); + } + + return 0; +} + +static int rtl8366_get_vlan(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val) +{ + u32 data; + struct rtl8366_smi *smi = to_rtl8366(dev); + + if (attr->ofs == 1) { + rtl8366_smi_read_reg(smi, RTL8366_CHIP_GLOBAL_CTRL_REG, &data); + + if (data & RTL8366_CHIP_CTRL_VLAN) + val->value.i = 1; + else + val->value.i = 0; + } else if (attr->ofs == 2) { + rtl8366_smi_read_reg(smi, RTL8366S_VLAN_TB_CTRL_REG, &data); + + if (data & 0x0001) + val->value.i = 1; + else + val->value.i = 0; + } + + return 0; +} + +static int rtl8366_global_get_blinkrate(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val) +{ + u32 data; + struct rtl8366_smi *smi = to_rtl8366(dev); + rtl8366_smi_read_reg(smi, RTL8366_LED_BLINKRATE_REG, &data); + + val->value.i = (data & (RTL8366_LED_BLINKRATE_MASK)); + + return 0; +} + +static int rtl8366_global_set_blinkrate(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val) +{ + u32 data; + struct rtl8366_smi *smi = to_rtl8366(dev); + + if (val->value.i >= 6) + return -EINVAL; + + rtl8366_smi_read_reg(smi, RTL8366_LED_BLINKRATE_REG, &data); + + data &= ~(data & RTL8366_LED_BLINKRATE_MASK); + data |= val->value.i; + + rtl8366_smi_write_reg(smi, RTL8366_LED_BLINKRATE_REG, data); + + return 0; +} + +static int rtl8366_set_vlan(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val) +{ + struct rtl8366_smi *smi = to_rtl8366(dev); + + if (attr->ofs == 1) + return rtl8366_vlan_set_vlan(smi, val->value.i); + else + return rtl8366_vlan_set_4ktable(smi, val->value.i); +} + +static int rtl8366_init_vlan(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val) +{ + struct rtl8366_smi *smi = to_rtl8366(dev); + return rtl8366s_reset_vlan(smi); +} + +static int rtl8366_attr_get_port_link(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val) +{ + char buf[1024]; + u32 len = 0, data = 0; + int speed, duplex, link, txpause, rxpause, nway; + struct rtl8366_smi *smi = to_rtl8366(dev); + + if (val->port_vlan >= RTL8366_NUM_PORTS) + return -EINVAL; + + memset(buf, '\0', sizeof(buf)); + rtl8366_smi_read_reg(smi, RTL8366S_PORT_LINK_STATUS_BASE + + (val->port_vlan >> 1), + &data); + + if (val->port_vlan & 0x1) + data = data >> 8; + + speed = (data & RTL8366S_PORT_STATUS_SPEED_MASK); + duplex = (data & RTL8366S_PORT_STATUS_DUPLEX_MASK) >> 2; + link = (data & RTL8366S_PORT_STATUS_LINK_MASK) >> 4; + txpause = (data & RTL8366S_PORT_STATUS_TXPAUSE_MASK) >> 5; + rxpause = (data & RTL8366S_PORT_STATUS_RXPAUSE_MASK) >> 6; + nway = (data & RTL8366S_PORT_STATUS_AN_MASK) >> 7; + + len += snprintf(buf + len, sizeof(buf) - len, "Port %d: ", + val->port_vlan); + + if (link) + len += snprintf(buf + len, sizeof(buf) - len, + "Link UP, Speed: "); + else + len += snprintf(buf + len, sizeof(buf) - len, + "Link DOWN, Speed: "); + + if (speed == 0) + len += snprintf(buf + len, sizeof(buf) - len, "10Base-TX "); + else if (speed == 1) + len += snprintf(buf + len, sizeof(buf) - len, "100Base-TX "); + else if (speed == 2) + len += snprintf(buf + len, sizeof(buf) - len, "1000Base-TX "); + + if (duplex) + len += snprintf(buf + len, sizeof(buf) - len, "Full-Duplex, "); + else + len += snprintf(buf + len, sizeof(buf) - len, "Half-Duplex, "); + + if (txpause) + len += snprintf(buf + len, sizeof(buf) - len, "TX-Pause "); + if (rxpause) + len += snprintf(buf + len, sizeof(buf) - len, "RX-Pause "); + if (nway) + len += snprintf(buf + len, sizeof(buf) - len, "nway "); + + val->value.s = buf; + val->len = len; + + return 0; +} + +static int rtl8366_attr_get_vlan_info(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val) +{ + int i; + char buf[1024]; + u32 len = 0; + struct rtl8366s_vlanconfig vlanMC; + struct rtl8366s_vlan4kentry vlan4K; + struct rtl8366_smi *smi = to_rtl8366(dev); + + if (val->port_vlan >= RTL8366_NUM_PORTS) + return -EINVAL; + + memset(buf, '\0', sizeof(buf)); + memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); + memset(&vlan4K, '\0', sizeof(struct rtl8366s_vlan4kentry)); + + rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); + vlan4K.vid = vlanMC.vid; + rtl8366s_get_vlan_4k_entry(smi, &vlan4K); + + len += snprintf(buf + len, sizeof(buf) - len, "VLAN %d: Ports: ", + val->port_vlan); + + for (i = 0; i < RTL8366_NUM_PORTS; ++i) { + int index = 0; + if (!rtl8366_get_port_vlan_index(smi, i, &index) && + index == val->port_vlan) + len += snprintf(buf + len, sizeof(buf) - len, "%d", i); + } + len += snprintf(buf + len, sizeof(buf) - len, "\n"); + + len += snprintf(buf + len, sizeof(buf) - len, + "\t\t vid \t prio \t member \t untag \t fid\n"); + len += snprintf(buf + len, sizeof(buf) - len, "\tMC:\t"); + len += snprintf(buf + len, sizeof(buf) - len, + "%d \t %d \t 0x%04x \t 0x%04x \t %d\n", + vlanMC.vid, vlanMC.priority, vlanMC.member, + vlanMC.untag, vlanMC.fid); + len += snprintf(buf + len, sizeof(buf) - len, "\t4K:\t"); + len += snprintf(buf + len, sizeof(buf) - len, + "%d \t \t 0x%04x \t 0x%04x \t %d", + vlan4K.vid, vlan4K.member, vlan4K.untag, vlan4K.fid); + + val->value.s = buf; + val->len = len; + + return 0; +} + +static int rtl8366_set_port_led(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val) +{ + u32 data = 0; + struct rtl8366_smi *smi = to_rtl8366(dev); + if (val->port_vlan >= RTL8366_NUM_PORTS || + (1 << val->port_vlan) == RTL8366_PORT_UNKNOWN) + return -EINVAL; + + if (val->port_vlan == RTL8366_PORT_NUM_CPU) { + rtl8366_smi_read_reg(smi, RTL8366_LED_BLINKRATE_REG, &data); + data = (data & (~(0xF << 4))) | (val->value.i << 4); + rtl8366_smi_write_reg(smi, RTL8366_LED_BLINKRATE_REG, data); + } else { + rtl8366_smi_read_reg(smi, RTL8366_LED_CTRL_REG, &data); + data = (data & (~(0xF << (val->port_vlan * 4)))) | + (val->value.i << (val->port_vlan * 4)); + rtl8366_smi_write_reg(smi, RTL8366_LED_CTRL_REG, data); + } + + return 0; +} + +static int rtl8366_get_port_led(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val) +{ + u32 data = 0; + struct rtl8366_smi *smi = to_rtl8366(dev); + if (val->port_vlan >= RTL8366_NUM_LEDGROUPS) + return -EINVAL; + + rtl8366_smi_read_reg(smi, RTL8366_LED_CTRL_REG, &data); + val->value.i = (data >> (val->port_vlan * 4)) & 0x000F; + + return 0; +} + +static int rtl8366_reset_port_mibs(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val) +{ + u32 data = 0; + struct rtl8366_smi *smi = to_rtl8366(dev); + if (val->port_vlan >= RTL8366_NUM_PORTS) + return -EINVAL; + + rtl8366_smi_read_reg(smi, RTL8366S_MIB_CTRL_REG, &data); + data |= (1 << (val->port_vlan + 3)); + rtl8366_smi_write_reg(smi, RTL8366S_MIB_CTRL_REG, data); + + return 0; +} + +static int rtl8366_get_port_mib(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val) +{ + char buf[2048]; + int i, len = 0; + unsigned long long counter = 0; + struct rtl8366_smi *smi = to_rtl8366(dev); + if (val->port_vlan >= RTL8366_NUM_PORTS) + return -EINVAL; + + len += snprintf(buf + len, sizeof(buf) - len, "Port %d MIB counters\n", + val->port_vlan); + for (i = 0; i < RTL8366S_MIB_COUNT; ++i) { + + len += snprintf(buf + len, sizeof(buf) - len, + "%d:%s\t", i, MIBCOUNTERS[i]); + if (!rtl8366_get_mib_counter(smi, i, val->port_vlan, &counter)) + len += snprintf(buf + len, sizeof(buf) - len, + "[%llu]\n", counter); + else + len += snprintf(buf + len, sizeof(buf) - len, + "[error]\n"); + } + + val->value.s = buf; + val->len = len; + return 0; +} + +static int rtl8366_set_member(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val) +{ + struct rtl8366s_vlanconfig vlanMC; + struct rtl8366s_vlan4kentry vlan4K; + struct rtl8366_smi *smi = to_rtl8366(dev); + memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); + memset(&vlan4K, '\0', sizeof(struct rtl8366s_vlan4kentry)); + + if (val->port_vlan >= RTL8366_NUM_VLANS) + return -EINVAL; + + rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); + + vlan4K.vid = vlanMC.vid; + rtl8366s_get_vlan_4k_entry(smi, &vlan4K); + + vlan4K.member = vlanMC.member = val->value.i; + rtl8366s_set_vlan_member_config(smi, val->port_vlan, &vlanMC); + rtl8366s_set_vlan_4k_entry(smi, &vlan4K); + + return 0; +} + +static int rtl8366_get_member(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val) +{ + struct rtl8366s_vlanconfig vlanMC; + struct rtl8366s_vlan4kentry vlan4K; + struct rtl8366_smi *smi = to_rtl8366(dev); + memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); + memset(&vlan4K, '\0', sizeof(struct rtl8366s_vlan4kentry)); + + if (val->port_vlan >= RTL8366_NUM_VLANS) + return -EINVAL; + + rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); + + vlan4K.vid = vlanMC.vid; + rtl8366s_get_vlan_4k_entry(smi, &vlan4K); + + val->value.i = vlanMC.member; + + return 0; +} + +static int rtl8366_set_untag(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val) +{ + struct rtl8366s_vlanconfig vlanMC; + struct rtl8366s_vlan4kentry vlan4K; + struct rtl8366_smi *smi = to_rtl8366(dev); + memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); + memset(&vlan4K, '\0', sizeof(struct rtl8366s_vlan4kentry)); + + if (val->port_vlan >= RTL8366_NUM_VLANS) + return -EINVAL; + + rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); + + vlan4K.vid = vlanMC.vid; + rtl8366s_get_vlan_4k_entry(smi, &vlan4K); + + vlan4K.untag = vlanMC.untag = val->value.i; + rtl8366s_set_vlan_member_config(smi, val->port_vlan, &vlanMC); + rtl8366s_set_vlan_4k_entry(smi, &vlan4K); + + return 0; +} + +static int rtl8366_get_untag(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val) +{ + struct rtl8366s_vlanconfig vlanMC; + struct rtl8366s_vlan4kentry vlan4K; + struct rtl8366_smi *smi = to_rtl8366(dev); + memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); + memset(&vlan4K, '\0', sizeof(struct rtl8366s_vlan4kentry)); + + if (val->port_vlan >= RTL8366_NUM_VLANS) + return -EINVAL; + + rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); + vlan4K.vid = vlanMC.vid; + rtl8366s_get_vlan_4k_entry(smi, &vlan4K); + + + val->value.i = vlanMC.untag; + + return 0; +} + +static int rtl8366_get_port_pvid(struct switch_dev *dev, int port, int *val) +{ + struct rtl8366_smi *smi = to_rtl8366(dev); + return rtl8366_get_vlan_port_pvid(smi, port, val); +} + +static int rtl8366_set_port_pvid(struct switch_dev *dev, int port, int val) +{ + struct rtl8366_smi *smi = to_rtl8366(dev); + return rtl8366_set_vlan_port_pvid(smi, port, val); +} + +static int rtl8366_reset_switch(struct switch_dev *dev) +{ + struct rtl8366_smi *smi = to_rtl8366(dev); + rtl8366_smi_write_reg(smi, RTL8366_RESET_CTRL_REG, + RTL8366_CHIP_CTRL_RESET_HW); + return 0; +} + +static struct switch_attr rtl8366_globals[] = { + { + .type = SWITCH_TYPE_INT, + .name = "enable_vlan", + .description = "Enable VLAN mode", + .set = rtl8366_set_vlan, + .get = rtl8366_get_vlan, + .max = 1, + .ofs = 1 + }, + { + .type = SWITCH_TYPE_INT, + .name = "enable_vlan4k", + .description = "Enable VLAN 4K mode", + .set = rtl8366_set_vlan, + .get = rtl8366_get_vlan, + .max = 1, + .ofs = 2 + }, + { + .type = SWITCH_TYPE_INT, + .name = "init_vlan", + .description = "Initialize VLAN tables to defaults", + .set = rtl8366_init_vlan, + .get = NULL, + .max = 1 + }, + + { + .type = SWITCH_TYPE_INT, + .name = "reset_mibs", + .description = "Reset all MIB counters", + .set = rtl8366_global_reset_mibs, + .get = NULL, + .max = 1 + }, + { + .type = SWITCH_TYPE_INT, + .name = "blinkrate", + .description = "Get/Set LED blinking rate (0 = 43ms, 1 = 84ms," + " 2 = 120ms, 3 = 170ms, 4 = 340ms, 5 = 670ms)", + .set = rtl8366_global_set_blinkrate, + .get = rtl8366_global_get_blinkrate, + .max = 5 + }, +}; + +static struct switch_attr rtl8366_port[] = { + { + .type = SWITCH_TYPE_STRING, + .name = "link", + .description = "Get port link information", + .max = 1, + .set = NULL, + .get = rtl8366_attr_get_port_link + }, + { + .type = SWITCH_TYPE_INT, + .name = "reset_mib", + .description = "Reset single port MIB counters", + .max = 1, + .set = rtl8366_reset_port_mibs, + .get = NULL + }, + { + .type = SWITCH_TYPE_STRING, + .name = "mib", + .description = "Get MIB counters for port", + .max = 33, + .set = NULL, + .get = rtl8366_get_port_mib + }, + { + .type = SWITCH_TYPE_INT, + .name = "led", + .description = "Get/Set port group (0 - 3) led mode (0 - 15)", + .max = 15, + .set = rtl8366_set_port_led, + .get = rtl8366_get_port_led + }, +}; + +static struct switch_attr rtl8366_vlan[] = { + { + .type = SWITCH_TYPE_INT, + .name = "untag", + .description = "Get/Set VLAN untag port set (bitmask)", + .set = rtl8366_set_untag, + .get = rtl8366_get_untag, + .max = 63, + }, + { + .type = SWITCH_TYPE_INT, + .name = "member", + .description = "Get/Set VLAN member port set (bitmask)", + .set = rtl8366_set_member, + .get = rtl8366_get_member, + .max = 63, + }, + { + .type = SWITCH_TYPE_STRING, + .name = "info", + .description = "Get vlan information", + .max = 1, + .set = NULL, + .get = rtl8366_attr_get_vlan_info + }, +}; + + +/* template */ +static struct switch_dev rtldev = { + .name = "RTL8366S", + .cpu_port = RTL8366_PORT_NUM_CPU, + .ports = RTL8366_NUM_PORTS, + .vlans = RTL8366_NUM_VLANS, + .attr_global = { + .attr = rtl8366_globals, + .n_attr = ARRAY_SIZE(rtl8366_globals), + }, + .attr_port = { + .attr = rtl8366_port, + .n_attr = ARRAY_SIZE(rtl8366_port), + }, + .attr_vlan = { + .attr = rtl8366_vlan, + .n_attr = ARRAY_SIZE(rtl8366_vlan), + }, + + .get_port_pvid = rtl8366_get_port_pvid, + .set_port_pvid = rtl8366_set_port_pvid, + .reset_switch = rtl8366_reset_switch, +}; + static int rtl8366_smi_mii_read(struct mii_bus *bus, int addr, int reg) { struct rtl8366_smi *smi = bus->priv; @@ -458,14 +1790,10 @@ static int rtl8366_smi_mii_init(struct rtl8366_smi *smi) for (i = 0; i < PHY_MAX_ADDR; i++) smi->mii_irq[i] = PHY_POLL; - rtl8366_smi_dump_regs(smi); - ret = mdiobus_register(smi->mii_bus); if (ret) goto err_free; - rtl8366_smi_dump_regs(smi); - return 0; err_free: @@ -510,6 +1838,8 @@ static int rtl8366_smi_setup(struct rtl8366_smi *smi) dev_info(&smi->pdev->dev, "RTL%04x ver. %u chip found\n", chip_id, chip_ver & RTL8366S_CHIP_VERSION_MASK); + rtl8366_debugfs_init(smi); + return 0; } @@ -582,6 +1912,50 @@ static int __init rtl8366_smi_probe(struct platform_device *pdev) return err; } +int rtl8366_phy_config_init(struct phy_device *phydev) +{ + int err; + struct net_device *netdev = phydev->attached_dev; + struct rtl8366_smi *smi = phydev->bus->priv; + struct switch_dev *dev = &smi->dev; + + /* Only init the switch for the primary PHY */ + if (phydev->addr != 4) { + printk(KERN_INFO "Discarding address: %d\n", phydev->addr); + return 0; + } + + memcpy(&smi->dev, &rtldev, sizeof(struct switch_dev)); + dev->priv = smi; + dev->netdev = netdev; + + err = register_switch(dev, netdev); + if (err < 0) { + printk(KERN_INFO "Switch registration failed\n"); + return err; + } + + return 0; +} + +int rtl8366_phy_config_aneg(struct phy_device *phydev) +{ + return 0; +} + +static struct phy_driver rtl8366_smi_phy_driver = { + .phy_id = 0x001cc960, + .name = "Realtek RTL8366", + .phy_id_mask = 0x1ffffff0, + .features = PHY_GBIT_FEATURES, + .config_aneg = rtl8366_phy_config_aneg, + .config_init = rtl8366_phy_config_init, + .read_status = genphy_read_status, + .driver = { + .owner = THIS_MODULE, + }, +}; + static int __devexit rtl8366_smi_remove(struct platform_device *pdev) { struct rtl8366_smi *smi = platform_get_drvdata(pdev); @@ -591,6 +1965,8 @@ static int __devexit rtl8366_smi_remove(struct platform_device *pdev) pdata = pdev->dev.platform_data; + rtl8366_debugfs_remove(smi); + phy_driver_unregister(&rtl8366_smi_phy_driver); rtl8366_smi_mii_cleanup(smi); platform_set_drvdata(pdev, NULL); gpio_free(pdata->gpio_sck); @@ -601,11 +1977,6 @@ static int __devexit rtl8366_smi_remove(struct platform_device *pdev) return 0; } -int rtl8366_phy_config_aneg(struct phy_device *phydev) -{ - return 0; -} - static struct platform_driver rtl8366_smi_driver = { .driver = { .name = RTL8366_SMI_DRIVER_NAME, @@ -615,47 +1986,35 @@ static struct platform_driver rtl8366_smi_driver = { .remove = __devexit_p(rtl8366_smi_remove), }; -static struct phy_driver rtl8366_smi_phy_driver = { - .phy_id = 0x001cc960, - .name = "Realtek RTL8366", - .phy_id_mask = 0x1ffffff0, - .features = PHY_GBIT_FEATURES, - .config_aneg = rtl8366_phy_config_aneg, - .read_status = genphy_read_status, - .driver = { - .owner = THIS_MODULE, - }, -}; - static int __init rtl8366_smi_init(void) { int ret; - - ret = phy_driver_register(&rtl8366_smi_phy_driver); + ret = platform_driver_register(&rtl8366_smi_driver); if (ret) return ret; - ret = platform_driver_register(&rtl8366_smi_driver); + ret = phy_driver_register(&rtl8366_smi_phy_driver); if (ret) - goto err_phy_unregister; + goto err_platform_unregister; return 0; - err_phy_unregister: - phy_driver_unregister(&rtl8366_smi_phy_driver); + err_platform_unregister: + platform_driver_unregister(&rtl8366_smi_driver); return ret; } module_init(rtl8366_smi_init); static void __exit rtl8366_smi_exit(void) { - platform_driver_unregister(&rtl8366_smi_driver); phy_driver_unregister(&rtl8366_smi_phy_driver); + platform_driver_unregister(&rtl8366_smi_driver); } module_exit(rtl8366_smi_exit); MODULE_DESCRIPTION(RTL8366_SMI_DRIVER_DESC); MODULE_VERSION(RTL8366_SMI_DRIVER_VER); MODULE_AUTHOR("Gabor Juhos "); +MODULE_AUTHOR("Antti SeppƤlƤ "); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:" RTL8366_SMI_DRIVER_NAME); From ef0ac006fffc32659c071f7ab85e167ea3608b01 Mon Sep 17 00:00:00 2001 From: juhosg Date: Sun, 17 Jan 2010 21:17:46 +0000 Subject: [PATCH 049/210] rtl8366_smi: add vid parameter to the rtl8366s_get_vlan_4k_entry function git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19197 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../files/drivers/net/phy/rtl8366_smi.c | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c index f0f9a76c9..557d84902 100644 --- a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c +++ b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c @@ -597,15 +597,14 @@ static int rtl8366_get_mib_counter(struct rtl8366_smi *smi, int counter, return 0; } -static int rtl8366s_get_vlan_4k_entry(struct rtl8366_smi *smi, +static int rtl8366s_get_vlan_4k_entry(struct rtl8366_smi *smi, u32 vid, struct rtl8366s_vlan4kentry *vlan4k) { int err; u32 data; - u32 vid; u16 *tableaddr; - vid = vlan4k->vid; + vlan4k->vid = vid; if (vid >= RTL8366_NUM_VIDS) return -EINVAL; @@ -857,8 +856,7 @@ static int rtl8366_set_vlan_port_pvid(struct rtl8366_smi *smi, int port, /* Updating the 4K entry; lookup it and change the port member set */ memset(&vlan4K, '\0', sizeof(struct rtl8366s_vlan4kentry)); - vlan4K.vid = val; - rtl8366s_get_vlan_4k_entry(smi, &vlan4K); + rtl8366s_get_vlan_4k_entry(smi, val, &vlan4K); vlan4K.member |= ((1 << port) | RTL8366_PORT_CPU); vlan4K.untag = RTL8366_PORT_ALL_BUT_CPU; rtl8366s_set_vlan_4k_entry(smi, &vlan4K); @@ -1372,8 +1370,7 @@ static int rtl8366_attr_get_vlan_info(struct switch_dev *dev, memset(&vlan4K, '\0', sizeof(struct rtl8366s_vlan4kentry)); rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); - vlan4K.vid = vlanMC.vid; - rtl8366s_get_vlan_4k_entry(smi, &vlan4K); + rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4K); len += snprintf(buf + len, sizeof(buf) - len, "VLAN %d: Ports: ", val->port_vlan); @@ -1504,8 +1501,7 @@ static int rtl8366_set_member(struct switch_dev *dev, rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); - vlan4K.vid = vlanMC.vid; - rtl8366s_get_vlan_4k_entry(smi, &vlan4K); + rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4K); vlan4K.member = vlanMC.member = val->value.i; rtl8366s_set_vlan_member_config(smi, val->port_vlan, &vlanMC); @@ -1529,8 +1525,7 @@ static int rtl8366_get_member(struct switch_dev *dev, rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); - vlan4K.vid = vlanMC.vid; - rtl8366s_get_vlan_4k_entry(smi, &vlan4K); + rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4K); val->value.i = vlanMC.member; @@ -1551,9 +1546,7 @@ static int rtl8366_set_untag(struct switch_dev *dev, return -EINVAL; rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); - - vlan4K.vid = vlanMC.vid; - rtl8366s_get_vlan_4k_entry(smi, &vlan4K); + rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4K); vlan4K.untag = vlanMC.untag = val->value.i; rtl8366s_set_vlan_member_config(smi, val->port_vlan, &vlanMC); @@ -1576,8 +1569,7 @@ static int rtl8366_get_untag(struct switch_dev *dev, return -EINVAL; rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); - vlan4K.vid = vlanMC.vid; - rtl8366s_get_vlan_4k_entry(smi, &vlan4K); + rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4K); val->value.i = vlanMC.untag; From f0d1ad31ba2c35695f6c521895d00149f6da2ea5 Mon Sep 17 00:00:00 2001 From: juhosg Date: Sun, 17 Jan 2010 21:17:49 +0000 Subject: [PATCH 050/210] rtl8366_smi: move memset into the rtl8366s_get_vlan_4k_entry function git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19198 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c index 557d84902..e5c65ccbc 100644 --- a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c +++ b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c @@ -604,6 +604,7 @@ static int rtl8366s_get_vlan_4k_entry(struct rtl8366_smi *smi, u32 vid, u32 data; u16 *tableaddr; + memset(vlan4k, '\0', sizeof(struct rtl8366s_vlan4kentry)); vlan4k->vid = vid; if (vid >= RTL8366_NUM_VIDS) @@ -855,7 +856,6 @@ static int rtl8366_set_vlan_port_pvid(struct rtl8366_smi *smi, int port, /* Updating the 4K entry; lookup it and change the port member set */ - memset(&vlan4K, '\0', sizeof(struct rtl8366s_vlan4kentry)); rtl8366s_get_vlan_4k_entry(smi, val, &vlan4K); vlan4K.member |= ((1 << port) | RTL8366_PORT_CPU); vlan4K.untag = RTL8366_PORT_ALL_BUT_CPU; @@ -1367,7 +1367,6 @@ static int rtl8366_attr_get_vlan_info(struct switch_dev *dev, memset(buf, '\0', sizeof(buf)); memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); - memset(&vlan4K, '\0', sizeof(struct rtl8366s_vlan4kentry)); rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4K); @@ -1494,7 +1493,6 @@ static int rtl8366_set_member(struct switch_dev *dev, struct rtl8366s_vlan4kentry vlan4K; struct rtl8366_smi *smi = to_rtl8366(dev); memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); - memset(&vlan4K, '\0', sizeof(struct rtl8366s_vlan4kentry)); if (val->port_vlan >= RTL8366_NUM_VLANS) return -EINVAL; @@ -1518,7 +1516,6 @@ static int rtl8366_get_member(struct switch_dev *dev, struct rtl8366s_vlan4kentry vlan4K; struct rtl8366_smi *smi = to_rtl8366(dev); memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); - memset(&vlan4K, '\0', sizeof(struct rtl8366s_vlan4kentry)); if (val->port_vlan >= RTL8366_NUM_VLANS) return -EINVAL; @@ -1540,7 +1537,6 @@ static int rtl8366_set_untag(struct switch_dev *dev, struct rtl8366s_vlan4kentry vlan4K; struct rtl8366_smi *smi = to_rtl8366(dev); memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); - memset(&vlan4K, '\0', sizeof(struct rtl8366s_vlan4kentry)); if (val->port_vlan >= RTL8366_NUM_VLANS) return -EINVAL; @@ -1563,7 +1559,6 @@ static int rtl8366_get_untag(struct switch_dev *dev, struct rtl8366s_vlan4kentry vlan4K; struct rtl8366_smi *smi = to_rtl8366(dev); memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); - memset(&vlan4K, '\0', sizeof(struct rtl8366s_vlan4kentry)); if (val->port_vlan >= RTL8366_NUM_VLANS) return -EINVAL; From ced9e0d6c7acfd4bd1d9c3674cb468ba8e82c1d5 Mon Sep 17 00:00:00 2001 From: juhosg Date: Sun, 17 Jan 2010 21:17:53 +0000 Subject: [PATCH 051/210] rtl8366_smi: move memset into the rtl8366s_get_member_config function git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19199 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../ar71xx/files/drivers/net/phy/rtl8366_smi.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c index e5c65ccbc..cca4af2e2 100644 --- a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c +++ b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c @@ -688,6 +688,8 @@ static int rtl8366s_get_vlan_member_config(struct rtl8366_smi *smi, u32 index, u32 data; u16 *tableaddr; + memset(vlanmconf, '\0', sizeof(struct rtl8366s_vlanconfig)); + if (index >= RTL8366_NUM_VLANS) return -EINVAL; @@ -789,8 +791,6 @@ static int rtl8366_get_vlan_port_pvid(struct rtl8366_smi *smi, int port, int index; struct rtl8366s_vlanconfig vlanMC; - memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); - err = rtl8366_get_port_vlan_index(smi, port, &index); if (err) return err; @@ -864,7 +864,6 @@ static int rtl8366_set_vlan_port_pvid(struct rtl8366_smi *smi, int port, /* For the 16 entries more work needs to be done. First see if such VID is already there and change it */ for (i = 0; i < RTL8366_NUM_VLANS; ++i) { - memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); rtl8366s_get_vlan_member_config(smi, i, &vlanMC); /* Try to find an existing vid and update port member set */ @@ -882,7 +881,6 @@ static int rtl8366_set_vlan_port_pvid(struct rtl8366_smi *smi, int port, /* PVID could not be found from vlan table. Replace unused (one that has no member ports) with new one */ for (i = 0; i < RTL8366_NUM_VLANS; ++i) { - memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); rtl8366s_get_vlan_member_config(smi, i, &vlanMC); /* See if this vlan member configuration is unused. It is @@ -1035,7 +1033,7 @@ static ssize_t rtl8366_read_debugfs_vlan(struct file *file, for (i = 0; i < RTL8366_NUM_VLANS; ++i) { struct rtl8366s_vlanconfig vlanMC; - memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); + rtl8366s_get_vlan_member_config(smi, i, &vlanMC); len += snprintf(buf + len, sizeof(buf) - len, @@ -1366,7 +1364,6 @@ static int rtl8366_attr_get_vlan_info(struct switch_dev *dev, return -EINVAL; memset(buf, '\0', sizeof(buf)); - memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4K); @@ -1492,7 +1489,6 @@ static int rtl8366_set_member(struct switch_dev *dev, struct rtl8366s_vlanconfig vlanMC; struct rtl8366s_vlan4kentry vlan4K; struct rtl8366_smi *smi = to_rtl8366(dev); - memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); if (val->port_vlan >= RTL8366_NUM_VLANS) return -EINVAL; @@ -1515,7 +1511,6 @@ static int rtl8366_get_member(struct switch_dev *dev, struct rtl8366s_vlanconfig vlanMC; struct rtl8366s_vlan4kentry vlan4K; struct rtl8366_smi *smi = to_rtl8366(dev); - memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); if (val->port_vlan >= RTL8366_NUM_VLANS) return -EINVAL; @@ -1536,7 +1531,6 @@ static int rtl8366_set_untag(struct switch_dev *dev, struct rtl8366s_vlanconfig vlanMC; struct rtl8366s_vlan4kentry vlan4K; struct rtl8366_smi *smi = to_rtl8366(dev); - memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); if (val->port_vlan >= RTL8366_NUM_VLANS) return -EINVAL; @@ -1558,7 +1552,6 @@ static int rtl8366_get_untag(struct switch_dev *dev, struct rtl8366s_vlanconfig vlanMC; struct rtl8366s_vlan4kentry vlan4K; struct rtl8366_smi *smi = to_rtl8366(dev); - memset(&vlanMC, '\0', sizeof(struct rtl8366s_vlanconfig)); if (val->port_vlan >= RTL8366_NUM_VLANS) return -EINVAL; From c0e88a59a8a90d645a22f2635f60d974812be101 Mon Sep 17 00:00:00 2001 From: juhosg Date: Sun, 17 Jan 2010 21:17:57 +0000 Subject: [PATCH 052/210] rtl8366_smi: use vlan4k name for all vlan4kentry variables git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19200 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../files/drivers/net/phy/rtl8366_smi.c | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c index cca4af2e2..ffd275822 100644 --- a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c +++ b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c @@ -848,7 +848,7 @@ static int rtl8366_set_vlan_port_pvid(struct rtl8366_smi *smi, int port, { int i; struct rtl8366s_vlanconfig vlanMC; - struct rtl8366s_vlan4kentry vlan4K; + struct rtl8366s_vlan4kentry vlan4k; if (port >= RTL8366_NUM_PORTS || val >= RTL8366_NUM_VIDS) return -EINVAL; @@ -856,10 +856,10 @@ static int rtl8366_set_vlan_port_pvid(struct rtl8366_smi *smi, int port, /* Updating the 4K entry; lookup it and change the port member set */ - rtl8366s_get_vlan_4k_entry(smi, val, &vlan4K); - vlan4K.member |= ((1 << port) | RTL8366_PORT_CPU); - vlan4K.untag = RTL8366_PORT_ALL_BUT_CPU; - rtl8366s_set_vlan_4k_entry(smi, &vlan4K); + rtl8366s_get_vlan_4k_entry(smi, val, &vlan4k); + vlan4k.member |= ((1 << port) | RTL8366_PORT_CPU); + vlan4k.untag = RTL8366_PORT_ALL_BUT_CPU; + rtl8366s_set_vlan_4k_entry(smi, &vlan4k); /* For the 16 entries more work needs to be done. First see if such VID is already there and change it */ @@ -934,7 +934,7 @@ static int rtl8366_vlan_set_4ktable(struct rtl8366_smi *smi, int enable) static int rtl8366s_reset_vlan(struct rtl8366_smi *smi) { int i; - struct rtl8366s_vlan4kentry vlan4K; + struct rtl8366s_vlan4kentry vlan4k; struct rtl8366s_vlanconfig vlanMC; /* clear 16 VLAN member configuration */ @@ -949,11 +949,11 @@ static int rtl8366s_reset_vlan(struct rtl8366_smi *smi) } /* Set a default VLAN with vid 1 to 4K table for all ports */ - vlan4K.vid = 1; - vlan4K.member = RTL8366_PORT_ALL; - vlan4K.untag = RTL8366_PORT_ALL; - vlan4K.fid = 0; - if (rtl8366s_set_vlan_4k_entry(smi, &vlan4K) != 0) + vlan4k.vid = 1; + vlan4k.member = RTL8366_PORT_ALL; + vlan4k.untag = RTL8366_PORT_ALL; + vlan4k.fid = 0; + if (rtl8366s_set_vlan_4k_entry(smi, &vlan4k) != 0) return -EIO; /* Set all ports PVID to default VLAN */ @@ -1357,7 +1357,7 @@ static int rtl8366_attr_get_vlan_info(struct switch_dev *dev, char buf[1024]; u32 len = 0; struct rtl8366s_vlanconfig vlanMC; - struct rtl8366s_vlan4kentry vlan4K; + struct rtl8366s_vlan4kentry vlan4k; struct rtl8366_smi *smi = to_rtl8366(dev); if (val->port_vlan >= RTL8366_NUM_PORTS) @@ -1366,7 +1366,7 @@ static int rtl8366_attr_get_vlan_info(struct switch_dev *dev, memset(buf, '\0', sizeof(buf)); rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); - rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4K); + rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4k); len += snprintf(buf + len, sizeof(buf) - len, "VLAN %d: Ports: ", val->port_vlan); @@ -1389,7 +1389,7 @@ static int rtl8366_attr_get_vlan_info(struct switch_dev *dev, len += snprintf(buf + len, sizeof(buf) - len, "\t4K:\t"); len += snprintf(buf + len, sizeof(buf) - len, "%d \t \t 0x%04x \t 0x%04x \t %d", - vlan4K.vid, vlan4K.member, vlan4K.untag, vlan4K.fid); + vlan4k.vid, vlan4k.member, vlan4k.untag, vlan4k.fid); val->value.s = buf; val->len = len; @@ -1487,7 +1487,7 @@ static int rtl8366_set_member(struct switch_dev *dev, struct switch_val *val) { struct rtl8366s_vlanconfig vlanMC; - struct rtl8366s_vlan4kentry vlan4K; + struct rtl8366s_vlan4kentry vlan4k; struct rtl8366_smi *smi = to_rtl8366(dev); if (val->port_vlan >= RTL8366_NUM_VLANS) @@ -1495,11 +1495,11 @@ static int rtl8366_set_member(struct switch_dev *dev, rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); - rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4K); + rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4k); - vlan4K.member = vlanMC.member = val->value.i; + vlan4k.member = vlanMC.member = val->value.i; rtl8366s_set_vlan_member_config(smi, val->port_vlan, &vlanMC); - rtl8366s_set_vlan_4k_entry(smi, &vlan4K); + rtl8366s_set_vlan_4k_entry(smi, &vlan4k); return 0; } @@ -1509,7 +1509,7 @@ static int rtl8366_get_member(struct switch_dev *dev, struct switch_val *val) { struct rtl8366s_vlanconfig vlanMC; - struct rtl8366s_vlan4kentry vlan4K; + struct rtl8366s_vlan4kentry vlan4k; struct rtl8366_smi *smi = to_rtl8366(dev); if (val->port_vlan >= RTL8366_NUM_VLANS) @@ -1517,7 +1517,7 @@ static int rtl8366_get_member(struct switch_dev *dev, rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); - rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4K); + rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4k); val->value.i = vlanMC.member; @@ -1529,18 +1529,18 @@ static int rtl8366_set_untag(struct switch_dev *dev, struct switch_val *val) { struct rtl8366s_vlanconfig vlanMC; - struct rtl8366s_vlan4kentry vlan4K; + struct rtl8366s_vlan4kentry vlan4k; struct rtl8366_smi *smi = to_rtl8366(dev); if (val->port_vlan >= RTL8366_NUM_VLANS) return -EINVAL; rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); - rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4K); + rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4k); - vlan4K.untag = vlanMC.untag = val->value.i; + vlan4k.untag = vlanMC.untag = val->value.i; rtl8366s_set_vlan_member_config(smi, val->port_vlan, &vlanMC); - rtl8366s_set_vlan_4k_entry(smi, &vlan4K); + rtl8366s_set_vlan_4k_entry(smi, &vlan4k); return 0; } @@ -1550,14 +1550,14 @@ static int rtl8366_get_untag(struct switch_dev *dev, struct switch_val *val) { struct rtl8366s_vlanconfig vlanMC; - struct rtl8366s_vlan4kentry vlan4K; + struct rtl8366s_vlan4kentry vlan4k; struct rtl8366_smi *smi = to_rtl8366(dev); if (val->port_vlan >= RTL8366_NUM_VLANS) return -EINVAL; rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); - rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4K); + rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4k); val->value.i = vlanMC.untag; From 221c0d2b2d2a960986dbe0d8ce8b9a085178a22d Mon Sep 17 00:00:00 2001 From: juhosg Date: Sun, 17 Jan 2010 21:17:59 +0000 Subject: [PATCH 053/210] rtl8366_smi: use vlanmc name for all vlanconfig variables git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19201 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../files/drivers/net/phy/rtl8366_smi.c | 121 +++++++++--------- 1 file changed, 60 insertions(+), 61 deletions(-) diff --git a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c index ffd275822..0d54126cc 100644 --- a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c +++ b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c @@ -680,20 +680,19 @@ static int rtl8366s_set_vlan_4k_entry(struct rtl8366_smi *smi, } static int rtl8366s_get_vlan_member_config(struct rtl8366_smi *smi, u32 index, - struct rtl8366s_vlanconfig - *vlanmconf) + struct rtl8366s_vlanconfig *vlanmc) { int err; u32 addr; u32 data; u16 *tableaddr; - memset(vlanmconf, '\0', sizeof(struct rtl8366s_vlanconfig)); + memset(vlanmc, '\0', sizeof(struct rtl8366s_vlanconfig)); if (index >= RTL8366_NUM_VLANS) return -EINVAL; - tableaddr = (u16 *)vlanmconf; + tableaddr = (u16 *)vlanmc; addr = RTL8366S_VLAN_MEMCONF_BASE + (index << 1); @@ -717,7 +716,7 @@ static int rtl8366s_get_vlan_member_config(struct rtl8366_smi *smi, u32 index, static int rtl8366s_set_vlan_member_config(struct rtl8366_smi *smi, u32 index, const struct rtl8366s_vlanconfig - *vlanmconf) + *vlanmc) { int err; u32 addr; @@ -725,17 +724,17 @@ static int rtl8366s_set_vlan_member_config(struct rtl8366_smi *smi, u32 index, u16 *tableaddr; if (index >= RTL8366_NUM_VLANS || - vlanmconf->vid >= RTL8366_NUM_VIDS || - vlanmconf->priority > RTL8366S_PRIORITYMAX || - vlanmconf->member > RTL8366_PORT_ALL || - vlanmconf->untag > RTL8366_PORT_ALL || - vlanmconf->fid > RTL8366S_FIDMAX) + vlanmc->vid >= RTL8366_NUM_VIDS || + vlanmc->priority > RTL8366S_PRIORITYMAX || + vlanmc->member > RTL8366_PORT_ALL || + vlanmc->untag > RTL8366_PORT_ALL || + vlanmc->fid > RTL8366S_FIDMAX) return -EINVAL; addr = RTL8366S_VLAN_MEMCONF_BASE + (index << 1); - tableaddr = (u16 *)vlanmconf; + tableaddr = (u16 *)vlanmc; data = *tableaddr; err = rtl8366_smi_write_reg(smi, addr, data); @@ -789,17 +788,17 @@ static int rtl8366_get_vlan_port_pvid(struct rtl8366_smi *smi, int port, { int err; int index; - struct rtl8366s_vlanconfig vlanMC; + struct rtl8366s_vlanconfig vlanmc; err = rtl8366_get_port_vlan_index(smi, port, &index); if (err) return err; - err = rtl8366s_get_vlan_member_config(smi, index, &vlanMC); + err = rtl8366s_get_vlan_member_config(smi, index, &vlanmc); if (err) return err; - *val = vlanMC.vid; + *val = vlanmc.vid; return 0; } @@ -847,7 +846,7 @@ static int rtl8366_set_vlan_port_pvid(struct rtl8366_smi *smi, int port, int val) { int i; - struct rtl8366s_vlanconfig vlanMC; + struct rtl8366s_vlanconfig vlanmc; struct rtl8366s_vlan4kentry vlan4k; if (port >= RTL8366_NUM_PORTS || val >= RTL8366_NUM_VIDS) @@ -864,12 +863,12 @@ static int rtl8366_set_vlan_port_pvid(struct rtl8366_smi *smi, int port, /* For the 16 entries more work needs to be done. First see if such VID is already there and change it */ for (i = 0; i < RTL8366_NUM_VLANS; ++i) { - rtl8366s_get_vlan_member_config(smi, i, &vlanMC); + rtl8366s_get_vlan_member_config(smi, i, &vlanmc); /* Try to find an existing vid and update port member set */ - if (val == vlanMC.vid) { - vlanMC.member |= ((1 << port) | RTL8366_PORT_CPU); - rtl8366s_set_vlan_member_config(smi, i, &vlanMC); + if (val == vlanmc.vid) { + vlanmc.member |= ((1 << port) | RTL8366_PORT_CPU); + rtl8366s_set_vlan_member_config(smi, i, &vlanmc); /* Now update PVID register settings */ rtl8366_set_port_vlan_index(smi, port, i); @@ -881,18 +880,18 @@ static int rtl8366_set_vlan_port_pvid(struct rtl8366_smi *smi, int port, /* PVID could not be found from vlan table. Replace unused (one that has no member ports) with new one */ for (i = 0; i < RTL8366_NUM_VLANS; ++i) { - rtl8366s_get_vlan_member_config(smi, i, &vlanMC); + rtl8366s_get_vlan_member_config(smi, i, &vlanmc); /* See if this vlan member configuration is unused. It is unused if member set contains no ports or CPU port only */ - if (!vlanMC.member || vlanMC.member == RTL8366_PORT_CPU) { - vlanMC.vid = val; - vlanMC.priority = 0; - vlanMC.untag = RTL8366_PORT_ALL_BUT_CPU; - vlanMC.member = ((1 << port) | RTL8366_PORT_CPU); - vlanMC.fid = 0; + if (!vlanmc.member || vlanmc.member == RTL8366_PORT_CPU) { + vlanmc.vid = val; + vlanmc.priority = 0; + vlanmc.untag = RTL8366_PORT_ALL_BUT_CPU; + vlanmc.member = ((1 << port) | RTL8366_PORT_CPU); + vlanmc.fid = 0; - rtl8366s_set_vlan_member_config(smi, i, &vlanMC); + rtl8366s_set_vlan_member_config(smi, i, &vlanmc); /* Now update PVID register settings */ rtl8366_set_port_vlan_index(smi, port, i); @@ -935,16 +934,16 @@ static int rtl8366s_reset_vlan(struct rtl8366_smi *smi) { int i; struct rtl8366s_vlan4kentry vlan4k; - struct rtl8366s_vlanconfig vlanMC; + struct rtl8366s_vlanconfig vlanmc; /* clear 16 VLAN member configuration */ for (i = 0; i < RTL8366_NUM_VLANS; i++) { - vlanMC.vid = 0; - vlanMC.priority = 0; - vlanMC.member = 0; - vlanMC.untag = 0; - vlanMC.fid = 0; - if (rtl8366s_set_vlan_member_config(smi, i, &vlanMC) != 0) + vlanmc.vid = 0; + vlanmc.priority = 0; + vlanmc.member = 0; + vlanmc.untag = 0; + vlanmc.fid = 0; + if (rtl8366s_set_vlan_member_config(smi, i, &vlanmc) != 0) return -EIO; } @@ -1032,14 +1031,14 @@ static ssize_t rtl8366_read_debugfs_vlan(struct file *file, "\tports\n"); for (i = 0; i < RTL8366_NUM_VLANS; ++i) { - struct rtl8366s_vlanconfig vlanMC; + struct rtl8366s_vlanconfig vlanmc; - rtl8366s_get_vlan_member_config(smi, i, &vlanMC); + rtl8366s_get_vlan_member_config(smi, i, &vlanmc); len += snprintf(buf + len, sizeof(buf) - len, "\t[%d] \t %d \t %d \t 0x%04x \t 0x%04x \t %d " - "\t", i, vlanMC.vid, vlanMC.priority, - vlanMC.member, vlanMC.untag, vlanMC.fid); + "\t", i, vlanmc.vid, vlanmc.priority, + vlanmc.member, vlanmc.untag, vlanmc.fid); for (j = 0; j < RTL8366_NUM_PORTS; ++j) { int index = 0; @@ -1356,7 +1355,7 @@ static int rtl8366_attr_get_vlan_info(struct switch_dev *dev, int i; char buf[1024]; u32 len = 0; - struct rtl8366s_vlanconfig vlanMC; + struct rtl8366s_vlanconfig vlanmc; struct rtl8366s_vlan4kentry vlan4k; struct rtl8366_smi *smi = to_rtl8366(dev); @@ -1365,8 +1364,8 @@ static int rtl8366_attr_get_vlan_info(struct switch_dev *dev, memset(buf, '\0', sizeof(buf)); - rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); - rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4k); + rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanmc); + rtl8366s_get_vlan_4k_entry(smi, vlanmc.vid, &vlan4k); len += snprintf(buf + len, sizeof(buf) - len, "VLAN %d: Ports: ", val->port_vlan); @@ -1384,8 +1383,8 @@ static int rtl8366_attr_get_vlan_info(struct switch_dev *dev, len += snprintf(buf + len, sizeof(buf) - len, "\tMC:\t"); len += snprintf(buf + len, sizeof(buf) - len, "%d \t %d \t 0x%04x \t 0x%04x \t %d\n", - vlanMC.vid, vlanMC.priority, vlanMC.member, - vlanMC.untag, vlanMC.fid); + vlanmc.vid, vlanmc.priority, vlanmc.member, + vlanmc.untag, vlanmc.fid); len += snprintf(buf + len, sizeof(buf) - len, "\t4K:\t"); len += snprintf(buf + len, sizeof(buf) - len, "%d \t \t 0x%04x \t 0x%04x \t %d", @@ -1486,19 +1485,19 @@ static int rtl8366_set_member(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val) { - struct rtl8366s_vlanconfig vlanMC; + struct rtl8366s_vlanconfig vlanmc; struct rtl8366s_vlan4kentry vlan4k; struct rtl8366_smi *smi = to_rtl8366(dev); if (val->port_vlan >= RTL8366_NUM_VLANS) return -EINVAL; - rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); + rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanmc); - rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4k); + rtl8366s_get_vlan_4k_entry(smi, vlanmc.vid, &vlan4k); - vlan4k.member = vlanMC.member = val->value.i; - rtl8366s_set_vlan_member_config(smi, val->port_vlan, &vlanMC); + vlan4k.member = vlanmc.member = val->value.i; + rtl8366s_set_vlan_member_config(smi, val->port_vlan, &vlanmc); rtl8366s_set_vlan_4k_entry(smi, &vlan4k); return 0; @@ -1508,18 +1507,18 @@ static int rtl8366_get_member(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val) { - struct rtl8366s_vlanconfig vlanMC; + struct rtl8366s_vlanconfig vlanmc; struct rtl8366s_vlan4kentry vlan4k; struct rtl8366_smi *smi = to_rtl8366(dev); if (val->port_vlan >= RTL8366_NUM_VLANS) return -EINVAL; - rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); + rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanmc); - rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4k); + rtl8366s_get_vlan_4k_entry(smi, vlanmc.vid, &vlan4k); - val->value.i = vlanMC.member; + val->value.i = vlanmc.member; return 0; } @@ -1528,18 +1527,18 @@ static int rtl8366_set_untag(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val) { - struct rtl8366s_vlanconfig vlanMC; + struct rtl8366s_vlanconfig vlanmc; struct rtl8366s_vlan4kentry vlan4k; struct rtl8366_smi *smi = to_rtl8366(dev); if (val->port_vlan >= RTL8366_NUM_VLANS) return -EINVAL; - rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); - rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4k); + rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanmc); + rtl8366s_get_vlan_4k_entry(smi, vlanmc.vid, &vlan4k); - vlan4k.untag = vlanMC.untag = val->value.i; - rtl8366s_set_vlan_member_config(smi, val->port_vlan, &vlanMC); + vlan4k.untag = vlanmc.untag = val->value.i; + rtl8366s_set_vlan_member_config(smi, val->port_vlan, &vlanmc); rtl8366s_set_vlan_4k_entry(smi, &vlan4k); return 0; @@ -1549,18 +1548,18 @@ static int rtl8366_get_untag(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val) { - struct rtl8366s_vlanconfig vlanMC; + struct rtl8366s_vlanconfig vlanmc; struct rtl8366s_vlan4kentry vlan4k; struct rtl8366_smi *smi = to_rtl8366(dev); if (val->port_vlan >= RTL8366_NUM_VLANS) return -EINVAL; - rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanMC); - rtl8366s_get_vlan_4k_entry(smi, vlanMC.vid, &vlan4k); + rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanmc); + rtl8366s_get_vlan_4k_entry(smi, vlanmc.vid, &vlan4k); - val->value.i = vlanMC.untag; + val->value.i = vlanmc.untag; return 0; } From ad726f6e1c1613cf49a2545c81a1ca6dfc9acfcd Mon Sep 17 00:00:00 2001 From: juhosg Date: Sun, 17 Jan 2010 21:37:09 +0000 Subject: [PATCH 054/210] rtl8366_smi: register the switch directly from the probe routine git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19202 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../files/drivers/net/phy/rtl8366_smi.c | 57 ++++++++++++------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c index 0d54126cc..3b4795ba4 100644 --- a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c +++ b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c @@ -1718,6 +1718,27 @@ static struct switch_dev rtldev = { .reset_switch = rtl8366_reset_switch, }; +static int rtl8366_smi_switch_init(struct rtl8366_smi *smi) +{ + struct switch_dev *dev = &smi->dev; + int err; + + memcpy(dev, &rtldev, sizeof(struct switch_dev)); + dev->priv = smi; + dev->devname = dev_name(&smi->pdev->dev); + + err = register_switch(dev, NULL); + if (err) + dev_err(&smi->pdev->dev, "switch registration failed\n"); + + return; +} + +static void rtl8366_smi_switch_cleanup(struct rtl8366_smi *smi) +{ + unregister_switch(&smi->dev); +} + static int rtl8366_smi_mii_read(struct mii_bus *bus, int addr, int reg) { struct rtl8366_smi *smi = bus->priv; @@ -1787,6 +1808,12 @@ static void rtl8366_smi_mii_cleanup(struct rtl8366_smi *smi) mdiobus_free(smi->mii_bus); } +static int rtl8366_smi_mii_bus_match(struct mii_bus *bus) +{ + return (bus->read == rtl8366_smi_mii_read && + bus->write == rtl8366_smi_mii_write); +} + static int rtl8366_smi_setup(struct rtl8366_smi *smi) { u32 chip_id = 0; @@ -1878,8 +1905,14 @@ static int __init rtl8366_smi_probe(struct platform_device *pdev) if (err) goto err_clear_drvdata; + err = rtl8366_smi_switch_init(smi); + if (err) + goto err_mii_cleanup; + return 0; + err_mii_cleanup: + rtl8366_smi_mii_cleanup(smi); err_clear_drvdata: platform_set_drvdata(pdev, NULL); gpio_free(pdata->gpio_sck); @@ -1893,26 +1926,8 @@ static int __init rtl8366_smi_probe(struct platform_device *pdev) int rtl8366_phy_config_init(struct phy_device *phydev) { - int err; - struct net_device *netdev = phydev->attached_dev; - struct rtl8366_smi *smi = phydev->bus->priv; - struct switch_dev *dev = &smi->dev; - - /* Only init the switch for the primary PHY */ - if (phydev->addr != 4) { - printk(KERN_INFO "Discarding address: %d\n", phydev->addr); - return 0; - } - - memcpy(&smi->dev, &rtldev, sizeof(struct switch_dev)); - dev->priv = smi; - dev->netdev = netdev; - - err = register_switch(dev, netdev); - if (err < 0) { - printk(KERN_INFO "Switch registration failed\n"); - return err; - } + if (!rtl8366_smi_mii_bus_match(phydev->bus)) + return -EINVAL; return 0; } @@ -1944,8 +1959,8 @@ static int __devexit rtl8366_smi_remove(struct platform_device *pdev) pdata = pdev->dev.platform_data; + rtl8366_smi_switch_cleanup(smi); rtl8366_debugfs_remove(smi); - phy_driver_unregister(&rtl8366_smi_phy_driver); rtl8366_smi_mii_cleanup(smi); platform_set_drvdata(pdev, NULL); gpio_free(pdata->gpio_sck); From 7029e829c7617bd7bb29797525d9dcd86b7c385f Mon Sep 17 00:00:00 2001 From: nbd Date: Sun, 17 Jan 2010 22:52:24 +0000 Subject: [PATCH 055/210] add mini_fo locking fix from #5864 git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19203 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../patches-2.6.30/216-mini_fo_locking.patch | 25 +++++++++++++++++++ .../patches-2.6.31/216-mini_fo_locking.patch | 25 +++++++++++++++++++ .../patches-2.6.32/216-mini_fo_locking.patch | 25 +++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 target/linux/generic-2.6/patches-2.6.30/216-mini_fo_locking.patch create mode 100644 target/linux/generic-2.6/patches-2.6.31/216-mini_fo_locking.patch create mode 100644 target/linux/generic-2.6/patches-2.6.32/216-mini_fo_locking.patch diff --git a/target/linux/generic-2.6/patches-2.6.30/216-mini_fo_locking.patch b/target/linux/generic-2.6/patches-2.6.30/216-mini_fo_locking.patch new file mode 100644 index 000000000..4f075920f --- /dev/null +++ b/target/linux/generic-2.6/patches-2.6.30/216-mini_fo_locking.patch @@ -0,0 +1,25 @@ +--- a/fs/mini_fo/state.c ++++ b/fs/mini_fo/state.c +@@ -537,17 +537,17 @@ int nondir_mod_to_del(dentry_t *dentry) + dtohd(dentry) = NULL; + dtost(dentry) = DELETED; + +- /* add deleted file to META-file */ +- meta_add_d_entry(dentry->d_parent, +- dentry->d_name.name, +- dentry->d_name.len); +- + /* was: unlock_dir(hidden_sto_dir_dentry); */ + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) + mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex); + #else + up(&hidden_sto_dir_dentry->d_inode->i_sem); + #endif ++ /* add deleted file to META-file */ ++ meta_add_d_entry(dentry->d_parent, ++ dentry->d_name.name, ++ dentry->d_name.len); ++ + dput(hidden_sto_dir_dentry); + + out: diff --git a/target/linux/generic-2.6/patches-2.6.31/216-mini_fo_locking.patch b/target/linux/generic-2.6/patches-2.6.31/216-mini_fo_locking.patch new file mode 100644 index 000000000..4f075920f --- /dev/null +++ b/target/linux/generic-2.6/patches-2.6.31/216-mini_fo_locking.patch @@ -0,0 +1,25 @@ +--- a/fs/mini_fo/state.c ++++ b/fs/mini_fo/state.c +@@ -537,17 +537,17 @@ int nondir_mod_to_del(dentry_t *dentry) + dtohd(dentry) = NULL; + dtost(dentry) = DELETED; + +- /* add deleted file to META-file */ +- meta_add_d_entry(dentry->d_parent, +- dentry->d_name.name, +- dentry->d_name.len); +- + /* was: unlock_dir(hidden_sto_dir_dentry); */ + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) + mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex); + #else + up(&hidden_sto_dir_dentry->d_inode->i_sem); + #endif ++ /* add deleted file to META-file */ ++ meta_add_d_entry(dentry->d_parent, ++ dentry->d_name.name, ++ dentry->d_name.len); ++ + dput(hidden_sto_dir_dentry); + + out: diff --git a/target/linux/generic-2.6/patches-2.6.32/216-mini_fo_locking.patch b/target/linux/generic-2.6/patches-2.6.32/216-mini_fo_locking.patch new file mode 100644 index 000000000..4f075920f --- /dev/null +++ b/target/linux/generic-2.6/patches-2.6.32/216-mini_fo_locking.patch @@ -0,0 +1,25 @@ +--- a/fs/mini_fo/state.c ++++ b/fs/mini_fo/state.c +@@ -537,17 +537,17 @@ int nondir_mod_to_del(dentry_t *dentry) + dtohd(dentry) = NULL; + dtost(dentry) = DELETED; + +- /* add deleted file to META-file */ +- meta_add_d_entry(dentry->d_parent, +- dentry->d_name.name, +- dentry->d_name.len); +- + /* was: unlock_dir(hidden_sto_dir_dentry); */ + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) + mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex); + #else + up(&hidden_sto_dir_dentry->d_inode->i_sem); + #endif ++ /* add deleted file to META-file */ ++ meta_add_d_entry(dentry->d_parent, ++ dentry->d_name.name, ++ dentry->d_name.len); ++ + dput(hidden_sto_dir_dentry); + + out: From f79dd5c8406414c2913af9a4fdb913539f88c011 Mon Sep 17 00:00:00 2001 From: nbd Date: Sun, 17 Jan 2010 22:57:08 +0000 Subject: [PATCH 056/210] ar71xx: fix return statement in the rtl8366 driver git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19204 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c index 3b4795ba4..e2172f1b9 100644 --- a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c +++ b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c @@ -1731,7 +1731,7 @@ static int rtl8366_smi_switch_init(struct rtl8366_smi *smi) if (err) dev_err(&smi->pdev->dev, "switch registration failed\n"); - return; + return err; } static void rtl8366_smi_switch_cleanup(struct rtl8366_smi *smi) From efa2a6f909676dd526dc673273dcd95fc49447e4 Mon Sep 17 00:00:00 2001 From: nbd Date: Mon, 18 Jan 2010 00:12:07 +0000 Subject: [PATCH 057/210] rtl8366_smi: fix excessive stack usage and buffer handling bugs git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19205 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../files/drivers/net/phy/rtl8366_smi.c | 102 +++++++++--------- 1 file changed, 52 insertions(+), 50 deletions(-) diff --git a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c index e2172f1b9..72ead316c 100644 --- a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c +++ b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c @@ -209,6 +209,7 @@ struct rtl8366_smi { struct mii_bus *mii_bus; struct switch_dev dev; int mii_irq[PHY_MAX_ADDR]; + char buf[4096]; #ifdef DEBUG struct dentry *debugfs_root; #endif @@ -975,44 +976,44 @@ static ssize_t rtl8366_read_debugfs_mibs(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - char buf[4096]; int i, j, len = 0; struct rtl8366_smi *smi = (struct rtl8366_smi *)file->private_data; + char *buf = smi->buf; - len += snprintf(buf + len, sizeof(buf) - len, "MIB Counters:\n"); - len += snprintf(buf + len, sizeof(buf) - len, "Counter" + len += snprintf(buf + len, sizeof(smi->buf) - len, "MIB Counters:\n"); + len += snprintf(buf + len, sizeof(smi->buf) - len, "Counter" " " "Port 0 \t\t Port 1 \t\t Port 2 \t\t Port 3 \t\t " "Port 4\n"); for (i = 0; i < 33; ++i) { - len += snprintf(buf + len, sizeof(buf) - len, "%d:%s ", + len += snprintf(buf + len, sizeof(smi->buf) - len, "%d:%s ", i, MIBCOUNTERS[i]); for (j = 0; j < RTL8366_NUM_PORTS; ++j) { unsigned long long counter = 0; if (!rtl8366_get_mib_counter(smi, i, j, &counter)) - len += snprintf(buf + len, sizeof(buf) - len, + len += snprintf(buf + len, sizeof(smi->buf) - len, "[%llu]", counter); else - len += snprintf(buf + len, sizeof(buf) - len, + len += snprintf(buf + len, sizeof(smi->buf) - len, "[error]"); if (j != RTL8366_NUM_PORTS - 1) { if (counter < 100000) len += snprintf(buf + len, - sizeof(buf) - len, + sizeof(smi->buf) - len, "\t"); - len += snprintf(buf + len, sizeof(buf) - len, + len += snprintf(buf + len, sizeof(smi->buf) - len, "\t"); } } - len += snprintf(buf + len, sizeof(buf) - len, "\n"); + len += snprintf(buf + len, sizeof(smi->buf) - len, "\n"); } - len += snprintf(buf + len, sizeof(buf) - len, "\n"); + len += snprintf(buf + len, sizeof(smi->buf) - len, "\n"); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } @@ -1021,12 +1022,12 @@ static ssize_t rtl8366_read_debugfs_vlan(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - char buf[4096]; int i, j, len = 0; struct rtl8366_smi *smi = (struct rtl8366_smi *)file->private_data; + char *buf = smi->buf; - len += snprintf(buf + len, sizeof(buf) - len, "VLAN Member Config:\n"); - len += snprintf(buf + len, sizeof(buf) - len, + len += snprintf(buf + len, sizeof(smi->buf) - len, "VLAN Member Config:\n"); + len += snprintf(buf + len, sizeof(smi->buf) - len, "\t id \t vid \t prio \t member \t untag \t fid " "\tports\n"); @@ -1035,7 +1036,7 @@ static ssize_t rtl8366_read_debugfs_vlan(struct file *file, rtl8366s_get_vlan_member_config(smi, i, &vlanmc); - len += snprintf(buf + len, sizeof(buf) - len, + len += snprintf(buf + len, sizeof(smi->buf) - len, "\t[%d] \t %d \t %d \t 0x%04x \t 0x%04x \t %d " "\t", i, vlanmc.vid, vlanmc.priority, vlanmc.member, vlanmc.untag, vlanmc.fid); @@ -1045,11 +1046,11 @@ static ssize_t rtl8366_read_debugfs_vlan(struct file *file, if (!rtl8366_get_port_vlan_index(smi, j, &index)) { if (index == i) len += snprintf(buf + len, - sizeof(buf) - len, + sizeof(smi->buf) - len, "%d", j); } } - len += snprintf(buf + len, sizeof(buf) - len, "\n"); + len += snprintf(buf + len, sizeof(smi->buf) - len, "\n"); } return simple_read_from_buffer(user_buf, count, ppos, buf, len); @@ -1061,19 +1062,19 @@ static ssize_t rtl8366_read_debugfs_reg(struct file *file, { u32 t, reg = g_dbg_reg; int err, len = 0; - char buf[512]; struct rtl8366_smi *smi = (struct rtl8366_smi *)file->private_data; + char *buf = smi->buf; - memset(buf, '\0', sizeof(buf)); + memset(buf, '\0', sizeof(smi->buf)); err = rtl8366_smi_read_reg(smi, reg, &t); if (err) { - len += snprintf(buf, sizeof(buf), + len += snprintf(buf, sizeof(smi->buf), "Read failed (reg: 0x%04x)\n", reg); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } - len += snprintf(buf, sizeof(buf), "reg = 0x%04x, val = 0x%04x\n", + len += snprintf(buf, sizeof(smi->buf), "reg = 0x%04x, val = 0x%04x\n", reg, t); return simple_read_from_buffer(user_buf, count, ppos, buf, len); @@ -1086,11 +1087,11 @@ static ssize_t rtl8366_write_debugfs_reg(struct file *file, unsigned long data; u32 reg = g_dbg_reg; int err; - char buf[50]; size_t len; struct rtl8366_smi *smi = (struct rtl8366_smi *)file->private_data; + char *buf = smi->buf; - len = min(count, sizeof(buf) - 1); + len = min(count, sizeof(smi->buf) - 1); if (copy_from_user(buf, user_buf, len)) { dev_err(&smi->pdev->dev, "copy from user failed\n"); return -EFAULT; @@ -1290,15 +1291,15 @@ static int rtl8366_attr_get_port_link(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val) { - char buf[1024]; u32 len = 0, data = 0; int speed, duplex, link, txpause, rxpause, nway; struct rtl8366_smi *smi = to_rtl8366(dev); + char *buf = smi->buf; if (val->port_vlan >= RTL8366_NUM_PORTS) return -EINVAL; - memset(buf, '\0', sizeof(buf)); + memset(buf, '\0', sizeof(smi->buf)); rtl8366_smi_read_reg(smi, RTL8366S_PORT_LINK_STATUS_BASE + (val->port_vlan >> 1), &data); @@ -1313,34 +1314,34 @@ static int rtl8366_attr_get_port_link(struct switch_dev *dev, rxpause = (data & RTL8366S_PORT_STATUS_RXPAUSE_MASK) >> 6; nway = (data & RTL8366S_PORT_STATUS_AN_MASK) >> 7; - len += snprintf(buf + len, sizeof(buf) - len, "Port %d: ", + len += snprintf(buf + len, sizeof(smi->buf) - len, "Port %d: ", val->port_vlan); if (link) - len += snprintf(buf + len, sizeof(buf) - len, + len += snprintf(buf + len, sizeof(smi->buf) - len, "Link UP, Speed: "); else - len += snprintf(buf + len, sizeof(buf) - len, + len += snprintf(buf + len, sizeof(smi->buf) - len, "Link DOWN, Speed: "); if (speed == 0) - len += snprintf(buf + len, sizeof(buf) - len, "10Base-TX "); + len += snprintf(buf + len, sizeof(smi->buf) - len, "10Base-TX "); else if (speed == 1) - len += snprintf(buf + len, sizeof(buf) - len, "100Base-TX "); + len += snprintf(buf + len, sizeof(smi->buf) - len, "100Base-TX "); else if (speed == 2) - len += snprintf(buf + len, sizeof(buf) - len, "1000Base-TX "); + len += snprintf(buf + len, sizeof(smi->buf) - len, "1000Base-TX "); if (duplex) - len += snprintf(buf + len, sizeof(buf) - len, "Full-Duplex, "); + len += snprintf(buf + len, sizeof(smi->buf) - len, "Full-Duplex, "); else - len += snprintf(buf + len, sizeof(buf) - len, "Half-Duplex, "); + len += snprintf(buf + len, sizeof(smi->buf) - len, "Half-Duplex, "); if (txpause) - len += snprintf(buf + len, sizeof(buf) - len, "TX-Pause "); + len += snprintf(buf + len, sizeof(smi->buf) - len, "TX-Pause "); if (rxpause) - len += snprintf(buf + len, sizeof(buf) - len, "RX-Pause "); + len += snprintf(buf + len, sizeof(smi->buf) - len, "RX-Pause "); if (nway) - len += snprintf(buf + len, sizeof(buf) - len, "nway "); + len += snprintf(buf + len, sizeof(smi->buf) - len, "nway "); val->value.s = buf; val->len = len; @@ -1353,40 +1354,40 @@ static int rtl8366_attr_get_vlan_info(struct switch_dev *dev, struct switch_val *val) { int i; - char buf[1024]; u32 len = 0; struct rtl8366s_vlanconfig vlanmc; struct rtl8366s_vlan4kentry vlan4k; struct rtl8366_smi *smi = to_rtl8366(dev); + char *buf = smi->buf; if (val->port_vlan >= RTL8366_NUM_PORTS) return -EINVAL; - memset(buf, '\0', sizeof(buf)); + memset(buf, '\0', sizeof(smi->buf)); rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanmc); rtl8366s_get_vlan_4k_entry(smi, vlanmc.vid, &vlan4k); - len += snprintf(buf + len, sizeof(buf) - len, "VLAN %d: Ports: ", + len += snprintf(buf + len, sizeof(smi->buf) - len, "VLAN %d: Ports: ", val->port_vlan); for (i = 0; i < RTL8366_NUM_PORTS; ++i) { int index = 0; if (!rtl8366_get_port_vlan_index(smi, i, &index) && index == val->port_vlan) - len += snprintf(buf + len, sizeof(buf) - len, "%d", i); + len += snprintf(buf + len, sizeof(smi->buf) - len, "%d", i); } - len += snprintf(buf + len, sizeof(buf) - len, "\n"); + len += snprintf(buf + len, sizeof(smi->buf) - len, "\n"); - len += snprintf(buf + len, sizeof(buf) - len, + len += snprintf(buf + len, sizeof(smi->buf) - len, "\t\t vid \t prio \t member \t untag \t fid\n"); - len += snprintf(buf + len, sizeof(buf) - len, "\tMC:\t"); - len += snprintf(buf + len, sizeof(buf) - len, + len += snprintf(buf + len, sizeof(smi->buf) - len, "\tMC:\t"); + len += snprintf(buf + len, sizeof(smi->buf) - len, "%d \t %d \t 0x%04x \t 0x%04x \t %d\n", vlanmc.vid, vlanmc.priority, vlanmc.member, vlanmc.untag, vlanmc.fid); - len += snprintf(buf + len, sizeof(buf) - len, "\t4K:\t"); - len += snprintf(buf + len, sizeof(buf) - len, + len += snprintf(buf + len, sizeof(smi->buf) - len, "\t4K:\t"); + len += snprintf(buf + len, sizeof(smi->buf) - len, "%d \t \t 0x%04x \t 0x%04x \t %d", vlan4k.vid, vlan4k.member, vlan4k.untag, vlan4k.fid); @@ -1455,24 +1456,25 @@ static int rtl8366_get_port_mib(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val) { - char buf[2048]; int i, len = 0; unsigned long long counter = 0; struct rtl8366_smi *smi = to_rtl8366(dev); + char *buf = smi->buf; + if (val->port_vlan >= RTL8366_NUM_PORTS) return -EINVAL; - len += snprintf(buf + len, sizeof(buf) - len, "Port %d MIB counters\n", + len += snprintf(buf + len, sizeof(smi->buf) - len, "Port %d MIB counters\n", val->port_vlan); for (i = 0; i < RTL8366S_MIB_COUNT; ++i) { - len += snprintf(buf + len, sizeof(buf) - len, + len += snprintf(buf + len, sizeof(smi->buf) - len, "%d:%s\t", i, MIBCOUNTERS[i]); if (!rtl8366_get_mib_counter(smi, i, val->port_vlan, &counter)) - len += snprintf(buf + len, sizeof(buf) - len, + len += snprintf(buf + len, sizeof(smi->buf) - len, "[%llu]\n", counter); else - len += snprintf(buf + len, sizeof(buf) - len, + len += snprintf(buf + len, sizeof(smi->buf) - len, "[error]\n"); } From a289808594a3baeec2584d9cbab4fde7869bea02 Mon Sep 17 00:00:00 2001 From: nbd Date: Mon, 18 Jan 2010 00:12:12 +0000 Subject: [PATCH 058/210] rtl8366_smi: reset the vlan table when resetting the switch and use vlan get/set ports for vlan member lists git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19206 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../files/drivers/net/phy/rtl8366_smi.c | 138 +++++++----------- 1 file changed, 51 insertions(+), 87 deletions(-) diff --git a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c index 72ead316c..588f33603 100644 --- a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c +++ b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c @@ -1279,14 +1279,6 @@ static int rtl8366_set_vlan(struct switch_dev *dev, return rtl8366_vlan_set_4ktable(smi, val->value.i); } -static int rtl8366_init_vlan(struct switch_dev *dev, - const struct switch_attr *attr, - struct switch_val *val) -{ - struct rtl8366_smi *smi = to_rtl8366(dev); - return rtl8366s_reset_vlan(smi); -} - static int rtl8366_attr_get_port_link(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val) @@ -1483,55 +1475,41 @@ static int rtl8366_get_port_mib(struct switch_dev *dev, return 0; } -static int rtl8366_set_member(struct switch_dev *dev, - const struct switch_attr *attr, - struct switch_val *val) +static int rtl8366_get_ports(struct switch_dev *dev, + struct switch_val *val) { struct rtl8366s_vlanconfig vlanmc; - struct rtl8366s_vlan4kentry vlan4k; struct rtl8366_smi *smi = to_rtl8366(dev); + struct switch_port *port; + int i; if (val->port_vlan >= RTL8366_NUM_VLANS) return -EINVAL; rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanmc); - rtl8366s_get_vlan_4k_entry(smi, vlanmc.vid, &vlan4k); - - vlan4k.member = vlanmc.member = val->value.i; - rtl8366s_set_vlan_member_config(smi, val->port_vlan, &vlanmc); - rtl8366s_set_vlan_4k_entry(smi, &vlan4k); + port = &val->value.ports[0]; + val->len = 0; + for (i = 0; i < RTL8366_NUM_PORTS; i++) { + if (!(vlanmc.member & BIT(i))) + continue; + port->id = i; + port->flags = vlanmc.untag ? 0 : BIT(SWITCH_PORT_FLAG_TAGGED); + val->len++; + port++; + } return 0; } -static int rtl8366_get_member(struct switch_dev *dev, - const struct switch_attr *attr, - struct switch_val *val) -{ - struct rtl8366s_vlanconfig vlanmc; - struct rtl8366s_vlan4kentry vlan4k; - struct rtl8366_smi *smi = to_rtl8366(dev); - - if (val->port_vlan >= RTL8366_NUM_VLANS) - return -EINVAL; - - rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanmc); - - rtl8366s_get_vlan_4k_entry(smi, vlanmc.vid, &vlan4k); - - val->value.i = vlanmc.member; - - return 0; -} - -static int rtl8366_set_untag(struct switch_dev *dev, - const struct switch_attr *attr, +static int rtl8366_set_ports(struct switch_dev *dev, struct switch_val *val) { struct rtl8366s_vlanconfig vlanmc; struct rtl8366s_vlan4kentry vlan4k; struct rtl8366_smi *smi = to_rtl8366(dev); + struct switch_port *port; + int i; if (val->port_vlan >= RTL8366_NUM_VLANS) return -EINVAL; @@ -1539,30 +1517,22 @@ static int rtl8366_set_untag(struct switch_dev *dev, rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanmc); rtl8366s_get_vlan_4k_entry(smi, vlanmc.vid, &vlan4k); - vlan4k.untag = vlanmc.untag = val->value.i; + vlanmc.untag = 0; + vlanmc.member = 0; + + port = &val->value.ports[0]; + for (i = 0; i < val->len; i++, port++) { + vlanmc.member |= BIT(port->id); + + if (!(port->flags & BIT(SWITCH_PORT_FLAG_TAGGED))) + vlanmc.untag |= BIT(port->id); + } + + vlan4k.member = vlanmc.member; + vlan4k.untag = vlanmc.untag; + rtl8366s_set_vlan_member_config(smi, val->port_vlan, &vlanmc); rtl8366s_set_vlan_4k_entry(smi, &vlan4k); - - return 0; -} - -static int rtl8366_get_untag(struct switch_dev *dev, - const struct switch_attr *attr, - struct switch_val *val) -{ - struct rtl8366s_vlanconfig vlanmc; - struct rtl8366s_vlan4kentry vlan4k; - struct rtl8366_smi *smi = to_rtl8366(dev); - - if (val->port_vlan >= RTL8366_NUM_VLANS) - return -EINVAL; - - rtl8366s_get_vlan_member_config(smi, val->port_vlan, &vlanmc); - rtl8366s_get_vlan_4k_entry(smi, vlanmc.vid, &vlan4k); - - - val->value.i = vlanmc.untag; - return 0; } @@ -1581,9 +1551,26 @@ static int rtl8366_set_port_pvid(struct switch_dev *dev, int port, int val) static int rtl8366_reset_switch(struct switch_dev *dev) { struct rtl8366_smi *smi = to_rtl8366(dev); + int timeout = 10; + u32 data; + rtl8366_smi_write_reg(smi, RTL8366_RESET_CTRL_REG, RTL8366_CHIP_CTRL_RESET_HW); - return 0; + do { + msleep(1); + if (rtl8366_smi_read_reg(smi, RTL8366_RESET_CTRL_REG, &data)) + return -EIO; + + if (!(data & RTL8366_CHIP_CTRL_RESET_HW)) + break; + } while (--timeout); + + if (!timeout) { + printk("Timeout waiting for the switch to reset\n"); + return -EIO; + } + + return rtl8366s_reset_vlan(smi); } static struct switch_attr rtl8366_globals[] = { @@ -1605,15 +1592,6 @@ static struct switch_attr rtl8366_globals[] = { .max = 1, .ofs = 2 }, - { - .type = SWITCH_TYPE_INT, - .name = "init_vlan", - .description = "Initialize VLAN tables to defaults", - .set = rtl8366_init_vlan, - .get = NULL, - .max = 1 - }, - { .type = SWITCH_TYPE_INT, .name = "reset_mibs", @@ -1669,22 +1647,6 @@ static struct switch_attr rtl8366_port[] = { }; static struct switch_attr rtl8366_vlan[] = { - { - .type = SWITCH_TYPE_INT, - .name = "untag", - .description = "Get/Set VLAN untag port set (bitmask)", - .set = rtl8366_set_untag, - .get = rtl8366_get_untag, - .max = 63, - }, - { - .type = SWITCH_TYPE_INT, - .name = "member", - .description = "Get/Set VLAN member port set (bitmask)", - .set = rtl8366_set_member, - .get = rtl8366_get_member, - .max = 63, - }, { .type = SWITCH_TYPE_STRING, .name = "info", @@ -1715,6 +1677,8 @@ static struct switch_dev rtldev = { .n_attr = ARRAY_SIZE(rtl8366_vlan), }, + .get_vlan_ports = rtl8366_get_ports, + .set_vlan_ports = rtl8366_set_ports, .get_port_pvid = rtl8366_get_port_pvid, .set_port_pvid = rtl8366_set_port_pvid, .reset_switch = rtl8366_reset_switch, From 5ab0ca0fd51fd8856f3359956e85178d4c94f5c2 Mon Sep 17 00:00:00 2001 From: nbd Date: Mon, 18 Jan 2010 00:12:15 +0000 Subject: [PATCH 059/210] ar71xx: fix portability errors in dd commands git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19207 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/ar71xx/image/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile index 96611bb47..d3baec69e 100644 --- a/target/linux/ar71xx/image/Makefile +++ b/target/linux/ar71xx/image/Makefile @@ -126,7 +126,7 @@ define Image/Build/WZRHPG300NH -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \ -d $(KDIR)/vmlinux-$(2).bin.lzma $(KDIR)/vmlinux-$(2).uImage; \ ( \ - dd if=$(KDIR)/vmlinux-$(2).uImage bs=1M conv=sync; \ + dd if=$(KDIR)/vmlinux-$(2).uImage bs=1024k conv=sync; \ dd if=$(KDIR)/root.$(1) bs=128k conv=sync; \ ) > $(call imgname,$(1),$(2))-sysupgrade.bin; \ fi; fi @@ -305,7 +305,7 @@ define Image/Build/WNDR3700 $(KDIR)/vmlinux-$(2).uImage.squashfs -rm -f $(KDIR)/vmlinux-$(2).uImage.squashfs.tmp* ( \ - dd if=$(KDIR)/vmlinux-$(2).uImage.squashfs bs=1M conv=sync; \ + dd if=$(KDIR)/vmlinux-$(2).uImage.squashfs bs=1024k conv=sync; \ dd if=$(KDIR)/root.$(1) bs=64k; \ ) > $(call imgname,$(1),$(2))-sysupgrade.bin $(STAGING_DIR_HOST)/bin/mkdniimg \ From 65c8d28d39e590c291f7f40360a9ff2f930925de Mon Sep 17 00:00:00 2001 From: nbd Date: Mon, 18 Jan 2010 00:38:04 +0000 Subject: [PATCH 060/210] swconfig: support providing the switch device name in an option instead of the section name - necessary to support switches that contain characters such as "-" git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19208 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/swconfig/Makefile | 2 +- package/swconfig/files/switch.sh | 6 ++++-- package/swconfig/src/uci.c | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/package/swconfig/Makefile b/package/swconfig/Makefile index a7bed7317..72af8c735 100644 --- a/package/swconfig/Makefile +++ b/package/swconfig/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=swconfig -PKG_RELEASE:=3 +PKG_RELEASE:=4 include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/kernel.mk diff --git a/package/swconfig/files/switch.sh b/package/swconfig/files/switch.sh index 7078b2e82..18d5fbd2c 100644 --- a/package/swconfig/files/switch.sh +++ b/package/swconfig/files/switch.sh @@ -2,8 +2,10 @@ # Copyright (C) 2009 OpenWrt.org setup_switch_dev() { - ifconfig "$1" 0.0.0.0 - swconfig dev "$1" load network + config_get name "$1" name + name="${name:-$1}" + [ -d "/sys/class/net/$name" ] && ifconfig "$name" up + swconfig dev "$name" load network } setup_switch() { diff --git a/package/swconfig/src/uci.c b/package/swconfig/src/uci.c index 2df837d27..e597acebf 100644 --- a/package/swconfig/src/uci.c +++ b/package/swconfig/src/uci.c @@ -107,6 +107,7 @@ int swlib_apply_from_uci(struct switch_dev *dev, struct uci_package *p) struct uci_element *e; struct uci_section *s; struct uci_option *o; + struct uci_ptr ptr; struct switch_val val; int i; @@ -114,11 +115,28 @@ int swlib_apply_from_uci(struct switch_dev *dev, struct uci_package *p) head = &settings; uci_foreach_element(&p->sections, e) { + struct uci_element *n; + s = uci_to_section(e); if (strcmp(s->type, "switch") != 0) continue; + uci_foreach_element(&s->options, n) { + struct uci_option *o = uci_to_option(n); + + if (strcmp(n->name, "name") != 0) + continue; + + if (o->type != UCI_TYPE_STRING) + continue; + + if (!strcmp(o->v.string, dev->dev_name)) + goto found; + + break; + } + if (strcmp(e->name, dev->dev_name) != 0) continue; From f7997f15e2ece1e55c599e04c0d3867638fb09da Mon Sep 17 00:00:00 2001 From: nbd Date: Mon, 18 Jan 2010 00:38:08 +0000 Subject: [PATCH 061/210] adjust switch default configs for the swconfig api change git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19209 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/ar71xx/base-files/etc/defconfig/wrt160nl/network | 3 ++- target/linux/atheros/base-files/etc/uci-defaults/network | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/target/linux/ar71xx/base-files/etc/defconfig/wrt160nl/network b/target/linux/ar71xx/base-files/etc/defconfig/wrt160nl/network index f670d149c..0d17a2025 100644 --- a/target/linux/ar71xx/base-files/etc/defconfig/wrt160nl/network +++ b/target/linux/ar71xx/base-files/etc/defconfig/wrt160nl/network @@ -15,7 +15,8 @@ config interface wan option ifname eth1 option proto dhcp -config switch eth0 +config switch + option name eth0 option reset 1 option enable_vlan 1 diff --git a/target/linux/atheros/base-files/etc/uci-defaults/network b/target/linux/atheros/base-files/etc/uci-defaults/network index 49c2a4005..89ea9a102 100644 --- a/target/linux/atheros/base-files/etc/uci-defaults/network +++ b/target/linux/atheros/base-files/etc/uci-defaults/network @@ -2,6 +2,7 @@ if [ -e "/sys/bus/mdio_bus/drivers/IC+ IP175C/0:00" -a -x /sbin/swconfig ]; then uci batch < Date: Mon, 18 Jan 2010 00:44:52 +0000 Subject: [PATCH 062/210] ar71xx: add some default configs for rtl8366 based devices git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19210 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../etc/defconfig/tl-wr1043nd/network | 26 +++++++++++++++++++ .../etc/defconfig/wzr-hp-g300nh/network | 26 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 target/linux/ar71xx/base-files/etc/defconfig/tl-wr1043nd/network create mode 100644 target/linux/ar71xx/base-files/etc/defconfig/wzr-hp-g300nh/network diff --git a/target/linux/ar71xx/base-files/etc/defconfig/tl-wr1043nd/network b/target/linux/ar71xx/base-files/etc/defconfig/tl-wr1043nd/network new file mode 100644 index 000000000..7916286ec --- /dev/null +++ b/target/linux/ar71xx/base-files/etc/defconfig/tl-wr1043nd/network @@ -0,0 +1,26 @@ +config interface loopback + option ifname lo + option proto static + option ipaddr 127.0.0.1 + option netmask 255.0.0.0 + +config interface lan + option ifname eth0 + option type bridge + option proto static + option ipaddr 192.168.1.1 + option netmask 255.255.255.0 + +config interface wan + option ifname eth1 + option proto dhcp + +config switch + option name rtl8366-smi + option reset 1 + option enable_vlan 1 + +config switch_vlan + option device rtl8366-smi + option vlan 0 + option ports "0 1 2 3 5" diff --git a/target/linux/ar71xx/base-files/etc/defconfig/wzr-hp-g300nh/network b/target/linux/ar71xx/base-files/etc/defconfig/wzr-hp-g300nh/network new file mode 100644 index 000000000..7916286ec --- /dev/null +++ b/target/linux/ar71xx/base-files/etc/defconfig/wzr-hp-g300nh/network @@ -0,0 +1,26 @@ +config interface loopback + option ifname lo + option proto static + option ipaddr 127.0.0.1 + option netmask 255.0.0.0 + +config interface lan + option ifname eth0 + option type bridge + option proto static + option ipaddr 192.168.1.1 + option netmask 255.255.255.0 + +config interface wan + option ifname eth1 + option proto dhcp + +config switch + option name rtl8366-smi + option reset 1 + option enable_vlan 1 + +config switch_vlan + option device rtl8366-smi + option vlan 0 + option ports "0 1 2 3 5" From 5b24113601290c643f711d85c746ddd33c91f71a Mon Sep 17 00:00:00 2001 From: jow Date: Mon, 18 Jan 2010 05:38:44 +0000 Subject: [PATCH 063/210] [package] base-files: disable bridge firewalling by default git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19214 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/Makefile | 4 ++-- package/base-files/files/etc/sysctl.conf | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/package/base-files/Makefile b/package/base-files/Makefile index ea2b5a47f..fb30b94ab 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2007-2009 OpenWrt.org +# Copyright (C) 2007-2010 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=base-files -PKG_RELEASE:=35 +PKG_RELEASE:=36 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ diff --git a/package/base-files/files/etc/sysctl.conf b/package/base-files/files/etc/sysctl.conf index 63497beb1..759752ae5 100644 --- a/package/base-files/files/etc/sysctl.conf +++ b/package/base-files/files/etc/sysctl.conf @@ -4,7 +4,7 @@ net.ipv4.conf.all.arp_ignore=1 net.ipv4.ip_forward=1 net.ipv4.icmp_echo_ignore_broadcasts=1 net.ipv4.icmp_ignore_bogus_error_responses=1 -net.ipv4.tcp_ecn=0 +net.ipv4.tcp_ecn=0 net.ipv4.tcp_fin_timeout=30 net.ipv4.tcp_keepalive_time=120 net.ipv4.tcp_syncookies=1 @@ -17,3 +17,8 @@ net.ipv4.netfilter.ip_conntrack_tcp_timeout_established=3600 net.ipv4.netfilter.ip_conntrack_udp_timeout=60 net.ipv4.netfilter.ip_conntrack_udp_timeout_stream=180 # net.ipv6.conf.all.forwarding=1 + +# disable bridge firewalling by default +net.bridge.bridge-nf-call-arptables=0 +net.bridge.bridge-nf-call-ip6tables=0 +net.bridge.bridge-nf-call-iptables=0 From a3545860d0214ecaa3e04d922fee98bc62714596 Mon Sep 17 00:00:00 2001 From: juhosg Date: Mon, 18 Jan 2010 09:01:40 +0000 Subject: [PATCH 064/210] rtl8366_smi: use inline function instead of a macro on top of container_of git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19215 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../files/drivers/net/phy/rtl8366_smi.c | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c index 588f33603..b9158d6e3 100644 --- a/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c +++ b/target/linux/ar71xx/files/drivers/net/phy/rtl8366_smi.c @@ -219,7 +219,10 @@ struct rtl8366_smi { u16 g_dbg_reg; #endif -#define to_rtl8366(_dev) container_of(_dev, struct rtl8366_smi, dev) +static inline struct rtl8366_smi *sw_to_rtl8366(struct switch_dev *sw) +{ + return container_of(sw, struct rtl8366_smi, dev); +} static inline void rtl8366_smi_clk_delay(struct rtl8366_smi *smi) { @@ -1197,7 +1200,7 @@ static int rtl8366_global_reset_mibs(struct switch_dev *dev, struct switch_val *val) { u32 data = 0; - struct rtl8366_smi *smi = to_rtl8366(dev); + struct rtl8366_smi *smi = sw_to_rtl8366(dev); if (val->value.i == 1) { rtl8366_smi_read_reg(smi, RTL8366S_MIB_CTRL_REG, &data); @@ -1213,7 +1216,7 @@ static int rtl8366_get_vlan(struct switch_dev *dev, struct switch_val *val) { u32 data; - struct rtl8366_smi *smi = to_rtl8366(dev); + struct rtl8366_smi *smi = sw_to_rtl8366(dev); if (attr->ofs == 1) { rtl8366_smi_read_reg(smi, RTL8366_CHIP_GLOBAL_CTRL_REG, &data); @@ -1239,7 +1242,7 @@ static int rtl8366_global_get_blinkrate(struct switch_dev *dev, struct switch_val *val) { u32 data; - struct rtl8366_smi *smi = to_rtl8366(dev); + struct rtl8366_smi *smi = sw_to_rtl8366(dev); rtl8366_smi_read_reg(smi, RTL8366_LED_BLINKRATE_REG, &data); val->value.i = (data & (RTL8366_LED_BLINKRATE_MASK)); @@ -1252,7 +1255,7 @@ static int rtl8366_global_set_blinkrate(struct switch_dev *dev, struct switch_val *val) { u32 data; - struct rtl8366_smi *smi = to_rtl8366(dev); + struct rtl8366_smi *smi = sw_to_rtl8366(dev); if (val->value.i >= 6) return -EINVAL; @@ -1271,7 +1274,7 @@ static int rtl8366_set_vlan(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val) { - struct rtl8366_smi *smi = to_rtl8366(dev); + struct rtl8366_smi *smi = sw_to_rtl8366(dev); if (attr->ofs == 1) return rtl8366_vlan_set_vlan(smi, val->value.i); @@ -1285,7 +1288,7 @@ static int rtl8366_attr_get_port_link(struct switch_dev *dev, { u32 len = 0, data = 0; int speed, duplex, link, txpause, rxpause, nway; - struct rtl8366_smi *smi = to_rtl8366(dev); + struct rtl8366_smi *smi = sw_to_rtl8366(dev); char *buf = smi->buf; if (val->port_vlan >= RTL8366_NUM_PORTS) @@ -1349,7 +1352,7 @@ static int rtl8366_attr_get_vlan_info(struct switch_dev *dev, u32 len = 0; struct rtl8366s_vlanconfig vlanmc; struct rtl8366s_vlan4kentry vlan4k; - struct rtl8366_smi *smi = to_rtl8366(dev); + struct rtl8366_smi *smi = sw_to_rtl8366(dev); char *buf = smi->buf; if (val->port_vlan >= RTL8366_NUM_PORTS) @@ -1394,7 +1397,7 @@ static int rtl8366_set_port_led(struct switch_dev *dev, struct switch_val *val) { u32 data = 0; - struct rtl8366_smi *smi = to_rtl8366(dev); + struct rtl8366_smi *smi = sw_to_rtl8366(dev); if (val->port_vlan >= RTL8366_NUM_PORTS || (1 << val->port_vlan) == RTL8366_PORT_UNKNOWN) return -EINVAL; @@ -1418,7 +1421,7 @@ static int rtl8366_get_port_led(struct switch_dev *dev, struct switch_val *val) { u32 data = 0; - struct rtl8366_smi *smi = to_rtl8366(dev); + struct rtl8366_smi *smi = sw_to_rtl8366(dev); if (val->port_vlan >= RTL8366_NUM_LEDGROUPS) return -EINVAL; @@ -1433,7 +1436,7 @@ static int rtl8366_reset_port_mibs(struct switch_dev *dev, struct switch_val *val) { u32 data = 0; - struct rtl8366_smi *smi = to_rtl8366(dev); + struct rtl8366_smi *smi = sw_to_rtl8366(dev); if (val->port_vlan >= RTL8366_NUM_PORTS) return -EINVAL; @@ -1450,7 +1453,7 @@ static int rtl8366_get_port_mib(struct switch_dev *dev, { int i, len = 0; unsigned long long counter = 0; - struct rtl8366_smi *smi = to_rtl8366(dev); + struct rtl8366_smi *smi = sw_to_rtl8366(dev); char *buf = smi->buf; if (val->port_vlan >= RTL8366_NUM_PORTS) @@ -1479,7 +1482,7 @@ static int rtl8366_get_ports(struct switch_dev *dev, struct switch_val *val) { struct rtl8366s_vlanconfig vlanmc; - struct rtl8366_smi *smi = to_rtl8366(dev); + struct rtl8366_smi *smi = sw_to_rtl8366(dev); struct switch_port *port; int i; @@ -1507,7 +1510,7 @@ static int rtl8366_set_ports(struct switch_dev *dev, { struct rtl8366s_vlanconfig vlanmc; struct rtl8366s_vlan4kentry vlan4k; - struct rtl8366_smi *smi = to_rtl8366(dev); + struct rtl8366_smi *smi = sw_to_rtl8366(dev); struct switch_port *port; int i; @@ -1538,19 +1541,19 @@ static int rtl8366_set_ports(struct switch_dev *dev, static int rtl8366_get_port_pvid(struct switch_dev *dev, int port, int *val) { - struct rtl8366_smi *smi = to_rtl8366(dev); + struct rtl8366_smi *smi = sw_to_rtl8366(dev); return rtl8366_get_vlan_port_pvid(smi, port, val); } static int rtl8366_set_port_pvid(struct switch_dev *dev, int port, int val) { - struct rtl8366_smi *smi = to_rtl8366(dev); + struct rtl8366_smi *smi = sw_to_rtl8366(dev); return rtl8366_set_vlan_port_pvid(smi, port, val); } static int rtl8366_reset_switch(struct switch_dev *dev) { - struct rtl8366_smi *smi = to_rtl8366(dev); + struct rtl8366_smi *smi = sw_to_rtl8366(dev); int timeout = 10; u32 data; From bec3a93334039149ec639191c03a82458e350689 Mon Sep 17 00:00:00 2001 From: juhosg Date: Mon, 18 Jan 2010 09:01:44 +0000 Subject: [PATCH 065/210] ar71xx: fix ethernet mac address on the WZR-HP-G300NH git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19216 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c index 5ffb816bf..eb1f814d6 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c @@ -50,6 +50,8 @@ #define WZRHPG300NH_BUTTONS_POLL_INTERVAL 20 +#define WZRHPG300NH_MAC_OFFSET 0x20c + #ifdef CONFIG_MTD_PARTITIONS static struct mtd_partition wzrhpg300nh_flash_partitions[] = { { @@ -227,7 +229,7 @@ static void __init wzrhpg300nh_setup(void) { u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000); - ar71xx_set_mac_base(eeprom); + ar71xx_set_mac_base(eeprom + WZRHPG300NH_MAC_OFFSET); ar71xx_eth0_pll_data.pll_1000 = 0x1e000100; ar71xx_eth0_data.mii_bus_dev = &wzrhpg300nh_rtl8366_smi_device.dev; From 8ce4375c1a088f26f6a42f7eb44963b91f63f132 Mon Sep 17 00:00:00 2001 From: juhosg Date: Mon, 18 Jan 2010 09:01:47 +0000 Subject: [PATCH 066/210] ar71xx: update default network configuration for the WNDR3700/DIR-825-B1 Also drop the default network configuration of the TL-WR1043ND, because the RTL8366RB switch is not yet supported by the rtl8366-smi driver. git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19217 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../etc/defconfig/dir-825-b1/network | 10 +++++++ .../etc/defconfig/tl-wr1043nd/network | 26 ------------------- .../base-files/etc/defconfig/wndr3700/network | 10 +++++++ 3 files changed, 20 insertions(+), 26 deletions(-) delete mode 100644 target/linux/ar71xx/base-files/etc/defconfig/tl-wr1043nd/network diff --git a/target/linux/ar71xx/base-files/etc/defconfig/dir-825-b1/network b/target/linux/ar71xx/base-files/etc/defconfig/dir-825-b1/network index 2d4d8e012..7916286ec 100644 --- a/target/linux/ar71xx/base-files/etc/defconfig/dir-825-b1/network +++ b/target/linux/ar71xx/base-files/etc/defconfig/dir-825-b1/network @@ -14,3 +14,13 @@ config interface lan config interface wan option ifname eth1 option proto dhcp + +config switch + option name rtl8366-smi + option reset 1 + option enable_vlan 1 + +config switch_vlan + option device rtl8366-smi + option vlan 0 + option ports "0 1 2 3 5" diff --git a/target/linux/ar71xx/base-files/etc/defconfig/tl-wr1043nd/network b/target/linux/ar71xx/base-files/etc/defconfig/tl-wr1043nd/network deleted file mode 100644 index 7916286ec..000000000 --- a/target/linux/ar71xx/base-files/etc/defconfig/tl-wr1043nd/network +++ /dev/null @@ -1,26 +0,0 @@ -config interface loopback - option ifname lo - option proto static - option ipaddr 127.0.0.1 - option netmask 255.0.0.0 - -config interface lan - option ifname eth0 - option type bridge - option proto static - option ipaddr 192.168.1.1 - option netmask 255.255.255.0 - -config interface wan - option ifname eth1 - option proto dhcp - -config switch - option name rtl8366-smi - option reset 1 - option enable_vlan 1 - -config switch_vlan - option device rtl8366-smi - option vlan 0 - option ports "0 1 2 3 5" diff --git a/target/linux/ar71xx/base-files/etc/defconfig/wndr3700/network b/target/linux/ar71xx/base-files/etc/defconfig/wndr3700/network index 2d4d8e012..7916286ec 100644 --- a/target/linux/ar71xx/base-files/etc/defconfig/wndr3700/network +++ b/target/linux/ar71xx/base-files/etc/defconfig/wndr3700/network @@ -14,3 +14,13 @@ config interface lan config interface wan option ifname eth1 option proto dhcp + +config switch + option name rtl8366-smi + option reset 1 + option enable_vlan 1 + +config switch_vlan + option device rtl8366-smi + option vlan 0 + option ports "0 1 2 3 5" From 284a8ff5eb78f5f53e759dd9826a1fe1c6252c9d Mon Sep 17 00:00:00 2001 From: juhosg Date: Mon, 18 Jan 2010 09:01:49 +0000 Subject: [PATCH 067/210] ar71xx: add swconfig to the default packages git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19218 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/ar71xx/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/ar71xx/Makefile b/target/linux/ar71xx/Makefile index b16b42863..b5184b64d 100644 --- a/target/linux/ar71xx/Makefile +++ b/target/linux/ar71xx/Makefile @@ -18,7 +18,7 @@ include $(INCLUDE_DIR)/target.mk DEFAULT_PACKAGES += \ kmod-leds-gpio kmod-input-core kmod-input-polldev \ - kmod-input-gpio-buttons kmod-button-hotplug + kmod-input-gpio-buttons kmod-button-hotplug swconfig define Target/Description Build firmware images for Atheros AR71xx/AR913x based boards. From 69e7cdaa1431b87e93d883232483544e1a4f75c5 Mon Sep 17 00:00:00 2001 From: juhosg Date: Mon, 18 Jan 2010 09:01:52 +0000 Subject: [PATCH 068/210] ar71xx: update package list for the DIR-825 rev. B1 git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19219 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/ar71xx/profiles/d-link.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/ar71xx/profiles/d-link.mk b/target/linux/ar71xx/profiles/d-link.mk index d28a74ca9..bb861d80e 100644 --- a/target/linux/ar71xx/profiles/d-link.mk +++ b/target/linux/ar71xx/profiles/d-link.mk @@ -31,7 +31,7 @@ $(eval $(call Profile,DIR615C1)) define Profile/DIR825B1 NAME:=D-Link DIR-825 rev. B1 - PACKAGES:=kmod-ath9k hostapd-mini + PACKAGES:=kmod-ath9k hostapd-mini kmod-usb-core kmod-usb-ohci kmod-usb2 endef define Profile/DIR825B1/Description From b61a8be55cbad8dc6dfe36d08b1f5c23b3662854 Mon Sep 17 00:00:00 2001 From: juhosg Date: Mon, 18 Jan 2010 09:08:54 +0000 Subject: [PATCH 069/210] ar71xx: the AR913x has no OHCI controller, remove that package from the relevant profiles git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19220 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/ar71xx/profiles/buffalo.mk | 2 +- target/linux/ar71xx/profiles/d-link.mk | 2 +- target/linux/ar71xx/profiles/linksys.mk | 2 +- target/linux/ar71xx/profiles/netgear.mk | 2 +- target/linux/ar71xx/profiles/planex.mk | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/target/linux/ar71xx/profiles/buffalo.mk b/target/linux/ar71xx/profiles/buffalo.mk index 429ecbaaa..939977bb6 100644 --- a/target/linux/ar71xx/profiles/buffalo.mk +++ b/target/linux/ar71xx/profiles/buffalo.mk @@ -7,7 +7,7 @@ define Profile/WZRHPG300NH NAME:=Buffalo WZR-HP-G300NH - PACKAGES:=kmod-ath9k hostapd-mini kmod-usb-core kmod-usb-ohci kmod-usb2 + PACKAGES:=kmod-ath9k hostapd-mini kmod-usb-core kmod-usb2 endef define Profile/WZRHPG300NH/Description diff --git a/target/linux/ar71xx/profiles/d-link.mk b/target/linux/ar71xx/profiles/d-link.mk index bb861d80e..82e108bc7 100644 --- a/target/linux/ar71xx/profiles/d-link.mk +++ b/target/linux/ar71xx/profiles/d-link.mk @@ -31,7 +31,7 @@ $(eval $(call Profile,DIR615C1)) define Profile/DIR825B1 NAME:=D-Link DIR-825 rev. B1 - PACKAGES:=kmod-ath9k hostapd-mini kmod-usb-core kmod-usb-ohci kmod-usb2 + PACKAGES:=kmod-ath9k hostapd-mini kmod-usb-core kmod-usb2 endef define Profile/DIR825B1/Description diff --git a/target/linux/ar71xx/profiles/linksys.mk b/target/linux/ar71xx/profiles/linksys.mk index ca2b6cc2c..a2d4bbd51 100644 --- a/target/linux/ar71xx/profiles/linksys.mk +++ b/target/linux/ar71xx/profiles/linksys.mk @@ -7,7 +7,7 @@ define Profile/WRT160NL NAME:=Linksys WRT160NL - PACKAGES:=kmod-ath9k hostapd-mini kmod-usb-core kmod-usb-ohci kmod-usb2 swconfig + PACKAGES:=kmod-ath9k hostapd-mini kmod-usb-core kmod-usb2 swconfig endef define Profile/WRT160NL/Description diff --git a/target/linux/ar71xx/profiles/netgear.mk b/target/linux/ar71xx/profiles/netgear.mk index 89deaaa84..896ab0605 100644 --- a/target/linux/ar71xx/profiles/netgear.mk +++ b/target/linux/ar71xx/profiles/netgear.mk @@ -7,7 +7,7 @@ define Profile/WNDR3700 NAME:=NETGEAR WNDR3700 - PACKAGES:=kmod-ath9k hostapd-mini kmod-usb-core kmod-usb-ohci kmod-usb2 + PACKAGES:=kmod-ath9k hostapd-mini kmod-usb-core kmod-usb2 endef define Profile/WNDR3700/Description diff --git a/target/linux/ar71xx/profiles/planex.mk b/target/linux/ar71xx/profiles/planex.mk index 35d88e512..40f45b50e 100644 --- a/target/linux/ar71xx/profiles/planex.mk +++ b/target/linux/ar71xx/profiles/planex.mk @@ -7,7 +7,7 @@ define Profile/MZKW04NU NAME:=Planex MZK-W04NU - PACKAGES:=kmod-ath9k hostapd-mini kmod-usb-core kmod-usb-ohci kmod-usb2 + PACKAGES:=kmod-ath9k hostapd-mini kmod-usb-core kmod-usb2 endef define Profile/MZKW04NU/Description From 8d8efd341271239bd80b438a15774ffbfbcf1a91 Mon Sep 17 00:00:00 2001 From: juhosg Date: Mon, 18 Jan 2010 09:15:35 +0000 Subject: [PATCH 070/210] ar71xx: change failsafe message git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19221 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/ar71xx/base-files/etc/preinit.arch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/ar71xx/base-files/etc/preinit.arch b/target/linux/ar71xx/base-files/etc/preinit.arch index 637aa5fc5..f770ca371 100644 --- a/target/linux/ar71xx/base-files/etc/preinit.arch +++ b/target/linux/ar71xx/base-files/etc/preinit.arch @@ -49,7 +49,7 @@ ifname=eth0 failsafe_ip -netmsg 192.168.1.255 "Press reset now, to enter Failsafe!" +netmsg 192.168.1.255 "Press any button now, to enter Failsafe!" ifconfig "$ifname" 0.0.0.0 down From ba5966123758fdcb73b227c334de42c4a9a5e418 Mon Sep 17 00:00:00 2001 From: nbd Date: Mon, 18 Jan 2010 14:18:08 +0000 Subject: [PATCH 071/210] mac80211: fix firmware compat stuff for 2.6.32 git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19222 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../patches/100-compat_firmware.patch | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 package/mac80211/patches/100-compat_firmware.patch diff --git a/package/mac80211/patches/100-compat_firmware.patch b/package/mac80211/patches/100-compat_firmware.patch new file mode 100644 index 000000000..18ab55f71 --- /dev/null +++ b/package/mac80211/patches/100-compat_firmware.patch @@ -0,0 +1,103 @@ +--- a/include/linux/compat-2.6.32.h ++++ b/include/linux/compat-2.6.32.h +@@ -9,40 +9,6 @@ + #include + #include + #include +-#include +- +-#define release_firmware compat_release_firmware +-#define request_firmware compat_request_firmware +-#define request_firmware_nowait compat_request_firmware_nowait +- +-#if defined(CONFIG_FW_LOADER) || (defined(CONFIG_FW_LOADER_MODULE) && defined(MODULE)) +-int compat_request_firmware(const struct firmware **fw, const char *name, +- struct device *device); +-int compat_request_firmware_nowait( +- struct module *module, int uevent, +- const char *name, struct device *device, gfp_t gfp, void *context, +- void (*cont)(const struct firmware *fw, void *context)); +- +-void compat_release_firmware(const struct firmware *fw); +-#else +-static inline int compat_request_firmware(const struct firmware **fw, +- const char *name, +- struct device *device) +-{ +- return -EINVAL; +-} +-static inline int request_firmware_nowait( +- struct module *module, int uevent, +- const char *name, struct device *device, gfp_t gfp, void *context, +- void (*cont)(const struct firmware *fw, void *context)) +-{ +- return -EINVAL; +-} +- +-static inline void compat_release_firmware(const struct firmware *fw) +-{ +-} +-#endif + + #define SDIO_VENDOR_ID_INTEL 0x0089 + #define SDIO_DEVICE_ID_INTEL_IWMC3200WIMAX 0x1402 +--- a/include/linux/compat-2.6.33.h ++++ b/include/linux/compat-2.6.33.h +@@ -10,6 +10,40 @@ + #include + #include + #include ++#include ++ ++#define release_firmware compat_release_firmware ++#define request_firmware compat_request_firmware ++#define request_firmware_nowait compat_request_firmware_nowait ++ ++#if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE) ++int compat_request_firmware(const struct firmware **fw, const char *name, ++ struct device *device); ++int compat_request_firmware_nowait( ++ struct module *module, int uevent, ++ const char *name, struct device *device, gfp_t gfp, void *context, ++ void (*cont)(const struct firmware *fw, void *context)); ++ ++void compat_release_firmware(const struct firmware *fw); ++#else ++static inline int compat_request_firmware(const struct firmware **fw, ++ const char *name, ++ struct device *device) ++{ ++ return -EINVAL; ++} ++static inline int request_firmware_nowait( ++ struct module *module, int uevent, ++ const char *name, struct device *device, gfp_t gfp, void *context, ++ void (*cont)(const struct firmware *fw, void *context)) ++{ ++ return -EINVAL; ++} ++ ++static inline void compat_release_firmware(const struct firmware *fw) ++{ ++} ++#endif + + #define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */ + /* source: include/linux/if.h */ +--- a/compat/compat_firmware_class.c ++++ b/compat/compat_firmware_class.c +@@ -20,6 +20,8 @@ + #include + #include + ++#if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE) ++ + #define to_dev(obj) container_of(obj, struct device, kobj) + + MODULE_AUTHOR("Manuel Estrada Sainz"); +@@ -724,3 +726,5 @@ module_exit(firmware_class_exit); + EXPORT_SYMBOL(release_firmware); + EXPORT_SYMBOL(request_firmware); + EXPORT_SYMBOL(request_firmware_nowait); ++ ++#endif From fce30da13a4ccf6d1e9fc80d3d89838eeee7d9d3 Mon Sep 17 00:00:00 2001 From: juhosg Date: Mon, 18 Jan 2010 16:46:57 +0000 Subject: [PATCH 072/210] ar71xx: create rescue image for the WZR-HP-G300NH git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19223 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/ar71xx/image/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile index d3baec69e..09d743c47 100644 --- a/target/linux/ar71xx/image/Makefile +++ b/target/linux/ar71xx/image/Makefile @@ -129,6 +129,10 @@ define Image/Build/WZRHPG300NH dd if=$(KDIR)/vmlinux-$(2).uImage bs=1024k conv=sync; \ dd if=$(KDIR)/root.$(1) bs=128k conv=sync; \ ) > $(call imgname,$(1),$(2))-sysupgrade.bin; \ + ( \ + echo -n -e "# Airstation Public Fmt1\x00\x00\x00\x00\x00\x00\x00\x00"; \ + dd if=$(call imgname,$(1),$(2))-sysupgrade.bin; \ + ) > $(call imgname,$(1),$(2))-tftp.bin; \ fi; fi endef From f96dbb73b28b364f49bbd135f377ea4be859cafc Mon Sep 17 00:00:00 2001 From: kaloz Date: Tue, 19 Jan 2010 11:53:56 +0000 Subject: [PATCH 073/210] update to latest kernel versions git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19224 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- include/kernel-version.mk | 8 ++++---- target/linux/mpc83xx/Makefile | 2 +- target/linux/omap35xx/Makefile | 6 +++--- target/linux/x86/Makefile | 4 ++-- target/linux/xburst/Makefile | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/kernel-version.mk b/include/kernel-version.mk index 4ab4bbe68..a082a87b6 100644 --- a/include/kernel-version.mk +++ b/include/kernel-version.mk @@ -19,11 +19,11 @@ endif ifeq ($(LINUX_VERSION),2.6.30.10) LINUX_KERNEL_MD5SUM:=eb6be465f914275967a5602cb33662f5 endif -ifeq ($(LINUX_VERSION),2.6.31.11) - LINUX_KERNEL_MD5SUM:=39e34c9a6439bcd4c088abe631302a99 +ifeq ($(LINUX_VERSION),2.6.31.12) + LINUX_KERNEL_MD5SUM:=517be354b81b780e2f4b2ad614d030de endif -ifeq ($(LINUX_VERSION),2.6.32.3) - LINUX_KERNEL_MD5SUM:=730045c2c7f7e6618db3c4d4d7094853 +ifeq ($(LINUX_VERSION),2.6.32.4) + LINUX_KERNEL_MD5SUM:=471e0fe07e27796f041ecb990302ccc4 endif # disable the md5sum check for unknown kernel versions diff --git a/target/linux/mpc83xx/Makefile b/target/linux/mpc83xx/Makefile index 1bbfa768d..5598b5b11 100644 --- a/target/linux/mpc83xx/Makefile +++ b/target/linux/mpc83xx/Makefile @@ -11,7 +11,7 @@ BOARD:=mpc83xx BOARDNAME:=Freescale MPC83xx FEATURES:=squashfs tgz broken -LINUX_VERSION:=2.6.31.11 +LINUX_VERSION:=2.6.31.12 include $(INCLUDE_DIR)/target.mk diff --git a/target/linux/omap35xx/Makefile b/target/linux/omap35xx/Makefile index 2ccfc1ac2..f12a6f570 100644 --- a/target/linux/omap35xx/Makefile +++ b/target/linux/omap35xx/Makefile @@ -1,5 +1,5 @@ -# -# Copyright (C) 2006-2009 OpenWrt.org +# +# Copyright (C) 2006-2010 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -12,7 +12,7 @@ BOARDNAME:=TI OMAP35xx FEATURES:=broken SUBTARGETS=generic -LINUX_VERSION:=2.6.32.3 +LINUX_VERSION:=2.6.32.4 KERNELNAME:="uImage" DEVICE_TYPE=developerboard diff --git a/target/linux/x86/Makefile b/target/linux/x86/Makefile index 9f526c6c3..7389530a7 100644 --- a/target/linux/x86/Makefile +++ b/target/linux/x86/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2008 OpenWrt.org +# Copyright (C) 2006-2010 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -12,7 +12,7 @@ BOARDNAME:=x86 FEATURES:=squashfs jffs2 ext2 vdi vmdk pcmcia tgz SUBTARGETS=generic olpc -LINUX_VERSION:=2.6.31.11 +LINUX_VERSION:=2.6.31.12 include $(INCLUDE_DIR)/target.mk diff --git a/target/linux/xburst/Makefile b/target/linux/xburst/Makefile index 61b42af88..571cc296e 100644 --- a/target/linux/xburst/Makefile +++ b/target/linux/xburst/Makefile @@ -11,7 +11,7 @@ BOARD:=xburst BOARDNAME:=XBurst JZ47x0 FEATURES:=jffs2 tgz ubifs -LINUX_VERSION:=2.6.32.3 +LINUX_VERSION:=2.6.32.4 DEVICE_TYPE=other From a73dfff0e74907833a83b3d20015ae5df07eae86 Mon Sep 17 00:00:00 2001 From: kaloz Date: Tue, 19 Jan 2010 12:53:34 +0000 Subject: [PATCH 074/210] refresh patch git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19225 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/generic-2.6/patches-2.6.31/980-vm_exports.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/generic-2.6/patches-2.6.31/980-vm_exports.patch b/target/linux/generic-2.6/patches-2.6.31/980-vm_exports.patch index 1b8f3a930..3f1848b9e 100644 --- a/target/linux/generic-2.6/patches-2.6.31/980-vm_exports.patch +++ b/target/linux/generic-2.6/patches-2.6.31/980-vm_exports.patch @@ -125,7 +125,7 @@ #ifndef CONFIG_MMU --- a/kernel/signal.c +++ b/kernel/signal.c -@@ -1061,6 +1061,7 @@ struct sighand_struct *lock_task_sighand +@@ -1062,6 +1062,7 @@ struct sighand_struct *lock_task_sighand return sighand; } From abf14b93446bdb20d2db4a8a06c9552678d101be Mon Sep 17 00:00:00 2001 From: nico Date: Tue, 19 Jan 2010 13:23:59 +0000 Subject: [PATCH 075/210] [toolchain] binutils: remove unrelated hunk in 2.18 avr32 support patch git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19226 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- toolchain/binutils/patches/2.18/500-avr32.patch | 9 --------- 1 file changed, 9 deletions(-) diff --git a/toolchain/binutils/patches/2.18/500-avr32.patch b/toolchain/binutils/patches/2.18/500-avr32.patch index 27b7044df..40239aaf6 100644 --- a/toolchain/binutils/patches/2.18/500-avr32.patch +++ b/toolchain/binutils/patches/2.18/500-avr32.patch @@ -18103,15 +18103,6 @@ extern int print_insn_bfin (bfd_vma, disassemble_info *); extern int print_insn_big_arm (bfd_vma, disassemble_info *); extern int print_insn_big_mips (bfd_vma, disassemble_info *); -@@ -242,7 +243,7 @@ extern int print_insn_little_arm (bfd_vm - extern int print_insn_little_mips (bfd_vma, disassemble_info *); - extern int print_insn_little_or32 (bfd_vma, disassemble_info *); - extern int print_insn_little_powerpc (bfd_vma, disassemble_info *); --extern int print_insn_little_score (bfd_vma, disassemble_info *); -+extern int print_insn_little_score (bfd_vma, disassemble_info *); - extern int print_insn_m32c (bfd_vma, disassemble_info *); - extern int print_insn_m32r (bfd_vma, disassemble_info *); - extern int print_insn_m68hc11 (bfd_vma, disassemble_info *); @@ -290,7 +291,9 @@ extern void print_i386_disassembler_opti extern void print_mips_disassembler_options (FILE *); extern void print_ppc_disassembler_options (FILE *); From d5131ab847f3a8093cbcc2267a4a2a7da0e86e51 Mon Sep 17 00:00:00 2001 From: nico Date: Tue, 19 Jan 2010 13:26:03 +0000 Subject: [PATCH 076/210] [toolchain] gcc: use coherent version selector between binutils & gcc git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19227 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- toolchain/gcc/Config.in | 2 +- toolchain/gcc/Config.version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/toolchain/gcc/Config.in b/toolchain/gcc/Config.in index ccaccaf00..9562a02c9 100644 --- a/toolchain/gcc/Config.in +++ b/toolchain/gcc/Config.in @@ -3,7 +3,7 @@ choice prompt "GCC compiler Version" if TOOLCHAINOPTS default GCC_VERSION_3_4_6 if LINUX_2_4 - default GCC_VERSION_4_2_4 if TARGET_avr32 + default GCC_VERSION_4_2_4 if avr32 default GCC_VERSION_4_2_4 if TARGET_ppc40x default GCC_VERSION_4_2_4 if TARGET_ppc44x default GCC_VERSION_4_3_3 if powerpc64 diff --git a/toolchain/gcc/Config.version b/toolchain/gcc/Config.version index f4e701784..660b10de0 100644 --- a/toolchain/gcc/Config.version +++ b/toolchain/gcc/Config.version @@ -56,7 +56,7 @@ if !TOOLCHAINOPTS if !LINUX_2_4 config GCC_VERSION_4_2_4 - default y if TARGET_avr32 + default y if avr32 default y if TARGET_ppc40x default y if TARGET_ppc44x From 3ed308ebba9166e3238b4a96c68d89a662342800 Mon Sep 17 00:00:00 2001 From: nbd Date: Tue, 19 Jan 2010 18:23:06 +0000 Subject: [PATCH 077/210] hostapd: remove all object files on config changes git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19229 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/hostapd/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package/hostapd/Makefile b/package/hostapd/Makefile index 6b4679616..342c7519d 100644 --- a/package/hostapd/Makefile +++ b/package/hostapd/Makefile @@ -83,9 +83,8 @@ endef ifneq ($(wildcard $(PKG_BUILD_DIR)/.config_*),$(subst .configured_,.config_,$(STAMP_CONFIGURED))) $(warning $(wildcard $(PKG_BUILD_DIR)/.config_*) != $(subst .configured_,.config_,$(STAMP_CONFIGURED))) define Build/Configure/rebuild + $(FIND) $(PKG_BUILD_DIR) -name \*.o | $(XARGS) rm -f rm -f $(PKG_BUILD_DIR)/hostapd/hostapd - rm -f $(PKG_BUILD_DIR)/hostapd/*.o - rm -f $(PKG_BUILD_DIR)/src/drivers/drivers.o rm -f $(PKG_BUILD_DIR)/.config_* touch $(subst .configured_,.config_,$(STAMP_CONFIGURED)) endef From a9dfded77b0a68162a6c5a007521ca8c101e53ee Mon Sep 17 00:00:00 2001 From: juhosg Date: Tue, 19 Jan 2010 18:27:57 +0000 Subject: [PATCH 078/210] ar71xx: fix image generation for TL-WR741ND/TL-WR841ND-v5 git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19230 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/ar71xx/image/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile index 09d743c47..61f390d05 100644 --- a/target/linux/ar71xx/image/Makefile +++ b/target/linux/ar71xx/image/Makefile @@ -334,6 +334,10 @@ define Image/Build/Template/squashfs-only/squashfs $(call Image/Build/$(1),squashfs,$(2),$(3),$(4),$(5),$(6),$(7)) endef +define Image/Build/Template/4k/squashfs + $(call Image/Build/$(1),squashfs-4k,$(2),$(3),$(4),$(5),$(6),$(7)) +endef + define Image/Build/Template/64k/squashfs $(call Image/Build/$(1),squashfs,$(2),$(3),$(4),$(5),$(6),$(7)) endef @@ -432,7 +436,7 @@ define Image/Build/Profile/MZKW300NH endef define Image/Build/Profile/TLWR741NDV1 - $(call Image/Build/Template/squashfs-only/$(1),TPLINK4K,tl-wr741nd-v1,board=TL-WR741ND,TL-WR741NDv1) + $(call Image/Build/Template/4k/$(1),TPLINK,tl-wr741nd-v1,board=TL-WR741ND,TL-WR741NDv1) endef define Image/Build/Profile/TLWR841NV15 @@ -444,7 +448,7 @@ define Image/Build/Profile/TLWR841NDV3 endef define Image/Build/Profile/TLWR841NDV5 - $(call Image/Build/Template/squashfs-only/$(1),TPLINK4K,tl-wr841nd-v5,board=TL-WR741ND,TL-WR841NDv5) + $(call Image/Build/Template/4k/$(1),TPLINK,tl-wr841nd-v5,board=TL-WR741ND,TL-WR841NDv5) endef define Image/Build/Profile/TLWR941NDV2 From baab9a6aec814bd57f5a598fefe164f7c87aed6a Mon Sep 17 00:00:00 2001 From: jow Date: Tue, 19 Jan 2010 21:28:22 +0000 Subject: [PATCH 079/210] [package] mtd: treat failure to open FIS partition as fatal when a fis_layout is given, aborts mtd write if reformat is needed and FIS table not available git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19231 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/mtd/Makefile | 2 +- package/mtd/src/fis.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package/mtd/Makefile b/package/mtd/Makefile index 172235d30..ced26d5c6 100644 --- a/package/mtd/Makefile +++ b/package/mtd/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=mtd -PKG_RELEASE:=10 +PKG_RELEASE:=11 PKG_BUILD_DIR := $(KERNEL_BUILD_DIR)/$(PKG_NAME) STAMP_PREPARED := $(STAMP_PREPARED)_$(call confvar,CONFIG_MTD_REDBOOT_PARTS) diff --git a/package/mtd/src/fis.c b/package/mtd/src/fis.c index f99101988..3108c5a9e 100644 --- a/package/mtd/src/fis.c +++ b/package/mtd/src/fis.c @@ -99,7 +99,7 @@ fis_validate(struct fis_part *old, int n_old, struct fis_part *new, int n_new) desc = fis_open(); if (!desc) - return 0; + return -1; for (i = 0; i < n_new - 1; i++) { if (!new[i].size) { From 8084bc3069cbedf99e3a30642d0516f6023a1792 Mon Sep 17 00:00:00 2001 From: jow Date: Tue, 19 Jan 2010 23:02:11 +0000 Subject: [PATCH 080/210] [package] firewall: fix a race condition preventing interfaces from being added to the firewall on boot git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19232 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/firewall/Makefile | 2 +- package/firewall/files/uci_firewall.sh | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/package/firewall/Makefile b/package/firewall/Makefile index 8d0452602..abc602043 100644 --- a/package/firewall/Makefile +++ b/package/firewall/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=firewall PKG_VERSION:=1 -PKG_RELEASE:=9 +PKG_RELEASE:=10 include $(INCLUDE_DIR)/package.mk diff --git a/package/firewall/files/uci_firewall.sh b/package/firewall/files/uci_firewall.sh index 05fe39beb..49e5ca859 100755 --- a/package/firewall/files/uci_firewall.sh +++ b/package/firewall/files/uci_firewall.sh @@ -506,9 +506,13 @@ fw_init() { uci_set_state firewall core loaded 1 config_set core loaded 1 config_foreach fw_check_notrack zone - INTERFACES="$(sh -c '. /etc/functions.sh; config_load network; config_foreach echo interface')" + INTERFACES="$(sh -c ' + . /etc/functions.sh; config_load network + echo_up() { local up; config_get_bool up "$1" up 0; [ $up = 1 ] && echo "$1"; } + config_foreach echo_up interface + ')" for interface in $INTERFACES; do - fw_addif "$interface" + fw_event ifup "$interface" done } From e25263b21def36527d39e1e20aa72e6449c0c510 Mon Sep 17 00:00:00 2001 From: nbd Date: Wed, 20 Jan 2010 02:25:55 +0000 Subject: [PATCH 081/210] ath9k: fix a beacon buffer leak on interface up/down git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19233 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../mac80211/patches/570-ath9k_bcnslot_leak.patch | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 package/mac80211/patches/570-ath9k_bcnslot_leak.patch diff --git a/package/mac80211/patches/570-ath9k_bcnslot_leak.patch b/package/mac80211/patches/570-ath9k_bcnslot_leak.patch new file mode 100644 index 000000000..bbd94894e --- /dev/null +++ b/package/mac80211/patches/570-ath9k_bcnslot_leak.patch @@ -0,0 +1,14 @@ +--- a/drivers/net/wireless/ath/ath9k/main.c ++++ b/drivers/net/wireless/ath/ath9k/main.c +@@ -1471,10 +1471,10 @@ static void ath9k_remove_interface(struc + (sc->sc_ah->opmode == NL80211_IFTYPE_MESH_POINT)) { + ath9k_ps_wakeup(sc); + ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq); +- ath_beacon_return(sc, avp); + ath9k_ps_restore(sc); + } + ++ ath_beacon_return(sc, avp); + sc->sc_flags &= ~SC_OP_BEACONS; + + for (i = 0; i < ARRAY_SIZE(sc->beacon.bslot); i++) { From 92ca87f9e7ed1b52208366537d563a211f6680c1 Mon Sep 17 00:00:00 2001 From: nbd Date: Wed, 20 Jan 2010 02:26:00 +0000 Subject: [PATCH 082/210] hostapd: upgrade to latest git version, add patches to fix multi-bss support with a single hostapd instance git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19234 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/hostapd/Makefile | 4 +- package/hostapd/patches/130-scan_wait.patch | 148 +++ .../hostapd/patches/140-wds_sta_remove.patch | 12 + .../patches/150-mbss_driver_handling.patch | 1110 +++++++++++++++++ .../patches/160-sta_roam_between_bss.patch | 79 ++ 5 files changed, 1351 insertions(+), 2 deletions(-) create mode 100644 package/hostapd/patches/130-scan_wait.patch create mode 100644 package/hostapd/patches/140-wds_sta_remove.patch create mode 100644 package/hostapd/patches/150-mbss_driver_handling.patch create mode 100644 package/hostapd/patches/160-sta_roam_between_bss.patch diff --git a/package/hostapd/Makefile b/package/hostapd/Makefile index 342c7519d..682d6ab85 100644 --- a/package/hostapd/Makefile +++ b/package/hostapd/Makefile @@ -8,9 +8,9 @@ include $(TOPDIR)/rules.mk PKG_NAME:=hostapd -PKG_VERSION:=20100108 +PKG_VERSION:=20100117 PKG_RELEASE:=1 -PKG_REV:=d97572a40fd7ec77094e2e4ef83424a4c0f7e24d +PKG_REV:=43a7fe2e0e614e52fa05ff4d78af91bd4e17d3b2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=git://w1.fi/srv/git/hostap.git diff --git a/package/hostapd/patches/130-scan_wait.patch b/package/hostapd/patches/130-scan_wait.patch new file mode 100644 index 000000000..7fe928549 --- /dev/null +++ b/package/hostapd/patches/130-scan_wait.patch @@ -0,0 +1,148 @@ +--- a/src/ap/hostapd.h ++++ b/src/ap/hostapd.h +@@ -238,6 +238,7 @@ struct hostapd_iface { + int (*for_each_interface)(struct hapd_interfaces *interfaces, + int (*cb)(struct hostapd_iface *iface, + void *ctx), void *ctx); ++ int (*init_complete)(struct hostapd_iface *iface); + }; + + /* hostapd.c */ +--- a/src/ap/hostapd.c ++++ b/src/ap/hostapd.c +@@ -745,6 +745,9 @@ int hostapd_setup_interface_complete(str + wpa_printf(MSG_DEBUG, "%s: Setup of interface done.", + iface->bss[0]->conf->iface); + ++ if (iface->init_complete) ++ iface->init_complete(iface); ++ + return 0; + } + +--- a/hostapd/main.c ++++ b/hostapd/main.c +@@ -35,6 +35,8 @@ + extern int wpa_debug_level; + extern int wpa_debug_show_keys; + extern int wpa_debug_timestamp; ++static int daemonize = 0; ++static char *pid_file = NULL; + + + struct hapd_interfaces { +@@ -162,6 +164,15 @@ static void hostapd_logger_cb(void *ctx, + } + #endif /* CONFIG_NO_HOSTAPD_LOGGER */ + ++static int hostapd_init_complete(struct hostapd_iface *iface) ++{ ++ if (daemonize && os_daemonize(pid_file)) { ++ perror("daemon"); ++ return -1; ++ } ++ daemonize = 0; ++} ++ + + /** + * hostapd_init - Allocate and initialize per-interface data +@@ -183,6 +194,7 @@ static struct hostapd_iface * hostapd_in + if (hapd_iface == NULL) + goto fail; + ++ hapd_iface->init_complete = hostapd_init_complete; + hapd_iface->reload_config = hostapd_reload_config; + hapd_iface->config_read_cb = hostapd_config_read; + hapd_iface->config_fname = os_strdup(config_file); +@@ -390,7 +402,7 @@ static int hostapd_global_init(struct ha + } + + +-static void hostapd_global_deinit(const char *pid_file) ++static void hostapd_global_deinit(void) + { + #ifdef EAP_SERVER_TNC + tncs_global_deinit(); +@@ -408,8 +420,7 @@ static void hostapd_global_deinit(const + } + + +-static int hostapd_global_run(struct hapd_interfaces *ifaces, int daemonize, +- const char *pid_file) ++static int hostapd_global_run(struct hapd_interfaces *iface) + { + #ifdef EAP_SERVER_TNC + int tnc = 0; +@@ -430,11 +441,6 @@ static int hostapd_global_run(struct hap + } + #endif /* EAP_SERVER_TNC */ + +- if (daemonize && os_daemonize(pid_file)) { +- perror("daemon"); +- return -1; +- } +- + eloop_run(); + + return 0; +@@ -478,8 +484,7 @@ int main(int argc, char *argv[]) + struct hapd_interfaces interfaces; + int ret = 1; + size_t i; +- int c, debug = 0, daemonize = 0; +- char *pid_file = NULL; ++ int c, debug = 0; + + if (os_program_init()) + return -1; +@@ -544,7 +549,7 @@ int main(int argc, char *argv[]) + goto out; + } + +- if (hostapd_global_run(&interfaces, daemonize, pid_file)) ++ if (hostapd_global_run(&interfaces)) + goto out; + + ret = 0; +@@ -555,7 +560,7 @@ int main(int argc, char *argv[]) + hostapd_interface_deinit_free(interfaces.iface[i]); + os_free(interfaces.iface); + +- hostapd_global_deinit(pid_file); ++ hostapd_global_deinit(); + os_free(pid_file); + + os_program_deinit(); +--- a/hostapd/config_file.c ++++ b/hostapd/config_file.c +@@ -1854,6 +1854,8 @@ struct hostapd_config * hostapd_config_r + } + #endif /* CONFIG_IEEE80211W */ + #ifdef CONFIG_IEEE80211N ++ } else if (os_strcmp(buf, "noscan") == 0) { ++ conf->noscan = atoi(pos); + } else if (os_strcmp(buf, "ieee80211n") == 0) { + conf->ieee80211n = atoi(pos); + } else if (os_strcmp(buf, "ht_capab") == 0) { +--- a/src/ap/ap_config.h ++++ b/src/ap/ap_config.h +@@ -366,6 +366,7 @@ struct hostapd_config { + + int ht_op_mode_fixed; + u16 ht_capab; ++ int noscan; + int ieee80211n; + int secondary_channel; + }; +--- a/src/ap/hw_features.c ++++ b/src/ap/hw_features.c +@@ -460,7 +460,7 @@ static int ieee80211n_check_40mhz(struct + { + struct wpa_driver_scan_params params; + +- if (!iface->conf->secondary_channel) ++ if (!iface->conf->secondary_channel || iface->conf->noscan) + return 0; /* HT40 not used */ + + wpa_printf(MSG_DEBUG, "Scan for neighboring BSSes prior to enabling " diff --git a/package/hostapd/patches/140-wds_sta_remove.patch b/package/hostapd/patches/140-wds_sta_remove.patch new file mode 100644 index 000000000..80e036eef --- /dev/null +++ b/package/hostapd/patches/140-wds_sta_remove.patch @@ -0,0 +1,12 @@ +--- a/src/ap/sta_info.c ++++ b/src/ap/sta_info.c +@@ -121,7 +121,8 @@ void ap_free_sta(struct hostapd_data *ha + + accounting_sta_stop(hapd, sta); + +- hapd->drv.set_wds_sta(hapd, sta->addr, sta->aid, 0); ++ if (sta->flags & WLAN_STA_WDS) ++ hapd->drv.set_wds_sta(hapd, sta->addr, sta->aid, 0); + if (!ap_sta_in_other_bss(hapd, sta, WLAN_STA_ASSOC) && + !(sta->flags & WLAN_STA_PREAUTH)) + hapd->drv.sta_remove(hapd, sta->addr); diff --git a/package/hostapd/patches/150-mbss_driver_handling.patch b/package/hostapd/patches/150-mbss_driver_handling.patch new file mode 100644 index 000000000..ccae4e6db --- /dev/null +++ b/package/hostapd/patches/150-mbss_driver_handling.patch @@ -0,0 +1,1110 @@ +--- a/src/drivers/driver_nl80211.c ++++ b/src/drivers/driver_nl80211.c +@@ -59,8 +59,10 @@ + #endif + + struct i802_bss { ++ struct wpa_driver_nl80211_data *drv; + struct i802_bss *next; + int ifindex; ++ char ifname[IFNAMSIZ + 1]; + unsigned int beacon_set:1; + }; + +@@ -68,7 +70,6 @@ struct wpa_driver_nl80211_data { + void *ctx; + struct netlink_data *netlink; + int ioctl_sock; /* socket for ioctl() use */ +- char ifname[IFNAMSIZ + 1]; + char brname[IFNAMSIZ]; + int ifindex; + int if_removed; +@@ -107,6 +108,8 @@ struct wpa_driver_nl80211_data { + + u64 remain_on_chan_cookie; + ++ struct i802_bss first_bss; ++ + #ifdef HOSTAPD + int eapol_sock; /* socket for EAPOL frames */ + +@@ -114,8 +117,6 @@ struct wpa_driver_nl80211_data { + int *if_indices; + int num_if_indices; + +- struct i802_bss bss; +- + int last_freq; + int last_freq_ht; + #endif /* HOSTAPD */ +@@ -135,8 +136,6 @@ static void nl80211_remove_monitor_inter + #ifdef HOSTAPD + static void add_ifidx(struct wpa_driver_nl80211_data *drv, int ifidx); + static void del_ifidx(struct wpa_driver_nl80211_data *drv, int ifidx); +-static struct i802_bss * get_bss(struct wpa_driver_nl80211_data *drv, +- int ifindex); + static int i802_set_freq(void *priv, struct hostapd_freq_params *freq); + static int wpa_driver_nl80211_if_remove(void *priv, + enum wpa_driver_if_type type, +@@ -278,7 +277,8 @@ nla_put_failure: + + static int wpa_driver_nl80211_get_bssid(void *priv, u8 *bssid) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + if (!drv->associated) + return -1; + os_memcpy(bssid, drv->bssid, ETH_ALEN); +@@ -288,7 +288,8 @@ static int wpa_driver_nl80211_get_bssid( + + static int wpa_driver_nl80211_get_ssid(void *priv, u8 *ssid) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + if (!drv->associated) + return -1; + os_memcpy(ssid, drv->ssid, drv->ssid_len); +@@ -313,7 +314,7 @@ static void wpa_driver_nl80211_event_lin + event.interface_status.ifname, + del ? "removed" : "added"); + +- if (os_strcmp(drv->ifname, event.interface_status.ifname) == 0) { ++ if (os_strcmp(drv->first_bss.ifname, event.interface_status.ifname) == 0) { + if (del) + drv->if_removed = 1; + else +@@ -336,7 +337,7 @@ static int wpa_driver_nl80211_own_ifname + rta_len = RTA_ALIGN(sizeof(struct rtattr)); + while (RTA_OK(attr, attrlen)) { + if (attr->rta_type == IFLA_IFNAME) { +- if (os_strcmp(((char *) attr) + rta_len, drv->ifname) ++ if (os_strcmp(((char *) attr) + rta_len, drv->first_bss.ifname) + == 0) + return 1; + else +@@ -356,7 +357,7 @@ static int wpa_driver_nl80211_own_ifinde + return 1; + + if (drv->if_removed && wpa_driver_nl80211_own_ifname(drv, buf, len)) { +- drv->ifindex = if_nametoindex(drv->ifname); ++ drv->first_bss.ifindex = if_nametoindex(drv->first_bss.ifname); + wpa_printf(MSG_DEBUG, "nl80211: Update ifindex for a removed " + "interface"); + wpa_driver_nl80211_finish_drv_init(drv); +@@ -785,7 +786,7 @@ static int process_event(struct nl_msg * + if (drv->ap_scan_as_station && + (gnlh->cmd == NL80211_CMD_NEW_SCAN_RESULTS || + gnlh->cmd == NL80211_CMD_SCAN_ABORTED)) { +- wpa_driver_nl80211_set_mode(drv, IEEE80211_MODE_AP); ++ wpa_driver_nl80211_set_mode(&drv->first_bss, IEEE80211_MODE_AP); + drv->ap_scan_as_station = 0; + } + +@@ -889,7 +890,8 @@ static void wpa_driver_nl80211_event_rec + */ + static int wpa_driver_nl80211_set_country(void *priv, const char *alpha2_arg) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + char alpha2[3]; + struct nl_msg *msg; + +@@ -978,7 +980,7 @@ static int wpa_driver_nl80211_get_info(s + genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, + 0, NL80211_CMD_GET_WIPHY, 0); + +- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex); ++ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->first_bss.ifindex); + + if (send_and_recv_msgs(drv, msg, wiphy_info_handler, info) == 0) + return 0; +@@ -1152,15 +1154,18 @@ static void * wpa_driver_nl80211_init(vo + { + struct wpa_driver_nl80211_data *drv; + struct netlink_config *cfg; ++ struct i802_bss *bss; + + drv = os_zalloc(sizeof(*drv)); + if (drv == NULL) + return NULL; + drv->ctx = ctx; +- os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname)); ++ bss = &drv->first_bss; ++ os_strlcpy(bss->ifname, ifname, sizeof(bss->ifname)); + drv->monitor_ifidx = -1; + drv->monitor_sock = -1; + drv->ioctl_sock = -1; ++ drv->first_bss.drv = drv; + + if (wpa_driver_nl80211_init_nl(drv, ctx)) { + os_free(drv); +@@ -1187,7 +1192,7 @@ static void * wpa_driver_nl80211_init(vo + if (wpa_driver_nl80211_finish_drv_init(drv)) + goto failed; + +- return drv; ++ return bss; + + failed: + netlink_deinit(drv->netlink); +@@ -1207,17 +1212,19 @@ failed: + static int + wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv) + { +- drv->ifindex = if_nametoindex(drv->ifname); ++ struct i802_bss *bss = &drv->first_bss; ++ ++ drv->ifindex = if_nametoindex(drv->first_bss.ifname); + + #ifndef HOSTAPD +- if (wpa_driver_nl80211_set_mode(drv, IEEE80211_MODE_INFRA) < 0) { ++ if (wpa_driver_nl80211_set_mode(bss, IEEE80211_MODE_INFRA) < 0) { + wpa_printf(MSG_DEBUG, "nl80211: Could not configure driver to " + "use managed mode"); + } + +- if (linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 1)) { ++ if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1)) { + wpa_printf(MSG_ERROR, "Could not set interface '%s' UP", +- drv->ifname); ++ bss->ifname); + return -1; + } + +@@ -1232,20 +1239,6 @@ wpa_driver_nl80211_finish_drv_init(struc + } + + +-#ifdef HOSTAPD +-static void wpa_driver_nl80211_free_bss(struct wpa_driver_nl80211_data *drv) +-{ +- struct i802_bss *bss, *prev; +- bss = drv->bss.next; +- while (bss) { +- prev = bss; +- bss = bss->next; +- os_free(bss); +- } +-} +-#endif /* HOSTAPD */ +- +- + static int wpa_driver_nl80211_del_beacon(struct wpa_driver_nl80211_data *drv) + { + struct nl_msg *msg; +@@ -1273,14 +1266,15 @@ static int wpa_driver_nl80211_del_beacon + */ + static void wpa_driver_nl80211_deinit(void *priv) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + + if (drv->added_if_into_bridge) { +- if (linux_br_del_if(drv->ioctl_sock, drv->brname, drv->ifname) ++ if (linux_br_del_if(drv->ioctl_sock, drv->brname, bss->ifname) + < 0) + wpa_printf(MSG_INFO, "nl80211: Failed to remove " + "interface %s from bridge %s: %s", +- drv->ifname, drv->brname, strerror(errno)); ++ bss->ifname, drv->brname, strerror(errno)); + } + if (drv->added_bridge) { + if (linux_br_del(drv->ioctl_sock, drv->brname) < 0) +@@ -1310,8 +1304,6 @@ static void wpa_driver_nl80211_deinit(vo + + if (drv->if_indices != drv->default_if_indices) + os_free(drv->if_indices); +- +- wpa_driver_nl80211_free_bss(drv); + #endif /* HOSTAPD */ + + if (drv->disable_11b_rates) +@@ -1322,8 +1314,8 @@ static void wpa_driver_nl80211_deinit(vo + + eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, drv, drv->ctx); + +- (void) linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 0); +- wpa_driver_nl80211_set_mode(drv, IEEE80211_MODE_INFRA); ++ (void) linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 0); ++ wpa_driver_nl80211_set_mode(bss, IEEE80211_MODE_INFRA); + + if (drv->ioctl_sock >= 0) + close(drv->ioctl_sock); +@@ -1355,7 +1347,7 @@ static void wpa_driver_nl80211_scan_time + { + struct wpa_driver_nl80211_data *drv = eloop_ctx; + if (drv->ap_scan_as_station) { +- wpa_driver_nl80211_set_mode(drv, IEEE80211_MODE_AP); ++ wpa_driver_nl80211_set_mode(&drv->first_bss, IEEE80211_MODE_AP); + drv->ap_scan_as_station = 0; + } + wpa_printf(MSG_DEBUG, "Scan timeout - try to get results"); +@@ -1372,7 +1364,8 @@ static void wpa_driver_nl80211_scan_time + static int wpa_driver_nl80211_scan(void *priv, + struct wpa_driver_scan_params *params) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + int ret = 0, timeout; + struct nl_msg *msg, *ssids, *freqs; + size_t i; +@@ -1421,12 +1414,12 @@ static int wpa_driver_nl80211_scan(void + * mac80211 does not allow scan requests in AP mode, so + * try to do this in station mode. + */ +- if (wpa_driver_nl80211_set_mode(drv, ++ if (wpa_driver_nl80211_set_mode(bss, + IEEE80211_MODE_INFRA)) + goto nla_put_failure; + + if (wpa_driver_nl80211_scan(drv, params)) { +- wpa_driver_nl80211_set_mode(drv, ++ wpa_driver_nl80211_set_mode(bss, + IEEE80211_MODE_AP); + goto nla_put_failure; + } +@@ -1662,7 +1655,8 @@ static void wpa_scan_results_free(struct + static struct wpa_scan_results * + wpa_driver_nl80211_get_scan_results(void *priv) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg; + struct wpa_scan_results *res; + int ret; +@@ -1701,7 +1695,8 @@ static int wpa_driver_nl80211_set_key(co + const u8 *seq, size_t seq_len, + const u8 *key, size_t key_len) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + int ifindex = if_nametoindex(ifname); + struct nl_msg *msg; + int ret; +@@ -1958,7 +1953,8 @@ static int wpa_driver_nl80211_disconnect + static int wpa_driver_nl80211_deauthenticate(void *priv, const u8 *addr, + int reason_code) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + if (!(drv->capa.flags & WPA_DRIVER_FLAGS_SME)) + return wpa_driver_nl80211_disconnect(drv, addr, reason_code); + wpa_printf(MSG_DEBUG, "%s", __func__); +@@ -1971,7 +1967,8 @@ static int wpa_driver_nl80211_deauthenti + static int wpa_driver_nl80211_disassociate(void *priv, const u8 *addr, + int reason_code) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + if (!(drv->capa.flags & WPA_DRIVER_FLAGS_SME)) + return wpa_driver_nl80211_disconnect(drv, addr, reason_code); + wpa_printf(MSG_DEBUG, "%s", __func__); +@@ -1984,7 +1981,8 @@ static int wpa_driver_nl80211_disassocia + static int wpa_driver_nl80211_authenticate( + void *priv, struct wpa_driver_auth_params *params) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + int ret = -1, i; + struct nl_msg *msg; + enum nl80211_auth_type type; +@@ -1996,7 +1994,7 @@ static int wpa_driver_nl80211_authentica + if (drv->nlmode != NL80211_IFTYPE_STATION) + wpa_driver_nl80211_set_mode(priv, IEEE80211_MODE_INFRA); + +- if (wpa_driver_nl80211_set_mode(drv, IEEE80211_MODE_INFRA) < 0) ++ if (wpa_driver_nl80211_set_mode(priv, IEEE80211_MODE_INFRA) < 0) + return -1; + + retry: +@@ -2013,7 +2011,7 @@ retry: + for (i = 0; i < 4; i++) { + if (!params->wep_key[i]) + continue; +- wpa_driver_nl80211_set_key(drv->ifname, drv, WPA_ALG_WEP, NULL, ++ wpa_driver_nl80211_set_key(bss->ifname, drv, WPA_ALG_WEP, NULL, + i, + i == params->wep_tx_keyidx, NULL, 0, + params->wep_key[i], +@@ -2348,7 +2346,8 @@ wpa_driver_nl80211_add_11b(struct hostap + static struct hostapd_hw_modes * + wpa_driver_nl80211_get_hw_feature_data(void *priv, u16 *num_modes, u16 *flags) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg; + struct phy_info_arg result = { + .num_modes = num_modes, +@@ -2417,7 +2416,8 @@ static int wpa_driver_nl80211_send_frame + static int wpa_driver_nl80211_send_mlme(void *priv, const u8 *data, + size_t data_len) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct ieee80211_mgmt *mgmt; + int encrypt = 1; + u16 fc; +@@ -2448,23 +2448,15 @@ static int wpa_driver_nl80211_set_beacon + const u8 *tail, size_t tail_len, + int dtim_period, int beacon_int) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg; + u8 cmd = NL80211_CMD_NEW_BEACON; + int ret; + int beacon_set; + int ifindex = if_nametoindex(ifname); +-#ifdef HOSTAPD +- struct i802_bss *bss; + +- bss = get_bss(drv, ifindex); +- if (bss == NULL) +- return -ENOENT; + beacon_set = bss->beacon_set; +-#else /* HOSTAPD */ +- beacon_set = drv->beacon_set; +-#endif /* HOSTAPD */ +- + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; +@@ -2487,11 +2479,7 @@ static int wpa_driver_nl80211_set_beacon + wpa_printf(MSG_DEBUG, "nl80211: Beacon set failed: %d (%s)", + ret, strerror(-ret)); + } else { +-#ifdef HOSTAPD + bss->beacon_set = 1; +-#else /* HOSTAPD */ +- drv->beacon_set = 1; +-#endif /* HOSTAPD */ + } + return ret; + nla_put_failure: +@@ -2545,7 +2533,8 @@ nla_put_failure: + static int wpa_driver_nl80211_sta_add(const char *ifname, void *priv, + struct hostapd_sta_add_params *params) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg; + int ret = -ENOBUFS; + +@@ -2582,7 +2571,8 @@ static int wpa_driver_nl80211_sta_add(co + + static int wpa_driver_nl80211_sta_remove(void *priv, const u8 *addr) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg; + int ret; + +@@ -2594,7 +2584,7 @@ static int wpa_driver_nl80211_sta_remove + 0, NL80211_CMD_DEL_STATION, 0); + + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, +- if_nametoindex(drv->ifname)); ++ if_nametoindex(bss->ifname)); + NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr); + + ret = send_and_recv_msgs(drv, msg, NULL, NULL); +@@ -3032,7 +3022,7 @@ nl80211_create_monitor_interface(struct + int optval; + socklen_t optlen; + +- snprintf(buf, IFNAMSIZ, "mon.%s", drv->ifname); ++ snprintf(buf, IFNAMSIZ, "mon.%s", drv->first_bss.ifname); + buf[IFNAMSIZ - 1] = '\0'; + + drv->monitor_ifidx = +@@ -3092,7 +3082,8 @@ static int wpa_driver_nl80211_hapd_send_ + void *priv, const u8 *addr, const u8 *data, + size_t data_len, int encrypt, const u8 *own_addr) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct ieee80211_hdr *hdr; + size_t len; + u8 *pos; +@@ -3177,7 +3168,8 @@ static int wpa_driver_nl80211_sta_set_fl + int total_flags, int flags_or, + int flags_and) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg, *flags = NULL; + struct nl80211_sta_flag_update upd; + +@@ -3195,7 +3187,7 @@ static int wpa_driver_nl80211_sta_set_fl + 0, NL80211_CMD_SET_STATION, 0); + + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, +- if_nametoindex(drv->ifname)); ++ if_nametoindex(bss->ifname)); + NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr); + + /* +@@ -3234,7 +3226,7 @@ static int wpa_driver_nl80211_sta_set_fl + static int wpa_driver_nl80211_ap(struct wpa_driver_nl80211_data *drv, + struct wpa_driver_associate_params *params) + { +- if (wpa_driver_nl80211_set_mode(drv, params->mode) || ++ if (wpa_driver_nl80211_set_mode(&drv->first_bss, params->mode) || + wpa_driver_nl80211_set_freq(drv, params->freq, 0, 0)) { + nl80211_remove_monitor_interface(drv); + return -1; +@@ -3285,7 +3277,7 @@ static int wpa_driver_nl80211_ibss(struc + + wpa_printf(MSG_DEBUG, "nl80211: Join IBSS (ifindex=%d)", drv->ifindex); + +- if (wpa_driver_nl80211_set_mode(drv, params->mode)) { ++ if (wpa_driver_nl80211_set_mode(&drv->first_bss, params->mode)) { + wpa_printf(MSG_INFO, "nl80211: Failed to set interface into " + "IBSS mode"); + return -1; +@@ -3499,7 +3491,8 @@ nla_put_failure: + static int wpa_driver_nl80211_associate( + void *priv, struct wpa_driver_associate_params *params) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + int ret = -1; + struct nl_msg *msg; + +@@ -3510,7 +3503,7 @@ static int wpa_driver_nl80211_associate( + return wpa_driver_nl80211_ibss(drv, params); + + if (!(drv->capa.flags & WPA_DRIVER_FLAGS_SME)) { +- if (wpa_driver_nl80211_set_mode(drv, params->mode) < 0) ++ if (wpa_driver_nl80211_set_mode(priv, params->mode) < 0) + return -1; + return wpa_driver_nl80211_connect(drv, params); + } +@@ -3611,7 +3604,8 @@ nla_put_failure: + + static int wpa_driver_nl80211_set_mode(void *priv, int mode) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + int ret = -1; + int nlmode; + +@@ -3646,10 +3640,10 @@ static int wpa_driver_nl80211_set_mode(v + * take the device down, try to set the mode again, and bring the + * device back up. + */ +- if (linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 0) == 0) { ++ if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 0) == 0) { + /* Try to set the mode again while the interface is down */ + ret = nl80211_set_mode(drv, drv->ifindex, nlmode); +- if (linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 1)) ++ if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1)) + ret = -1; + } + +@@ -3684,7 +3678,8 @@ done: + static int wpa_driver_nl80211_get_capa(void *priv, + struct wpa_driver_capa *capa) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + if (!drv->has_capability) + return -1; + os_memcpy(capa, &drv->capa, sizeof(*capa)); +@@ -3694,7 +3689,8 @@ static int wpa_driver_nl80211_get_capa(v + + static int wpa_driver_nl80211_set_operstate(void *priv, int state) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + + wpa_printf(MSG_DEBUG, "%s: operstate %d->%d (%s)", + __func__, drv->operstate, state, state ? "UP" : "DORMANT"); +@@ -3706,7 +3702,8 @@ static int wpa_driver_nl80211_set_operst + + static int wpa_driver_nl80211_set_supp_port(void *priv, int authorized) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg; + struct nl80211_sta_flag_update upd; + +@@ -3718,7 +3715,7 @@ static int wpa_driver_nl80211_set_supp_p + 0, NL80211_CMD_SET_STATION, 0); + + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, +- if_nametoindex(drv->ifname)); ++ if_nametoindex(bss->ifname)); + NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, drv->bssid); + + os_memset(&upd, 0, sizeof(upd)); +@@ -3735,20 +3732,6 @@ static int wpa_driver_nl80211_set_supp_p + + #ifdef HOSTAPD + +-static struct i802_bss * get_bss(struct wpa_driver_nl80211_data *drv, +- int ifindex) +-{ +- struct i802_bss *bss = &drv->bss; +- while (bss) { +- if (ifindex == bss->ifindex) +- return bss; +- bss = bss->next; +- } +- wpa_printf(MSG_DEBUG, "nl80211: get_bss(%d) failed", ifindex); +- return NULL; +-} +- +- + static void add_ifidx(struct wpa_driver_nl80211_data *drv, int ifidx) + { + int i; +@@ -3842,7 +3825,8 @@ static int get_key_handler(struct nl_msg + static int i802_get_seqnum(const char *iface, void *priv, const u8 *addr, + int idx, u8 *seq) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg; + + msg = nlmsg_alloc(); +@@ -3868,7 +3852,8 @@ static int i802_get_seqnum(const char *i + static int i802_set_rate_sets(void *priv, int *supp_rates, int *basic_rates, + int mode) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg; + u8 rates[NL80211_MAX_SUPP_RATES]; + u8 rates_len = 0; +@@ -3887,7 +3872,7 @@ static int i802_set_rate_sets(void *priv + NLA_PUT(msg, NL80211_ATTR_BSS_BASIC_RATES, rates_len, rates); + + /* TODO: multi-BSS support */ +- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->ifname)); ++ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(bss->ifname)); + + return send_and_recv_msgs(drv, msg, NULL, NULL); + nla_put_failure: +@@ -3898,7 +3883,8 @@ static int i802_set_rate_sets(void *priv + /* Set kernel driver on given frequency (MHz) */ + static int i802_set_freq(void *priv, struct hostapd_freq_params *freq) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + return wpa_driver_nl80211_set_freq(drv, freq->freq, freq->ht_enabled, + freq->sec_channel_offset); + } +@@ -3906,7 +3892,8 @@ static int i802_set_freq(void *priv, str + + static int i802_set_rts(void *priv, int rts) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg; + int ret = -ENOBUFS; + u32 val; +@@ -3937,7 +3924,8 @@ nla_put_failure: + + static int i802_set_frag(void *priv, int frag) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg; + int ret = -ENOBUFS; + u32 val; +@@ -3968,7 +3956,8 @@ nla_put_failure: + + static int i802_flush(void *priv) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg; + + msg = nlmsg_alloc(); +@@ -3982,7 +3971,7 @@ static int i802_flush(void *priv) + * XXX: FIX! this needs to flush all VLANs too + */ + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, +- if_nametoindex(drv->ifname)); ++ if_nametoindex(bss->ifname)); + + return send_and_recv_msgs(drv, msg, NULL, NULL); + nla_put_failure: +@@ -4044,7 +4033,8 @@ static int get_sta_handler(struct nl_msg + static int i802_read_sta_data(void *priv, struct hostap_sta_driver_data *data, + const u8 *addr) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg; + + os_memset(data, 0, sizeof(*data)); +@@ -4056,7 +4046,7 @@ static int i802_read_sta_data(void *priv + 0, NL80211_CMD_GET_STATION, 0); + + NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr); +- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->ifname)); ++ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(bss->ifname)); + + return send_and_recv_msgs(drv, msg, get_sta_handler, data); + nla_put_failure: +@@ -4067,7 +4057,8 @@ static int i802_read_sta_data(void *priv + static int i802_set_tx_queue_params(void *priv, int queue, int aifs, + int cw_min, int cw_max, int burst_time) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg; + struct nlattr *txq, *params; + +@@ -4078,7 +4069,7 @@ static int i802_set_tx_queue_params(void + genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, + 0, NL80211_CMD_SET_WIPHY, 0); + +- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->ifname)); ++ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(bss->ifname)); + + txq = nla_nest_start(msg, NL80211_ATTR_WIPHY_TXQ_PARAMS); + if (!txq) +@@ -4110,7 +4101,8 @@ static int i802_set_tx_queue_params(void + + static int i802_set_bss(void *priv, int cts, int preamble, int slot) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg; + + msg = nlmsg_alloc(); +@@ -4128,7 +4120,7 @@ static int i802_set_bss(void *priv, int + NLA_PUT_U8(msg, NL80211_ATTR_BSS_SHORT_SLOT_TIME, slot); + + /* TODO: multi-BSS support */ +- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->ifname)); ++ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(bss->ifname)); + + return send_and_recv_msgs(drv, msg, NULL, NULL); + nla_put_failure: +@@ -4157,7 +4149,8 @@ static int i802_set_short_slot_time(void + static int i802_set_sta_vlan(void *priv, const u8 *addr, + const char *ifname, int vlan_id) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg; + + msg = nlmsg_alloc(); +@@ -4168,7 +4161,7 @@ static int i802_set_sta_vlan(void *priv, + 0, NL80211_CMD_SET_STATION, 0); + + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, +- if_nametoindex(drv->ifname)); ++ if_nametoindex(bss->ifname)); + NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr); + NLA_PUT_U32(msg, NL80211_ATTR_STA_VLAN, + if_nametoindex(ifname)); +@@ -4181,10 +4174,11 @@ static int i802_set_sta_vlan(void *priv, + + static int i802_set_wds_sta(void *priv, const u8 *addr, int aid, int val) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + char name[16]; + +- os_snprintf(name, sizeof(name), "%s.sta%d", drv->ifname, aid); ++ os_snprintf(name, sizeof(name), "%s.sta%d", bss->ifname, aid); + if (val) { + if (nl80211_create_iface(priv, name, NL80211_IFTYPE_AP_VLAN, + NULL, 1) < 0) +@@ -4192,7 +4186,7 @@ static int i802_set_wds_sta(void *priv, + linux_set_iface_flags(drv->ioctl_sock, name, 1); + return i802_set_sta_vlan(priv, addr, name, 0); + } else { +- i802_set_sta_vlan(priv, addr, drv->ifname, 0); ++ i802_set_sta_vlan(priv, addr, bss->ifname, 0); + return wpa_driver_nl80211_if_remove(priv, WPA_IF_AP_VLAN, + name); + } +@@ -4244,7 +4238,8 @@ static int i802_sta_clear_stats(void *pr + static int i802_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr, + int reason) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct ieee80211_mgmt mgmt; + + memset(&mgmt, 0, sizeof(mgmt)); +@@ -4254,7 +4249,7 @@ static int i802_sta_deauth(void *priv, c + memcpy(mgmt.sa, own_addr, ETH_ALEN); + memcpy(mgmt.bssid, own_addr, ETH_ALEN); + mgmt.u.deauth.reason_code = host_to_le16(reason); +- return wpa_driver_nl80211_send_mlme(drv, (u8 *) &mgmt, ++ return wpa_driver_nl80211_send_mlme(bss, (u8 *) &mgmt, + IEEE80211_HDRLEN + + sizeof(mgmt.u.deauth)); + } +@@ -4263,7 +4258,8 @@ static int i802_sta_deauth(void *priv, c + static int i802_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr, + int reason) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct ieee80211_mgmt mgmt; + + memset(&mgmt, 0, sizeof(mgmt)); +@@ -4273,7 +4269,7 @@ static int i802_sta_disassoc(void *priv, + memcpy(mgmt.sa, own_addr, ETH_ALEN); + memcpy(mgmt.bssid, own_addr, ETH_ALEN); + mgmt.u.disassoc.reason_code = host_to_le16(reason); +- return wpa_driver_nl80211_send_mlme(drv, (u8 *) &mgmt, ++ return wpa_driver_nl80211_send_mlme(bss, (u8 *) &mgmt, + IEEE80211_HDRLEN + + sizeof(mgmt.u.disassoc)); + } +@@ -4335,17 +4331,17 @@ static void *i802_init(struct hostapd_da + struct wpa_init_params *params) + { + struct wpa_driver_nl80211_data *drv; ++ struct i802_bss *bss; + size_t i; + char brname[IFNAMSIZ]; + int ifindex, br_ifindex; + int br_added = 0; + +- drv = wpa_driver_nl80211_init(hapd, params->ifname); +- if (drv == NULL) ++ bss = wpa_driver_nl80211_init(hapd, params->ifname); ++ if (bss == NULL) + return NULL; + +- drv->bss.ifindex = drv->ifindex; +- ++ drv = bss->drv; + if (linux_br_get(brname, params->ifname) == 0) { + wpa_printf(MSG_DEBUG, "nl80211: Interface %s is in bridge %s", + params->ifname, brname); +@@ -4373,18 +4369,18 @@ static void *i802_init(struct hostapd_da + /* start listening for EAPOL on the default AP interface */ + add_ifidx(drv, drv->ifindex); + +- if (linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 0)) ++ if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 0)) + goto failed; + + if (params->bssid) { +- if (linux_set_ifhwaddr(drv->ioctl_sock, drv->ifname, ++ if (linux_set_ifhwaddr(drv->ioctl_sock, bss->ifname, + params->bssid)) + goto failed; + } + +- if (wpa_driver_nl80211_set_mode(drv, IEEE80211_MODE_AP)) { ++ if (wpa_driver_nl80211_set_mode(bss, IEEE80211_MODE_AP)) { + wpa_printf(MSG_ERROR, "nl80211: Failed to set interface %s " +- "into AP mode", drv->ifname); ++ "into AP mode", bss->ifname); + goto failed; + } + +@@ -4392,7 +4388,7 @@ static void *i802_init(struct hostapd_da + i802_check_bridge(drv, params->bridge[0], params->ifname) < 0) + goto failed; + +- if (linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 1)) ++ if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1)) + goto failed; + + drv->eapol_sock = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_PAE)); +@@ -4407,10 +4403,10 @@ static void *i802_init(struct hostapd_da + goto failed; + } + +- if (linux_get_ifhwaddr(drv->ioctl_sock, drv->ifname, params->own_addr)) ++ if (linux_get_ifhwaddr(drv->ioctl_sock, bss->ifname, params->own_addr)) + goto failed; + +- return drv; ++ return bss; + + failed: + nl80211_remove_monitor_interface(drv); +@@ -4453,27 +4449,30 @@ static enum nl80211_iftype wpa_driver_nl + static int wpa_driver_nl80211_if_add(const char *iface, void *priv, + enum wpa_driver_if_type type, + const char *ifname, const u8 *addr, +- void *bss_ctx) ++ void *bss_ctx, void **drv_priv) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + int ifidx; + #ifdef HOSTAPD +- struct i802_bss *bss = NULL; ++ struct i802_bss *new_bss = NULL; + + if (type == WPA_IF_AP_BSS) { +- bss = os_zalloc(sizeof(*bss)); +- if (bss == NULL) ++ new_bss = os_zalloc(sizeof(*new_bss)); ++ if (new_bss == NULL) + return -1; + } +-#endif /* HOSTAPD */ ++#endif + + ifidx = nl80211_create_iface(drv, ifname, + wpa_driver_nl80211_if_type(type), addr, + 0); ++ + if (ifidx < 0) { + #ifdef HOSTAPD +- os_free(bss); +-#endif /* HOSTAPD */ ++ if (type == WPA_IF_AP_BSS) ++ os_free(new_bss); ++#endif + return -1; + } + +@@ -4484,9 +4483,12 @@ static int wpa_driver_nl80211_if_add(con + os_free(bss); + return -1; + } +- bss->ifindex = ifidx; +- bss->next = drv->bss.next; +- drv->bss.next = bss; ++ strncpy(new_bss->ifname, ifname, IFNAMSIZ); ++ new_bss->ifindex = ifidx; ++ new_bss->drv = drv; ++ new_bss->next = drv->first_bss.next; ++ drv->first_bss.next = new_bss; ++ *drv_priv = new_bss; + } + #endif /* HOSTAPD */ + +@@ -4498,27 +4500,27 @@ static int wpa_driver_nl80211_if_remove( + enum wpa_driver_if_type type, + const char *ifname) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + int ifindex = if_nametoindex(ifname); + + nl80211_remove_iface(drv, ifindex); + +-#ifdef HOSTAPD +- if (type == WPA_IF_AP_BSS) { +- struct i802_bss *bss, *prev; +- prev = &drv->bss; +- bss = drv->bss.next; +- while (bss) { +- if (ifindex == bss->ifindex) { +- prev->next = bss->next; +- os_free(bss); +- break; +- } +- prev = bss; +- bss = bss->next; ++ if (type != WPA_IF_AP_BSS) ++ return 0; ++ ++ if (bss != &drv->first_bss) { ++ struct i802_bss *tbss = &drv->first_bss; ++ ++ while (tbss) { ++ if (tbss->next != bss) ++ continue; ++ ++ tbss->next = bss->next; ++ os_free(bss); ++ break; + } + } +-#endif /* HOSTAPD */ + + return 0; + } +@@ -4540,7 +4542,8 @@ static int cookie_handler(struct nl_msg + static int wpa_driver_nl80211_remain_on_channel(void *priv, unsigned int freq, + unsigned int duration) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg; + int ret; + u64 cookie; +@@ -4574,7 +4577,8 @@ nla_put_failure: + + static int wpa_driver_nl80211_cancel_remain_on_channel(void *priv) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg; + int ret; + +@@ -4629,7 +4633,8 @@ static void wpa_driver_nl80211_probe_req + + static int wpa_driver_nl80211_probe_req_report(void *priv, int report) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + + if (drv->nlmode != NL80211_IFTYPE_STATION) { + wpa_printf(MSG_DEBUG, "nl80211: probe_req_report control only " +@@ -4666,9 +4671,10 @@ static int wpa_driver_nl80211_probe_req_ + + static int wpa_driver_nl80211_alloc_interface_addr(void *priv, u8 *addr) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + +- if (linux_get_ifhwaddr(drv->ioctl_sock, drv->ifname, addr) < 0) ++ if (linux_get_ifhwaddr(drv->ioctl_sock, bss->ifname, addr) < 0) + return -1; + + if (addr[0] & 0x02) { +@@ -4738,7 +4744,8 @@ nla_put_failure: + + static int wpa_driver_nl80211_disable_11b_rates(void *priv, int disabled) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + drv->disable_11b_rates = disabled; + return nl80211_disable_11b_rates(drv, drv->ifindex, disabled); + } +@@ -4746,11 +4753,12 @@ static int wpa_driver_nl80211_disable_11 + + static int wpa_driver_nl80211_deinit_ap(void *priv) + { +- struct wpa_driver_nl80211_data *drv = priv; ++ struct i802_bss *bss = priv; ++ struct wpa_driver_nl80211_data *drv = bss->drv; + if (drv->nlmode != NL80211_IFTYPE_AP) + return -1; + wpa_driver_nl80211_del_beacon(drv); +- return wpa_driver_nl80211_set_mode(drv, IEEE80211_MODE_INFRA); ++ return wpa_driver_nl80211_set_mode(priv, IEEE80211_MODE_INFRA); + } + + +--- a/src/drivers/driver.h ++++ b/src/drivers/driver.h +@@ -1472,11 +1472,12 @@ struct wpa_driver_ops { + * @addr: Local address to use for the interface or %NULL to use the + * parent interface address + * @bss_ctx: BSS context for %WPA_IF_AP_BSS interfaces ++ * @drv_priv: Pointer for overwriting the driver context + * Returns: 0 on success, -1 on failure + */ + int (*if_add)(const char *iface, void *priv, + enum wpa_driver_if_type type, const char *ifname, +- const u8 *addr, void *bss_ctx); ++ const u8 *addr, void *bss_ctx, void **drv_priv); + + /** + * if_remove - Remove a virtual interface +--- a/src/drivers/driver_test.c ++++ b/src/drivers/driver_test.c +@@ -1030,7 +1030,7 @@ static int test_driver_bss_remove(void * + + static int test_driver_if_add(const char *iface, void *priv, + enum wpa_driver_if_type type, const char *ifname, +- const u8 *addr, void *bss_ctx) ++ const u8 *addr, void *bss_ctx, void **drv_priv) + { + wpa_printf(MSG_DEBUG, "%s(iface=%s type=%d ifname=%s bss_ctx=%p)", + __func__, iface, type, ifname, bss_ctx); +--- a/src/ap/ap_drv_ops.c ++++ b/src/ap/ap_drv_ops.c +@@ -242,7 +242,8 @@ static int hostapd_set_beacon(const char + + static int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname) + { +- return hostapd_if_add(hapd, WPA_IF_AP_VLAN, ifname, NULL, NULL); ++ return hostapd_if_add(hapd, WPA_IF_AP_VLAN, ifname, NULL, NULL, ++ &hapd->drv_priv); + } + + static int hostapd_vlan_if_remove(struct hostapd_data *hapd, +@@ -407,12 +408,13 @@ int hostapd_set_ssid(struct hostapd_data + + + int hostapd_if_add(struct hostapd_data *hapd, enum wpa_driver_if_type type, +- const char *ifname, const u8 *addr, void *bss_ctx) ++ const char *ifname, const u8 *addr, void *bss_ctx, ++ void **drv_priv) + { + if (hapd->driver == NULL || hapd->driver->if_add == NULL) + return -1; + return hapd->driver->if_add(hapd->conf->iface, hapd->drv_priv, type, +- ifname, addr, bss_ctx); ++ ifname, addr, bss_ctx, drv_priv); + } + + +--- a/src/ap/ap_drv_ops.h ++++ b/src/ap/ap_drv_ops.h +@@ -26,7 +26,8 @@ int hostapd_set_generic_elem(struct host + int hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len); + int hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len); + int hostapd_if_add(struct hostapd_data *hapd, enum wpa_driver_if_type type, +- const char *ifname, const u8 *addr, void *bss_ctx); ++ const char *ifname, const u8 *addr, void *bss_ctx, ++ void **drv_priv); + int hostapd_if_remove(struct hostapd_data *hapd, enum wpa_driver_if_type type, + const char *ifname); + int hostapd_set_ieee8021x(struct hostapd_data *hapd, +--- a/src/ap/hostapd.c ++++ b/src/ap/hostapd.c +@@ -484,7 +484,8 @@ static int hostapd_setup_bss(struct host + + hapd->interface_added = 1; + if (hostapd_if_add(hapd->iface->bss[0], WPA_IF_AP_BSS, +- hapd->conf->iface, hapd->own_addr, hapd)) { ++ hapd->conf->iface, hapd->own_addr, hapd, ++ &hapd->drv_priv)) { + wpa_printf(MSG_ERROR, "Failed to add BSS (BSSID=" + MACSTR ")", MAC2STR(hapd->own_addr)); + return -1; diff --git a/package/hostapd/patches/160-sta_roam_between_bss.patch b/package/hostapd/patches/160-sta_roam_between_bss.patch new file mode 100644 index 000000000..dfd5fd88c --- /dev/null +++ b/package/hostapd/patches/160-sta_roam_between_bss.patch @@ -0,0 +1,79 @@ +--- a/src/ap/sta_info.c ++++ b/src/ap/sta_info.c +@@ -32,8 +32,8 @@ + #include "vlan_init.h" + #include "sta_info.h" + +-static int ap_sta_in_other_bss(struct hostapd_data *hapd, +- struct sta_info *sta, u32 flags); ++static void ap_sta_remove_in_other_bss(struct hostapd_data *hapd, ++ struct sta_info *sta); + static void ap_handle_session_timer(void *eloop_ctx, void *timeout_ctx); + #ifdef CONFIG_IEEE80211W + static void ap_sa_query_timer(void *eloop_ctx, void *timeout_ctx); +@@ -123,8 +123,8 @@ void ap_free_sta(struct hostapd_data *ha + + if (sta->flags & WLAN_STA_WDS) + hapd->drv.set_wds_sta(hapd, sta->addr, sta->aid, 0); +- if (!ap_sta_in_other_bss(hapd, sta, WLAN_STA_ASSOC) && +- !(sta->flags & WLAN_STA_PREAUTH)) ++ ++ if (!(sta->flags & WLAN_STA_PREAUTH)) + hapd->drv.sta_remove(hapd, sta->addr); + + ap_sta_hash_del(hapd, sta); +@@ -451,6 +451,7 @@ struct sta_info * ap_sta_add(struct host + hapd->num_sta++; + ap_sta_hash_add(hapd, sta); + sta->ssid = &hapd->conf->ssid; ++ ap_sta_remove_in_other_bss(hapd, sta); + + return sta; + } +@@ -472,8 +473,8 @@ static int ap_sta_remove(struct hostapd_ + } + + +-static int ap_sta_in_other_bss(struct hostapd_data *hapd, +- struct sta_info *sta, u32 flags) ++static void ap_sta_remove_in_other_bss(struct hostapd_data *hapd, ++ struct sta_info *sta) + { + struct hostapd_iface *iface = hapd->iface; + size_t i; +@@ -488,11 +489,11 @@ static int ap_sta_in_other_bss(struct ho + if (bss == hapd || bss == NULL) + continue; + sta2 = ap_get_sta(bss, sta->addr); +- if (sta2 && ((sta2->flags & flags) == flags)) +- return 1; +- } ++ if (!sta2) ++ continue; + +- return 0; ++ ap_sta_disconnect(bss, sta2, sta2->addr, WLAN_REASON_DEAUTH_LEAVING); ++ } + } + + +@@ -502,8 +503,7 @@ void ap_sta_disassociate(struct hostapd_ + wpa_printf(MSG_DEBUG, "%s: disassociate STA " MACSTR, + hapd->conf->iface, MAC2STR(sta->addr)); + sta->flags &= ~WLAN_STA_ASSOC; +- if (!ap_sta_in_other_bss(hapd, sta, WLAN_STA_ASSOC)) +- ap_sta_remove(hapd, sta); ++ ap_sta_remove(hapd, sta); + sta->timeout_next = STA_DEAUTH; + eloop_cancel_timeout(ap_handle_timer, hapd, sta); + eloop_register_timeout(AP_MAX_INACTIVITY_AFTER_DISASSOC, 0, +@@ -521,8 +521,7 @@ void ap_sta_deauthenticate(struct hostap + wpa_printf(MSG_DEBUG, "%s: deauthenticate STA " MACSTR, + hapd->conf->iface, MAC2STR(sta->addr)); + sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC); +- if (!ap_sta_in_other_bss(hapd, sta, WLAN_STA_ASSOC)) +- ap_sta_remove(hapd, sta); ++ ap_sta_remove(hapd, sta); + sta->timeout_next = STA_REMOVE; + eloop_cancel_timeout(ap_handle_timer, hapd, sta); + eloop_register_timeout(AP_MAX_INACTIVITY_AFTER_DEAUTH, 0, From 2eb1c2d1df2f93d1722ddee225a21561c689f689 Mon Sep 17 00:00:00 2001 From: nbd Date: Wed, 20 Jan 2010 02:26:05 +0000 Subject: [PATCH 083/210] mac80211: restructure /lib/wifi/mac80211.sh use the new multi-bss single instance hostapd mode move mac80211 specific bits out of /lib/wifi/hostapd.sh add a new option 'htmode' for switching between HT20 and HT40+,HT40- git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19235 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/hostapd/files/hostapd.sh | 142 +++++--------- package/mac80211/files/lib/wifi/mac80211.sh | 195 ++++++++++++++++---- 2 files changed, 209 insertions(+), 128 deletions(-) diff --git a/package/hostapd/files/hostapd.sh b/package/hostapd/files/hostapd.sh index 740155725..9ee7657e2 100644 --- a/package/hostapd/files/hostapd.sh +++ b/package/hostapd/files/hostapd.sh @@ -1,7 +1,10 @@ -hostapd_setup_vif() { - local vif="$1" - local driver="$2" - local hostapd_cfg= +hostapd_set_bss_options() { + local var="$1" + local vif="$2" + local enc wpa_group_rekey + + config_get enc "$vif" encryption + config_get wpa_group_rekey "$vif" wpa_group_rekey # Examples: # psk-mixed/tkip => WPA1+2 PSK, TKIP @@ -14,7 +17,7 @@ hostapd_setup_vif() { # crypto defaults: WPA2 vs WPA1 case "$enc" in - wpa2*|WPA2*|*PSK2*|*psk2*) + wpa2*|*psk2*) wpa=2 crypto="CCMP" ;; @@ -30,137 +33,82 @@ hostapd_setup_vif() { # explicit override for crypto setting case "$enc" in - *tkip+aes|*TKIP+AES|*tkip+ccmp|*TKIP+CCMP) crypto="CCMP TKIP";; - *tkip|*TKIP) crypto="TKIP";; - *aes|*AES|*ccmp|*CCMP) crypto="CCMP";; + *tkip+aes|*tkip+ccmp) crypto="CCMP TKIP";; + *aes|*ccmp) crypto="CCMP";; + *tkip) crypto="TKIP";; esac # use crypto/auth settings for building the hostapd config case "$enc" in - *psk*|*PSK*) + *psk*) config_get psk "$vif" key if [ ${#psk} -eq 64 ]; then - append hostapd_cfg "wpa_psk=$psk" "$N" + append "$var" "wpa_psk=$psk" "$N" else - append hostapd_cfg "wpa_passphrase=$psk" "$N" + append "$var" "wpa_passphrase=$psk" "$N" fi ;; - *wpa*|*WPA*) + *wpa*) # required fields? formats? # hostapd is particular, maybe a default configuration for failures config_get server "$vif" server - append hostapd_cfg "auth_server_addr=$server" "$N" + append "$var" "auth_server_addr=$server" "$N" config_get port "$vif" port port=${port:-1812} - append hostapd_cfg "auth_server_port=$port" "$N" + append "$var" "auth_server_port=$port" "$N" config_get secret "$vif" key - append hostapd_cfg "auth_server_shared_secret=$secret" "$N" + append "$var" "auth_server_shared_secret=$secret" "$N" config_get nasid "$vif" nasid - append hostapd_cfg "nas_identifier=$nasid" "$N" - append hostapd_cfg "eapol_key_index_workaround=1" "$N" - append hostapd_cfg "radius_acct_interim_interval=300" "$N" - append hostapd_cfg "ieee8021x=1" "$N" - append hostapd_cfg "auth_algs=1" "$N" - append hostapd_cfg "wpa_key_mgmt=WPA-EAP" "$N" - append hostapd_cfg "wpa_group_rekey=300" "$N" - append hostapd_cfg "wpa_gmk_rekey=640" "$N" + append "$var" "nas_identifier=$nasid" "$N" + append "$var" "eapol_key_index_workaround=1" "$N" + append "$var" "radius_acct_interim_interval=300" "$N" + append "$var" "ieee8021x=1" "$N" + append "$var" "auth_algs=1" "$N" + append "$var" "wpa_key_mgmt=WPA-EAP" "$N" + append "$var" "wpa_group_rekey=300" "$N" + append "$var" "wpa_gmk_rekey=640" "$N" ;; *) wpa=0 crypto= ;; esac - config_get ifname "$vif" ifname - config_get bridge "$vif" bridge + append "$var" "wpa=$wpa" "$N" + [ -n "$crypto" ] && append "$var" "wpa_pairwise=$crypto" "$N" + [ -n "$wpa_group_rekey" ] && append "$var" "wpa_group_rekey=$wpa_group_rekey" "$N" + config_get ssid "$vif" ssid + config_get bridge "$vif" bridge + config_get ieee80211d "$vif" ieee80211d + + append "$var" "ssid=$ssid" "$N" + [ -n "$bridge" ] && append "$var" "bridge=$bridge" "$N" + [ -n "$ieee80211d" ] && append "$var" "ieee80211d=$ieee80211d" "$N" +} + +hostapd_setup_vif() { + local vif="$1" + local driver="$2" + hostapd_cfg= + + hostapd_set_bss_options hostapd_cfg "$vif" + config_get ifname "$vif" ifname config_get device "$vif" device config_get channel "$device" channel config_get hwmode "$device" hwmode - config_get wpa_group_rekey "$vif" wpa_group_rekey - config_get ieee80211d "$vif" ieee80211d - config_get_bool hidden "$vif" hidden 0 - config_get_bool wds "$vif" wds 0 - [ "$wds" -gt 0 -a "$driver" = "nl80211" ] && wds="wds_sta=1" || wds="" case "$hwmode" in bg) hwmode=g;; esac - config_get country "$device" country [ "$channel" = auto ] && channel= [ -n "$channel" -a -z "$hwmode" ] && wifi_fixup_hwmode "$device" - [ -n "$hwmode" ] && { - config_get hwmode_11n "$device" hwmode_11n - [ -n "$hwmode_11n" ] && { - hwmode="$hwmode_11n" - config_get ht_capab "$device" ht_capab - [ -n "$ht_capab" -a -n "${ht_capab%%\[*}" ] && { - ht_capab=`echo "[$ht_capab]" | sed -e 's, ,][,g'` - } - } - } cat > /var/run/hostapd-$ifname.conf <> /var/run/hostapd-$ifname.conf < "$cfgfile" <