summaryrefslogtreecommitdiff
path: root/na/include
diff options
context:
space:
mode:
Diffstat (limited to 'na/include')
-rw-r--r--na/include/lume/errno.h43
-rw-r--r--na/include/lume/new.h18
-rw-r--r--na/include/lume/panic.h16
-rw-r--r--na/include/lume/types.h39
4 files changed, 116 insertions, 0 deletions
diff --git a/na/include/lume/errno.h b/na/include/lume/errno.h
new file mode 100644
index 0000000..e0786ce
--- /dev/null
+++ b/na/include/lume/errno.h
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2026 Richard Qin */
+/* from linux kernel linux/include/uapi/asm-generic/errno-base.h*/
+
+#ifndef _ASM_GENERIC_ERRNO_BASE_H
+#define _ASM_GENERIC_ERRNO_BASE_H
+
+#define EPERM 1 /* Operation not permitted */
+#define ENOENT 2 /* No such file or directory */
+#define ESRCH 3 /* No such process */
+#define EINTR 4 /* Interrupted system call */
+#define EIO 5 /* I/O error */
+#define ENXIO 6 /* No such device or address */
+#define E2BIG 7 /* Argument list too long */
+#define ENOEXEC 8 /* Exec format error */
+#define EBADF 9 /* Bad file number */
+#define ECHILD 10 /* No child processes */
+#define EAGAIN 11 /* Try again */
+#define ENOMEM 12 /* Out of memory */
+#define EACCES 13 /* Permission denied */
+#define EFAULT 14 /* Bad address */
+#define ENOTBLK 15 /* Block device required */
+#define EBUSY 16 /* Device or resource busy */
+#define EEXIST 17 /* File exists */
+#define EXDEV 18 /* Cross-device link */
+#define ENODEV 19 /* No such device */
+#define ENOTDIR 20 /* Not a directory */
+#define EISDIR 21 /* Is a directory */
+#define EINVAL 22 /* Invalid argument */
+#define ENFILE 23 /* File table overflow */
+#define EMFILE 24 /* Too many open files */
+#define ENOTTY 25 /* Not a typewriter */
+#define ETXTBSY 26 /* Text file busy */
+#define EFBIG 27 /* File too large */
+#define ENOSPC 28 /* No space left on device */
+#define ESPIPE 29 /* Illegal seek */
+#define EROFS 30 /* Read-only file system */
+#define EMLINK 31 /* Too many links */
+#define EPIPE 32 /* Broken pipe */
+#define EDOM 33 /* Math argument out of domain of func */
+#define ERANGE 34 /* Math result not representable */
+
+#endif \ No newline at end of file
diff --git a/na/include/lume/new.h b/na/include/lume/new.h
new file mode 100644
index 0000000..cdcacb8
--- /dev/null
+++ b/na/include/lume/new.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/* Copyright (C) 2026 Richard Qin */
+
+#pragma once
+
+/*
+ * Placement New for Freestanding Environments
+ *
+ * In -ffreestanding -nostdlib mode, <new> may not be available.
+ * LumeOS provides its own placement new/delete operators.
+ *
+ * Usage: g_obj = new (g_obj_buf) MyClass(args...);
+ *
+ * Reference: docs/specs/global_init.md §3.1
+ */
+
+inline void* operator new(decltype(sizeof(0)), void* ptr) noexcept { return ptr; }
+inline void operator delete(void*, void*) noexcept {}
diff --git a/na/include/lume/panic.h b/na/include/lume/panic.h
new file mode 100644
index 0000000..6316c28
--- /dev/null
+++ b/na/include/lume/panic.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/* Copyright (C) 2026 Richard Qin */
+
+#pragma once
+
+/*
+ * Kernel Panic — fatal error handler.
+ *
+ * Prints the message (if UART is ready), disables interrupts,
+ * and enters an infinite wfi loop. Never returns.
+ *
+ * Implementation will be provided by lib/kprintf.cc or a
+ * dedicated panic module. For now this header declares the interface.
+ */
+
+extern "C" [[noreturn]] void kernel_panic(const char* msg, const char* detail = nullptr);
diff --git a/na/include/lume/types.h b/na/include/lume/types.h
new file mode 100644
index 0000000..a8440f6
--- /dev/null
+++ b/na/include/lume/types.h
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/* Copyright (C) 2026 Richard Qin */
+
+#pragma once
+
+/*
+ * LumeOS Base Type Definitions
+ *
+ * All kernel code should use these types instead of
+ * stdint.h (which may not exist in freestanding mode).
+ */
+
+using uint8 = unsigned char;
+using uint16 = unsigned short;
+using uint32 = unsigned int;
+using uint64 = unsigned long long;
+
+using int8 = signed char;
+using int16 = signed short;
+using int32 = signed int;
+using int64 = signed long long;
+
+using size_t = uint64;
+using ssize_t = int64;
+using uintptr = uint64;
+
+/* Null pointer constant */
+#ifndef nullptr
+/* C++11 and later have nullptr built-in */
+#endif
+
+/* Max CPUs supported */
+inline constexpr int kMaxCPUs = 8;
+
+/* Page size */
+inline constexpr uint64 kPageSize = 4096;
+
+/* Kernel virtual address offset */
+inline constexpr uint64 kPageOffset = 0xFFFFFFC000000000ULL;