On Mon, Jul 23, 2012 at 06:26:02AM +0200, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
> Today we link to whole barebox and rely on gcc to cleanup via it's garbage
> collector.
> Now we specify only what is needed and introduce a new directory with source
> only related to the compressed target.
> 
> Build it in arch/<arm>/compressed
> Rebuild all the needed object.
> 
> Keep the previous target untouched.
> This fix the modules support and allow custom flags for each file.
> 
> Import string functions from linux 3.4 (arch/arm/boot/compressed/string.c) and
> implement a dummy panic.

This does not work on all targets having a lowlevel init:

arch/arm/compressed/start.o: In function `reset':
start.c:(.text_bare_init.text+0x28): undefined reference to 
`board_init_lowlevel'

Why don't we simply do this:


diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 647c536..12869b3 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -150,11 +150,9 @@ TEXT_BASE = $(CONFIG_TEXT_BASE)
 
 CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE)
 
-ifndef CONFIG_MODULES
 # Add cleanup flags
 CPPFLAGS += -fdata-sections -ffunction-sections
 LDFLAGS_barebox += -static --gc-sections
-endif
 
 barebox.netx: barebox.bin
        $(Q)scripts/gen_netx_image -i barebox.bin -o barebox.netx               
\

>  
> +void barebox_decompress(uint32_t offset)
> +{
> +     uint32_t compressed_start, compressed_end, len;
> +     void (*uncompress)(void *compressed_start, unsigned int len);
> +
> +     compressed_start = (uint32_t)&input_data - offset;
> +     compressed_end = (uint32_t)&input_data_end - offset;
> +     len = compressed_end - compressed_start;
> +
> +     uncompress = barebox_uncompress;
> +
> +     /* call barebox_uncompress with its absolute address */
> +     __asm__ __volatile__(
> +             "mov r0, %1\n"
> +             "mov r1, %2\n"
> +             "mov pc, %0\n"
> +             :
> +             : "r"(uncompress), "r"(compressed_start), "r"(len)
> +             : "r0", "r1");
> +}
> +#else
> +void barebox_decompress(uint32_t offset) {}
> +#endif
>  
>  /*
>   * Board code can jump here by either returning from board_init_lowlevel
> @@ -137,8 +161,6 @@ void barebox_uncompress(void *compressed_start, unsigned 
> int len)
>  void __naked __section(.text_ll_return) board_init_lowlevel_return(void)
>  {
>       uint32_t r, addr, offset;
> -     uint32_t compressed_start, compressed_end, len;
> -     void (*uncompress)(void *compressed_start, unsigned int len);
>  
>       /*
>        * Get runtime address of this function. Do not
> @@ -169,20 +191,7 @@ void __naked __section(.text_ll_return) 
> board_init_lowlevel_return(void)
>       __asm__ __volatile__("mcr p15, 0, %0, c7, c5, 0" : : "r" (0));
>  
>       if (IS_ENABLED(CONFIG_IMAGE_COMPRESSION)) {
> -             compressed_start = (uint32_t)&input_data - offset;
> -             compressed_end = (uint32_t)&input_data_end - offset;
> -             len = compressed_end - compressed_start;
> -
> -             uncompress = barebox_uncompress;
> -
> -             /* call barebox_uncompress with its absolute address */
> -             __asm__ __volatile__(
> -                     "mov r0, %1\n"
> -                     "mov r1, %2\n"
> -                     "mov pc, %0\n"
> -                     :
> -                     : "r"(uncompress), "r"(compressed_start), "r"(len)
> -                     : "r0", "r1");
> +             barebox_decompress(offset);

With this you don't call the decompressor with it's absolute address
anymore, which means that the decompressor won't run at the address it's
linked at.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to