From: "Mark A. Greer" <mgreer@mvista.com>
To: linuxppc-dev <Linuxppc-dev@ozlabs.org>
Subject: Re: [PATCH 5/6] bootwrapper: Add simple memory allocator
Date: Thu, 7 Sep 2006 20:40:36 -0700 [thread overview]
Message-ID: <20060908034036.GE5203@mag.az.mvista.com> (raw)
In-Reply-To: <20060719231421.GF3887@mag.az.mvista.com>
This patch adds a simple memory allocator to the bootwrapper.
Signed-off-by: Mark A. Greer <mgreer@mvista.com>
--
simple_alloc.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+)
--
diff --git a/arch/powerpc/boot/simple_alloc.c b/arch/powerpc/boot/simple_alloc.c
new file mode 100644
index 0000000..ccf61b2
--- /dev/null
+++ b/arch/powerpc/boot/simple_alloc.c
@@ -0,0 +1,48 @@
+/*
+ * Simple memory allocator.
+ *
+ * Author: Mark A. Greer <mgreer@mvista.com>
+ *
+ * 2006 (c) MontaVista, Software, Inc. This file is licensed under
+ * the terms of the GNU General Public License version 2. This program
+ * is licensed "as is" without any warranty of any kind, whether express
+ * or implied.
+ */
+
+/* Some day, put in a real memory allocator */
+
+#include <stddef.h>
+#include "types.h"
+#include "page.h"
+#include "ops.h"
+
+#define MB (1024*1024)
+
+extern char _end[];
+
+static u32 cur_base;
+static u32 end_of_ram = 32 * MB;
+
+static void *simple_malloc(u32 size)
+{
+ void *area = NULL;
+ static u8 first_time = 1;
+
+ if (first_time) {
+ cur_base = _ALIGN_UP((unsigned long)_end, MB);
+ first_time = 0;
+ }
+
+ if ((cur_base + size) < end_of_ram) {
+ area = (void *)cur_base;
+ cur_base += _ALIGN_UP(size, MB);
+ }
+
+ return area;
+}
+
+void simple_alloc_init(void)
+{
+ platform_ops.malloc = simple_malloc;
+ platform_ops.free = NULL;
+}
prev parent reply other threads:[~2006-09-08 3:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-19 23:14 [PATCH 5/6] bootwrapper: Add support for the DINK firmware Mark A. Greer
2006-07-19 23:33 ` Mark A. Greer
2006-08-02 16:19 ` Tom Rini
2006-08-02 18:14 ` Mark A. Greer
2006-08-02 18:15 ` Tom Rini
2006-08-02 18:31 ` Mark A. Greer
2006-09-08 3:40 ` Mark A. Greer [this message]
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=20060908034036.GE5203@mag.az.mvista.com \
--to=mgreer@mvista.com \
--cc=Linuxppc-dev@ozlabs.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;
as well as URLs for NNTP newsgroup(s).