summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include/rtems/sysinit.h
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-09-22 16:21:12 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-12-11 08:17:16 +0100
commitd0c39838146c6a186ddda3d95dac71c3fa90f11e (patch)
tree1f96df0fd4b6e5ee9658060529b69bea1a46de4a /cpukit/score/include/rtems/sysinit.h
parentm32r/configure.ac: Looked for m32rsim to exist and now is gone (diff)
downloadrtems-d0c39838146c6a186ddda3d95dac71c3fa90f11e.tar.bz2
Use linker set for system initialization
Make rtems_initialize_data_structures(), rtems_initialize_before_drivers() and rtems_initialize_device_drivers() static. Rename rtems_initialize_start_multitasking() to rtems_initialize_executive() and call the registered system initialization handlers in this function. Add system initialization API available via #include <rtems/sysinit.h>. Update the documentation accordingly. This is no functional change, only the method to call the existing initialization routines changes. Instead of direct function calls a table of function pointers contained in the new RTEMS system initialization linker set is used. This table looks like this (the actual addresses depend on the target). nm *.exe | grep _Linker | sort 0201a2d0 D _Linker_set__Sysinit_begin 0201a2d0 D _Linker_set__Sysinit_bsp_work_area_initialize 0201a2d4 D _Linker_set__Sysinit_bsp_start 0201a2d8 D _Linker_set__Sysinit_rtems_initialize_data_structures 0201a2dc D _Linker_set__Sysinit_bsp_libc_init 0201a2e0 D _Linker_set__Sysinit_rtems_initialize_before_drivers 0201a2e4 D _Linker_set__Sysinit_bsp_predriver_hook 0201a2e8 D _Linker_set__Sysinit_rtems_initialize_device_drivers 0201a2ec D _Linker_set__Sysinit_bsp_postdriver_hook 0201a2f0 D _Linker_set__Sysinit_end Add test sptests/spsysinit01. Update #2408.
Diffstat (limited to 'cpukit/score/include/rtems/sysinit.h')
-rw-r--r--cpukit/score/include/rtems/sysinit.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/cpukit/score/include/rtems/sysinit.h b/cpukit/score/include/rtems/sysinit.h
new file mode 100644
index 0000000000..855198d4d8
--- /dev/null
+++ b/cpukit/score/include/rtems/sysinit.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2015 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_SYSINIT_H
+#define _RTEMS_SYSINIT_H
+
+#include <rtems/linkersets.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*
+ * The value of each module define must consist of exactly six hexadecimal
+ * digits without a 0x-prefix. A 0x-prefix is concatenated with the module and
+ * order values to form a proper integer literal.
+ */
+#define RTEMS_SYSINIT_BSP_WORK_AREAS 000100
+#define RTEMS_SYSINIT_BSP_START 000200
+#define RTEMS_SYSINIT_DATA_STRUCTURES 000300
+#define RTEMS_SYSINIT_BSP_LIBC 000400
+#define RTEMS_SYSINIT_BEFORE_DRIVERS 000500
+#define RTEMS_SYSINIT_BSP_PRE_DRIVERS 000600
+#define RTEMS_SYSINIT_DEVICE_DRIVERS 000700
+#define RTEMS_SYSINIT_BSP_POST_DRIVERS 000800
+
+/*
+ * The value of each order define must consist of exactly two hexadecimal
+ * digits without a 0x-prefix. A 0x-prefix is concatenated with the module and
+ * order values to form a proper integer literal.
+ */
+#define RTEMS_SYSINIT_ORDER_FIRST 00
+#define RTEMS_SYSINIT_ORDER_MIDDLE 08
+#define RTEMS_SYSINIT_ORDER_LAST 0f
+
+typedef void ( *rtems_sysinit_handler )( void );
+
+typedef struct {
+ rtems_sysinit_handler handler;
+} rtems_sysinit_item;
+
+/* The enum helps to detect typos in the module and order parameters */
+#define _RTEMS_SYSINIT_INDEX_ITEM( handler, index ) \
+ enum { _Sysinit_##handler = index }; \
+ RTEMS_LINKER_ROSET_ITEM_ORDERED( \
+ _Sysinit, \
+ rtems_sysinit_item, \
+ handler, \
+ index \
+ ) = { handler }
+
+/* Create index from module and order */
+#define _RTEMS_SYSINIT_ITEM( handler, module, order ) \
+ _RTEMS_SYSINIT_INDEX_ITEM( handler, 0x##module##order )
+
+/* Perform parameter expansion */
+#define RTEMS_SYSINIT_ITEM( handler, module, order ) \
+ _RTEMS_SYSINIT_ITEM( handler, module, order )
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _RTEMS_SYSINIT_H */