aboutsummaryrefslogtreecommitdiff
path: root/include/kern
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2020-11-25 15:47:02 -0700
committerJosh Rahm <joshuarahm@gmail.com>2020-11-25 15:47:02 -0700
commit6d22b0dfc7761a605758552d5824f8039ac5a00f (patch)
treede0cd4848c02b787d45b41afaca244606eceab5d /include/kern
parentb07c6f6a9d926d4eac726b94963e479839382675 (diff)
downloadstm32l4-6d22b0dfc7761a605758552d5824f8039ac5a00f.tar.gz
stm32l4-6d22b0dfc7761a605758552d5824f8039ac5a00f.tar.bz2
stm32l4-6d22b0dfc7761a605758552d5824f8039ac5a00f.zip
Primitive ability to call kernel code from userspace.
Diffstat (limited to 'include/kern')
-rw-r--r--include/kern/mpu/mpu_manager.h26
-rw-r--r--include/kern/priv.h2
-rw-r--r--include/kern/syscall.h8
-rw-r--r--include/kern/syscall/syscall_tbl.inc5
4 files changed, 40 insertions, 1 deletions
diff --git a/include/kern/mpu/mpu_manager.h b/include/kern/mpu/mpu_manager.h
index 7c47722..5a0904c 100644
--- a/include/kern/mpu/mpu_manager.h
+++ b/include/kern/mpu/mpu_manager.h
@@ -55,7 +55,7 @@ typedef enum {
/* Both privileged and non-privileged users can access this memory, but only
as Read-only.*/
- ACCESS_PERMS_BOTH_RO = 5,
+ ACCESS_PERMS_BOTH_RO = 6,
} access_perms_t;
typedef struct {
@@ -81,4 +81,28 @@ void mpu_set_enabled(bool enabled);
*/
void mpu_configure_region(int region_number, memory_region_opts_t* opts);
+typedef enum {
+ PRIVILEGED,
+ NOT_PRIVILEGED,
+} privilege_t;
+
+
+/** Configure a peripheral region with default peripheral attributes. */
+void configure_peripheral_region(
+ void* peripheral_base,
+ region_size_t region_size,
+ privilege_t priv);
+
+/** Configure a flash region with default flash attributes. */
+void configure_flash_region(
+ void* flash_base,
+ region_size_t region_size,
+ privilege_t priv);
+
+/** Configure a ram region with default ram attributes. */
+void configure_ram_region(
+ void* ram_base,
+ region_size_t region_size,
+ privilege_t priv);
+
#endif /* KERN_MPU_MPU_MANAGER_H_ */
diff --git a/include/kern/priv.h b/include/kern/priv.h
index 8940b23..35404f4 100644
--- a/include/kern/priv.h
+++ b/include/kern/priv.h
@@ -10,5 +10,7 @@ void set_control_register(uint32_t reg);
/* Enters user mode from privilieged mode. */
void enter_user_mode();
+void jump_to_user_mode();
+
#endif /* _KERN_PRIV_H_ */
diff --git a/include/kern/syscall.h b/include/kern/syscall.h
new file mode 100644
index 0000000..d39b620
--- /dev/null
+++ b/include/kern/syscall.h
@@ -0,0 +1,8 @@
+#ifndef KERN_SYSCALL_H_
+#define KERN_SYSCALL_H_
+
+#define SYSCALL(id, fn, kernfn, argt) void kernfn(argt arg);
+#include "kern/syscall/syscall_tbl.inc"
+#undef SYSCALL
+
+#endif
diff --git a/include/kern/syscall/syscall_tbl.inc b/include/kern/syscall/syscall_tbl.inc
new file mode 100644
index 0000000..6c4be57
--- /dev/null
+++ b/include/kern/syscall/syscall_tbl.inc
@@ -0,0 +1,5 @@
+/*
+ * Defines a table of SYSCALLS. The syscalls need to be void functions that
+ * a single 32-bit integer as their argument.
+ */
+SYSCALL(25, logs, kern_logs, const char*)