All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] [PATCH] Adding DTB to architecture independent vmlinux
@ 2010-10-26 14:24 Dirk Brandewie
       [not found] ` <4CC6E491.7060304-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 19+ messages in thread
From: Dirk Brandewie @ 2010-10-26 14:24 UTC (permalink / raw)
  To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
  Cc: sodaville-hfZtesqFncYOwBW4kG4KsQ, Dirk Brandewie

Hi All,

I am working on working on adding support device tree support to an
x86 based platform, hpa pointed out that the device tree blob is
architecture independent and should be part of the generic kernel.

The patch below is a first cut at adding dtb support to the architecture
independent kernel and adding a generic dts->dtb build rule.

This has only been tested on x86.

Comments/suggestions gratefully accepted.

--Dirk

of: add support for linking platform dtb into vmlinux

From: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

This patch adds support for linking a device tree blob into
vmlinux. The platform DTB to be built and linked into the kernel is
specified by passing PLATFORM_DTB=<platform name> to make.

The command:
make PLATFORM_DTB=ce4100

will link the device tree blob into vmlinux

Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
  arch/powerpc/boot/zImage.coff.lds.S |    5 ++---
  arch/powerpc/boot/zImage.lds.S      |    5 ++---
  arch/powerpc/boot/zImage.ps3.lds.S  |    5 ++---
  arch/x86/kernel/Makefile            |   15 +++++++++++++++
  include/asm-generic/vmlinux.lds.h   |   12 ++++++++++++
  scripts/Makefile.lib                |    7 +++++++
  7 files changed, 42 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/boot/zImage.coff.lds.S 
b/arch/powerpc/boot/zImage.coff.lds.S
index 856dc78..c23145f 100644
--- a/arch/powerpc/boot/zImage.coff.lds.S
+++ b/arch/powerpc/boot/zImage.coff.lds.S
@@ -1,3 +1,4 @@
+#include <asm-generic/vmlinux.lds.h>
  OUTPUT_ARCH(powerpc:common)
  ENTRY(_zimage_start_opd)
  EXTERN(_zimage_start_opd)
@@ -21,9 +22,7 @@ SECTIONS
      *(.got2)
      __got2_end = .;

-    _dtb_start = .;
-    *(.kernel:dtb)
-    _dtb_end = .;
+    KERNEL_DTB()

      _vmlinux_start =  .;
      *(.kernel:vmlinux.strip)
diff --git a/arch/powerpc/boot/zImage.lds.S b/arch/powerpc/boot/zImage.lds.S
index 0962d62..f5b9c56 100644
--- a/arch/powerpc/boot/zImage.lds.S
+++ b/arch/powerpc/boot/zImage.lds.S
@@ -1,3 +1,4 @@
+#include <asm-generic/vmlinux.lds.h>
  OUTPUT_ARCH(powerpc:common)
  ENTRY(_zimage_start)
  EXTERN(_zimage_start)
@@ -22,9 +23,7 @@ SECTIONS
    }

    . = ALIGN(8);
-  _dtb_start = .;
-  .kernel:dtb : { *(.kernel:dtb) }
-  _dtb_end = .;
+  KERNEL_DTB()

    . = ALIGN(4096);
    _vmlinux_start =  .;
diff --git a/arch/powerpc/boot/zImage.ps3.lds.S b/arch/powerpc/boot/zImage.ps3.lds.S
index aaa469c..246d227 100644
--- a/arch/powerpc/boot/zImage.ps3.lds.S
+++ b/arch/powerpc/boot/zImage.ps3.lds.S
@@ -1,3 +1,4 @@
+#include <asm-generic/vmlinux.lds.h>
  OUTPUT_ARCH(powerpc:common)
  ENTRY(_zimage_start)
  EXTERN(_zimage_start)
@@ -8,9 +9,7 @@ SECTIONS
    _vmlinux_end =  .;

    . = ALIGN(4096);
-  _dtb_start = .;
-  .kernel:dtb : { *(.kernel:dtb) }
-  _dtb_end = .;
+  KERNEL_DTB()

    . = ALIGN(4096);
    _initrd_start =  .;
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 3068e1e..992b3dd 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -120,6 +120,21 @@ obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o
  obj-$(CONFIG_SWIOTLB)			+= pci-swiotlb.o
  obj-$(CONFIG_X86_OF)			+= prom.o

+ifeq ($(CONFIG_X86_OF),y)
+ifneq ($(PLATFORM_DTB),)
+obj-y += $(PLATFORM_DTB).dtb.o
+endif
+endif
+
+dtstree	:= $(srctree)/arch/x86/boot/dts
+
+$(obj)/%.dtb: $(dtstree)/%.dts
+	$(call if_changed,dtc)
+
+$(obj)/%.dtb.S: $(obj)/%.dtb
+	@echo '.section .kernel:dtb,"a"' > $@
+	@echo '.incbin "$<" ' >> $@
+
  ###
  # 64 bit specific files
  ifeq ($(CONFIG_X86_64),y)
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 8a92a17..5729a24 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -146,6 +146,14 @@
  #define TRACE_SYSCALLS()
  #endif

+#ifdef CONFIG_OF
+#define KERNEL_DTB() _dtb_start = .;	    				\
+		   *(.kernel:dtb)					\
+		   _dtb_end = .;					
+#else
+ KERNEL_DTB()
+#endif
+
  /* .data section */
  #define DATA_DATA							\
  	*(.data)							\
@@ -245,6 +253,10 @@
  		VMLINUX_SYMBOL(__end_pci_fixups_suspend) = .;		\
  	}								\
  									\
+	.dtb : AT(ADDR(.dtb) - LOAD_OFFSET) {				\
+	     KERNEL_DTB()      		    				\
+	}		   						\
+								\
  	/* Built-in firmware blobs */					\
  	.builtin_fw        : AT(ADDR(.builtin_fw) - LOAD_OFFSET) {	\
  		VMLINUX_SYMBOL(__start_builtin_fw) = .;			\
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 54fd1b7..ce32644 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -207,6 +207,13 @@ quiet_cmd_gzip = GZIP    $@
  cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -f -9 > $@) || \
  	(rm -f $@ ; false)

+# DTC
+#  ---------------------------------------------------------------------------
+
+DTC = $(objtree)/scripts/dtc/dtc
+
+quiet_cmd_dtc = DTC	$@
+      cmd_dtc = $(DTC) -O dtb -o $(obj)/$*.dtb -b 0 -p 1024 $(dtstree)/$*.dts

  # Bzip2
  # ---------------------------------------------------------------------------

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2010-11-02  1:27 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-26 14:24 [RFC] [PATCH] Adding DTB to architecture independent vmlinux Dirk Brandewie
     [not found] ` <4CC6E491.7060304-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-10-27 11:09   ` Grant Likely
     [not found]     ` <20101027110937.GD7822-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2010-10-27 17:27       ` [sodaville] " H. Peter Anvin
     [not found]         ` <4CC860EF.6060503-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2010-10-28  0:30           ` [RFC] [PATCH V2] " Dirk Brandewie
     [not found]             ` <4CC8C423.9050600-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-10-28  0:57               ` David VomLehn
     [not found]                 ` <20101028005754.GA27386-ZEW99E7oL/EiWxQNNj96ibh/4TqKg8J2XqFh9Ls21Oc@public.gmane.org>
