treewide: do board detection during preinit
Do the board detection during preinit to unify it across all targets. Signed-off-by: Mathias Kresin <dev@kresin.me>
This commit is contained in:
parent
ac3e05c5d7
commit
78cf5eed6e
13 changed files with 134 additions and 23 deletions
12
target/linux/brcm47xx/base-files/lib/preinit/01_sysinfo
Normal file
12
target/linux/brcm47xx/base-files/lib/preinit/01_sysinfo
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/bin/sh
|
||||
|
||||
do_sysinfo_brcm47xx() {
|
||||
local name="$(sed -ne 's/^machine[ \t]*: //p' /proc/cpuinfo)"
|
||||
[ -z "$name" ] && name="unknown"
|
||||
|
||||
[ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
|
||||
echo "$name" > /tmp/sysinfo/board_name
|
||||
echo "unknown" > /tmp/sysinfo/model
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main do_sysinfo_brcm47xx
|
|
@ -1,9 +1,9 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2012 OpenWrt.org
|
||||
#
|
||||
|
||||
cns3xxx_board_name() {
|
||||
CNS3XXX_BOARD_NAME=
|
||||
CNS3XXX_MODEL=
|
||||
|
||||
cns3xxx_board_detect() {
|
||||
local machine
|
||||
local name
|
||||
|
||||
|
@ -18,5 +18,20 @@ cns3xxx_board_name() {
|
|||
;;
|
||||
esac
|
||||
|
||||
echo $name
|
||||
[ -z "$CNS3XXX_BOARD_NAME" ] && CNS3XXX_BOARD_NAME="$name"
|
||||
[ -z "$CNS3XXX_MODEL" ] && CNS3XXX_MODEL="$machine"
|
||||
|
||||
[ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
|
||||
|
||||
echo "$CNS3XXX_BOARD_NAME" > /tmp/sysinfo/board_name
|
||||
echo "$CNS3XXX_MODEL" > /tmp/sysinfo/model
|
||||
}
|
||||
|
||||
cns3xxx_board_name() {
|
||||
local name
|
||||
|
||||
[ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
|
||||
[ -z "$name" ] && name="unknown"
|
||||
|
||||
echo "$name"
|
||||
}
|
||||
|
|
9
target/linux/cns3xxx/base-files/lib/preinit/01_sysinfo
Normal file
9
target/linux/cns3xxx/base-files/lib/preinit/01_sysinfo
Normal file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
do_sysinfo_cns3xxx() {
|
||||
. /lib/cns3xxx.sh
|
||||
|
||||
cns3xxx_board_detect
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main do_sysinfo_cns3xxx
|
|
@ -75,7 +75,6 @@ imx6_board_detect() {
|
|||
imx6_board_name() {
|
||||
local name
|
||||
|
||||
[ -f /tmp/sysinfo/board_name ] || imx6_board_detect
|
||||
[ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
|
||||
[ -z "$name" ] && name="unknown"
|
||||
|
||||
|
|
9
target/linux/imx6/base-files/lib/preinit/01_sysinfo
Normal file
9
target/linux/imx6/base-files/lib/preinit/01_sysinfo
Normal file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
do_sysinfo_imx6() {
|
||||
. /lib/imx6.sh
|
||||
|
||||
imx6_board_detect
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main do_sysinfo_imx6
|
|
@ -3,7 +3,10 @@
|
|||
# Copyright (C) 2012 OpenWrt.org
|
||||
#
|
||||
|
||||
ixp4xx_board_name() {
|
||||
IXP4XX_BOARD_NAME=
|
||||
IXP4XX_MODEL=
|
||||
|
||||
ixp4xx_board_detect() {
|
||||
local machine
|
||||
local name
|
||||
|
||||
|
@ -21,5 +24,20 @@ ixp4xx_board_name() {
|
|||
;;
|
||||
esac
|
||||
|
||||
[ -z "$IXP4XX_BOARD_NAME" ] && IXP4XX_BOARD_NAME="$name"
|
||||
[ -z "$IXP4XX_MODEL" ] && IXP4XX_MODEL="$machine"
|
||||
|
||||
[ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
|
||||
|
||||
echo "$IXP4XX_BOARD_NAME" > /tmp/sysinfo/board_name
|
||||
echo "$IXP4XX_MODEL" > /tmp/sysinfo/model
|
||||
}
|
||||
|
||||
ixp4xx_board_name() {
|
||||
local name
|
||||
|
||||
[ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
|
||||
[ -z "$name" ] && name="unknown"
|
||||
|
||||
echo $name
|
||||
}
|
||||
|
|
9
target/linux/ixp4xx/base-files/lib/preinit/01_sysinfo
Normal file
9
target/linux/ixp4xx/base-files/lib/preinit/01_sysinfo
Normal file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
do_sysinfo_ixp4xx() {
|
||||
. /lib/ixp4xx.sh
|
||||
|
||||
ixp4xx_board_detect
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main do_sysinfo_ixp4xx
|
|
@ -90,7 +90,6 @@ kirkwood_board_detect() {
|
|||
kirkwood_board_name() {
|
||||
local name
|
||||
|
||||
[ -f /tmp/sysinfo/board_name ] || kirkwood_board_detect
|
||||
[ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
|
||||
[ -z "$name" ] && name="unknown"
|
||||
|
||||
|
|
9
target/linux/kirkwood/base-files/lib/preinit/01_sysinfo
Normal file
9
target/linux/kirkwood/base-files/lib/preinit/01_sysinfo
Normal file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
do_sysinfo_kirkwood() {
|
||||
. /lib/kirkwood.sh
|
||||
|
||||
kirkwood_board_detect
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main do_sysinfo_kirkwood
|
|
@ -75,7 +75,6 @@ mvebu_board_detect() {
|
|||
mvebu_board_name() {
|
||||
local name
|
||||
|
||||
[ -f /tmp/sysinfo/board_name ] || mvebu_board_detect
|
||||
[ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
|
||||
[ -z "$name" ] && name="unknown"
|
||||
|
||||
|
|
9
target/linux/mvebu/base-files/lib/preinit/01_sysinfo
Normal file
9
target/linux/mvebu/base-files/lib/preinit/01_sysinfo
Normal file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
do_sysinfo_mvebu() {
|
||||
. /lib/mvebu.sh
|
||||
|
||||
mvebu_board_detect
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main do_sysinfo_mvebu
|
12
target/linux/orion/base-files/lib/preinit/01_sysinfo
Normal file
12
target/linux/orion/base-files/lib/preinit/01_sysinfo
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/bin/sh
|
||||
|
||||
do_sysinfo_orion() {
|
||||
local name="$(sed -n /Hardware/s/.*:.//p /proc/cpuinfo)"
|
||||
[ -z "$name" ] && name="unknown"
|
||||
|
||||
[ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
|
||||
echo "$name" > /tmp/sysinfo/board_name
|
||||
echo "unknown" > /tmp/sysinfo/model
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main do_sysinfo_orion
|
12
target/linux/ppc40x/base-files/lib/preinit/01_sysinfo
Normal file
12
target/linux/ppc40x/base-files/lib/preinit/01_sysinfo
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/bin/sh
|
||||
|
||||
do_sysinfo_ppc40x() {
|
||||
local name="$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /model/ {print $2}' /proc/cpuinfo)"
|
||||
[ -z "$name" ] && name="unknown"
|
||||
|
||||
[ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
|
||||
echo "$name" > /tmp/sysinfo/board_name
|
||||
echo "unknown" > /tmp/sysinfo/model
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main do_sysinfo_ppc40x
|
Loading…
Reference in a new issue