Commit graph

23 commits

Author SHA1 Message Date
Daniel Leung 8bfdb23a08 logging: rename shadow variables
Rename shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-22 11:39:58 +02:00
Daniel Leung 287916c71e logging: sys_t/catalog: fix unaligned access
When copying parameters into payload buffer, it is possible
that after copying a string over, the pointer to buffer is
no longer aligned on 4 or 8 bytes. And some toolchains may
decide to treat the copy as aligned since the values being
copied are 4 or 8 bytes. This results in unaligned memory
access and hardware exception. So change the copy to memcpy
to avoid potential unaligned access.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-07-25 09:14:17 +02:00
Kumar Gala caea9dc196 logging: Use TYPE_SECTION macros for log strings
Clean up log_strings to utilize macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-20 10:52:07 +02:00
Gerard Marull-Paretas a5fd0d184a init: remove the need for a dummy device pointer in SYS_INIT functions
The init infrastructure, found in `init.h`, is currently used by:

- `SYS_INIT`: to call functions before `main`
- `DEVICE_*`: to initialize devices

They are all sorted according to an initialization level + a priority.
`SYS_INIT` calls are really orthogonal to devices, however, the required
function signature requires a `const struct device *dev` as a first
argument. The only reason for that is because the same init machinery is
used by devices, so we have something like:

```c
struct init_entry {
	int (*init)(const struct device *dev);
	/* only set by DEVICE_*, otherwise NULL */
	const struct device *dev;
}
```

As a result, we end up with such weird/ugly pattern:

```c
static int my_init(const struct device *dev)
{
	/* always NULL! add ARG_UNUSED to avoid compiler warning */
	ARG_UNUSED(dev);
	...
}
```

This is really a result of poor internals isolation. This patch proposes
a to make init entries more flexible so that they can accept sytem
initialization calls like this:

```c
static int my_init(void)
{
	...
}
```

This is achieved using a union:

```c
union init_function {
	/* for SYS_INIT, used when init_entry.dev == NULL */
	int (*sys)(void);
	/* for DEVICE*, used when init_entry.dev != NULL */
	int (*dev)(const struct device *dev);
};

struct init_entry {
	/* stores init function (either for SYS_INIT or DEVICE*)
	union init_function init_fn;
	/* stores device pointer for DEVICE*, NULL for SYS_INIT. Allows
	 * to know which union entry to call.
	 */
	const struct device *dev;
}
```

This solution **does not increase ROM usage**, and allows to offer clean
public APIs for both SYS_INIT and DEVICE*. Note that however, init
machinery keeps a coupling with devices.

**NOTE**: This is a breaking change! All `SYS_INIT` functions will need
to be converted to the new signature. See the script offered in the
following commit.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

init: convert SYS_INIT functions to the new signature

Conversion scripted using scripts/utils/migrate_sys_init.py.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

manifest: update projects for SYS_INIT changes

Update modules with updated SYS_INIT calls:

- hal_ti
- lvgl
- sof
- TraceRecorderSource

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: devicetree: devices: adjust test

Adjust test according to the recently introduced SYS_INIT
infrastructure.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: kernel: threads: adjust SYS_INIT call

Adjust to the new signature: int (*init_fn)(void);

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-12 14:28:07 +00:00
Dennis Sitelew 42f9b69f50 logging: Fix signed integer cast for isprint
Casting the value byte to char may result in it being a negative
number. On some platforms this could lead to either UB, or a crash.

Signed-off-by: Dennis Sitelew <dennis.sitelew@grandcentrix.net>
2022-09-13 08:51:22 +00:00
Krzysztof Chruscinski 9833ca61c9 logging: Removing v2 suffix from logging names
Renaming objects which had 2 in the name to indicate that
it is v2 specific. Once logging v1 has been removed such
suffixes are redundant.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-23 15:46:37 -04:00
Krzysztof Chruscinski c5f2cdef09 logging: Remove logging v1 from the logging
Remove v1 implementation from log_core and all references in the tree.
Remove modules used by v1: log_list and log_msg.
Remove Kconfig v1 specific options.
Remove Kconfig flags used for distinction between v1 and v2.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-16 10:51:15 -04:00
Daniel Leung 134d26bade logging: syst: extend catalog messages support for other archs
This extends Sys-T catalog messages support for other architectures,
by utilizing tagged arguments to prepare the catalog messages. So
this is no longer limited to architectures where the printf
argument list has the exact format as the catalog message argument
list.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-08 00:15:55 +09:00
Daniel Leung 6ec1fcc214 logging: syst: embed log message source IDs in Sys-T messages
This embeds the log message source IDs inside the origin unit
as module IDs in Sys-T messages. This allows Sys-T message
parsers to see where the log messages are coming from.

