aboutsummaryrefslogtreecommitdiff
path: root/include/util
diff options
context:
space:
mode:
Diffstat (limited to 'include/util')
-rw-r--r--include/util/mutex.h17
-rw-r--r--include/util/status.h6
-rw-r--r--include/util/time.h26
3 files changed, 49 insertions, 0 deletions
diff --git a/include/util/mutex.h b/include/util/mutex.h
new file mode 100644
index 0000000..524a461
--- /dev/null
+++ b/include/util/mutex.h
@@ -0,0 +1,17 @@
+#ifndef UTIL_MUTEX_H
+#define UTIL_MUTEX_H
+
+#define NULL_PID 0
+#define SYS_PID 1
+#define SCHED_PID 2
+
+struct Mutex {
+ void* addr;
+ unsigned long pid;
+} __attribute__((packed, aligned(4)));;
+
+unsigned char lock_mutex(struct Mutex*, unsigned long);
+unsigned char release_mutex(struct Mutex*, unsigned long);
+struct Mutex* create_mutex(void* addr);
+
+#endif
diff --git a/include/util/status.h b/include/util/status.h
new file mode 100644
index 0000000..f6966dd
--- /dev/null
+++ b/include/util/status.h
@@ -0,0 +1,6 @@
+#ifndef UTIL_STATUS_H
+#define UTIL_STATUS_H
+
+void status(void);
+
+#endif
diff --git a/include/util/time.h b/include/util/time.h
new file mode 100644
index 0000000..f6dacb0
--- /dev/null
+++ b/include/util/time.h
@@ -0,0 +1,26 @@
+#ifndef UTIL_TIME_H
+#define UTIL_TIME_H
+
+void routing_core0cntv_to_core0irq(void);
+unsigned long read_core0timer_pending(void);
+unsigned long long read_cntvct(void);
+unsigned long long read_cntvoff(void);
+unsigned long read_cntv_tval(void);
+void write_cntv_tval(unsigned long val);
+unsigned long read_cntfrq(void);
+
+static inline void enablecntv(void)
+{
+ unsigned long cntv_ctl;
+ cntv_ctl = 1;
+ asm volatile ("mcr p15, 0, %0, c14, c3, 1" :: "r"(cntv_ctl) ); // write CNTV_CTL
+}
+
+static inline void disablecntv(void)
+{
+ unsigned long cntv_ctl;
+ cntv_ctl = 0;
+ asm volatile ("mcr p15, 0, %0, c14, c3, 1" :: "r"(cntv_ctl) ); // write CNTV_CTL
+}
+
+#endif