Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
log_instance.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef ZEPHYR_INCLUDE_LOGGING_LOG_INSTANCE_H_
7#define ZEPHYR_INCLUDE_LOGGING_LOG_INSTANCE_H_
8
9#include <zephyr/types.h>
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
17 const char *name;
19#ifdef CONFIG_NIOS2
20 /* Workaround alert! Dummy data to ensure that structure is >8 bytes.
21 * Nios2 uses global pointer register for structures <=8 bytes and
22 * apparently does not handle well variables placed in custom sections.
23 */
24 uint32_t dummy;
25#endif
26};
27
31#ifdef CONFIG_NIOS2
32 /* Workaround alert! Dummy data to ensure that structure is >8 bytes.
33 * Nios2 uses global pointer register for structures <=8 bytes and
34 * apparently does not handle well variables placed in custom sections.
35 */
36 uint32_t dummy[2];
37#endif
38#if defined(CONFIG_RISCV) && defined(CONFIG_64BIT)
39 /* Workaround: RV64 needs to ensure that structure is just 8 bytes. */
40 uint32_t dummy;
41#endif
42};
43
48#define LOG_ITEM_CONST_DATA(_name) UTIL_CAT(log_const_, _name)
49
50#define Z_LOG_CONST_ITEM_REGISTER(_name, _str_name, _level) \
51 const struct log_source_const_data LOG_ITEM_CONST_DATA(_name) \
52 __attribute__ ((section("." STRINGIFY(LOG_ITEM_CONST_DATA(_name))))) \
53 __attribute__((used)) = { \
54 .name = _str_name, \
55 .level = (_level), \
56 }
57
73#ifdef CONFIG_LOG
74
75#define LOG_INSTANCE_FULL_NAME(_module_name, _inst_name) \
76 UTIL_CAT(_module_name, UTIL_CAT(_, _inst_name))
77
78#if defined(CONFIG_LOG_RUNTIME_FILTERING)
79#define LOG_INSTANCE_PTR_DECLARE(_name) \
80 struct log_source_dynamic_data *_name
81
82#define LOG_INSTANCE_REGISTER(_module_name, _inst_name, _level) \
83 Z_LOG_CONST_ITEM_REGISTER( \
84 LOG_INSTANCE_FULL_NAME(_module_name, _inst_name), \
85 STRINGIFY(_module_name._inst_name), \
86 _level); \
87 struct log_source_dynamic_data LOG_INSTANCE_DYNAMIC_DATA( \
88 _module_name, _inst_name) \
89 __attribute__ ((section("." STRINGIFY( \
90 LOG_INSTANCE_DYNAMIC_DATA(_module_name, \
91 _inst_name) \
92 ) \
93 ))) __attribute__((used))
94
95#define LOG_INSTANCE_PTR_INIT(_name, _module_name, _inst_name) \
96 ._name = &LOG_ITEM_DYNAMIC_DATA( \
97 LOG_INSTANCE_FULL_NAME(_module_name, _inst_name)),
98
99#else /* CONFIG_LOG_RUNTIME_FILTERING */
100#define LOG_INSTANCE_PTR_DECLARE(_name) \
101 const struct log_source_const_data *_name
102
103#define LOG_INSTANCE_REGISTER(_module_name, _inst_name, _level) \
104 Z_LOG_CONST_ITEM_REGISTER( \
105 LOG_INSTANCE_FULL_NAME(_module_name, _inst_name), \
106 STRINGIFY(_module_name._inst_name), \
107 _level)
108
109
110#define LOG_INSTANCE_PTR_INIT(_name, _module_name, _inst_name) \
111 ._name = &LOG_ITEM_CONST_DATA( \
112 LOG_INSTANCE_FULL_NAME(_module_name, _inst_name)),
113
114#endif /* CONFIG_LOG_RUNTIME_FILTERING */
115#else /* CONFIG_LOG */
116#define LOG_INSTANCE_PTR_DECLARE(_name) /* empty */
117#define LOG_INSTANCE_REGISTER(_module_name, _inst_name, _level) /* empty */
118#define LOG_INSTANCE_PTR_INIT(_name, _module_name, _inst_name) /* empty */
119#endif
120
121#ifdef __cplusplus
122}
123#endif
124
125#endif /* ZEPHYR_INCLUDE_LOGGING_LOG_INSTANCE_H_ */
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
Constant data associated with the source of log messages.
Definition: log_instance.h:16
uint8_t level
Definition: log_instance.h:18
const char * name
Definition: log_instance.h:17
Dynamic data associated with the source of log messages.
Definition: log_instance.h:29
uint32_t filters
Definition: log_instance.h:30