summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNathan Lee <me@nwlee.tech>2026-08-12 17:44:17 -0500
committerNathan Lee <me@nwlee.tech>2026-08-12 17:44:17 -0500
commit2c0efd93530c472e96ff3529aee983b53f3b78d9 (patch)
treecc36e7334e162ba67df79333e267ac93b4d984b9 /include
parent640a81b3ee366c651286efd1b80b37992cd53282 (diff)
rework project structure
Diffstat (limited to 'include')
-rw-r--r--include/common.h39
-rw-r--r--include/early/bump.h (renamed from include/bump.h)5
-rw-r--r--include/early/dtb.h (renamed from include/dtb.h)2
-rw-r--r--include/mmio.h8
-rw-r--r--include/sys/cpio.h (renamed from include/cpio.h)2
-rw-r--r--include/sys/elf.h (renamed from include/elf.h)2
-rw-r--r--include/sys/log.h (renamed from include/log.h)0
-rw-r--r--include/sys/mem.h (renamed from include/mem.h)8
-rw-r--r--include/sys/stddef.h (renamed from include/types.h)38
9 files changed, 49 insertions, 55 deletions
diff --git a/include/common.h b/include/common.h
deleted file mode 100644
index d26b8ae..0000000
--- a/include/common.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#pragma once
-#include <types.h>
-
-static inline size_t strlen(const char *s) {
- size_t len = 0;
- while (*s++) {
- ++len;
- }
- return len;
-}
-static inline int strcmp(const char *str1, const char* str2) {
- while (*str1 && (*str1 == *str2)) {
- ++str1;
- ++str2;
- }
- return *(const unsigned char *)str1 - *(const unsigned char *)str2;
-}
-
-static inline int memcmp(const void *s1, const void *s2, size_t n) {
- const unsigned char *p1 = (const unsigned char *)s1;
- const unsigned char *p2 = (const unsigned char *)s2;
-
- for (size_t i = 0; i < n; i++) {
- if (p1[i] != p2[i]) {
- return p1[i] - p2[i];
- }
- }
-
- return 0;
-}
-
-static inline void *memcpy(void *restrict dest, const void* restrict src, size_t size) {
- unsigned char *d = (unsigned char *)dest;
- unsigned char *s = (unsigned char *)src;
- for (size_t i = 0; i < size; i++) {
- d[i] = s[i];
- }
- return d;
-}
diff --git a/include/bump.h b/include/early/bump.h
index 81cd571..bf3e6f9 100644
--- a/include/bump.h
+++ b/include/early/bump.h
@@ -1,7 +1,6 @@
#pragma once
-#include <types.h>
-#include <dtb.h>
-#include <mem.h>
+#include <sys/stddef.h>
+#include <early/dtb.h>
#define EHEAP_SIZE (512 * 1024)
diff --git a/include/dtb.h b/include/early/dtb.h
index 1f8f14f..41a7bcc 100644
--- a/include/dtb.h
+++ b/include/early/dtb.h
@@ -1,5 +1,5 @@
#pragma once
-#include <types.h>
+#include <sys/stddef.h>
#define FDT_MAGIC 0xEDFE0DD0
#define FDT_BEGIN_NODE 1
diff --git a/include/mmio.h b/include/mmio.h
deleted file mode 100644
index b6531bf..0000000
--- a/include/mmio.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma once
-#include <types.h>
-
-struct mmio_device_meta {
- const char *name;
- void *start;
- size_t size;
-};
diff --git a/include/cpio.h b/include/sys/cpio.h
index 3bb40c0..c501e96 100644
--- a/include/cpio.h
+++ b/include/sys/cpio.h
@@ -1,5 +1,5 @@
#pragma once
-#include <types.h>
+#include <sys/stddef.h>
#define CPIO_HEADER_LEN 110
struct cpio_newc_hdr {
diff --git a/include/elf.h b/include/sys/elf.h
index 76c384d..95ed592 100644
--- a/include/elf.h
+++ b/include/sys/elf.h
@@ -1,5 +1,5 @@
#pragma once
-#include <types.h>
+#include <sys/stddef.h>
#define ELF_MAGIC_LE 0x464C457F
#define ELF_PAD 0
diff --git a/include/log.h b/include/sys/log.h
index da9274b..da9274b 100644
--- a/include/log.h
+++ b/include/sys/log.h
diff --git a/include/mem.h b/include/sys/mem.h
index bd6c911..769a162 100644
--- a/include/mem.h
+++ b/include/sys/mem.h
@@ -1,5 +1,5 @@
#pragma once
-#include <types.h>
+#include <sys/stddef.h>
struct mem_info {
void* start;
@@ -16,6 +16,12 @@ struct page {
enum PageStatus status;
};
+struct mmio_device_meta {
+ const char *name;
+ void *start;
+ size_t size;
+};
+
void* kmalloc(size_t size);
void* kzalloc(size_t size);
void kfree(void* ptr);
diff --git a/include/types.h b/include/sys/stddef.h
index 5be3023..27aea74 100644
--- a/include/types.h
+++ b/include/sys/stddef.h
@@ -1,5 +1,4 @@
#pragma once
-
#define NULL (void*)0
#define uintptr_t __wk_size_t
@@ -39,3 +38,40 @@ typedef __UINT16_TYPE__ __wk_uint16_t;
typedef __UINT32_TYPE__ __wk_uint32_t;
typedef __UINT64_TYPE__ __wk_uint64_t;
+
+static inline size_t strlen(const char *s) {
+ size_t len = 0;
+ while (*s++) {
+ ++len;
+ }
+ return len;
+}
+static inline int strcmp(const char *str1, const char* str2) {
+ while (*str1 && (*str1 == *str2)) {
+ ++str1;
+ ++str2;
+ }
+ return *(const unsigned char *)str1 - *(const unsigned char *)str2;
+}
+
+static inline int memcmp(const void *s1, const void *s2, size_t n) {
+ const unsigned char *p1 = (const unsigned char *)s1;
+ const unsigned char *p2 = (const unsigned char *)s2;
+
+ for (size_t i = 0; i < n; i++) {
+ if (p1[i] != p2[i]) {
+ return p1[i] - p2[i];
+ }
+ }
+
+ return 0;
+}
+
+static inline void *memcpy(void *restrict dest, const void* restrict src, size_t size) {
+ unsigned char *d = (unsigned char *)dest;
+ unsigned char *s = (unsigned char *)src;
+ for (size_t i = 0; i < size; i++) {
+ d[i] = s[i];
+ }
+ return d;
+}