aboutsummaryrefslogtreecommitdiff
path: root/include/kern/init.h
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2020-11-24 13:46:41 -0700
committerJosh Rahm <joshuarahm@gmail.com>2020-11-24 13:46:41 -0700
commit93b063fedfcf7409a67df035170ea5670cad22e1 (patch)
treea23321a7465d966b1ccf196ca00e65a70c9f9110 /include/kern/init.h
parentb040195d31df6ad759f16ea3456471897f55daa1 (diff)
downloadstm32l4-93b063fedfcf7409a67df035170ea5670cad22e1.tar.gz
stm32l4-93b063fedfcf7409a67df035170ea5670cad22e1.tar.bz2
stm32l4-93b063fedfcf7409a67df035170ea5670cad22e1.zip
Moved action to top level.
Removed old iterations of the project and moved the files from 02-usart to the root directory since that's the sole place where the action is and that subproject has outgrown its initial title.
Diffstat (limited to 'include/kern/init.h')
-rw-r--r--include/kern/init.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/include/kern/init.h b/include/kern/init.h
new file mode 100644
index 0000000..737b85f
--- /dev/null
+++ b/include/kern/init.h
@@ -0,0 +1,67 @@
+#ifndef INIT_H_
+#define INIT_H_
+
+/** Globals annotated with _no_init will not be set during init1 bootup
+ * where the data segement is loaded from flash and the bss segment is
+ * cleared.
+ *
+ * This is useful for routines that run in the init0 boot procedure
+ * that need persistent globals.
+ *
+ * Note that initializing a global annotated with _no_init will have
+ * no effect as the variable will remain uninitialized until explicitly
+ * set by by the program.
+ */
+#define _no_init \
+ __attribute((__section__(".noinit")))
+
+#define init0 \
+ static void init0fn(); \
+ static __attribute((__section__(".init0"))) \
+ __attribute((__used__)) \
+ void(*init0_ptr)() = init0fn; \
+ static void init0fn
+#define init1 \
+ static void init1fn(); \
+ static __attribute((__section__(".init1"))) \
+ __attribute((__used__)) \
+ void(*init1_ptr)() = init1fn; \
+ static void init1fn
+#define init2 \
+ static void init2fn(); \
+ static __attribute((__section__(".init2"))) \
+ __attribute((__used__)) \
+ void(*init2_ptr)() = init2fn; \
+ static void init2fn
+#define init3 \
+ static void init3fn(); \
+ static __attribute((__section__(".init3"))) \
+ __attribute((__used__)) \
+ void(*init3_ptr)() = init3fn; \
+ static void init3fn
+#define init4 \
+ static void init4fn(); \
+ static __attribute((__section__(".init4"))) \
+ __attribute((__used__)) \
+ void(*init4_ptr)() = init4fn; \
+ static void init4fn
+#define init5 \
+ static void init5fn(); \
+ static __attribute((__section__(".init5"))) \
+ __attribute((__used__)) \
+ void(*init5_ptr)() = init5fn; \
+ static void init5fn
+#define init6 \
+ static void init6fn(); \
+ static __attribute((__section__(".init6"))) \
+ __attribute((__used__)) \
+ void(*init6_ptr)() = init6fn; \
+ static void init6fn
+#define init7 \
+ static void init7fn(); \
+ static __attribute((__section__(".init7"))) \
+ __attribute((__used__)) \
+ void(*init7_ptr)() = init7fn; \
+ static void init7fn
+
+#endif /* INIT_H_ */