Initial Contribution

msm-2.6.38: tag AU_LINUX_ANDROID_GINGERBREAD.02.03.04.00.142

Signed-off-by: Bryan Huntsman <bryanh@codeaurora.org>
diff --git a/chromeos/scripts/allconfigs b/chromeos/scripts/allconfigs
new file mode 100755
index 0000000..1643199
--- /dev/null
+++ b/chromeos/scripts/allconfigs
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+bindir="`pwd`/chromeos/scripts"
+confdir="`pwd`/chromeos/config"
+
+get_flavourconfigs() {
+    for file in `find $confdir`; do
+	if echo $file | egrep -q "config\.flavour\..*[^~]$"; then
+            basename $file | awk -F . '{ print $3 }'
+        fi
+    done
+}
+
+get_arch() {
+    if find . -name config.flavour.$1 | grep -q i386; then
+        echo i386
+    else
+        echo arm
+    fi
+}
+
+for flavour in $(get_flavourconfigs); do
+    echo $flavour $(get_arch $flavour)
+    $bindir/prepareconfig $flavour
+    yes "" | make ARCH=$(get_arch $flavour) oldconfig
+    cp .config .config-$flavour
+done
+
diff --git a/chromeos/scripts/compat_wireless_config b/chromeos/scripts/compat_wireless_config
new file mode 100755
index 0000000..22cbd9c
--- /dev/null
+++ b/chromeos/scripts/compat_wireless_config
@@ -0,0 +1,120 @@
+# /bin/sh
+
+# Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
+# Distributed under the terms of the GNU General Public License v2
+
+#
+# Helper script to setup compat-wireless configuration.
+#
+
+S=${1:?No kernel source directory specified}
+
+COMPAT_WIRELESS="${S}"/chromeos/compat-wireless
+COMPAT_VERSION=`cat ${COMPAT_WIRELESS}/compat_version`
+COMPAT_RELEASE=`cat ${COMPAT_WIRELESS}/compat_version`
+COMPAT_BASE_TREE=`cat ${COMPAT_WIRELESS}/compat_base_tree`
+COMPAT_BASE_TREE_VERSION=`cat ${COMPAT_WIRELESS}/compat_base_tree_version`
+# TODO(sleffler) calculate CONFIG_COMPAT_KERNEL version
+
+COMPAT_CONFIG='
+	CONFIG_COMPAT_KERNEL_33=y
+	CONFIG_COMPAT_FIRMWARE_CLASS=m
+
+	CONFIG_COMPAT_RFKILL=y
+	CONFIG_RFKILL_BACKPORT=y
+	CONFIG_RFKILL_BACKPORT_INPUT=y
+
+	CONFIG_COMPAT_WIRELESS=m
+	CONFIG_COMPAT_WIRELESS_MODULES=m
+
+	CONFIG_MAC80211=m
+	CONFIG_MAC80211_LEDS=y
+	CONFIG_MAC80211_DEBUGFS=y
+	CONFIG_MAC80211_RC_MINSTREL=y
+	CONFIG_MAC80211_RC_DEFAULT="minstrel"
+	CONFIG_COMPAT_MAC80211_RC_DEFAULT="minstrel"
+
+	CONFIG_CFG80211=m
+	CONFIG_CFG80211_DEBUGFS=y
+	CONFIG_CFG80211_DEFAULT_PS=y
+	CONFIG_CFG80211_WEXT=y
+
+	CONFIG_ATH=y
+	CONFIG_ATH_COMMON=m
+	CONFIG_ATH_DEBUG=y
+	CONFIG_ATH5K=m
+	CONFIG_ATH9K=m
+	CONFIG_ATH9K_HW=m
+	CONFIG_ATH9K_COMMON=m
+	CONFIG_ATH9K_DEBUGFS=y
+
+	CONFIG_IWLWIFI=m
+	CONFIG_IWLWIFI_SPECTRUM_MANAGEMENT=y
+	CONFIG_IWLAGN=m
+	CONFIG_COMPAT_IWL4965=y
+	CONFIG_IWL5000=y
+	CONFIG_IWL3945=m
+	CONFIG_IWL3945_SPECTRUM_MANAGEMENT=y
+	CONFIG_IWLWIFI_DEBUG=y
+	CONFIG_IWLWIFI_DEBUGFS=y
+
+	CONFIG_USB_NET_COMPAT_CDCETHER=m
+	CONFIG_USB_NET_COMPAT_RNDIS_HOST=m
+	CONFIG_USB_COMPAT_USBNET=m
+'
+echo "Configure compat-wireless: ${COMPAT_CONFIG}"
+
+#
+# Edit Makefiles to reflect configuration knobs
+#
+SED_ARGS=
+for c in $COMPAT_CONFIG; do
+	a=`echo $c | sed s/=.*//`
+	b=`echo $c | sed s/.*=//`
+	SED_ARGS="$SED_ARGS -e s/[\$]("$a")/"$b"/"
+done
+
+Makefiles=`find -L "${COMPAT_WIRELESS}" -name Makefile`
+for m in $Makefiles; do
+	sed $SED_ARGS -i $m
+done
+
+# Construct include/linux/compat_autoconf.h
+(cat<<EOF
+#ifndef COMPAT_AUTOCONF_INCLUDED
+#define COMPAT_AUTOCONF_INCLUDED
+/*
+* Automatically generated by chromeos-base/kernel/kernel-*.ebuild
+* compat-wireless-2.6: $COMPAT_VERSION
+* linux-2.6: v2.6.32
+*/
+#define COMPAT_BASE_TREE "$COMPAT_BASE_TREE"
+#define COMPAT_BASE_TREE_VERSION "$COMPAT_BASE_TREE_VERSION"
+#define COMPAT_PROJECT "Compat-wireless"
+#define COMPAT_VERSION "$COMPAT_VERSION"
+
+#ifndef CONFIG_WIRELESS_EXT
+#error Compat-wireless requirement: CONFIG_WIRELESS_EXT must be enabled in your kernel
+#endif /* CONFIG_WIRELESS_EXT */
+EOF
+ for c in $COMPAT_CONFIG; do
+	a=`echo $c | sed s/=.*//`
+	b=`echo $c | sed s/.*=//`
+	case $b in
+	m|y)
+	    echo "#define $a 1";;
+	*)
+	    echo "#define $a $b";;
+	esac
+ done
+ cat<<'EOF'
+#ifdef CONFIG_NET_SCHED
+#ifdef CONFIG_NETDEVICES_MULTIQUEUE
+#ifndef CONFIG_MAC80211_QOS
+#define CONFIG_MAC80211_QOS 1
+#endif /* CONFIG_MAC80211_QOS */
+#endif
+#endif
+#endif /* COMPAT_AUTOCONF_INCLUDED */
+EOF
+)>"${COMPAT_WIRELESS}"/include/linux/compat_autoconf.h
diff --git a/chromeos/scripts/kernelconfig b/chromeos/scripts/kernelconfig
new file mode 100755
index 0000000..c056c8c
--- /dev/null
+++ b/chromeos/scripts/kernelconfig
@@ -0,0 +1,123 @@
+#!/bin/bash
+
+# Script to merge all configs and run 'make silentoldconfig' on it to wade out bad juju.
+# Then split the configs into distro-commmon and flavour-specific parts
+
+# We have to be in the top level kernel source directory
+if [ ! -f MAINTAINERS ] || [ ! -f Makefile ]; then
+	echo "This does not appear to be the kernel source directory." 1>&2
+	exit 1
+fi
+
+mode=${1:?"Usage: $0 [oldconfig|editconfig]"}
+case "$mode" in
+    oldconfig)  ;; # All is good
+    editconfig) ;; # All is good
+    genconfig)  ;; # All is good
+    *) echo "$0 called with invalid mode" 1>&2
+       exit 1 ;;
+esac
+kerneldir="`pwd`"
+confdir="$kerneldir/chromeos/config"
+archs="x86_64 i386 armel"
+family='chromeos'
+bindir="`pwd`/chromeos/scripts"
+common_conf="$confdir/config.common.$family"
+tmpdir=`mktemp -d`
+
+if [ "$mode" = "genconfig" ]; then
+	keep=1
+	mode="oldconfig"
+	test -d CONFIGS || mkdir CONFIGS
+fi
+
+test -d build || mkdir build
+
+for arch in $archs; do
+	# Map debian archs to kernel archs
+	case "$arch" in
+		amd64)	kernarch="x86_64"	;;
+		lpia)   kernarch="x86" ;;
+		sparc)	kernarch="sparc64"	;;
+		armel)  kernarch="arm" ;;
+		*)	kernarch="$arch"	;;
+	esac
+
+	echo ""
+	echo "***************************************"
+	echo "* Processing $arch ($kernarch) ... "
+	archconfdir=$confdir/$arch
+	flavourconfigs=$(cd $archconfdir && ls config.flavour.*[^~])
+
+	# Merge configs
+	# We merge config.common.ubuntu + config.common.<arch> +
+	# config.flavour.<flavour>
+
+	for config in $flavourconfigs; do
+		fullconf="$tmpdir/$arch-$config-full"
+		case $config in
+		*)
+			: >"$fullconf"
+			if [ -f $common_conf ]; then
+				cat $common_conf >> "$fullconf"
+			fi
+			if [ -f $archconfdir/config.common.$arch ]; then
+				cat $archconfdir/config.common.$arch >> "$fullconf"
+			fi
+			cat "$archconfdir/$config" >>"$fullconf"
+			;;
+		esac
+	done
+
+	for config in $flavourconfigs; do
+		if [ -f $archconfdir/$config ]; then
+			fullconf="$tmpdir/$arch-$config-full"
+			cat "$fullconf" > build/.config
+			# Call oldconfig or menuconfig
+			case "$mode" in
+			    oldconfig)
+				# Weed out incorrect config parameters
+				echo "* Run silentoldconfig on $arch/$config ..."
+				make O=`pwd`/build ARCH=$kernarch silentoldconfig ;;
+			    editconfig)
+				# Interactively edit config parameters
+				echo " * Run menuconfig on $arch/$config... Press a key."
+				read
+				make O=`pwd`/build ARCH=$kernarch menuconfig ;;
+			    *)  # Bad!
+				exit 1 ;;
+			esac
+			cat build/.config > $archconfdir/$config
+			if [ "$keep" = "1" ]; then
+				cat build/.config > CONFIGS/$arch-$config
+			fi
+		else
+			echo "!! Config not found $archconfdir/$config..."
+		fi
+	done
+
+	echo "Running splitconfig for $arch"
+	echo
+
+	# Can we make this more robust by avoiding $tmpdir completely?
+	# This approach was used for now because I didn't want to change
+	# splitconfig
+	(cd $archconfdir; rm config.common.$arch; $bindir/splitconfig; \
+	    mv config.common config.common.$arch; \
+	    cp config.common.$arch $tmpdir)
+done
+
+rm -f $common_conf
+
+# Now run splitconfig on all the config.common.<arch> copied to
+# $tmpdir
+(cd $tmpdir; $bindir/splitconfig)
+(
+	cd $confdir;
+	rm -f *-full
+	grep -v 'is UNMERGABLE' <$tmpdir/config.common >$common_conf
+	for arch in $archs; do
+		grep -v 'is UNMERGABLE' <$tmpdir/config.common.$arch \
+			>$arch/config.common.$arch
+	done
+)
diff --git a/chromeos/scripts/prepareconfig b/chromeos/scripts/prepareconfig
new file mode 100755
index 0000000..b841366
--- /dev/null
+++ b/chromeos/scripts/prepareconfig
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+family=chromeos
+
+# The source package name will be the first token in the changelog
+changelog="${family}/changelog"
+package=$(sed -n '1s/\([^ ]*\).*/\1/p' ${changelog})
+
+# Get some version info
+release=$(sed -n "1s/^${package} (\([^-]*\)-.*/\1/p" ${changelog})
+revision=$(sed -n "1s/^${package} (${release}-\([^)]*\).*/\1/p" ${changelog})
+
+flavourconf=$(find ${family} -name config.flavour.$1)
+archconfdir=$(dirname ${flavourconf})
+version="Ubuntu ${release}-${revision}-$1"
+re="s/.*\(CONFIG_VERSION_SIGNATURE\).*/\1=""\"${version}\"""/"
+
+# Generarte .config
+cat ${family}/config/config.common.${family} \
+    ${archconfdir}/config.common.* \
+    ${flavourconf} | sed -e "${re}" > .config
diff --git a/chromeos/scripts/splitconfig b/chromeos/scripts/splitconfig
new file mode 100755
index 0000000..262fa20
--- /dev/null
+++ b/chromeos/scripts/splitconfig
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+
+import os
+import re
+import sys
+
+allconfigs = {}
+
+# Parse config files
+for config in os.listdir("."):
+    # Only config.*
+    if not config.startswith("config."):
+        continue
+    # Ignore emacs backups
+    if config.endswith("~"):
+        continue
+    # Nothing that is disabled, or remnant
+    if re.search("\.(default|disabled|stub)$", config):
+        continue
+
+    allconfigs[config] = set()
+
+    for line in open(config):
+        m = re.match("#*\s*CONFIG_(\w+)[\s=](.*)$", line)
+        if not m:
+            continue
+        option, value = m.groups()
+        allconfigs[config].add((option, value))
+
+# Split out common config options
+common = allconfigs.values()[0].copy()
+for config in allconfigs.keys():
+    common &= allconfigs[config]
+for config in allconfigs.keys():
+    allconfigs[config] -= common
+allconfigs["config.common"] = common
+
+# Generate new splitconfigs
+for config in allconfigs.keys():
+    f = open(config, "w")
+    command = os.path.basename(sys.argv[0])
+    print >>f, "#\n# Config options generated by %s\n#" % command
+    for option, value in sorted(list(allconfigs[config])):
+        if value == "is not set":
+            print >>f, "# CONFIG_%s %s" % (option, value)
+        else:
+            print >>f, "CONFIG_%s=%s" % (option, value)
+
+    f.close()