summaryrefslogtreecommitdiff
path: root/kernel/include/gen_offset.h
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2016-12-17 17:48:47 -0500
committerAnas Nashif <anas.nashif@intel.com>2016-12-19 14:59:35 -0500
commitd687a95611bbd737fa56ba0a99a3e65255715cac (patch)
tree7f472cc8d694f95b3dfdd5fcdcd03e824f5a43ef /kernel/include/gen_offset.h
parent9463dc0b8f0ae9916b410cb9e5f9ce8e758cc5ad (diff)
kernel: move kernel code to kernel/ directly
Also remove mentions of unified kernel in various places in the kernel, samples and documentation. Change-Id: Ice43bc73badbe7e14bae40fd6f2a302f6528a77d Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Diffstat (limited to 'kernel/include/gen_offset.h')
-rw-r--r--kernel/include/gen_offset.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/kernel/include/gen_offset.h b/kernel/include/gen_offset.h
new file mode 100644
index 000000000..9b8286da6
--- /dev/null
+++ b/kernel/include/gen_offset.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2010, 2012, 2014 Wind River Systems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file
+ * @brief Macros to generate structure member offset definitions
+ *
+ * This header contains macros to allow a nanokernel implementation to
+ * generate absolute symbols whose values represents the member offsets for
+ * various nanokernel structures. These absolute symbols are typically
+ * utilized by assembly source files rather than hardcoding the values in
+ * some local header file.
+ *
+ * WARNING: Absolute symbols can potentially be utilized by external tools --
+ * for example, to locate a specific field within a data structure.
+ * Consequently, changes made to such symbols may require modifications to the
+ * associated tool(s). Typically, relocating a member of a structure merely
+ * requires that a tool be rebuilt; however, moving a member to another
+ * structure (or to a new sub-structure within an existing structure) may
+ * require that the tool itself be modified. Likewise, deleting, renaming, or
+ * changing the meaning of an absolute symbol may require modifications to a
+ * tool.
+ *
+ * The macro "GEN_OFFSET_SYM(structure, member)" is used to generate a single
+ * absolute symbol. The absolute symbol will appear in the object module
+ * generated from the source file that utilizes the GEN_OFFSET_SYM() macro.
+ * Absolute symbols representing a structure member offset have the following
+ * form:
+ *
+ * __<structure>_<member>_OFFSET
+ *
+ * This header also defines the GEN_ABSOLUTE_SYM macro to simply define an
+ * absolute symbol, irrespective of whether the value represents a structure
+ * or offset.
+ *
+ * The following sample file illustrates the usage of the macros available
+ * in this file:
+ *
+ * <START of sample source file: offsets.c>
+ *
+ * #include <gen_offset.h>
+ * /@ include struct definitions for which offsets symbols are to be
+ * generated @/
+ *
+ * #include <kernel_structs.h>
+ * GEN_ABS_SYM_BEGIN (_OffsetAbsSyms) /@ the name parameter is arbitrary @/
+ * /@ _kernel_t structure member offsets @/
+ *
+ * GEN_OFFSET_SYM (_kernel_t, nested);
+ * GEN_OFFSET_SYM (_kernel_t, irq_stack);
+ * GEN_OFFSET_SYM (_kernel_t, current);
+ * GEN_OFFSET_SYM (_kernel_t, idle);
+ *
+ * GEN_ABSOLUTE_SYM (___kernel_t_SIZEOF, sizeof(_kernel_t));
+ *
+ * GEN_ABS_SYM_END
+ * <END of sample source file: offsets.c>
+ *
+ * Compiling the sample offsets.c results in the following symbols in offsets.o:
+ *
+ * $ nm offsets.o
+ * 00000000 A ___kernel_t_nested_OFFSET
+ * 00000004 A ___kernel_t_irq_stack_OFFSET
+ * 00000008 A ___kernel_t_current_OFFSET
+ * 0000000c A ___kernel_t_idle_OFFSET
+ */
+
+#ifndef _GEN_OFFSET_H
+#define _GEN_OFFSET_H
+
+#include <toolchain.h>
+#include <stddef.h>
+
+/* definition of the GEN_OFFSET_SYM() macros is toolchain independent */
+
+#define GEN_OFFSET_SYM(S, M) \
+ GEN_ABSOLUTE_SYM(__##S##_##M##_##OFFSET, offsetof(S, M))
+
+#endif /* _GEN_OFFSET_H */