9
0
Fork 0

Merge branch 'for-next/pbl'

This commit is contained in:
Sascha Hauer 2013-02-04 15:49:07 +01:00
commit 56325edd79
11 changed files with 125 additions and 84 deletions

View File

@ -24,6 +24,7 @@
#include <common.h>
#include <init.h>
#include <sizes.h>
#include <pbl.h>
#include <asm/barebox-arm.h>
#include <asm/barebox-arm-head.h>
#include <asm-generic/memory_layout.h>
@ -59,16 +60,6 @@ void __naked __bare_init reset(void)
extern void *input_data;
extern void *input_data_end;
#define STATIC static
#ifdef CONFIG_IMAGE_COMPRESSION_LZO
#include "../../../lib/decompress_unlzo.c"
#endif
#ifdef CONFIG_IMAGE_COMPRESSION_GZIP
#include "../../../lib/decompress_inflate.c"
#endif
static unsigned long *ttb;
static void create_sections(unsigned long addr, int size_m, unsigned int flags)
@ -127,11 +118,6 @@ static void mmu_disable(void)
__mmu_cache_off();
}
static void noinline errorfn(char *error)
{
while (1);
}
static void barebox_uncompress(void *compressed_start, unsigned int len)
{
void (*barebox)(void);
@ -155,10 +141,7 @@ static void barebox_uncompress(void *compressed_start, unsigned int len)
else
barebox = (void *)TEXT_BASE;
decompress((void *)compressed_start,
len,
NULL, NULL,
(void *)TEXT_BASE, NULL, errorfn);
pbl_barebox_uncompress((void*)TEXT_BASE, compressed_start, len);
if (use_mmu)
mmu_disable();

View File

@ -1,6 +1,7 @@
suffix_$(CONFIG_IMAGE_COMPRESSION_GZIP) = gzip
suffix_$(CONFIG_IMAGE_COMPRESSION_LZO) = lzo
suffix_$(CONFIG_IMAGE_COMPRESSION_NONE) = shipped
OBJCOPYFLAGS_zbarebox.bin = -O binary
piggy_o := piggy.$(suffix_y).o
@ -9,7 +10,7 @@ targets := zbarebox.lds zbarebox zbarebox.bin zbarebox.S \
$(piggy_o) piggy.$(suffix_y)
# Make sure files are removed during clean
extra-y += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern zbarebox.map
extra-y += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern piggy.shipped zbarebox.map
$(obj)/zbarebox.bin: $(obj)/zbarebox FORCE
$(call if_changed,objcopy)

View File

@ -0,0 +1,6 @@
.section .piggydata,#alloc
.globl input_data
input_data:
.incbin "arch/arm/pbl/piggy.shipped"
.globl input_data_end
input_data_end:

View File

@ -17,6 +17,7 @@
*/
#include <common.h>
#include <pbl.h>
#include <init.h>
#include <sizes.h>
#include <string.h>
@ -30,28 +31,10 @@ extern void *input_data_end;
unsigned long free_mem_ptr;
unsigned long free_mem_end_ptr;
#define STATIC static
#ifdef CONFIG_IMAGE_COMPRESSION_LZO
#include "../../../lib/decompress_unlzo.c"
#endif
#ifdef CONFIG_IMAGE_COMPRESSION_GZIP
#include "../../../lib/decompress_inflate.c"
#endif
void pbl_main_entry(void);
static unsigned long *ttb;
static noinline void errorfn(char *error)
{
PUTS_LL(error);
PUTC_LL('\n');
unreachable();
}
static void barebox_uncompress(void *compressed_start, unsigned int len)
{
/* set 128 KiB at the end of the MALLOC_BASE for early malloc */
@ -60,10 +43,7 @@ static void barebox_uncompress(void *compressed_start, unsigned int len)
ttb = (void *)((free_mem_ptr - 0x4000) & ~0x3fff);
decompress((void *)compressed_start,
len,
NULL, NULL,
(void *)TEXT_BASE, NULL, errorfn);
pbl_barebox_uncompress((void*)TEXT_BASE, compressed_start, len);
}
void __section(.text_entry) pbl_main_entry(void)

View File

@ -1,6 +1,7 @@
suffix_$(CONFIG_IMAGE_COMPRESSION_GZIP) = gzip
suffix_$(CONFIG_IMAGE_COMPRESSION_LZO) = lzo
suffix_$(CONFIG_IMAGE_COMPRESSION_NONE) = shipped
OBJCOPYFLAGS_zbarebox.bin = -O binary
piggy_o := piggy.$(suffix_y).o
@ -9,7 +10,7 @@ targets := zbarebox.lds zbarebox zbarebox.bin zbarebox.S \
$(piggy_o) piggy.$(suffix_y)
# Make sure files are removed during clean
extra-y += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern zbarebox.map
extra-y += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern piggy.shipped zbarebox.map
$(obj)/zbarebox.bin: $(obj)/zbarebox FORCE
$(call if_changed,objcopy)

View File

@ -0,0 +1,6 @@
.section .piggydata,#alloc
.globl input_data
input_data:
.incbin "arch/mips/pbl/piggy.shipped"
.globl input_data_end
input_data_end:

View File

@ -105,47 +105,7 @@ config ENVIRONMENT_VARIABLES
menu "memory layout"
config HAVE_PBL_IMAGE
bool
config HAVE_IMAGE_COMPRESSION
bool
config PBL_IMAGE
bool "Pre-Bootloader image"
depends on HAVE_PBL_IMAGE
config PBL_FORCE_PIGGYDATA_COPY
bool
help
In some case we need to copy the PIGGYDATA as the link address
as example we run from SRAM and shutdown the SDRAM/DDR for
reconfiguration but most of the time we just need to copy the
executable code.
if PBL_IMAGE
config IMAGE_COMPRESSION
bool
depends on HAVE_IMAGE_COMPRESSION
default y
if IMAGE_COMPRESSION
choice
prompt "Compression"
config IMAGE_COMPRESSION_LZO
bool "lzo"
config IMAGE_COMPRESSION_GZIP
bool "gzip"
endchoice
endif
endif
source "pbl/Kconfig"
config MMU
bool "Enable MMU"

15
include/pbl.h Normal file
View File

@ -0,0 +1,15 @@
/*
* Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
*
* Under GPLv2
*/
#ifndef __PBL_H__
#define __PBL_H__
extern unsigned long free_mem_ptr;
extern unsigned long free_mem_end_ptr;
void pbl_barebox_uncompress(void *dest, void *compressed_start, unsigned int len);
#endif /* __PBL_H__ */

44
pbl/Kconfig Normal file
View File

@ -0,0 +1,44 @@
config HAVE_PBL_IMAGE
bool
config HAVE_IMAGE_COMPRESSION
bool
config PBL_IMAGE
bool "Pre-Bootloader image"
depends on HAVE_PBL_IMAGE
config PBL_FORCE_PIGGYDATA_COPY
bool
help
In some case we need to copy the PIGGYDATA as the link address
as example we run from SRAM and shutdown the SDRAM/DDR for
reconfiguration but most of the time we just need to copy the
executable code.
if PBL_IMAGE
config IMAGE_COMPRESSION
bool
depends on HAVE_IMAGE_COMPRESSION
default y
if IMAGE_COMPRESSION
choice
prompt "Compression"
config IMAGE_COMPRESSION_LZO
bool "lzo"
config IMAGE_COMPRESSION_GZIP
bool "gzip"
config IMAGE_COMPRESSION_NONE
bool "none"
endchoice
endif
endif

View File

@ -3,3 +3,4 @@
#
pbl-y += misc.o
pbl-y += string.o
pbl-y += decomp.o

44
pbl/decomp.c Normal file
View File

@ -0,0 +1,44 @@
/*
* Copyright (c) 2010-2012 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
* Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
*
* Under GPLv2 only
*/
#include <common.h>
#include <pbl.h>
#define STATIC static
#ifdef CONFIG_IMAGE_COMPRESSION_LZO
#include "../../../lib/decompress_unlzo.c"
#endif
#ifdef CONFIG_IMAGE_COMPRESSION_GZIP
#include "../../../lib/decompress_inflate.c"
#endif
#ifdef CONFIG_IMAGE_COMPRESSION_NONE
STATIC int decompress(u8 *input, int in_len,
int (*fill) (void *, unsigned int),
int (*flush) (void *, unsigned int),
u8 *output, int *posp,
void (*error) (char *x))
{
memcpy(output, input, in_len);
return 0;
}
#endif
static void noinline errorfn(char *error)
{
while (1);
}
void pbl_barebox_uncompress(void *dest, void *compressed_start, unsigned int len)
{
decompress((void *)compressed_start,
len,
NULL, NULL,
dest, NULL, errorfn);
}