From: James Bottomley <James.Bottomley@SteelEye.com>
To: debian-kernel@lists.debian.org, Greg KH <greg@kroah.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] MODULE_FIRMWARE for binary firmware(s)
Date: Mon, 28 Aug 2006 17:11:42 -0500 [thread overview]
Message-ID: <1156803102.3465.34.camel@mulgrave.il.steeleye.com> (raw)
In-Reply-To: <1156802900.3465.30.camel@mulgrave.il.steeleye.com>
This is a reference implementation with the debian mkinitrd-tools
package. It shows how to identify the firmware files necessary for
drivers in the initrd and also includes a primitive system for loading
them.
I've tested this with the aic94xx driver using the new MODULE_FIRMWARE()
tag. Initramfs should be much easier because it already includes most
of the boot time loading; all it has to do is the piece identifying the
firmware for the selected modules.
James
---
Index: initrd-tools-0.1.84.1/mkinitrd
===================================================================
--- initrd-tools-0.1.84.1.orig/mkinitrd 2006-08-28 13:37:30.000000000 -0500
+++ initrd-tools-0.1.84.1/mkinitrd 2006-08-28 16:33:28.000000000 -0500
@@ -950,6 +950,7 @@ add_modules_dep() {
return
elif ! [ $oldstyle ]; then
add_modules_dep_2_5 $VERSION
+ add_firmware $VERSION
return
fi
@@ -1016,6 +1017,25 @@ add_modules_dep_2_5() {
fi
}
+add_firmware() {
+ ver=$1
+ set -- $FSTYPES
+ unset IFS
+
+ cat modules.? |
+ while read junk mod junk; do
+ modpath=$(modprobe --set-version "$ver" --list $mod)
+ if [ -z "$modpath" ]; then
+ continue;
+ fi
+ p=$(modinfo -F firmware "$modpath" |sed 's/^/\/lib\/firmware\//')
+ if [ -n "$p" ]; then
+ echo $p
+ echo /usr/sbin/firmware_loader
+ fi
+ done
+}
+
add_command() {
if [ -h initrd/"$1" ]; then
return
Index: initrd-tools-0.1.84.1/firmware_loader
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ initrd-tools-0.1.84.1/firmware_loader 2006-08-28 16:56:18.000000000 -0500
@@ -0,0 +1,29 @@
+#!/bin/sh -e
+#
+# firmware loader agent
+#
+FIRMWARE_DIRS="/lib/firmware"
+
+if [ "$SUBSYSTEM" != "firmware" ]; then
+ exit 0;
+fi
+
+if [ ! -e /sys/$DEVPATH/loading ]; then
+ echo "/sys/$DEVPATH/ does not exist"
+ exit 1
+fi
+
+for DIR in $FIRMWARE_DIRS; do
+ [ -e "$DIR/$FIRMWARE" ] || continue
+ echo 1 > /sys/$DEVPATH/loading
+ cat "$DIR/$FIRMWARE" > /sys/$DEVPATH/data
+ echo 0 > /sys/$DEVPATH/loading
+ exit 0
+done
+
+# the firmware was not found
+echo -1 > /sys/$DEVPATH/loading
+
+echo "Cannot find the $FIRMWARE firmware"
+exit 1
+
Index: initrd-tools-0.1.84.1/debian/rules
===================================================================
--- initrd-tools-0.1.84.1.orig/debian/rules 2006-08-28 16:07:52.000000000 -0500
+++ initrd-tools-0.1.84.1/debian/rules 2006-08-28 16:08:56.000000000 -0500
@@ -35,7 +35,7 @@ install:
install -o root -g root -m 644 \
echo init linuxrc debian/initrd-tools/usr/share/initrd-tools/
install -o root -g root -m 755 \
- mkinitrd debian/initrd-tools/usr/sbin/
+ mkinitrd firmware_loader debian/initrd-tools/usr/sbin/
install -o root -g root -m 644 \
mkinitrd.conf modules debian/initrd-tools/etc/mkinitrd/
ifeq ($(DEB_HOST_ARCH),powerpc)
Index: initrd-tools-0.1.84.1/linuxrc
===================================================================
--- initrd-tools-0.1.84.1.orig/linuxrc 2006-08-28 16:30:30.000000000 -0500
+++ initrd-tools-0.1.84.1/linuxrc 2006-08-28 16:40:45.000000000 -0500
@@ -10,3 +10,7 @@ echo 256 > proc/sys/kernel/real-root-dev
mount -nt tmpfs tmpfs bin ||
mount -nt ramfs ramfs bin
echo $root > bin/root
+if [ -x /usr/sbin/firmware_loader ]; then
+ echo /usr/sbin/firmware_loader > /proc/sys/kernel/hotplug
+fi
+
Index: initrd-tools-0.1.84.1/init
===================================================================
--- initrd-tools-0.1.84.1.orig/init 2006-08-28 16:54:52.000000000 -0500
+++ initrd-tools-0.1.84.1/init 2006-08-28 16:55:01.000000000 -0500
@@ -366,6 +366,7 @@ get_cmdline
[ -c /dev/.devfsd ] && DEVFS=yes
mount -nt devfs devfs devfs
+mount -nt sysfs sysfs sys
if [ $IDE_CORE != none ] && [ -n "$ide_options" ]; then
echo modprobe -k $IDE_CORE "options=\"$ide_options\""
modprobe -k $IDE_CORE options="$ide_options"
next prev parent reply other threads:[~2006-08-28 22:11 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-28 22:08 James Bottomley
2006-08-28 22:11 ` James Bottomley [this message]
2006-08-28 23:04 ` Sven Luther
2006-08-28 23:50 ` James Bottomley
2006-08-29 0:35 ` Oleg Verych
2006-08-28 23:55 ` James Bottomley
2006-08-29 2:15 ` Oleg Verych
[not found] ` <20060829015103.GA28162@kroah.com>
[not found] ` <20060829031430.GA9820@flower.upol.cz>
2006-08-29 2:49 ` Greg KH
2006-08-29 4:19 ` Oleg Verych
2006-08-29 15:46 ` David Lang
2006-08-29 18:32 ` Greg KH
2006-08-29 19:04 ` Michael Buesch
2006-08-29 20:13 ` Olaf Hering
2006-08-29 20:42 ` David Lang
2006-08-29 20:52 ` Greg KH
2006-08-30 5:44 ` Olaf Hering
2006-08-30 17:52 ` David Lang
2006-08-30 18:13 ` Sven Luther
2006-08-30 18:20 ` David Lang
2006-08-30 19:15 ` Sven Luther
2006-08-30 19:34 ` David Lang
2006-08-30 20:57 ` Sven Luther
2006-08-30 21:11 ` David Lang
2006-08-31 1:16 ` Jim Crilly
2006-09-15 19:48 ` Olaf Hering
2006-08-29 16:30 ` Michael Buesch
2006-08-29 13:13 ` Marcel Holtmann
2006-08-29 20:16 ` Greg KH
2006-08-30 13:49 ` Marcel Holtmann
[not found] <6OXsW-4pW-7@gated-at.bofh.it>
[not found] ` <6Peat-82q-17@gated-at.bofh.it>
[not found] ` <6PgFh-53l-7@gated-at.bofh.it>
[not found] ` <6Ph8l-61I-9@gated-at.bofh.it>
2006-08-29 22:10 ` Bodo Eggert
-- strict thread matches above, loose matches on Subject: below --
2006-04-18 23:41 Jon Masters
2006-04-18 23:01 ` David Lang
2006-04-19 0:15 ` Jon Masters
2006-04-18 23:41 ` David Lang
2006-04-19 1:07 ` Jon Masters
2006-04-19 9:07 ` Duncan Sands
2006-04-19 12:41 ` Jon Masters
2006-04-19 15:32 ` Duncan Sands
2006-04-19 15:45 ` Jon Masters
2006-07-29 19:05 ` Jon Masters
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1156803102.3465.34.camel@mulgrave.il.steeleye.com \
--to=james.bottomley@steeleye.com \
--cc=debian-kernel@lists.debian.org \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®