All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] kexex: arm: create ATAGS_MEM tag from devicetree memory node
@ 2015-11-20  9:47 Andreas Fenkart
  2015-11-24  6:59 ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Fenkart @ 2015-11-20  9:47 UTC (permalink / raw)
  To: kexec; +Cc: Andreas Fenkart

booting a non-devicetree kernel from a devicetree kernel failed,
since the memory layout wasn't passed.

Signed-off-by: Andreas Fenkart <andreas.fenkart@dev.digitalstrom.org>
---
 kexec/arch/arm/kexec-zImage-arm.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
index ff4e38d..d5b8ab4 100644
--- a/kexec/arch/arm/kexec-zImage-arm.c
+++ b/kexec/arch/arm/kexec-zImage-arm.c
@@ -139,6 +139,38 @@ struct tag * atag_read_tags(void)
 	return (struct tag *) buf;
 }
 
+static
+int create_mem32_tag(struct tag_mem32 *tag_mem32)
+{
+	const char fn[]= "/proc/device-tree/memory/reg";
+	uint32_t tmp[2];
+	FILE *fp;
+
+	fp = fopen(fn, "r");
+	if (!fp) {
+		fprintf(stderr, "Cannot open %s: %m\n", fn);
+		return -1;
+	}
+
+	if (fread(tmp, sizeof(tmp[0]), 2, fp) != 2) {
+		fprintf(stderr, "Short read %s\n", fn);
+		fclose(fp);
+		return -1;
+	}
+
+	if (ferror(fp)) {
+		fprintf(stderr, "Cannot read %s: %m\n", fn);
+		fclose(fp);
+		return -1;
+	}
+
+	/* atags_mem32 has base/size fields reversed! */
+	tag_mem32->size = be32_to_cpu(tmp[1]);
+	tag_mem32->start = be32_to_cpu(tmp[0]);
+
+	fclose(fp);
+	return 0;
+}
 
 static
 int atag_arm_load(struct kexec_info *info, unsigned long base,
@@ -182,6 +214,12 @@ int atag_arm_load(struct kexec_info *info, unsigned long base,
 		params->hdr.size = 2;
 		params->hdr.tag = ATAG_CORE;
 		params = tag_next(params);
+
+		if (!create_mem32_tag(&params->u.mem)) {
+			params->hdr.size = 4;
+			params->hdr.tag = ATAG_MEM;
+			params = tag_next(params);
+		}
 	}
 
 	if (initrd) {
-- 
2.6.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* Re: [PATCH v2] kexex: arm: create ATAGS_MEM tag from devicetree memory node
  2015-11-20  9:47 [PATCH v2] kexex: arm: create ATAGS_MEM tag from devicetree memory node Andreas Fenkart
@ 2015-11-24  6:59 ` Simon Horman
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2015-11-24  6:59 UTC (permalink / raw)
  To: Andreas Fenkart; +Cc: Andreas Fenkart, kexec

On Fri, Nov 20, 2015 at 10:47:47AM +0100, Andreas Fenkart wrote:
> booting a non-devicetree kernel from a devicetree kernel failed,
> since the memory layout wasn't passed.
> 
> Signed-off-by: Andreas Fenkart <andreas.fenkart@dev.digitalstrom.org>
> ---
>  kexec/arch/arm/kexec-zImage-arm.c | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)

Thanks, applied.

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

end of thread, other threads:[~2015-11-24  6:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-20  9:47 [PATCH v2] kexex: arm: create ATAGS_MEM tag from devicetree memory node Andreas Fenkart
2015-11-24  6:59 ` Simon Horman

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.