aboutsummaryrefslogtreecommitdiff
path: root/include/lib
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2022-01-05 14:27:09 -0800
committerChristian Cunningham <cc@localhost>2022-01-05 14:27:09 -0800
commit866a6ca0e749f4446b7fdc7579a6d553df85ec10 (patch)
treed259223d85c224d649c6c38675e99b155d50cf48 /include/lib
parent3a8ed19bf83f11ff00c4904fab2cc083b7e33478 (diff)
Moved includes to its own directory
Diffstat (limited to 'include/lib')
-rw-r--r--include/lib/ll.h24
-rw-r--r--include/lib/mem.h25
-rw-r--r--include/lib/q.h30
-rw-r--r--include/lib/strings.h10
4 files changed, 89 insertions, 0 deletions
diff --git a/include/lib/ll.h b/include/lib/ll.h
new file mode 100644
index 0000000..ab4148d
--- /dev/null
+++ b/include/lib/ll.h
@@ -0,0 +1,24 @@
+#ifndef LIB_LL_H
+#define LIB_LL_H
+
+struct LL {
+ struct LL* prev;
+ struct LL* next;
+ void* data;
+};
+
+struct LL* new_ll(void* val);
+void push_ll(struct LL* l, void* val);
+void remove_ll(struct LL* l, unsigned long idx);
+
+#define show_ll(L, TYPE) { \
+ struct LL* t = L; \
+ do { \
+ uart_hex(*(TYPE*)t->data); \
+ t = t->next; \
+ if (t != l) \
+ uart_char(' '); \
+ } while (t != l); \
+}
+
+#endif
diff --git a/include/lib/mem.h b/include/lib/mem.h
new file mode 100644
index 0000000..5c5cc94
--- /dev/null
+++ b/include/lib/mem.h
@@ -0,0 +1,25 @@
+#ifndef LIB_MEM_H
+#define LIB_MEM_H
+
+struct MemTab {
+ unsigned char size;
+ unsigned char in_use;
+ void* data;
+} __attribute__((packed));
+
+void memcpy(unsigned char* src, unsigned char* dest, unsigned int n);
+unsigned char memcmp(unsigned char* a, unsigned char* b, unsigned int n);
+
+void memshow32(unsigned long* addr, unsigned int n);
+void memcpy32(unsigned long* src, unsigned long* dest, unsigned int n);
+unsigned char memcmp32(unsigned long* a, unsigned long* b, unsigned int n);
+
+void* malloc(unsigned char size);
+void* malloca(unsigned char size, unsigned char amnt);
+void free(void* memloc);
+void* heap_base(void);
+void* heap_top(void);
+void heap_info(void);
+void heap_info_u(void);
+
+#endif
diff --git a/include/lib/q.h b/include/lib/q.h
new file mode 100644
index 0000000..cf75c6d
--- /dev/null
+++ b/include/lib/q.h
@@ -0,0 +1,30 @@
+#ifndef LIB_Q_H
+#define LIB_Q_H
+
+struct Q_base {
+ struct Q* next;
+ struct Q* last;
+};
+
+struct Q {
+ struct Q* next;
+ void* data;
+};
+
+struct Q_base* new_q();
+void push_q(struct Q_base* qb, void* val);
+void pop_q(struct Q_base* qb);
+
+#define show_q(QQ, TYPE) { \
+ if (QQ->next != 0) { \
+ struct Q* t = QQ->next; \
+ while (t->next != 0) { \
+ uart_hex(*(TYPE*)t->data); \
+ t = t->next; \
+ uart_char(' '); \
+ } \
+ uart_hex(*(TYPE*)t->data); \
+ } \
+}
+
+#endif
diff --git a/include/lib/strings.h b/include/lib/strings.h
new file mode 100644
index 0000000..1bbcac8
--- /dev/null
+++ b/include/lib/strings.h
@@ -0,0 +1,10 @@
+#ifndef LIB_STRINGS_H
+#define LIB_STRINGS_H
+
+#define string_t char*
+
+unsigned long strlen(string_t s);
+unsigned char strcmp(string_t a, string_t b);
+unsigned char strcmpn(string_t a, string_t b, unsigned int n);
+
+#endif