[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <E1K0DOP-0007EW-F0@shinybook.infradead.org>
Date: Sun, 25 May 2008 11:23:57 +0100
From: David Woodhouse <dwmw2@...radead.org>
To: linux-kernel@...r.kernel.org
Cc: sam@...nborg.org, alan@...rguk.ukuu.org.uk,
akpm@...ux-foundation.org
Subject: [PATCHv2 27/28] firmware: Add CONFIG_BUILTIN_FIRMWARE option
This allows arbitrary firmware files to be included in the static kernel
where the firmware loader can find them without requiring userspace to
be alive.
Signed-off-by: David Woodhouse <dwmw2@...radead.org>
---
Makefile | 2 +-
drivers/base/Kconfig | 12 ++++++++++
firmware/Makefile | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 71 insertions(+), 1 deletions(-)
create mode 100644 firmware/Makefile
diff --git a/Makefile b/Makefile
index 20b3235..ac2ab7e 100644
--- a/Makefile
+++ b/Makefile
@@ -450,7 +450,7 @@ scripts: scripts_basic include/config/auto.conf
# Objects we will link into vmlinux / subdirs we need to visit
init-y := init/
-drivers-y := drivers/ sound/
+drivers-y := drivers/ sound/ firmware/
net-y := net/
libs-y := lib/
core-y := usr/
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index d7da109..b856fe8 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -34,6 +34,18 @@ config FW_LOADER
require userspace firmware loading support, but a module built outside
the kernel tree does.
+config BUILTIN_FIRMWARE
+ string "Firmware blobs to build into the kernel binary"
+ depends on FW_LOADER
+ help
+ This option allows firmware to be built into the kernel, for the
+ cases where the user either cannot or doesn't want to provide it from
+ userspace at runtime (for example, when the firmware in question is
+ required for accessing the boot device, and the user doesn't want to
+ use an initrd). Multiple files should be separated with spaces, and
+ the required files should exist under the firmware/ directory in
+ the source tree.
+
config DEBUG_DRIVER
bool "Driver Core verbose debug messages"
depends on DEBUG_KERNEL
diff --git a/firmware/Makefile b/firmware/Makefile
new file mode 100644
index 0000000..4243c5a
--- /dev/null
+++ b/firmware/Makefile
@@ -0,0 +1,58 @@
+#
+# kbuild file for firmware/
+#
+
+firmware-y :=
+
+firmware_bins := $(subst ",,$(CONFIG_BUILTIN_FIRMWARE))
+firmware_srcs := $(patsubst %,$(obj)/%.S, $(firmware_bins))
+firmware_objs := $(patsubst %,%.o, $(firmware_bins) $(firmware-y))
+firmware_dirs := $(patsubst %,$(objtree)/$(obj)/%,$(dir $(firmware_objs)))
+
+quiet_cmd_mkdir = MKDIR $@
+ cmd_mkdir = mkdir -p $@
+
+ifdef CONFIG_64BIT
+SM_WORD := .quad
+SM_ALIGN := 3
+else
+ASM_WORD := .long
+ASM_ALIGN := 2
+endif
+
+quiet_cmd_fwbin = MK_FW $@
+ cmd_fwbin = FWNAME="$(patsubst firmware/%.S,%,$@)"; \
+ INCFILE="$(patsubst %.S,%,$@)"; \
+ FWSTR="$(subst /,_,$(subst .,_,$(patsubst \
+ firmware/%.S,%,$@)))"; \
+ echo "/* Generated by firmware/Makefile */" > $@;\
+ echo " .section .rodata" >>$@;\
+ echo " .align $(ASM_ALIGN)" >>$@;\
+ echo "_fw_$${FWSTR}_bin:" >>$@;\
+ echo " .incbin \"$$INCFILE\"" >>$@;\
+ echo "_fw_end:" >>$@;\
+ echo " .section .rodata.str,\"aMS\",@progbits,1" >>$@;\
+ echo " .align $(ASM_ALIGN)" >>$@;\
+ echo "_fw_$${FWSTR}_name:" >>$@;\
+ echo " .string \"$$FWNAME\"" >>$@;\
+ echo " .section .builtin_fw,\"a\",@progbits" >>$@;\
+ echo " .align $(ASM_ALIGN)" >>$@;\
+ echo " $(ASM_WORD) _fw_$${FWSTR}_name" >>$@;\
+ echo " $(ASM_WORD) _fw_$${FWSTR}_bin" >>$@;\
+ echo " $(ASM_WORD) _fw_end - _fw_$${FWSTR}_bin" >>$@;
+
+$(firmware_srcs): $(obj)/%.S: $(srctree)/$(obj)/% include/config/64bit.h
+ $(call cmd,fwbin)
+
+$(firmware_dirs):
+ $(call cmd,mkdir)
+
+$(patsubst %,$(obj)/%,$(firmware_objs)): $(firmware_dirs)
+
+obj-y := $(firmware_objs)
+
+targets := $(firmware_objs) $(patsubst $(obj)/%,%, $(firmware_srcs))
+
+# Without this, built-in.o won't be created when it's empty, and the
+# final vmlinux link will fail.
+obj-n := dummy
--
1.5.4.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists