1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2025-04-21 12:27:27 +03:00

add preinit modularization work by Daniel Dickinson (cshore)

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19331 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
nbd
2010-01-25 17:11:17 +00:00
parent 99c311e86c
commit a9929695c6
79 changed files with 1449 additions and 438 deletions

View File

@@ -1,16 +0,0 @@
. /etc/functions.sh
insmod input-core
insmod input-polldev
insmod gpio_buttons
insmod button-hotplug
ifname=eth0
failsafe_ip
netmsg 192.168.1.255 "Press reset now, to enter Failsafe!"
ifconfig "$ifname" 0.0.0.0 down
sleep 2

View File

@@ -0,0 +1,12 @@
#!/bin/sh
enable_leds() {
insmod input-core
insmod input-polldev
insmod gpio_buttons
insmod button-hotplug
}
boot_hook_add preinit_main enable_leds

View File

@@ -0,0 +1,9 @@
#!/bin/sh
set_preinit_ifname() {
ifname=eth0
}
boot_hook_add preinit_main set_preinit_ifname

View File

@@ -0,0 +1,16 @@
#
# Copyright (C) 2009 OpenWrt.org
#
. /lib/ar71xx.sh
preinit_enable_leds() {
insmod input-core
insmod input-polldev
insmod gpio_buttons
insmod button-hotplug
}
boot_hook_add preinit_main preinit_enable_leds

View File

@@ -20,13 +20,6 @@ fetch_mac_from_mtd() {
[ ! -z $mac ] && ifconfig eth1 hw ether $mac 2>/dev/null
}
preinit_load_modules() {
insmod input-core
insmod input-polldev
insmod gpio_buttons
insmod button-hotplug
}
preinit_set_mac_address() {
case $(ar71xx_board_name) in
tew-632brp)
@@ -42,15 +35,5 @@ preinit_set_mac_address() {
esac
}
preinit_set_mac_address
preinit_load_modules
boot_hook_add preinit_main preinit_set_mac_address
ifname=eth0
failsafe_ip
netmsg 192.168.1.255 "Press any button now, to enter Failsafe!"
ifconfig "$ifname" 0.0.0.0 down
sleep 2

View File

@@ -0,0 +1,16 @@
#!/bin/sh
#
# Copyright (C) 2009 OpenWrt.org
#
. /lib/ar71xx.sh
set_preinit_iface() {
ifname=eth0
}
boot_hook_add preinit_main set_preinit_iface

View File

@@ -1,21 +0,0 @@
# reset button only supported on ar5315+ at the moment
grep 'Atheros AR231[567]' /proc/cpuinfo > /dev/null && {
if [ -e "/sys/bus/mdio_bus/drivers/Infineon ADM6996/0:00" -o \
-e "/sys/bus/mdio_bus/drivers/Marvell 88E6060/0:10" ]; then
vconfig set_name_type DEV_PLUS_VID_NO_PAD
ifconfig eth0 up
vconfig add eth0 1
ifname=eth0.1
else
ifname=eth0
fi
failsafe_ip
netmsg 192.168.1.255 "Press reset now, to enter Failsafe!"
sleep 2
if [ -z "$FAILSAFE" -a \
\( -e "/sys/bus/mdio_bus/drivers/Infineon ADM6996/0:00" -o \
-e "/sys/bus/mdio_bus/drivers/Marvell 88E6060/0:10" \) ]; then
vconfig rem eth0.1
ifconfig eth0 down
fi
}

View File

