aboutsummaryrefslogtreecommitdiffstats
path: root/arch/cris/arch-v10
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>2008-07-25 04:45:44 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-25 13:53:28 -0400
commit2d6ffcca623a9a16df6cdfbe8250b7a5904a5f5e (patch)
tree70d30cb6516608e9a8a1dce60c59f3a5ff21b305 /arch/cris/arch-v10
parentba92a43dbaee339cf5915ef766d3d3ffbaaf103c (diff)
inflate: refactor inflate malloc code
Inflate requires some dynamic memory allocation very early in the boot process and this is provided with a set of four functions: malloc/free/gzip_mark/gzip_release. The old inflate code used a mark/release strategy rather than implement free. This new version instead keeps a count on the number of outstanding allocations and when it hits zero, it resets the malloc arena. This allows removing all the mark and release implementations and unifying all the malloc/free implementations. The architecture-dependent code must define two addresses: - free_mem_ptr, the address of the beginning of the area in which allocations should be made - free_mem_end_ptr, the address of the end of the area in which allocations should be made. If set to 0, then no check is made on the number of allocations, it just grows as much as needed The architecture-dependent code can also provide an arch_decomp_wdog() function call. This function will be called several times during the decompression process, and allow to notify the watchdog that the system is still running. If an architecture provides such a call, then it must define ARCH_HAS_DECOMP_WDOG so that the generic inflate code calls arch_decomp_wdog(). Work initially done by Matt Mackall, updated to a recent version of the kernel and improved by me. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Cc: Matt Mackall <mpm@selenic.com> Cc: Richard Henderson <rth@twiddle.net> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: Mikael Starvik <mikael.starvik@axis.com> Cc: Jesper Nilsson <jesper.nilsson@axis.com> Cc: Haavard Skinnemoen <hskinnemoen@atmel.com> Cc: David Howells <dhowells@redhat.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Andi Kleen <andi@firstfloor.org> Cc: "H. Peter Anvin" <hpa@zytor.com> Acked-by: Paul Mundt <lethal@linux-sh.org> Acked-by: Yoshinori Sato <ysato@users.sourceforge.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/cris/arch-v10')
-rw-r--r--arch/cris/arch-v10/boot/compressed/misc.c36
1 files changed, 1 insertions, 35 deletions
diff --git a/arch/cris/arch-v10/boot/compressed/misc.c b/arch/cris/arch-v10/boot/compressed/misc.c
index 18e13bce1400..d933c89889db 100644
--- a/arch/cris/arch-v10/boot/compressed/misc.c
+++ b/arch/cris/arch-v10/boot/compressed/misc.c
@@ -102,50 +102,16 @@ extern char *input_data; /* lives in head.S */
102static long bytes_out = 0; 102static long bytes_out = 0;
103static uch *output_data; 103static uch *output_data;
104static unsigned long output_ptr = 0; 104static unsigned long output_ptr = 0;
105
106static void *malloc(int size);
107static void free(void *where);
108static void gzip_mark(void **);
109static void gzip_release(void **);
110
111static void puts(const char *); 105static void puts(const char *);
112 106
113/* the "heap" is put directly after the BSS ends, at end */ 107/* the "heap" is put directly after the BSS ends, at end */
114 108
115extern int _end; 109extern int _end;
116static long free_mem_ptr = (long)&_end; 110static long free_mem_ptr = (long)&_end;
111static long free_mem_end_ptr;
117 112
118#include "../../../../../lib/inflate.c" 113#include "../../../../../lib/inflate.c"
119 114
120static void *malloc(int size)
121{
122 void *p;
123
124 if (size < 0)
125 error("Malloc error");
126
127 free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */
128
129 p = (void *)free_mem_ptr;
130 free_mem_ptr += size;
131
132 return p;
133}
134
135static void free(void *where)
136{ /* Don't care */
137}
138
139static void gzip_mark(void **ptr)
140{
141 *ptr = (void *) free_mem_ptr;
142}
143
144static void gzip_release(void **ptr)
145{
146 free_mem_ptr = (long) *ptr;
147}
148
149/* decompressor info and error messages to serial console */ 115/* decompressor info and error messages to serial console */
150 116
151static void 117static void