From patchwork Sun Jul 15 02:44:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Domenico Andreoli X-Patchwork-Id: 1198301 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 1C67DDF28C for ; Sun, 15 Jul 2012 02:53:33 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SqEsC-00006j-62; Sun, 15 Jul 2012 02:47:52 +0000 Received: from mail-we0-f177.google.com ([74.125.82.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SqEqd-0008VO-3f for linux-arm-kernel@lists.infradead.org; Sun, 15 Jul 2012 02:46:20 +0000 Received: by weyr3 with SMTP id r3so3441838wey.36 for ; Sat, 14 Jul 2012 19:46:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:user-agent:date:from:to:cc:subject:references :content-disposition; bh=UQCWa1LE5vbIzYzbrUpCGZ8eQGz/4iq+3+s/725TRTI=; b=N1rWbn/CORsdpbVXxGjXmUR6YKoVuQ4UK74SPgVVvuB5YVh9QE4VpoXDmQsdt8MKim 94Ce6JWZmZ9nv/YxmlFt0iG3GmCQSo00AokZIb9UitJ/cFyB8QDu4UKxuR7SWmKiw5Wg tY+44mahK1G5uosPKDAP+QEgEVCOQlBTVH79UnH704lojR1kxZ9xVz6cZopciFWvVJvV F4OihNzy/3+PC//V1Nh8klgRScGReNFaJ63z/BgPc1Q4/yoEosBJKvczh8AX8qRmqkr3 uuzTDK3UBJiofuHgTMXp16L8MWpscepgKXs0AnWJ1H496nToQPNpYHgytUdmhII/Obym 1fwg== Received: by 10.180.109.166 with SMTP id ht6mr8278229wib.11.1342320371422; Sat, 14 Jul 2012 19:46:11 -0700 (PDT) Received: from raptus.dandreoli.com (178-85-163-250.dynamic.upc.nl. [178.85.163.250]) by mx.google.com with ESMTPS id ex20sm13466765wid.7.2012.07.14.19.46.10 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 14 Jul 2012 19:46:10 -0700 (PDT) Received: by raptus.dandreoli.com (Postfix, from userid 1000) id C3E0137BA02; Sun, 15 Jul 2012 04:46:09 +0200 (CEST) Message-Id: <20120715024609.513918780@gmail.com> User-Agent: quilt/0.60-1 Date: Sun, 15 Jul 2012 04:44:13 +0200 From: Domenico Andreoli To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 05/12] ARM: Add DT support to decompressor tags References: <20120715024408.747946928@gmail.com> Content-Disposition: inline; filename=decomp-arch-dt.patch X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (cavokz[at]gmail.com) -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.177 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Domenico Andreoli , Russell King - ARM Linux , Arnd Bergmann X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Domenico Andreoli Thinking at multiplatform kernels we cannot miss DeviceTrees. So here we add some new glue to select tags also using dt_compat fields, mandatory in case of pure DT boards without numeric machine id. Note the care required to pack, relocate and unpack all those strings. Signed-off-by: Domenico Andreoli --- arch/arm/boot/compressed/Makefile | 2 -- arch/arm/boot/compressed/arch.c | 24 ++++++++++++++++++++++++ arch/arm/boot/compressed/atags_to_fdt.c | 15 +++++++++++++++ include/linux/decompress/arch.h | 1 + 4 files changed, 40 insertions(+), 2 deletions(-) Index: b/arch/arm/boot/compressed/atags_to_fdt.c =================================================================== --- a/arch/arm/boot/compressed/atags_to_fdt.c +++ b/arch/arm/boot/compressed/atags_to_fdt.c @@ -97,3 +97,18 @@ int atags_to_fdt(void *atag_list, void * return fdt_pack(fdt); } + +const char *get_fdt_prop(void *fdt, const char *path, const char *prop) +{ + int len, offset; + + /* if we don't get a DTB here we're done already */ + if (*(u32 *) fdt != fdt32_to_cpu(FDT_MAGIC)) + return NULL; + + offset = fdt_path_offset(fdt, path); + if (offset < 0) + return NULL; + + return fdt_getprop(fdt, offset, prop, &len); +} Index: b/arch/arm/boot/compressed/arch.c =================================================================== --- a/arch/arm/boot/compressed/arch.c +++ b/arch/arm/boot/compressed/arch.c @@ -24,6 +24,8 @@ unsigned int __machine_arch_type; #include "arch.h" +const char *get_fdt_prop(void *fdt, const char *path, const char *prop); + unsigned long free_mem_ptr; unsigned long free_mem_end_ptr; @@ -57,6 +59,15 @@ extern const struct decomp_tag_hdr __dec (p) < __decomp_tags_end; \ p = ((void *) p) + (p)->size) +static bool is_compatible(const char (*dt_compat)[16], const char *compatible) +{ + for ( ; strlen(*dt_compat); dt_compat++) + if (!strcmp(*dt_compat, compatible)) + return true; + + return false; +} + void arch_setup(unsigned int arch_id, void *atag_fdt, unsigned long free_mem_ptr_p, unsigned long free_mem_ptr_end_p) @@ -65,7 +76,11 @@ void arch_setup(unsigned int arch_id, vo const struct decomp_tag_hdr *hdr; void (*arch_setup_p)(void); + const char (*dt_compat)[16]; + const char *compatible; + __machine_arch_type = arch_id; + compatible = get_fdt_prop(atag_fdt, "/", "compatible"); arch_setup_p = fallback_arch_setup; arch_error_p = fallback_arch_error; @@ -77,6 +92,15 @@ void arch_setup(unsigned int arch_id, vo if (hdr->arch_id != arch_id) continue; + /* + * In case of DT entry, further inspection of the dt_compat + * table is required before accepting the tag. + */ + dt_compat = (const char (*)[16]) fix_data_ptr(hdr->dt_compat); + if (arch_id == ~0 && compatible && dt_compat && + !is_compatible(dt_compat, compatible)) + continue; + if (hdr->type == DECOMP_TAG_ARCH) { arch_tag = (struct decomp_arch_tag *) hdr; arch_setup_p = fix_text_ptr(arch_tag->setup); Index: b/include/linux/decompress/arch.h =================================================================== --- a/include/linux/decompress/arch.h +++ b/include/linux/decompress/arch.h @@ -24,6 +24,7 @@ enum decomp_tag_type { struct decomp_tag_hdr { unsigned int arch_id; + const char (*dt_compat)[16]; unsigned short type; unsigned short size; }; Index: b/arch/arm/boot/compressed/Makefile =================================================================== --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -107,9 +107,7 @@ $(addprefix $(obj)/,$(libfdt) $(libfdt_h $(addprefix $(obj)/,$(libfdt_objs) atags_to_fdt.o): \ $(addprefix $(obj)/,$(libfdt_hdrs)) -ifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y) OBJS += $(libfdt_objs) atags_to_fdt.o -endif targets := vmlinux vmlinux.lds \ piggy.$(suffix_y) piggy.$(suffix_y).o \