LCOV - code coverage report
Current view: top level - zephyr/logging - log_internal.h Hit Total Coverage
Test: new.info Lines: 2 5 40.0 %
Date: 2024-12-21 18:13:37

          Line data    Source code
       1           0 : /*
       2             :  * Copyright (c) 2021 Nordic Semiconductor ASA
       3             :  *
       4             :  * SPDX-License-Identifier: Apache-2.0
       5             :  */
       6             : #ifndef ZEPHYR_INCLUDE_LOGGING_LOG_INTERNAL_H_
       7             : #define ZEPHYR_INCLUDE_LOGGING_LOG_INTERNAL_H_
       8             : 
       9             : #include <zephyr/types.h>
      10             : #include <zephyr/sys/__assert.h>
      11             : #include <zephyr/logging/log_core.h>
      12             : #include <zephyr/sys/mpsc_pbuf.h>
      13             : 
      14             : #ifdef __cplusplus
      15             : extern "C" {
      16             : #endif
      17             : 
      18             : /* Header contains declarations of functions used internally in the logging,
      19             :  * shared between various portions of logging subsystem. Functions are internal
      20             :  * not intended to be used outside, including logging backends.
      21             :  */
      22             : 
      23             : /** @brief Structure wrapper to be used for memory section. */
      24           1 : struct log_mpsc_pbuf {
      25           0 :         struct mpsc_pbuf_buffer buf;
      26             : };
      27             : 
      28             : /** @brief Structure wrapper to be used for memory section. */
      29           1 : struct log_msg_ptr {
      30           0 :         union log_msg_generic *msg;
      31             : };
      32             : 
      33             : /** @brief Indicate to the log core that one log message has been dropped.
      34             :  *
      35             :  * @param buffered True if dropped message was already buffered and it is being
      36             :  * dropped to free space for another message. False if message is being dropped
      37             :  * because allocation failed.
      38             :  */
      39             : void z_log_dropped(bool buffered);
      40             : 
      41             : /** @brief Read and clear current drop indications counter.
      42             :  *
      43             :  * @return Dropped count.
      44             :  */
      45             : uint32_t z_log_dropped_read_and_clear(void);
      46             : 
      47             : /** @brief Check if there are any pending drop notifications.
      48             :  *
      49             :  * @retval true Pending unreported drop indications.
      50             :  * @retval false No pending unreported drop indications.
      51             :  */
      52             : bool z_log_dropped_pending(void);
      53             : 
      54             : /** @brief Free allocated buffer.
      55             :  *
      56             :  * @param buf Buffer.
      57             :  */
      58             : void z_log_free(void *buf);
      59             : 
      60             : /* Initialize runtime filters */
      61             : void z_log_runtime_filters_init(void);
      62             : 
      63             : /* Initialize links. */
      64             : void z_log_links_initiate(void);
      65             : 
      66             : /* Activate links.
      67             :  * Attempt to activate links,
      68             :  *
      69             :  * @param active_mask     Mask with links to activate. N bit set indicates that Nth
      70             :  * link should be activated.
      71             :  *
      72             :  * @param[in, out] offset Offset assigned to domains. Initialize to 0 before first use.
      73             :  *
      74             :  * @return Mask with links that still remain inactive.
      75             :  */
      76             : uint32_t z_log_links_activate(uint32_t active_mask, uint8_t *offset);
      77             : 
      78             : /* Notify log_core that a backend was enabled. */
      79             : void z_log_notify_backend_enabled(void);
      80             : 
      81             : /** @brief Get pointer to the filter set of the log source.
      82             :  *
      83             :  * @param source_id Source ID.
      84             :  *
      85             :  * @return Pointer to the filter set.
      86             :  */
      87             : static inline uint32_t *z_log_dynamic_filters_get(uint32_t source_id)
      88             : {
      89             :         return &TYPE_SECTION_START(log_dynamic)[source_id].filters;
      90             : }
      91             : 
      92             : /** @brief Get number of registered sources. */
      93             : static inline uint32_t z_log_sources_count(void)
      94             : {
      95             :         return log_const_source_id(TYPE_SECTION_END(log_const));
      96             : }
      97             : 
      98             : /** @brief Return number of external domains.
      99             :  *
     100             :  * @return Number of external domains.
     101             :  */
     102             : uint8_t z_log_ext_domain_count(void);
     103             : 
     104             : /** @brief Initialize module for handling logging message. */
     105             : void z_log_msg_init(void);
     106             : 
     107             : /** @brief Commit log message.
     108             :  *
     109             :  * @param msg Message.
     110             :  */
     111             : void z_log_msg_commit(struct log_msg *msg);
     112             : 
     113             : /** @brief Get pending log message.
     114             :  *
     115             :  * @param[out] backoff Recommended backoff needed to maintain ordering of processed
     116             :  * messages. Used only when links are using dedicated buffers.
     117             :  */
     118             : union log_msg_generic *z_log_msg_claim(k_timeout_t *backoff);
     119             : 
     120             : /** @brief Free message.
     121             :  *
     122             :  * @param msg Message.
     123             :  */
     124             : void z_log_msg_free(union log_msg_generic *msg);
     125             : 
     126             : /** @brief Check if there are any message pending.
     127             :  *
     128             :  * @retval true if at least one message is pending.
     129             :  * @retval false if no message is pending.
     130             :  */
     131             : bool z_log_msg_pending(void);
     132             : 
     133             : static inline void z_log_notify_drop(const struct mpsc_pbuf_buffer *buffer,
     134             :                                      const union mpsc_pbuf_generic *item)
     135             : {
     136             :         ARG_UNUSED(buffer);
     137             :         ARG_UNUSED(item);
     138             : 
     139             :         z_log_dropped(true);
     140             : }
     141             : 
     142             : /** @brief Get tag.
     143             :  *
     144             :  * @return Tag. Null if feature is disabled.
     145             :  */
     146             : const char *z_log_get_tag(void);
     147             : 
     148             : /** @brief Check if domain is local.
     149             :  *
     150             :  * @param domain_id Domain ID.
     151             :  *
     152             :  * @return True if domain is local.
     153             :  */
     154             : static inline bool z_log_is_local_domain(uint8_t domain_id)
     155             : {
     156             :         return !IS_ENABLED(CONFIG_LOG_MULTIDOMAIN) ||
     157             :                         (domain_id == Z_LOG_LOCAL_DOMAIN_ID);
     158             : }
     159             : 
     160             : /** @brief Get timestamp.
     161             :  *
     162             :  * @return Timestamp.
     163             :  */
     164             : log_timestamp_t z_log_timestamp(void);
     165             : 
     166             : #ifdef __cplusplus
     167             : }
     168             : #endif
     169             : 
     170             : #endif /* ZEPHYR_INCLUDE_LOGGING_LOG_INTERNAL_H_ */

Generated by: LCOV version 1.14