summaryrefslogtreecommitdiff
path: root/sys/include
diff options
context:
space:
mode:
Diffstat (limited to 'sys/include')
-rw-r--r--sys/include/asm.h6
-rw-r--r--sys/include/dev.h32
-rw-r--r--sys/include/kalloc.h2
-rw-r--r--sys/include/sbi.h8
-rw-r--r--sys/include/vm.h6
5 files changed, 52 insertions, 2 deletions
diff --git a/sys/include/asm.h b/sys/include/asm.h
index 0995f88..d345712 100644
--- a/sys/include/asm.h
+++ b/sys/include/asm.h
@@ -53,4 +53,10 @@ read_tp(void)
return x;
}
+static inline void
+csrw_satp(uint64_t x)
+{
+ asm volatile("csrw satp, %0" : : "r"(x));
+}
+
#endif /* _ASM_H */
diff --git a/sys/include/dev.h b/sys/include/dev.h
index b8bfef8..657c04c 100644
--- a/sys/include/dev.h
+++ b/sys/include/dev.h
@@ -2,7 +2,37 @@
#define _DEV_H
#include <libfdt.h>
+#include <stdint.h>
-void dev_init(struct fdt_header* fdt);
+enum { DT_MMUTYPE_SV32, DT_MMUTYPE_SV39, DT_MMUTYPE_SV48 };
+
+struct _reg {
+ fdt64_t address;
+ fdt64_t size;
+};
+/* unflattend device tree */
+struct devicetree {
+ const char *compat;
+ const char *model;
+ int nproc;
+ /* main cpu, monitor/alternative cores will be ignored for now */
+ struct {
+ short mmu_type;
+ const char *isa;
+ unsigned int freq;
+ } cpu;
+ struct {
+ uintptr_t origin;
+ uintptr_t size;
+ } memory;
+ struct {
+ unsigned int freq;
+ const char *compat;
+ int interrupt;
+ struct _reg reg;
+ } uart;
+};
+
+struct devicetree dev_init(struct fdt_header* fdt);
#endif /* _DEV_H */
diff --git a/sys/include/kalloc.h b/sys/include/kalloc.h
index 10adbda..5553d94 100644
--- a/sys/include/kalloc.h
+++ b/sys/include/kalloc.h
@@ -7,7 +7,7 @@ void *kzalloc(void);
void kfree(void *);
-void kalloc_init(void);
+void kalloc_init(size_t);
void walkfree(void);
diff --git a/sys/include/sbi.h b/sys/include/sbi.h
index 94c3749..86ca295 100644
--- a/sys/include/sbi.h
+++ b/sys/include/sbi.h
@@ -1,6 +1,8 @@
#ifndef _SBI_H
#define _SBI_H
+#include <stdint.h>
+
struct sbiret {
long err;
long val;
@@ -58,6 +60,12 @@ sbi_console_putchar(int c)
sbi_ecall(1, 0, c, 0, 0, 0, 0, 0);
}
+static inline void
+sbi_debug_console_write_byte(uint8_t byte)
+{
+ sbi_ecall(0x4442434E, 0x2, 'c', 0, 0, 0, 0, 0);
+}
+
static inline void
sbi_shutdown(void)
{
diff --git a/sys/include/vm.h b/sys/include/vm.h
new file mode 100644
index 0000000..1883ea7
--- /dev/null
+++ b/sys/include/vm.h
@@ -0,0 +1,6 @@
+#ifndef _VM_H
+#define _VM_H
+
+void vminit(void);
+
+#endif /* _VM_H */