@@ -0,0 +1,32 @@
#!/bin/sh
# reset button only supported on ar5315+ at the moment
preinit_ip() {
if [ -z "$pi_ifname" ]; then
grep 'Atheros AR231[567]' /proc/cpuinfo > /dev/null && {
if [ -e "/sys/bus/mdio_bus/drivers/Infineon ADM6996/0:00" -o \
-e "/sys/bus/mdio_bus/drivers/Marvell 88E6060/0:10" ]; then
vconfig set_name_type DEV_PLUS_VID_NO_PAD
ifconfig eth0 up
vconfig add eth0 1
ifname=eth0.1
else
ifname=eth0
fi
pi_ifname=$ifname
}
[ -n "$pi_ifname" ] && grep "$pi_ifname" /proc/net/dev >/dev/null && {
ifconfig $pi_ifname $pi_ip netmask $pi_netmask broadcast $pi_broadcast up
}
}
# reset button only supported on ar5315+ at the moment
preinit_ip_deconfig() {
if [ -e "/sys/bus/mdio_bus/drivers/Infineon ADM6996/0:00" -o \
-e "/sys/bus/mdio_bus/drivers/Marvell 88E6060/0:10" ]; then
vconfig rem eth0.1 2>/dev/null
ifconfig $pi_ifname down
fi
}

View File

@@ -1,71 +0,0 @@
. /etc/functions.sh
failsafe() {
lock /tmp/.failsafe
failsafe_ip
echo "0 1 2 3 4 ${cpu_port:-5u*}" > /proc/switch/eth0/vlan/0/ports
set_state failsafe
[ -x "/usr/sbin/nvram" ] && {
[ "$(nvram get boot_wait)" != "on" ] && {
nvram set boot_wait=on
nvram commit
}
}
netmsg 192.168.1.255 "Entering Failsafe!"
telnetd -l /bin/login.sh <> /dev/null 2>&1
ash --login
}
mount none /proc -t proc
insmod diag
set_state preinit
echo '/sbin/hotplug.failsafe' > /proc/sys/kernel/hotplug
ifname=eth0
# hardware specific overrides
case "$(cat /proc/diag/model)" in
"Linksys WAP54G V1") ifname=eth1;;
"ASUS WL-HDD") ifname=eth1;;
"ASUS WL-300g") ifname=eth1;;
"ASUS (unknown, BCM4702)") ifname=eth1;;
"Sitecom WL-105b") ifname=eth1;;
esac
check_module () {
module="$1"; shift; params="$*"
insmod "$module" "$params"
sleep 1
grep "^$module" /proc/modules
return $?
}
check_module tg3
failsafe_ip
insmod switch-core
check_module switch-robo || check_module switch-adm || {
check_module bcm57xx activate_gpio=0x4 && cpu_port="8u*"
} || rmmod switch-core
[ -d /proc/switch/eth0 ] && {
echo 1 > /proc/switch/eth0/reset
# this would be easier if we blasted the message across all ports
# but we don't want packets leaking across interfaces
for port in $(seq 0 4); do {
echo "$port ${cpu_port:-5u*}" > /proc/switch/eth0/vlan/0/ports
netmsg 192.168.1.255 "Press reset now, to enter Failsafe!"
}; done
} || netmsg 192.168.1.255 "Press reset now, to enter Failsafe!"
ifconfig $ifname 0.0.0.0 down
sleep 2

View File

@@ -0,0 +1,9 @@
#!/bin/sh
init_hotplug_failsafe() {
echo '/sbin/hotplug.failsafe' > /proc/sys/kernel/hotplug
}
boot_hook_add preinit_main init_hotplug_failsafe

View File

@@ -0,0 +1,38 @@
#!/bin/sh
set_preinit_iface() {
ifname=eth0
insmod diag
# hardware specific overrides
case "$(cat /proc/diag/model)" in
"Linksys WAP54G V1") ifname=eth1;;
"ASUS WL-HDD") ifname=eth1;;
"ASUS WL-300g") ifname=eth1;;
"ASUS (unknown, BCM4702)") ifname=eth1;;
"Sitecom WL-105b") ifname=eth1;;
esac
}
check_module () {
module="$1"; shift; params="$*"
insmod "$module" "$params"
sleep 1
grep "^$module" /proc/modules
return $?
}
init_iface() {
check_module tg3
insmod switch-core
check_module switch-robo || check_module switch-adm || {
check_module bcm57xx activate_gpio=0x4 && cpu_port="8u*"
} || rmmod switch-core
}
boot_hook_add preinit_main init_iface
boot_hook_add preinit_main set_preinit_iface

