From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763618AbYEYK2F (ORCPT ); Sun, 25 May 2008 06:28:05 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1762508AbYEYKYJ (ORCPT ); Sun, 25 May 2008 06:24:09 -0400 Received: from bombadil.infradead.org ([18.85.46.34]:42055 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762487AbYEYKYH (ORCPT ); Sun, 25 May 2008 06:24:07 -0400 In-Reply-To: <1211708969@pmac.infradead.org> References: <1211708969@pmac.infradead.org> From: David Woodhouse To: linux-kernel@vger.kernel.org Cc: sam@ravnborg.org, alan@lxorguk.ukuu.org.uk, akpm@linux-foundation.org Subject: [PATCHv2 27/28] firmware: Add CONFIG_BUILTIN_FIRMWARE option Message-Id: Date: Sun, 25 May 2008 11:23:57 +0100 X-Bad-Reply: References and In-Reply-To but no 'Re:' in Subject. X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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