USB: add hex/bcd detection to usb modalias generation
[linux-2.6.git] / include / linux / decompress / mm.h
blob12ff8c3f1d053f471c14e5f74ad50bf0355ebfa8
1 /*
2 * linux/compr_mm.h
4 * Memory management for pre-boot and ramdisk uncompressors
6 * Authors: Alain Knaff <alain@knaff.lu>
8 */
10 #ifndef DECOMPR_MM_H
11 #define DECOMPR_MM_H
13 #ifdef STATIC
15 /* Code active when included from pre-boot environment: */
17 /* A trivial malloc implementation, adapted from
18 * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
20 static unsigned long malloc_ptr;
21 static int malloc_count;
23 static void *malloc(int size)
25 void *p;
27 if (size < 0)
28 error("Malloc error");
29 if (!malloc_ptr)
30 malloc_ptr = free_mem_ptr;
32 malloc_ptr = (malloc_ptr + 3) & ~3; /* Align */
34 p = (void *)malloc_ptr;
35 malloc_ptr += size;
37 if (free_mem_end_ptr && malloc_ptr >= free_mem_end_ptr)
38 error("Out of memory");
40 malloc_count++;
41 return p;
44 static void free(void *where)
46 malloc_count--;
47 if (!malloc_count)
48 malloc_ptr = free_mem_ptr;
51 #define large_malloc(a) malloc(a)
52 #define large_free(a) free(a)
54 #define set_error_fn(x)
56 #define INIT
58 #else /* STATIC */
60 /* Code active when compiled standalone for use when loading ramdisk: */
62 #include <linux/kernel.h>
63 #include <linux/fs.h>
64 #include <linux/string.h>
65 #include <linux/vmalloc.h>
67 /* Use defines rather than static inline in order to avoid spurious
68 * warnings when not needed (indeed large_malloc / large_free are not
69 * needed by inflate */
71 #define malloc(a) kmalloc(a, GFP_KERNEL)
72 #define free(a) kfree(a)
74 #define large_malloc(a) vmalloc(a)
75 #define large_free(a) vfree(a)
77 static void(*error)(char *m);
78 #define set_error_fn(x) error = x;
80 #define INIT __init
81 #define STATIC
83 #include <linux/init.h>
85 #endif /* STATIC */
87 #endif /* DECOMPR_MM_H */