View File

@@ -0,0 +1,15 @@
#!/bin/sh
failsafe_ip() {
[ -d /proc/switch/eth0 ] && [ "$ifname" = "eth0" ] && {
ifconfig eth0 0.0.0.0 down
echo "0 1 2 3 4 ${cpu_port:-5u*}" > /proc/switch/eth0/vlan/0/ports
}
[ -n "$pi_ifname" ] && grep "$pi_ifname" /proc/net/dev >/dev/null && {
ifconfig $pi_ifname $pi_ip netmask $pi_netmask broadcast $pi_broadcast up
}
}
boot_hook_add failsafe failsafe_ip

View File

@@ -0,0 +1,6 @@
#!/bin/sh
do_mount_procfs() {
mount none /proc -t proc
}

View File

@@ -0,0 +1,38 @@
. /etc/functions.sh
port_net_echo() {
[ -n "$pi_ifname" ] && grep "$pi_ifname" /proc/net/dev >/dev/null ] {
if [ "$pi_preinit_net_messages" = "y" ] || [ "$pi_failsafe_net_message" = "true"] && [ "$pi_preinit_no_failsafe_netmsg" != "y" ]; then
netmsg $pi_broadcast "$1"
}
}
}
preinit_ip_deconfig() {
if [ -z "$pi_ifname" ]; then
ifconfig $ifname 0.0.0.0 down
else
grep "$pi_ifname" /proc/net/dev >/dev/null && {
ifconfig $pi_ifname 0.0.0.0 down
}
fi
}
preinit_net_echo() {
preinit_ip
[ -d /proc/switch/eth0 ] && [ "$pi_ifname" = "eth0" ] && {
echo 1 > /proc/switch/eth0/reset
# this would be easier if we blasted the message across all ports
# but we don't want packets leaking across interfaces
for port in $(seq 0 4); do {
echo "$port ${cpu_port:-5u*}" > /proc/switch/eth0/vlan/0/ports
port_net_echo $1
}; done
} || port_net_echo $1
preinit_ip_deconfig
}

View File

@@ -0,0 +1,14 @@
#!/bin/sh
. /etc/functions.sh
set_boot_wait() {
[ -x "/usr/sbin/nvram" ] && {
[ "$(nvram get boot_wait)" != "on" ] && {
nvram set boot_wait=on
nvram commit
}
}
}
boot_hook_add failsafe set_boot_wait

View File

@@ -1,6 +0,0 @@
CONFIG_PARTITION="$(grep "VCTL" /proc/mtd | cut -d: -f1)"
MAC1="$(strings /dev/$CONFIG_PARTITION |grep MAC|cut -d: -f2|cut -c3-14|sed -e 's,\(..\),:\1,g' -e 's,^:,,')"
MAC2="$(strings /dev/$CONFIG_PARTITION |grep MAC|cut -d: -f8|cut -c3-14|sed -e 's,\(..\),:\1,g' -e 's,^:,,')"
ifconfig eth0 hw ether $MAC1 2>/dev/null
ifconfig eth1 hw ether $MAC2 2>/dev/null

View File

@@ -0,0 +1,13 @@
#!/bin/sh
set_ether_mac() {
CONFIG_PARTITION="$(grep "VCTL" /proc/mtd | cut -d: -f1)"
MAC1="$(strings /dev/$CONFIG_PARTITION |grep MAC|cut -d: -f2|cut -c3-14|sed -e 's,\(..\),:\1,g' -e 's,^:,,')"
MAC2="$(strings /dev/$CONFIG_PARTITION |grep MAC|cut -d: -f8|cut -c3-14|sed -e 's,\(..\),:\1,g' -e 's,^:,,')"
ifconfig eth0 hw ether $MAC1 2>/dev/null
ifconfig eth1 hw ether $MAC2 2>/dev/null
}
boot_hook_add preinit_main set_ether_mac

