mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 09/12] decompressor: import malloc/free implementation for linux 3.4
Date: Fri, 27 Jul 2012 20:33:07 +0200	[thread overview]
Message-ID: <1343413990-31891-9-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1343413990-31891-1-git-send-email-plagnioj@jcrosoft.com>

This is need for gunzip support

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 include/linux/decompress/mm.h |   68 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 include/linux/decompress/mm.h

diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
new file mode 100644
index 0000000..0c35411
--- /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 */
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2012-07-27 18:33 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-27 18:31 [PATCH 00/12] Add Pre-Bootloader support Jean-Christophe PLAGNIOL-VILLARD
2012-07-27 18:32 ` [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so Jean-Christophe PLAGNIOL-VILLARD
2012-07-27 18:33   ` [PATCH 02/12] kbuild: add pre-bootloader (pbl) target Jean-Christophe PLAGNIOL-VILLARD
2012-07-27 18:33   ` [PATCH 03/12] Add pre-bootloader (pbl) image support Jean-Christophe PLAGNIOL-VILLARD
2012-07-27 18:33   ` [PATCH 04/12] pbl: discard unwind symbol if enable in barebox Jean-Christophe PLAGNIOL-VILLARD
2012-07-27 18:33   ` [PATCH 05/12] Add compressed image support Jean-Christophe PLAGNIOL-VILLARD
2012-07-27 18:33   ` [PATCH 06/12] only compress default env in uncompressed images Jean-Christophe PLAGNIOL-VILLARD
2012-07-27 18:33   ` [PATCH 07/12] ARM: Separate assembler functions into their own section Jean-Christophe PLAGNIOL-VILLARD
2012-07-30  7:50     ` Sascha Hauer
2012-07-30  8:27       ` Jean-Christophe PLAGNIOL-VILLARD
2012-07-27 18:33   ` [PATCH 08/12] decompress_unlzo: define decompress_unlzo as decompress Jean-Christophe PLAGNIOL-VILLARD
2012-07-30  7:56     ` Sascha Hauer
2012-07-30  8:06       ` Sascha Hauer
2012-07-27 18:33   ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-07-27 18:33   ` [PATCH 10/12] ARM: add early malloc support needed by the decompressor Jean-Christophe PLAGNIOL-VILLARD
2012-07-30  8:02     ` Sascha Hauer
2012-07-30  8:19       ` Jean-Christophe PLAGNIOL-VILLARD
2012-07-30  8:30         ` Sascha Hauer
2012-07-30  8:49           ` Jean-Christophe PLAGNIOL-VILLARD
2012-07-30  8:59             ` Sascha Hauer
2012-07-30  9:04               ` Jean-Christophe PLAGNIOL-VILLARD
2012-07-30  9:20                 ` Sascha Hauer
2012-07-30  9:30                   ` Jean-Christophe PLAGNIOL-VILLARD
2012-07-27 18:33   ` [PATCH 11/12] compressed image: add gzip support Jean-Christophe PLAGNIOL-VILLARD
2012-07-27 18:33   ` [PATCH 12/12] at91: add lowlevel init to the pbl Jean-Christophe PLAGNIOL-VILLARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1343413990-31891-9-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox