kexex: arm: create ATAGS_MEM tag from devicetree memory node
Subsystems (2)
PATCH 1/2 kexex: arm: create ATAGS_MEM tag from devicetree memory node
From: Andreas Fenkart <[email protected]>
booting a non-devicetree kernel from a devicetree kernel failed, since the memory layout wasn't passed.
--- kexec/arch/arm/kexec-zImage-arm.c | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
kexec/arch/arm/kexec-zImage-arm.c +43 -0
@@ -4,6 +4,7 @@*/ #define _GNU_SOURCE#define _XOPEN_SOURCE +#include <assert.h> #include <stdio.h> #include <string.h> #include <stdlib.h>
@@ -139,6 +140,42 @@ 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" ; +FILE *fp; +uint32_t tmp[2 ]; +int ret =0 ; + +assert (tag_mem32); + fp =fopen (fn,"r" ); +if (!fp) { + ret = errno; +fprintf (stderr,"Cannot open %s: %m\n" , fn); +return ret; + } + +if (!fread (tmp,sizeof (tmp[0 ]),2 , fp)) { + ret =ENOENT ; +fprintf (stderr,"Short read %s\n" , fn); + goto out; + } + +if (ferror (fp)) { + ret = errno; +fprintf (stderr,"Cannot read %s: %m\n" , fn); + goto out; + } + +/* atags_mem32 has base/size fields reversed! */ + tag_mem32->size =be32_to_cpu (tmp[1 ]); + tag_mem32->start =be32_to_cpu (tmp[0 ]); + +out: +fclose (fp); +return ret; +} static int atag_arm_load(struct kexec_info *info, unsigned long base,
@@ -182,6 +219,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 (¶ms->u.mem)) { + params->hdr.size =4 ; + params->hdr.tag =ATAG_MEM ; + params =tag_next (params); + } }if (initrd) {
Signature · 7 lines
2.6.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 2/2 uImage: fix pointer-sign warning
--- kexec/kexec-uImage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kexec/kexec-uImage.c +1 -1
@@ -224,7 +224,7 @@ static int uImage_gz_load(const unsigned char *buf, off_t len, return 0; }#else -static int uImage_gz_load (const char *UNUSED (buf ),off_t UNUSED (len ), +static int uImage_gz_load (const unsigned char *UNUSED (buf ),off_t UNUSED (len ),struct Image_info *UNUSED (image )) {return -1 ;
Signature · 7 lines
2.6.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Simon Horman
AppliedRe: [PATCH 2/2] uImage: fix pointer-sign warning
Quoted 1 line · Andreas Fenkart
Signed-off-by Andreas Fenkart <[email protected]>
Thanks, applied.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 4 lines · Andreas Fenkart
From: Andreas Fenkart <[email protected]>
booting a non-devicetree kernel from a devicetree kernel failed, since the memory layout wasn't passed.
Nice catch.
Quoted 20 lines
Signed-off-by Andreas Fenkart <[email protected]>--- kexec/arch/arm/kexec-zImage-arm.c | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)kexec/arch/arm/kexec-zImage-arm.c +1
-0@@ -4,6 +4,7 @@*/ #define _GNU_SOURCE#define _XOPEN_SOURCE +#include <assert.h> #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -139,6 +140,42 @@ struct tag * atag_read_tags(void)return (struct tag *) buf; }
kexec/arch/arm/kexec-zImage-arm.c struct tag * atag_read_tags(void) · line 151
Quoted 10 lines
kexec/arch/arm/kexec-zImage-arm.c +9
-0+static +int create_mem32_tag (struct tag_mem32 *tag_mem32) +{ +const char fn[]="/proc/device-tree/memory/reg" ; +FILE *fp; +uint32_t tmp[2 ]; +int ret =0 ; + +assert (tag_mem32);
I think the assertion here is unnecessary. Could you remove it?
kexec/arch/arm/kexec-zImage-arm.c struct tag * atag_read_tags(void) · line 156
Quoted 5 lines
kexec/arch/arm/kexec-zImage-arm.c +5
-0+ fp =fopen (fn,"r" ); +if (!fp) { + ret = errno; +fprintf (stderr,"Cannot open %s: %m\n" , fn); +return ret;
I think that returning -1 for error and 0 for success would be both consistent with the rest of the source in the same file and result in slightly simpler code.
Quoted 28 lines
kexec/arch/arm/kexec-zImage-arm.c +22
-0+ } + +if (!fread (tmp,sizeof (tmp[0 ]),2 , fp)) { + ret =ENOENT ; +fprintf (stderr,"Short read %s\n" , fn); + goto out; + } + +if (ferror (fp)) { + ret = errno; +fprintf (stderr,"Cannot read %s: %m\n" , fn); + goto out; + } + +/* atags_mem32 has base/size fields reversed! */ + tag_mem32->size =be32_to_cpu (tmp[1 ]); + tag_mem32->start =be32_to_cpu (tmp[0 ]); + +out: +fclose (fp); +return ret; +} static int atag_arm_load(struct kexec_info *info, unsigned long base,@@ -182,6 +219,12 @@ int atag_arm_load(struct kexec_info *info, unsigned long base, params->hdr.size =2 ; params->hdr.tag =ATAG_CORE ;
kexec/arch/arm/kexec-zImage-arm.c int atag_arm_load(struct kexec_info *info, unsigned long base, · line 230
Quoted 10 lines
kexec/arch/arm/kexec-zImage-arm.c +6
-0params =tag_next (params); + +if (!create_mem32_tag (¶ms->u.mem)) { + params->hdr.size =4 ; + params->hdr.tag =ATAG_MEM ; + params =tag_next (params); + } }if (initrd) {
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec