diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/fbos/compiler.h | 12 | ||||
| -rw-r--r-- | include/fbos/dt.h | 9 | ||||
| -rw-r--r-- | include/fbos/init.h | 2 | ||||
| -rw-r--r-- | include/fbos/printk.h | 17 | ||||
| -rw-r--r-- | include/fbos/string.h | 1 |
5 files changed, 38 insertions, 3 deletions
diff --git a/include/fbos/compiler.h b/include/fbos/compiler.h index 35091c0..b88bb0b 100644 --- a/include/fbos/compiler.h +++ b/include/fbos/compiler.h @@ -11,16 +11,24 @@ * Compiler attributes specific to linker sections. */ +#ifdef __KERNEL__ #define __section(s) __attribute__((__section__(s))) #define __kernel __section(".kernel.text") +#else +#define __kernel +#endif /* __KERNEL__ */ /* - * Multiple aliases for 64-bit integers which have their definition on the + * Multiple aliases for 32/64-bit integers which have their definition on the * standard library. */ +typedef int int32_t; typedef long ssize_t; +typedef long int64_t; + typedef unsigned long size_t; +typedef unsigned int uint32_t; typedef unsigned long uint64_t; typedef unsigned long uintptr_t; @@ -28,8 +36,10 @@ typedef unsigned long uintptr_t; * NULL */ +#ifdef __KERNEL__ #define NULL (void *)0 #define nullptr NULL +#endif /* __KERNEL__ */ // Helpful macro when prototyping. #define __unused(x) (void)x diff --git a/include/fbos/dt.h b/include/fbos/dt.h index 39d8381..fd77c35 100644 --- a/include/fbos/dt.h +++ b/include/fbos/dt.h @@ -3,6 +3,13 @@ #include <fbos/compiler.h> -void parse_dtb(uint64_t *dtb); +// Pair of addresses where the initrd is located in memory. +struct initrd_addr { + uintptr_t start; + uintptr_t end; +}; + +// Returns the `initrd` addresses as parsed from the given DTB blob. +struct initrd_addr find_dt_initrd_addr(uint32_t *dtb); #endif // __FBOS_DT_H_ diff --git a/include/fbos/init.h b/include/fbos/init.h index a919405..eb72508 100644 --- a/include/fbos/init.h +++ b/include/fbos/init.h @@ -6,6 +6,6 @@ extern struct task_struct init_task; // The entry point for the kernel. -__noreturn __kernel void start_kernel(uintptr_t *dtb); +__noreturn __kernel void start_kernel(void *dtb); #endif /* __FBOS_INIT_H */ diff --git a/include/fbos/printk.h b/include/fbos/printk.h index 2c82eda..6b32555 100644 --- a/include/fbos/printk.h +++ b/include/fbos/printk.h @@ -1,7 +1,24 @@ #ifndef __FBOS_PRINTK_H_ #define __FBOS_PRINTK_H_ +/* + * This file might be pulled from user space tests. Hence, define alternatives + * for this functions from glibc. + */ + +#ifdef __KERNEL__ extern void die(const char *const message); extern void printk(const char *const message); +#else +#include <stdio.h> +#include <stdlib.h> + +#define die(x) \ + do { \ + printf(x); \ + exit(1); \ + } while (0) +#define printk(x) printf(x) +#endif /* __KERNEL */ #endif // __FBOS_PRINTK_H_ diff --git a/include/fbos/string.h b/include/fbos/string.h index c3da266..af7e2ef 100644 --- a/include/fbos/string.h +++ b/include/fbos/string.h @@ -4,5 +4,6 @@ #include <fbos/compiler.h> extern size_t strlen(const char *); +extern int strcmp(const char *, const char *); #endif // __FBOS_STRING_H_ |
