Browse Source

Benjamin Schieder:


			
			
				rocklinux
			
			
		
Benjamin Schieder 18 years ago
parent
commit
24ca0bd8e3
4 changed files with 0 additions and 471 deletions
  1. +0
    -1
      package/base/sysfiles/etc_conf_hardware.txt
  2. +0
    -332
      package/base/sysfiles/hwscan.awk
  3. +0
    -105
      package/base/sysfiles/stone_mod_hardware.sh
  4. +0
    -33
      package/base/sysfiles/system.init

+ 0
- 1
package/base/sysfiles/etc_conf_hardware.txt

@ -1 +0,0 @@
HARDWARE_SETUP=hotplug

+ 0
- 332
package/base/sysfiles/hwscan.awk

@ -1,332 +0,0 @@
#!/bin/gawk -f
#
# Usually I'd write this in perl. But this should also work on a system
# with no perl installed, so it's in awk ...
function debug(text) {
if ( print_debug )
print text > "/dev/stderr";
}
function autocomplete(mod, id) {
driver_initrd[id] = 1;
if ( mod ~ /^snd-/ ) {
driver_mod[id] = driver_mod[id] \
" snd-pcm-oss snd-seq-oss snd-mixer-oss";
driver_initrd[id] = 0;
}
if ( modidx[mod] ~ "/video/" ) {
driver_cmd[id] = driver_cmd[id] \
"\n: touch /dev/vc/{1,2,3,4,5,6}" \
"\n: fbset -a 800x600-60" \
"\nchvt 2; sleep 1; chvt 1";
driver_initrd[id] = 0;
}
}
function get_pci_drivers() {
debug("Reading /lib/modules/" kernel "/modules.pcimap.");
while ( (getline < ("/lib/modules/" kernel "/modules.pcimap")) > 0 ) {
id = sprintf( "%04x%04x", and(strtonum($2),0xffff),
and(strtonum($3),0xffff));
# always prefer ALSA drivers if available
if ( id in pci_driver && pci_driver[id] ~ /^snd-/ ) continue;
pci_driver[id] = $1;
}
while ( (getline < "/usr/share/pci.ids") > 0 ) {
if ( /^\t\t/ ) {
id = $1 $2;
sub("^\t+[0-9a-f]+[ \t]+[0-9a-f]+[ \t]+", "");
pci_descs[id] = vendor_name " " $0;
} else
if ( /^\t/ ) {
id = vendor_id $1;
sub("^\t+[0-9a-f]+[ \t]+", "");
pci_descs[id] = vendor_name " " $0;
} else {
vendor_id = $1;
sub("^[0-9a-f]+[ \t]+", "");
vendor_name = $0;
}
}
while ( (getline < "/proc/bus/pci/devices") > 0 ) {
id = "pci" $1 " (Device " $2 ")";
driver_mod[id] = pci_driver[$2];
driver_dsc[id] = pci_descs[$2];
driver_cmd[id] = "";
drivers[id] = id;
autocomplete(pci_driver[$2], id);
}
}
function get_isapnp_drivers() {
debug("Reading /lib/modules/" kernel "/modules.isapnpmap.");
while ( (getline < ("/lib/modules/" kernel "/modules.isapnpmap")) > 0 ) {
vendor = strtonum($2);
device = strtonum($3);
# ugly mangling performed in the kernel ...
id = sprintf ("%c%c%c%x%x%x%x",
65 + and (vendor / 4, 0x3f) - 1,
65 + or (and (vendor, 3) * 8, and (vendor / 8192, 7) ) - 1,
65 + and (vendor / 256, 0x1f) - 1,
and (device / 16, 0x0f),
and (device, 0x0f),
and (device / 4096, 0x0f),
and (device / 256, 0x0f) );
isapnp_driver[id] = $1;
}
while ( (getline < "/proc/bus/isapnp/devices") > 0 ) {
id = substr ($2,0,7);
iid = "isapnp" id;
driver_mod[iid] = isapnp_driver[id];
driver_dsc[iid] = "ISA PnP (" id ")"; #isapnp_descs[id];
driver_cmd[iid] = "";
drivers[iid] = iid;
autocomplete(isapnp_driver[id], iid);
}
}
function match_usb_dev() {
if ( usb_device[ "Vendor" ] == 0 && usb_device[ "ProdID" ] == 0 ) return;
usbmap_idx[ "Vendor" ] = 1;
usbmap_idx[ "ProdID" ] = 2;
usbmap_idx[ "DevLo" ] = 4;
usbmap_idx[ "DevHi" ] = 8;
usbmap_idx[ "DevCls" ] = 16;
usbmap_idx[ "DevSub" ] = 32;
usbmap_idx[ "DevProt" ] = 64;
usbmap_idx[ "IfCls" ] = 128;
usbmap_idx[ "IfSub" ] = 256;
usbmap_idx[ "IfProt" ] = 512;
usbmap_idx[ "DrvInfo" ] = 1024;
usb_modlist="";
for ( usb_driver_id=0; usb_driver_id < usb_driver_c; usb_driver_id++ ) {
found=1;
for ( usbmap_idx_id in usbmap_idx ) {
if ( and(usb_driver[usb_driver_id, "match"], usbmap_idx[usbmap_idx_id]) ) {
if ( (usb_driver[usb_driver_id, usbmap_idx_id] != \
usb_device[usbmap_idx_id]) ) found=0;
}
}
if (found) {
if ( usb_modlist != "" ) usb_modlist = usb_modlist " ";
usb_modlist = usb_modlist usb_driver[usb_driver_id, "mod"];
}
}
if ( usb_modlist != "" ) {
id = "usb-device " usb_device[ "Vendor" ] ":" usb_device[ "ProdID" ] " (" usb_modlist ")";
driver_mod[id] = usb_modlist;
driver_dsc[id] = usb_device[ "Desc" ] " (" usb_modlist ")";
gsub(" +", " ", driver_dsc[id]);
driver_cmd[id] = "";
drivers[id] = id;
autocomplete(pci_driver[$2], id);
}
}
function get_usb_flag(name) {
split($0, usb_flags, " +");
for ( usb_flag_id in usb_flags ) {
split(usb_flags[usb_flag_id], usb_flag, "[=(]");
if ( usb_flag[1] == name ) return strtonum("0x" usb_flag[2]);
}
return 0;
}
function get_usb_drivers() {
while ( ("lspci -v" | getline) > 0 ) {
if ( / USB Controller: / ) {
usb_ctrl_desc="";
if ( /prog-if.*OHCI/ )
{ usb_ctrl_driver="usb-ohci"; usb_ctrl_desc="OHCI"; }
if ( /prog-if.*UHCI/ )
{ usb_ctrl_driver="usb-uhci"; usb_ctrl_desc="UHCI"; }
if ( usb_ctrl_desc != "" ) {
sub("^[^ ]*", ""); sub("\\(rev .*$", "");
usb_ctrl_desc = usb_ctrl_desc $0;
break;
}
}
}
if ( usb_ctrl_driver && modidx[usb_ctrl_driver] ) {
debug("Found USB " usb_ctrl_driver " device in lspci output.");
id = "usb-controller (PCI " usb_ctrl_driver ")";
driver_mod[id] = usb_ctrl_driver;
driver_dsc[id] = usb_ctrl_desc;
driver_cmd[id] = "\nmount -t usbfs usbfs /proc/bus/usb";
drivers[id] = id;
autocomplete(usb_ctrl_driver, id);
}
debug("Reading /lib/modules/" kernel "/modules.usbmap.");
for ( usb_driver_c=0;
(getline < ("/lib/modules/" kernel "/modules.usbmap")) > 0;
usb_driver_c++ ) {
if ( $1 == "#" ) { usb_driver_c--; continue; }
usb_driver[usb_driver_c, "mod" ] = $1;
usb_driver[usb_driver_c, "match" ] = strtonum($2);
usb_driver[usb_driver_c, "Vendor" ] = strtonum($3);
usb_driver[usb_driver_c, "ProdID" ] = strtonum($4);
usb_driver[usb_driver_c, "DevLo" ] = strtonum($5);
usb_driver[usb_driver_c, "DevHi" ] = strtonum($6);
usb_driver[usb_driver_c, "DevCls" ] = strtonum($7);
usb_driver[usb_driver_c, "DevSub" ] = strtonum($8);
usb_driver[usb_driver_c, "DevProt" ] = strtonum($9);
usb_driver[usb_driver_c, "IfCls" ] = strtonum($10);
usb_driver[usb_driver_c, "IfSub" ] = strtonum($11);
usb_driver[usb_driver_c, "IfProt" ] = strtonum($12);
usb_driver[usb_driver_c, "DrvInfo" ] = strtonum($13);
}
while ( (getline < "/proc/bus/usb/devices") > 0 ) {
if ( $1 == "T:" ) {
if ( usb_device["Vendor"] != "" ) match_usb_dev();
usb_device[ "Vendor" ] = 0;
usb_device[ "ProdID" ] = 0;
usb_device[ "DevLo" ] = 0; # FIXME: Where is this value in bus/usb/devices?
usb_device[ "DevHi" ] = 0; # FIXME: Where is this value in bus/usb/devices?
usb_device[ "DevCls" ] = 0;
usb_device[ "DevSub" ] = 0;
usb_device[ "DevProt" ] = 0;
usb_device[ "IfCls" ] = 0;
usb_device[ "IfSub" ] = 0;
usb_device[ "IfProt" ] = 0;
usb_device[ "DrvInfo" ] = 0; # FIXME: Where is this value in bus/usb/devices?
usb_device[ "Desc" ] = "USB:";
}
if ( $1 == "P:" ) {
usb_device[ "Vendor" ] = get_usb_flag("Vendor");
usb_device[ "ProdID" ] = get_usb_flag("ProdID");
}
if ( $1 == "D:" ) {
usb_device[ "DevCls" ] = get_usb_flag("Cls");
usb_device[ "DevSub" ] = get_usb_flag("Sub");
usb_device[ "DevProt" ] = get_usb_flag("Sub");
}
if ( $1 == "I:" ) {
usb_device[ "IfCls" ] = get_usb_flag("Cls");
usb_device[ "IfSub" ] = get_usb_flag("Sub");
usb_device[ "IfProt" ] = get_usb_flag("Prot");
}
if ( $1 == "S:" ) {
if ( ! match($0, "SerialNumber") ) {
sub(".*=", "");
usb_device[ "Desc" ] = usb_device[ "Desc" ] " " $0;
}
}
}
if ( usb_device["Vendor"] != "" ) match_usb_dev();
}
function print_driver(id) {
if ( driver_initrd[id] ) {
tmp = driver_mod[id];
gsub(" +", "\nmodprobe ", tmp);
tmp = "modprobe " tmp driver_cmd[id];
} else {
tmp = driver_mod[id] "\t#no-initrd";
gsub(" +", "\t#no-initrd\nmodprobe ", tmp);
tmp = "modprobe " tmp driver_cmd[id];
}
if ( disable_default ) {
gsub("\n", "\n#", tmp);
tmp = "#" tmp;
}
if ( driver_dsc[id] == "" ) {
tmp2 = driver_mod[id]; gsub(" .*", "", tmp2);
driver_dsc[id] = "Unkown device for driver " tmp2;
}
if ( file ) {
print "New Device: " id;
print "\n### " id " ###" >> file;
print "# " driver_dsc[id] >> file;
if ( print_echos )
print "echo '" driver_dsc[id] "'" >> file;
print tmp >> file;
} else {
print "\n### " id " ###";
print "# " driver_dsc[id];
if ( print_echos )
print "echo '" driver_dsc[id] "'";
print tmp;
}
}
BEGIN {
for (i=1; i<ARGC; i++) {
if ( ARGV[i] == "-k" )
kernel = ARGV[++i];
else if ( ARGV[i] == "-s" )
file = ARGV[++i];
else if ( ARGV[i] == "-d" )
disable_default = 1;
else if ( ARGV[i] == "-D" )
print_debug = 1;
else if ( ARGV[i] == "-V" )
print_echos = 1;
else {
print "\n" \
"HWScan - ROCK Linux (www.rocklinux.org)" "\n" \
"Copyright 2003 Clifford Wolf <clifford@clifford.at>" "\n" \
"This is free software with ABSOLUTELY NO WARRANTY." "\n" \
"\n" \
"Usage: hwscan [ [--] options ]" "\n" \
"\n" \
" -k <kernel-version> ......... use /lib/modules/<thisvalue>/" "\n" \
" -s <hw-init-script> ......... e.g. /etc/conf/kernel" "\n" \
" -d .......................... disable new driver on default" "\n" \
" -D .......................... debug (print auto-detected values)" "\n" \
" -V .......................... verbose (add echo's)" "\n";
exit 1;
}
}
if ( ! kernel ) {
if ( ("cat /proc/version" | getline) > 0 ) {
kernel = $3;
} else {
kernel = "*";
}
debug("Auto-detected kernel version: " kernel);
}
for ( c=0; (("find /lib/modules/" kernel \
"/. -name '*.o' -printf '%P %f\n'") | getline) > 0; c++ ) {
sub("\\.o$", "");
modidx[$2] = $1;
}
debug("Found " c " modules in /lib/modules/" kernel ".");
while ( file && (getline < file) > 0 ) {
if ( /^### .* ###$/ ) {
sub("^### ", "");
sub(" ###$", "");
skip[$0] = 1;
debug("Mark existing driver " $0 " to be skipped.");
}
}
get_pci_drivers();
get_isapnp_drivers();
get_usb_drivers();
asort(drivers);
for (i in drivers) {
id = drivers[i];
if ( driver_mod[id] && ! skip[id] ) {
print_driver(id);
}
}
}