View File

@@ -1,5 +0,0 @@
grep "/dev/root" /proc/mounts |grep -q nfs && {
echo "- init nfs -"
exec /sbin/init
}

View File

@@ -0,0 +1,12 @@
#!/bin/sh
init_nfs() {
grep "/dev/root" /proc/mounts |grep -q nfs && {
echo "- init nfs -"
exec /sbin/init
}
}
boot_hook_add preinit_main init_nfs

View File

@@ -1,15 +0,0 @@
RB_CONFIG="$(grep "RedBoot config" /proc/mtd | cut -d: -f1)"
for npe in eth0 eth1 eth2
do
if [ "$(ifconfig $npe 2>/dev/null | grep -c 00:00:00:00:00:00)" == "1" ]; then
ifconfig $npe hw ether $(fconfig -s -r -d /dev/$RB_CONFIG -n npe_"$npe"_esa)
fi
done
# Some developers should be shot on sight at Zcom/Netgear
# -- Fixup for the WG302v1, need someone with a WAG302v1 to fix that, too
if [ "$(ifconfig eth0 2>/dev/null | grep -c 00:00:00:00:00:00)" == "1" ]; then
ifconfig eth0 hw ether $(fconfig -s -r -d /dev/$RB_CONFIG -n zcom_npe_esa)
fi

View File

@@ -0,0 +1,23 @@
#!/bin/sh
set_ether_mac() {
RB_CONFIG="$(grep "RedBoot config" /proc/mtd | cut -d: -f1)"
for npe in eth0 eth1 eth2
do
if [ "$(ifconfig $npe 2>/dev/null | grep -c 00:00:00:00:00:00)" == "1" ]; then
ifconfig $npe hw ether $(fconfig -s -r -d /dev/$RB_CONFIG -n npe_"$npe"_esa)
fi
done
# Some developers should be shot on sight at Zcom/Netgear
# -- Fixup for the WG302v1, need someone with a WAG302v1 to fix that, too
if [ "$(ifconfig eth0 2>/dev/null | grep -c 00:00:00:00:00:00)" == "1" ]; then
ifconfig eth0 hw ether $(fconfig -s -r -d /dev/$RB_CONFIG -n zcom_npe_esa)
fi
}
boot_hook_add preinit_main set_ether_mac

View File

@@ -1,2 +0,0 @@
mount -t proc none /proc
grep 'failsafe=' /proc/cmdline > /dev/null && export FAILSAFE=true

View File

@@ -0,0 +1,8 @@
#!/bin/sh
#!/bin/sh
do_mount_procfs() {
mount -t proc none /proc
}

View File

@@ -0,0 +1,14 @@
#!/bin/sh
# Copyright (C) 2006-2010 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
failsafe_wait() {
FAILSAFE=
grep 'failsafe=' /proc/cmdline > /dev/null && FAILSAFE=true && export FAILSAFE
if [ "$FAILSAFE" != "true" ]; then
preinit_net_echo "Please press button now to enter failsafe"
echo -n "Press CTRL-C or "
fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true && export FAILSAFE
fi
}

View File