2010-10-28 15:18                   ` H. Peter Anvin
     [not found]                     ` <4CC99441.4030307-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2010-10-28 16:35                       ` [sodaville] " Sebastian Andrzej Siewior
     [not found]                         ` <4CC9A66B.6070408-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2010-10-28 16:38                           ` H. Peter Anvin
     [not found]                             ` <4CC9A705.3080806-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2010-10-28 18:00                               ` David VomLehn
     [not found]                                 ` <20101028180053.GC25771-ZEW99E7oL/EiWxQNNj96ibh/4TqKg8J2XqFh9Ls21Oc@public.gmane.org>
2010-11-01  4:15                                   ` Grant Likely
     [not found]                                     ` <AANLkTinYiTDsN+c_vgnK4OjmjpTzLHyyA8FqjPSaFm5h-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-11-02  1:27                                       ` David VomLehn
2010-10-29  4:02                           ` David Gibson
2010-10-28 17:32                       ` David VomLehn
     [not found]                         ` <20101028173202.GA25771-ZEW99E7oL/EiWxQNNj96ibh/4TqKg8J2XqFh9Ls21Oc@public.gmane.org>
2010-10-28 21:44                           ` H. Peter Anvin
     [not found]                             ` <4CC9EECF.9020208-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2010-10-29  4:04                               ` David Gibson
2010-10-29 20:29                                 ` H. Peter Anvin
     [not found]                                   ` <4CCB2E93.2010809-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2010-10-30 12:57                                     ` David Gibson
2010-11-01  4:12                           ` Grant Likely
2010-11-01  3:55           ` [sodaville] [RFC] [PATCH] " Grant Likely

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.