+ 0
- 105
package/base/sysfiles/stone_mod_hardware.sh

@ -26,49 +26,6 @@ set_dev_setup() {
echo "devtype=$1" > /etc/conf/devtype
}
set_hw_setup() {
echo "HARDWARE_SETUP=$1" > /etc/conf/hardware
}
flip_hw_config() {
local tmp=`mktemp`
awk "\$0 == \"### $1 ###\", \$0 == \"\" {"'
if ( /^#[^# ]/ ) {
sub("^#", "");
system($0 " >&2");
} else {
if ( /^[^# ]/ ) $0 = "#" $0;
if (/^#modprobe /) {
cmd = $0;
sub("^#modprobe", "modprobe -r", cmd);
system(cmd " >&2");
}
if (/^#mount /) {
cmd = $0;
sub("^#mount .* ", "umount ", cmd);
system(cmd " >&2");
}
}
} { print; }' < /etc/conf/kernel > $tmp
cat $tmp > /etc/conf/kernel; rm -f $tmp
# this is needed to e.g. initialize /proc/bus/usb/devices
sleep 1
}
add_hw_config() {
case $state in
1) cmd="$cmd '[ ] $name'" ;;
2) cmd="$cmd '[*] $name'" ;;
*) cmd="$cmd '[?] $name'" ;;
esac
case $state in
1|2) cmd="$cmd 'flip_hw_config \"$id\"'" ;;
*) cmd="$cmd 'true'" ;;
esac
id=""
}
store_clock() {
if [ -f /etc/conf/clock ] ; then
sed -e "s/clock_tz=.*/clock_tz=$clock_tz/" \
@ -107,11 +64,6 @@ main() {
. /etc/conf/devtype
fi
HARDWARE_SETUP=hwscan
if [ -f /etc/conf/hardware ]; then
. /etc/conf/hardware
fi
clock_tz=utc
clock_rtc="`cat /proc/sys/dev/rtc/max-user-freq 2> /dev/null`"
if [ -f /etc/conf/clock ]; then
@ -130,63 +82,6 @@ main() {
done
cmd="$cmd '' ''";
for x in hwscan hotplug rockplug; do
[ -x /sbin/$x ] || continue
if [ "$HARDWARE_SETUP" = $x ]; then
cmd="$cmd \"<*> Use $x to configure hardware.\""
else
cmd="$cmd \"< > Use $x to configure hardware.\""
fi
cmd="$cmd \"set_hw_setup $x\"";
done
cmd="$cmd '' ''";
if [ "$HARDWARE_SETUP" = rockplug ]; then
cmd="$cmd 'Edit/View PCI configuration'";
cmd="$cmd \"gui_edit PCI /etc/conf/pci\""
cmd="$cmd 'Edit/View USB configuration'";
cmd="$cmd \"gui_edit USB /etc/conf/usb\""
cmd="$cmd '' ''";
cmd="$cmd 'ROCK-Plug/Drivers Configuration'"
cmd="$cmd 'stone rockplug' '' ''"
cmd="$cmd 'Re-create initrd image (mkinitrd, `uname -r`)'"
cmd="$cmd 'gui_cmd mkinitrd mkinitrd' '' ''"
fi
if [ "$HARDWARE_SETUP" = hwscan ]; then
cmd="$cmd 'Edit /etc/conf/kernel (kernel drivers config file)'"
cmd="$cmd \"gui_edit 'Kernel Drivers Config File' /etc/conf/kernel\""
cmd="$cmd 'Re-create initrd image (mkinitrd, `uname -r`)'"
cmd="$cmd 'gui_cmd mkinitrd mkinitrd' '' ''"
hwscan -d -s /etc/conf/kernel
id=""
while read line; do
if [ "${line#\#\#\# }" != "${line}" -a \
"${line% \#\#\#}" != "${line}" ]
then
id="${line#\#\#\# }"; id="${id% \#\#\#}"
state=0; name="Unamed Kernel Driver"
elif [ -z "$id" ]; then
continue
elif [ "${line#\# }" != "${line}" ]; then
name="${line#\# }"
elif [ "${line#\#[!\# ]}" != "${line}" ]; then
[ $state -eq 0 ] && state=1
[ $state -eq 2 ] && state=3
elif [ "${line#[!\# ]}" != "${line}" ]; then
[ $state -eq 0 ] && state=2
[ $state -eq 1 ] && state=3
elif [ -z "$line" ]; then
add_hw_config
fi
done < /etc/conf/kernel
[ -z "$id" ] || add_hw_config
cmd="$cmd '' ''"
fi
if [ "$clock_tz" = localtime ] ; then
cmd="$cmd '[*] Use localtime instead of utc' 'set_zone utc'"
else

+ 0
- 33
package/base/sysfiles/system.init

@ -87,22 +87,6 @@ dnl
mkdir /tmp/.ICE-unix /var/lock/subsys
chmod 1777 /tmp/.ICE-unix
dnl
case "$HARDWARE_SETUP" in
rockplug)
block_split(`Configuring hardware by activating rockplug.')
echo "/sbin/rockplug" > /proc/sys/kernel/hotplug
for file in /etc/rockplug/*.init; do
[ -f $file ] && $file start
done
;;
hotplug)
block_split(`Disabling hotplug helper (udev uses netlink).')
echo "" > /proc/sys/kernel/hotplug
;;
*)
block_split(`Auto-load all modules at boot-time using hwscan.')
check(`hwscan -- -V | sh')
esac
block_split(`Loading kernel modules and configuring the kernel.')
check(`sh /etc/conf/kernel')
dnl
@ -190,23 +174,6 @@ dnl
else check(`reboot -w') ; fi
block_split(`Saving kernel random seed.')
dd if=/dev/urandom of=/var/state/random-seed count=1 2> /dev/null
dnl
case "$HARDWARE_SETUP" in
rockplug)
block_split(`Unconfiguring hardware by de-activating rockplug.')
for file in /etc/rockplug/*.init; do
[ -f $file ] && $file stop
done
;;
hotplug)
block_split(`Unconfiguring hardware by de-activating hotplug.')
for RC in /etc/hotplug/*.rc; do
echo -n "[$( basename ${RC%.rc} )] "
check(`$RC stop');
done; echo
rm -f /var/lock/subsys/hotplug
;;
esac
dnl
block_split(`Sending all processes a SIGTERM (15).')
check(`killall5 -15') ; sleep 5

Loading…
Cancel
Save