aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/fbos/compiler.h2
-rw-r--r--include/fbos/init.h9
-rw-r--r--include/fbos/sbi.h7
3 files changed, 18 insertions, 0 deletions
diff --git a/include/fbos/compiler.h b/include/fbos/compiler.h
index c26c05c..95596dd 100644
--- a/include/fbos/compiler.h
+++ b/include/fbos/compiler.h
@@ -6,6 +6,8 @@
*/
#define __noreturn __attribute__((__noreturn__))
+#define __s_interrupt __attribute__((interrupt("supervisor")))
+#define __aligned(x) __attribute__((aligned(x)))
/*
* Compiler attributes specific to linker sections.
diff --git a/include/fbos/init.h b/include/fbos/init.h
index 978eebe..711d2cf 100644
--- a/include/fbos/init.h
+++ b/include/fbos/init.h
@@ -3,10 +3,19 @@
#include <fbos/compiler.h>
+// Tracks the amount of seconds that have elapsed since activating timer
+// interrupts.
+//
+// Instantiated in kernel/trap.c, initialized in main.c.
+extern uint64_t seconds_elapsed;
+
// Extract the executables from the initrd that is located at `base_addr` and
// has the given `size`.
void extract_initrd(const unsigned char *const base_addr, uint64_t size);
+// Setup the interrupt vectors and the SBI timer.
+void setup_interrupts(void);
+
// The entry point for the kernel.
void start_kernel(void *dtb);
diff --git a/include/fbos/sbi.h b/include/fbos/sbi.h
index 2575415..b1c99ea 100644
--- a/include/fbos/sbi.h
+++ b/include/fbos/sbi.h
@@ -18,6 +18,7 @@ enum sbi_ret_error {
// SBI extensions supported by this kernel.
enum sbi_ext {
DBCN_EXT = 0x4442434E,
+ TIME_EXT = 0x54494D45,
};
// Function IDs for the Debug Console Extension "DBCN".
@@ -25,6 +26,11 @@ enum dbcn_actions {
DBCN_WRITE = 0x00,
};
+// Function IDs for the Timer Extension "TIME".
+enum time_actions {
+ TIME_SET_TIMER = 0x00,
+};
+
// Return value for any SBI ecall.
struct sbi_ret {
long error;
@@ -37,6 +43,7 @@ extern struct sbi_ret __sbi_ecall(unsigned long arg0, unsigned long arg1, unsign
unsigned long arg3, unsigned long arg4, unsigned long arg5,
int fid, int ext);
+#define sbi_ecall1(ext, fid, arg0) __sbi_ecall(arg0, 0, 0, 0, 0, 0, fid, ext)
#define sbi_ecall2(ext, fid, arg0, arg1) __sbi_ecall(arg0, arg1, 0, 0, 0, 0, fid, ext)
#endif // __FBOS_SBI_H_