This is enabled by default if using Sys-T catalog messages as
the collateral XML file contains the information to interpret
the module ID.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-05-09 12:54:53 -05:00
Gerard Marull-Paretas 5113c1418d subsystems: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all subsystems code to
the new prefix <zephyr/...>. Note that the conversion has been scripted,
refer to zephyrproject-rtos#45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-09 12:07:35 +02:00
Daniel Leung ba488d14d4 logging: syst: add support for catalog messages
MIPI Sys-T catalog messages are similar to dictionary logging
where an ID is emitted instead of the format string. This allows
the format strings to be removed from the final binary to save
a few bytes. This adds the necessary bits to determine to emit
catalog messages when appropriate.

Note that this implementation copies the argument list as-is
with string arguments stitched together since the format strings
are assumed to have been removed and they cannot be examined
to properly convert the argument lists into catalog message
payloads. Because of this, various build asserts are there to
avoid building for configurations where they are known not to
work.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-04-01 13:29:45 +02:00
Daniel Leung 8610f9f019 logging: syst: v1/imm: remove temp buffer for sync string output
The MIPI Sys-T library can now take a format string with a variable
argument list so there is no need for the temporary buffer anymore.

This saves some stack space in v1 immediate mode.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-04-01 13:29:45 +02:00
Daniel Leung 579829776a logging: syst: fix logging v2 with strings as arguments
The packaged string coming from logging subsys requires some
additional processing if there are string arguments.
These strings are actually embedded inside the package so
the string pointers inside the argument list must be
replaced with pointers to strings inside the package.
Without this extra step of processing, MIPI Sys-T's printf
function would process these arguments directly which may be
NULL pointers or invalid one pointing to somewhere.

This utilizes the new cbpprintf_external() for the processing
before feeding data to the MIPI library.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-02-04 11:14:55 +01:00
Daniel Leung 4b6eb55236 logging: output/syst: don't use raw output for hexdump
Hexdump via logging is supposed to be human-readable for
debug information. Therefore, it should actually print
in human-readable form (well... after some magical decoder
has processed the raw MIPI Sys-T output).

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-14 09:59:06 -05:00
Aastha Grover a89fae798c logging: Add MIPI sys-t support for v2 logging subsystem.
Adding functions log_output_msg2_syst_process and hexdump2_print
to support v2 logging subsystem.

Updates west.yml to pick up a new version of the MIPI sys-t library that
supports vprintf.

Signed-off-by: Aastha Grover <aastha.grover@intel.com>
Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-01-05 14:41:51 +01:00
Wentong Wu c85d353ca4 logging: add STP transport and raw data output support for syst
Add STP transport support for MIPI SyS-T with Kconfig MIPI_SYST_STP,
this is following SyS-T spec Section 7.
And with Kconfig MIPI_SYST_RAW_DATA, add raw data output support for
MIPI SyS-T protocol stack.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-11-17 10:09:19 -06:00
Xavier Chapron 824f423e54 misc: Replace assert include and calls by sys/__assert.h equivalent
Replace all calls to the assert macro that comes from libc by calls to
__ASSERT_NO_MSG(). This is usefull as the former might be different
depending on the libc used and the later can be customized to reduce
flash footprint.

Signed-off-by: Xavier Chapron <xavier.chapron@stimio.fr>
2020-10-02 11:42:40 +02:00
Tomasz Bursztyka e18fcbba5a device: Const-ify all device driver instance pointers
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Wentong Wu ab8392fb8f logging: syst: enable protocol timestamp in SyS-T message
Enable protocol timestamp in SyS-T message.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-05-08 17:47:30 +02:00
Wentong Wu 450f21ff42 logging: syst: enable length field for SyS-T message
Enable generation of length field for SyS-T message.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-05-08 17:47:30 +02:00
Wentong Wu c3f38db5cb logging: add syst initialization code to zephyr tree
Add syst initialization code to zephyr tree.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-05-08 17:47:30 +02:00
Wentong Wu dd9480913e logging: add syst format output
Add syst format output support for existing logging system.

Fixes: #19841.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-10-29 10:18:51 +01:00