cregit-Linux how code gets into the kernel

Release 4.7 include/linux/decompress/mm.h

/*
 * 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; }

Contributors

PersonTokensPropCommitsCommitProp
alain knaffalain knaff6791.78%150.00%
phillip lougherphillip lougher68.22%150.00%
Total73100.00%2100.00%


static void free(void *where) { malloc_count--; if (!malloc_count) malloc_ptr = free_mem_ptr; }

Contributors

PersonTokensPropCommitsCommitProp
alain knaffalain knaff22100.00%1100.00%
Total22100.00%1100.00%

#define large_malloc(a) malloc(a) #define large_free(a) free(a) #define INIT #else /* STATIC */ /* Code active when compiled standalone for use when loading ramdisk: */ #include <linux/kernel.h> #include <linux/fs.h> #include <linux/string.h> #include <linux/slab.h> #include <linux/vmalloc.h> /* Use defines rather than static inline in order to avoid spurious * warnings when not needed (indeed large_malloc / large_free are not * needed by inflate */ #define malloc(a) kmalloc(a, GFP_KERNEL) #define free(a) kfree(a) #define large_malloc(a) vmalloc(a) #define large_free(a) vfree(a) #define INIT __init #define STATIC #include <linux/init.h> #endif /* STATIC */ #endif /* DECOMPR_MM_H */

Overall Contributors

PersonTokensPropCommitsCommitProp
alain knaffalain knaff18689.86%120.00%
russell kingrussell king115.31%120.00%
phillip lougherphillip lougher62.90%120.00%
lasse collinlasse collin31.45%120.00%
lucas de marchilucas de marchi10.48%120.00%
Total207100.00%5100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
{% endraw %}