~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/decompress/mm.h

Version: ~ [ linux-5.4-rc7 ] ~ [ linux-5.3.11 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.84 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.154 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.201 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.201 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.77 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*
  3  * linux/compr_mm.h
  4  *
  5  * Memory management for pre-boot and ramdisk uncompressors
  6  *
  7  * Authors: Alain Knaff <alain@knaff.lu>
  8  *
  9  */
 10 
 11 #ifndef DECOMPR_MM_H
 12 #define DECOMPR_MM_H
 13 
 14 #ifdef STATIC
 15 
 16 /* Code active when included from pre-boot environment: */
 17 
 18 /*
 19  * Some architectures want to ensure there is no local data in their
 20  * pre-boot environment, so that data can arbitrarily relocated (via
 21  * GOT references).  This is achieved by defining STATIC_RW_DATA to
 22  * be null.
 23  */
 24 #ifndef STATIC_RW_DATA
 25 #define STATIC_RW_DATA static
 26 #endif
 27 
 28 /* A trivial malloc implementation, adapted from
 29  *  malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
 30  */
 31 STATIC_RW_DATA unsigned long malloc_ptr;
 32 STATIC_RW_DATA int malloc_count;
 33 
 34 static void *malloc(int size)
 35 {
 36         void *p;
 37 
 38         if (size < 0)
 39                 return NULL;
 40         if (!malloc_ptr)
 41                 malloc_ptr = free_mem_ptr;
 42 
 43         malloc_ptr = (malloc_ptr + 3) & ~3;     /* Align */
 44 
 45         p = (void *)malloc_ptr;
 46         malloc_ptr += size;
 47 
 48         if (free_mem_end_ptr && malloc_ptr >= free_mem_end_ptr)
 49                 return NULL;
 50 
 51         malloc_count++;
 52         return p;
 53 }
 54 
 55 static void free(void *where)
 56 {
 57         malloc_count--;
 58         if (!malloc_count)
 59                 malloc_ptr = free_mem_ptr;
 60 }
 61 
 62 #define large_malloc(a) malloc(a)
 63 #define large_free(a) free(a)
 64 
 65 #define INIT
 66 
 67 #else /* STATIC */
 68 
 69 /* Code active when compiled standalone for use when loading ramdisk: */
 70 
 71 #include <linux/kernel.h>
 72 #include <linux/fs.h>
 73 #include <linux/string.h>
 74 #include <linux/slab.h>
 75 #include <linux/vmalloc.h>
 76 
 77 /* Use defines rather than static inline in order to avoid spurious
 78  * warnings when not needed (indeed large_malloc / large_free are not
 79  * needed by inflate */
 80 
 81 #define malloc(a) kmalloc(a, GFP_KERNEL)
 82 #define free(a) kfree(a)
 83 
 84 #define large_malloc(a) vmalloc(a)
 85 #define large_free(a) vfree(a)
 86 
 87 #define INIT __init
 88 #define STATIC
 89 
 90 #include <linux/init.h>
 91 
 92 #endif /* STATIC */
 93 
 94 #endif /* DECOMPR_MM_H */
 95 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp