aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2022-01-20 18:50:41 -0700
committerChristian Cunningham <cc@localhost>2022-01-20 18:50:41 -0700
commit4bb5f36b8c696361d5a283680ea7dadde4e364df (patch)
tree9a5c3f6766945227e3d7d714559d15b7b3fc1e32 /src/lib
parent9ca0f8a8bdbfe543a23ff2e75502744a7263a5b7 (diff)
Added rotating buffers
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/mem.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/lib/mem.c b/src/lib/mem.c
index 91fed94..dc915e6 100644
--- a/src/lib/mem.c
+++ b/src/lib/mem.c
@@ -1,6 +1,19 @@
#include <drivers/uart.h>
#include <lib/mem.h>
+void memcpyrot(unsigned char* src, struct RotBuffer* rb, unsigned int n)
+{
+ if (n > rb->size)
+ return;
+ unsigned char* addr = rb->base + rb->offset;
+ for (unsigned int i = 0; i < n; i++) {
+ if (addr >= (unsigned char*)(rb->base + rb->size))
+ addr = rb->base;
+ *addr = src[i];
+ addr++;
+ }
+}
+
void memshow32(unsigned long* addr, unsigned int n)
{
for(unsigned int i = 0; i < n; i++) {