aboutsummaryrefslogtreecommitdiff
path: root/tests/simple_mesh/test.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2025-08-09 16:06:43 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2025-08-09 16:06:43 +0300
commit3083284c797fc8fc267144b05c8a58395e4583e3 (patch)
treed0413af85d65cf895aa85fdaaf3a9f090f41dac1 /tests/simple_mesh/test.c
parentaba90a3a6f6c1caee28aaf3dadebb4daba5b5761 (diff)
downloadgran-3083284c797fc8fc267144b05c8a58395e4583e3.tar.gz
gran-3083284c797fc8fc267144b05c8a58395e4583e3.zip
add 1d mesh node and refactor 2d mesh node
+ Seems to decrease performance a little bit, presumably due to extra register copy, but simplifies code a lot and opens up more genericism so I'll consider it an upgrade for now. Copying packets around is rather slow though, might in the future move to some kind of pointer based packet handling
Diffstat (limited to 'tests/simple_mesh/test.c')
-rw-r--r--tests/simple_mesh/test.c55
1 files changed, 0 insertions, 55 deletions
diff --git a/tests/simple_mesh/test.c b/tests/simple_mesh/test.c
deleted file mode 100644
index b1bbe84..0000000
--- a/tests/simple_mesh/test.c
+++ /dev/null
@@ -1,55 +0,0 @@
-__attribute__((always_inline))
-static inline void print_int8(volatile char *uart, unsigned x)
-{
- *uart = ((x >> 4) & 0xf) + '0';
- *uart = ((x >> 0) & 0xf) + '0';
-}
-
-__attribute__((always_inline))
-static inline void print_addr(volatile char *uart, unsigned x, unsigned y)
-{
- *uart = '(';
- print_int8(uart, x);
- *uart = ',';
- *uart = ' ';
- print_int8(uart, y);
- *uart = ')';
- *uart = '\n';
-}
-
-__attribute__((always_inline))
-static inline unsigned wrap(unsigned x, unsigned X)
-{
- return x + 1 >= X ? 0 : x + 1;
-}
-
-__attribute__((always_inline))
-static inline unsigned next_idx(unsigned x, unsigned y, unsigned X, unsigned Y)
-{
- unsigned yi = wrap(y, Y);
- unsigned xi = yi < y ? wrap(x, X) : x;
-
- return (xi << 16) | yi;
-}
-
-void _start(unsigned x, unsigned y, unsigned X, unsigned Y)
-{
- volatile char *uart = (char *)4096;
- volatile unsigned *control = (unsigned *)(1ULL << 48);
-
- if (x == 0 && y == 2) {
- goto do_work;
- } else {
- while (*control != ((x << 16) | y)) {}
- }
-
-do_work:
- print_addr(uart, x, y);
- *control = next_idx(x, y, X, Y);
-
- if (x == X - 1 && y == Y - 1)
- asm("ebreak");
-
- /* otherwise just loop */
- while (1) {}
-}