mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: barebox@lists.infradead.org
Subject: [RFC v2 09/16] picotcp: add barebox target support
Date: Sun, 19 Jul 2015 23:07:16 +0300	[thread overview]
Message-ID: <1437336443-8076-10-git-send-email-antonynpavlov@gmail.com> (raw)
In-Reply-To: <1437336443-8076-1-git-send-email-antonynpavlov@gmail.com>

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 net/picotcp/include/arch/pico_barebox.h | 76 +++++++++++++++++++++++++++++++++
 net/picotcp/include/pico_config.h       |  2 +
 2 files changed, 78 insertions(+)

diff --git a/net/picotcp/include/arch/pico_barebox.h b/net/picotcp/include/arch/pico_barebox.h
new file mode 100644
index 0000000..11e6ed3
--- /dev/null
+++ b/net/picotcp/include/arch/pico_barebox.h
@@ -0,0 +1,76 @@
+#ifndef PICO_SUPPORT_BAREBOX
+#define PICO_SUPPORT_BAREBOX
+
+#include <string.h>
+#include <stdio.h>
+#include <malloc.h>
+#include <clock.h>
+#include <linux/math64.h>
+
+/*
+   #define MEMORY_MEASURE
+ */
+#define dbg printf
+
+#define stack_fill_pattern(...) do {} while(0)
+#define stack_count_free_words(...) do {} while(0)
+#define stack_get_free_words() (0)
+
+/* measure allocated memory */
+#ifdef MEMORY_MEASURE
+extern uint32_t max_mem;
+extern uint32_t cur_mem;
+
+static inline void *pico_zalloc(int x)
+{
+    uint32_t *ptr;
+    if ((cur_mem + x) > (10 * 1024))
+        return NULL;
+
+    ptr = (uint32_t *)calloc(x + 4, 1);
+    *ptr = (uint32_t)x;
+    cur_mem += x;
+    if (cur_mem > max_mem) {
+        max_mem = cur_mem;
+    }
+
+    return (void*)(ptr + 1);
+}
+
+static inline void pico_free(void *x)
+{
+    uint32_t *ptr = (uint32_t*)(((uint8_t *)x) - 4);
+    cur_mem -= *ptr;
+    free(ptr);
+}
+#else
+
+#define pico_zalloc(x) calloc(x, 1)
+#define pico_free(x) free(x)
+#endif
+
+static inline uint32_t PICO_TIME(void)
+{
+    uint64_t time;
+
+    time = get_time_ns();
+    do_div(time, 1000000000);
+
+    return (uint32_t) time;
+}
+
+static inline uint32_t PICO_TIME_MS(void)
+{
+    uint64_t time;
+
+    time = get_time_ns();
+    do_div(time, 1000000);
+
+    return (uint32_t) time;
+}
+
+static inline void PICO_IDLE(void)
+{
+}
+
+#endif /* PICO_SUPPORT_BAREBOX */
diff --git a/net/picotcp/include/pico_config.h b/net/picotcp/include/pico_config.h
index 6b9c040..79aaadc 100644
--- a/net/picotcp/include/pico_config.h
+++ b/net/picotcp/include/pico_config.h
@@ -211,6 +211,8 @@ static inline uint64_t long_long_be(uint64_t le)
 # include "arch/pico_none.h"
 #elif defined GENERIC
 # include "arch/pico_generic_gcc.h"
+#elif defined __BAREBOX__
+# include "arch/pico_barebox.h"
 #elif defined __KERNEL__
 # include "arch/pico_linux.h"
 /* #elif defined ... */
-- 
2.1.4


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

  parent reply	other threads:[~2015-07-19 20:13 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-19 20:07 [RFC v2 00/16] barebox picotcp integration (2015.07.19) Antony Pavlov
2015-07-19 20:07 ` [RFC v2 01/16] net_udp_bind(): use uint16_t type for source port Antony Pavlov
2015-07-19 20:07 ` [RFC v2 02/16] fs/tftp.c: drop unused server_port variable Antony Pavlov
2015-07-19 20:07 ` [RFC v2 03/16] fs/nfs.c: use uint16_t for port numbers Antony Pavlov
2015-07-19 20:07 ` [RFC v2 04/16] fs/nfs.c: use SUNRPC_PORT remote port by default Antony Pavlov
2015-07-19 20:07 ` [RFC v2 05/16] net: change UDP handler function API Antony Pavlov
2015-07-19 20:07 ` [RFC v2 06/16] net: change net_udp_send() API Antony Pavlov
2015-07-19 20:07 ` [RFC v2 07/16] net: introduce setudppeerport() Antony Pavlov
2015-07-19 20:07 ` [RFC v2 08/16] net: import picotcp from github Antony Pavlov
2015-07-19 20:07 ` Antony Pavlov [this message]
2015-07-19 20:07 ` [RFC v2 10/16] picotcp: switch to Kbuild Antony Pavlov
2015-07-19 20:07 ` [RFC v2 11/16] net: add initial picotcp support Antony Pavlov
2015-07-19 20:07 ` [RFC v2 12/16] net: picotcp: add test_picotcp command Antony Pavlov
2015-07-19 20:07 ` [RFC v2 13/16] net: picotcp: add ifconfig command Antony Pavlov
2015-07-19 20:07 ` [RFC v2 14/16] net: picotcp: add ping command Antony Pavlov
2015-07-19 20:07 ` [RFC v2 15/16] net: picotcp: add route command Antony Pavlov
2015-07-19 20:07 ` [RFC v2 16/16] sandbox_defconfig: switch to picotcp Antony Pavlov
2015-07-20  7:10 ` [RFC v2 00/16] barebox picotcp integration (2015.07.19) Sascha Hauer
2015-07-20  9:50   ` Antony Pavlov
2015-07-20 10:06   ` Antony Pavlov
2015-07-20 10:45     ` Sascha Hauer
2015-07-20 12:16       ` Antony Pavlov
2015-07-24  4:58       ` Antony Pavlov
2015-07-24  7:19         ` Sascha Hauer

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=1437336443-8076-10-git-send-email-antonynpavlov@gmail.com \
    --to=antonynpavlov@gmail.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