diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2012-09-05 12:59:29 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-09-05 12:59:29 +0200 |
commit | bed1a6ffab6ba8f59146af07ccbdc7a625b6496f (patch) | |
tree | 6301a84dc2ef2d746a9a60979573e03eb6cc1c6a /include | |
parent | b40aeb00d32f07c5b1b617ea4e88032cb895d8b3 (diff) | |
parent | d5b6012ac1e674e7ce285d6b47cd346d765267d0 (diff) | |
download | barebox-bed1a6ffab6ba8f59146af07ccbdc7a625b6496f.tar.gz barebox-bed1a6ffab6ba8f59146af07ccbdc7a625b6496f.tar.xz |
Merge branch 'for-next/pbl'
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/memory_layout.h | 1 | ||||
-rw-r--r-- | include/asm-generic/sections.h | 2 | ||||
-rw-r--r-- | include/linux/decompress/mm.h | 68 |
3 files changed, 71 insertions, 0 deletions
diff --git a/include/asm-generic/memory_layout.h b/include/asm-generic/memory_layout.h index 941cd42955..eb1607f36d 100644 --- a/include/asm-generic/memory_layout.h +++ b/include/asm-generic/memory_layout.h @@ -13,6 +13,7 @@ #endif +#define HEAD_TEXT_BASE MALLOC_BASE #define MALLOC_SIZE CONFIG_MALLOC_SIZE #define STACK_SIZE CONFIG_STACK_SIZE diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h index 5484b6f004..17d5fd1ae4 100644 --- a/include/asm-generic/sections.h +++ b/include/asm-generic/sections.h @@ -7,8 +7,10 @@ extern char __bare_init_start[], __bare_init_end[]; extern char _end[]; extern void *_barebox_image_size; extern void *_barebox_bare_init_size; +extern void *_barebox_pbl_size; #define barebox_image_size (unsigned int)&_barebox_image_size #define barebox_bare_init_size (unsigned int)&_barebox_bare_init_size +#define barebox_pbl_size (unsigned int)&_barebox_pbl_size #endif /* _ASM_GENERIC_SECTIONS_H_ */ diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h new file mode 100644 index 0000000000..0c354110c0 --- /dev/null +++ b/include/linux/decompress/mm.h @@ -0,0 +1,68 @@ +/* + * linux/compr_mm.h + * + * Memory management for pre-boot and ramdisk uncompressors + * + * Authors: Alain Knaff <alain@knaff.lu> + * + */ + +#ifndef DECOMPR_MM_H +#define DECOMPR_MM_H + +#ifdef STATIC + +/* Code active when included from pre-boot environment: */ + +/* + * Some architectures want to ensure there is no local data in their + * pre-boot environment, so that data can arbitrarily relocated (via + * GOT references). This is achieved by defining STATIC_RW_DATA to + * be null. + */ +#ifndef STATIC_RW_DATA +#define STATIC_RW_DATA static +#endif + +/* A trivial malloc implementation, adapted from + * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994 + */ +STATIC_RW_DATA unsigned long malloc_ptr; +STATIC_RW_DATA int malloc_count; + +static void *malloc(int size) +{ + void *p; + + if (size < 0) + return NULL; + if (!malloc_ptr) + malloc_ptr = free_mem_ptr; + + malloc_ptr = (malloc_ptr + 3) & ~3; /* Align */ + + p = (void *)malloc_ptr; + malloc_ptr += size; + + if (free_mem_end_ptr && malloc_ptr >= free_mem_end_ptr) + return NULL; + + malloc_count++; + return p; +} + +static void free(void *where) +{ + malloc_count--; + if (!malloc_count) + malloc_ptr = free_mem_ptr; +} + +#define large_malloc(a) malloc(a) +#define large_free(a) free(a) + +#define INIT + +#endif /* STATIC */ + +#endif /* DECOMPR_MM_H */ |