@@ -1,23 +0,0 @@
# Copyright (C) 2009 OpenWrt.org
. /etc/functions.sh
insmod r6040
kernel=$(grep magic /proc/mtd | awk -F: '{print $1}')
[ -n $kernel ] && hdr=$(dd if=/dev/$kernel count=4 bs=1 2> /dev/null)
[ "$hdr" = "CSYS" ] && config=$(find_mtd_part config)
if [ -n "$config" ]; then
mac0=$(hexdump -n 6 -e '6/1 ":%X"' -s 24583 $config | cut -c2-)
[ "$mac0" = "FF:FF:FF:FF:FF:FF" -o "$mac0" = "0:0:0:0:0:0" ] && unset mac0
mac1=$(hexdump -n 6 -e '6/1 ":%X"' -s 24589 $config | cut -c2-)
[ "$mac1" = "FF:FF:FF:FF:FF:FF" -o "$mac0" = "0:0:0:0:0:0" ] && unset mac1
fi
if [ -n $mac0 ]; then
logger -t kernel -p user.info "r6040: Setting MAC for eth0 to $mac0"
ifconfig eth0 hw ether $mac0
fi
if [ -n $mac1 ]; then
logger -t kernel -p user.info "r6040: Setting MAC for eth1 to $mac1"
ifconfig eth1 hw ether $mac1
fi

View File

@@ -0,0 +1,32 @@
#!/bin/sh
# Copyright (C) 2009 OpenWrt.org
. /etc/boot.sh
r6040_module() {
insmod r6040
}
set_ether_mac() {
kernel=$(grep magic /proc/mtd | awk -F: '{print $1}')
[ -n $kernel ] && hdr=$(dd if=/dev/$kernel count=4 bs=1 2> /dev/null)
[ "$hdr" = "CSYS" ] && config=$(find_mtd_part config)
if [ -n "$config" ]; then
mac0=$(hexdump -n 6 -e '6/1 ":%X"' -s 24583 $config | cut -c2-)
[ "$mac0" = "FF:FF:FF:FF:FF:FF" -o "$mac0" = "0:0:0:0:0:0" ] && unset mac0
mac1=$(hexdump -n 6 -e '6/1 ":%X"' -s 24589 $config | cut -c2-)
[ "$mac1" = "FF:FF:FF:FF:FF:FF" -o "$mac0" = "0:0:0:0:0:0" ] && unset mac1
fi
if [ -n $mac0 ]; then
logger -t kernel -p user.info "r6040: Setting MAC for eth0 to $mac0"
ifconfig eth0 hw ether $mac0
fi
if [ -n $mac1 ]; then
logger -t kernel -p user.info "r6040: Setting MAC for eth1 to $mac1"
ifconfig eth1 hw ether $mac1
fi
}
boot_hook_add preinit_main r6040_module
boot_hook_add preinit_main set_ether_mac

View File

@@ -1,2 +0,0 @@
mount -t proc none /proc
grep 'failsafe=' /proc/cmdline > /dev/null && export FAILSAFE=true

View File

@@ -0,0 +1,8 @@
#!/bin/sh
# Copyright (C) 2006-2010 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
do_mount_procfs() {
mount -t proc none /proc
}

View File

@@ -0,0 +1,14 @@
#!/bin/sh
# Copyright (C) 2006-2010 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
failsafe_wait() {
FAILSAFE=
grep 'failsafe=' /proc/cmdline > /dev/null && FAILSAFE=true && export FAILSAFE
if [ "$FAILSAFE" != "true" ]; then
preinit_net_echo "Please press button now to enter failsafe"
echo -n "Press CTRL-C or "
fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true && export FAILSAFE
fi
}

View File

@@ -1,2 +0,0 @@
mount -t proc none /proc
grep 'failsafe=' /proc/cmdline && export FAILSAFE=true

View File

@@ -0,0 +1,9 @@
#!/bin/sh
# Copyright (C) 2006-2010 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
do_mount_procfs() {
mount -t proc none /proc
}

View File

@@ -0,0 +1,14 @@
#!/bin/sh
# Copyright (C) 2006-2010 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
failsafe_wait() {
FAILSAFE=
grep 'failsafe=' /proc/cmdline > /dev/null && FAILSAFE=true && export FAILSAFE
if [ "$FAILSAFE" != "true" ]; then
preinit_net_echo "Please press button now to enter failsafe"
echo -n "Press CTRL-C or "
fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true && export FAILSAFE
fi
}