aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/fbos/compiler.h23
-rw-r--r--include/fbos/dt.h8
-rw-r--r--include/fbos/init.h11
-rw-r--r--include/fbos/mm.h13
-rw-r--r--include/fbos/printk.h7
-rw-r--r--include/fbos/sbi.h35
-rw-r--r--include/fbos/sched.h8
-rw-r--r--include/fbos/string.h8
8 files changed, 105 insertions, 8 deletions
diff --git a/include/fbos/compiler.h b/include/fbos/compiler.h
index edf24d1..5e61ebd 100644
--- a/include/fbos/compiler.h
+++ b/include/fbos/compiler.h
@@ -1,9 +1,30 @@
#ifndef __FBOS_COMPILER_H
#define __FBOS_COMPILER_H
+/*
+ * Nicer looking versions of compiler attributes.
+ */
+
#define __noreturn __attribute__((__noreturn__))
+/*
+ * Compiler attributes specific to linker sections.
+ */
+
#define __section(s) __attribute__((__section__(s)))
-#define __kernel __section(".text.kernel")
+#define __kernel __section(".kernel.text")
+
+/*
+ * Multiple aliases for 64-bit integers which have their definition on the
+ * standard library.
+ */
+
+typedef long ssize_t;
+typedef unsigned long size_t;
+typedef unsigned long uint64_t;
+typedef unsigned long uintptr_t;
+
+// Helpful macro when prototyping.
+#define __unused(x) (void)x
#endif /* __FBOS_COMPILER_H */
diff --git a/include/fbos/dt.h b/include/fbos/dt.h
new file mode 100644
index 0000000..39d8381
--- /dev/null
+++ b/include/fbos/dt.h
@@ -0,0 +1,8 @@
+#ifndef __FBOS_DT_H_
+#define __FBOS_DT_H_
+
+#include <fbos/compiler.h>
+
+void parse_dtb(uint64_t *dtb);
+
+#endif // __FBOS_DT_H_
diff --git a/include/fbos/init.h b/include/fbos/init.h
index 1eeb33a..a919405 100644
--- a/include/fbos/init.h
+++ b/include/fbos/init.h
@@ -1,8 +1,11 @@
-#ifndef FBOS_INIT_H
-#define FBOS_INIT_H
+#ifndef __FBOS_INIT_H
+#define __FBOS_INIT_H
#include <fbos/compiler.h>
-extern __noreturn __kernel void start_kernel(void);
+extern struct task_struct init_task;
-#endif /* FBOS_INIT_H */
+// The entry point for the kernel.
+__noreturn __kernel void start_kernel(uintptr_t *dtb);
+
+#endif /* __FBOS_INIT_H */
diff --git a/include/fbos/mm.h b/include/fbos/mm.h
index 2b80076..25d18ce 100644
--- a/include/fbos/mm.h
+++ b/include/fbos/mm.h
@@ -1,5 +1,5 @@
-#ifndef FBOS_MM_H
-#define FBOS_MM_H
+#ifndef __FBOS_MM_H
+#define __FBOS_MM_H
/*
* Page = 4KB.
@@ -7,10 +7,17 @@
#define PAGE_SIZE 0x1000
/*
+ * Initial size of the thread, which coincides with the size of the stack for a
+ * given thread.
+ */
+#define THREAD_SIZE_ORDER 2
+#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
+
+/*
* The code will be linked to start at the first page, which will have a given
* offset.
*/
#define PAGE_OFFSET 0x80200000
#define LINK_ADDR PAGE_OFFSET
-#endif /* FBOS_MM_H */
+#endif /* __FBOS_MM_H */
diff --git a/include/fbos/printk.h b/include/fbos/printk.h
new file mode 100644
index 0000000..2c82eda
--- /dev/null
+++ b/include/fbos/printk.h
@@ -0,0 +1,7 @@
+#ifndef __FBOS_PRINTK_H_
+#define __FBOS_PRINTK_H_
+
+extern void die(const char *const message);
+extern void printk(const char *const message);
+
+#endif // __FBOS_PRINTK_H_
diff --git a/include/fbos/sbi.h b/include/fbos/sbi.h
new file mode 100644
index 0000000..a6b893d
--- /dev/null
+++ b/include/fbos/sbi.h
@@ -0,0 +1,35 @@
+#ifndef __FBOS_SBI_H_
+#define __FBOS_SBI_H_
+
+// TODO
+/* SBI_SUCCESS 0 Completed successfully */
+/* SBI_ERR_FAILED -1 Failed */
+/* SBI_ERR_NOT_SUPPORTED -2 Not supported */
+/* SBI_ERR_INVALID_PARAM -3 Invalid parameter(s) */
+/* SBI_ERR_DENIED -4 Denied or not allowed */
+/* SBI_ERR_INVALID_ADDRESS -5 Invalid address(s) */
+/* SBI_ERR_ALREADY_AVAILABLE -6 Already available */
+/* SBI_ERR_ALREADY_STARTED -7 Already started */
+/* SBI_ERR_ALREADY_STOPPED -8 Already stopped */
+/* SBI_ERR_NO_SHMEM -9 Shared memory not available */
+
+enum sbi_ext {
+ DBCN_EXT = 0x4442434E,
+};
+
+enum dbcn_actions {
+ DBCN_WRITE = 0x00,
+};
+
+struct sbi_ret {
+ long error;
+ long value;
+};
+
+extern struct sbi_ret __sbi_ecall(unsigned long arg0, unsigned long arg1, unsigned long arg2,
+ unsigned long arg3, unsigned long arg4, unsigned long arg5,
+ int fid, int ext);
+
+#define sbi_ecall2(ext, fid, arg0, arg1) __sbi_ecall(arg0, arg1, 0, 0, 0, 0, fid, ext)
+
+#endif // __FBOS_SBI_H_
diff --git a/include/fbos/sched.h b/include/fbos/sched.h
new file mode 100644
index 0000000..626f72f
--- /dev/null
+++ b/include/fbos/sched.h
@@ -0,0 +1,8 @@
+#ifndef __FBOS_SCHED_H_
+#define __FBOS_SCHED_H_
+
+struct task_struct {
+ void *stack;
+};
+
+#endif // __FBOS_SCHED_H_
diff --git a/include/fbos/string.h b/include/fbos/string.h
new file mode 100644
index 0000000..c3da266
--- /dev/null
+++ b/include/fbos/string.h
@@ -0,0 +1,8 @@
+#ifndef __FBOS_STRING_H_
+#define __FBOS_STRING_H_
+
+#include <fbos/compiler.h>
+
+extern size_t strlen(const char *);
+
+#endif // __FBOS_STRING_H_