blob: 6d3109fed309772f1b23fd495110a679fc576ef2 [file] [log] [blame]
Allan Stephens11dcaf22015-05-25 11:10:30 -04001/* kernel version support */
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -07002
3/*
4 * Copyright (c) 2015 Wind River Systems, Inc.
5 *
David B. Kinderac74d8b2017-01-18 17:01:01 -08006 * SPDX-License-Identifier: Apache-2.0
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -07007 */
8
Flavio Ceolin67ca1762018-09-14 10:43:44 -07009#ifndef ZEPHYR_INCLUDE_KERNEL_VERSION_H_
10#define ZEPHYR_INCLUDE_KERNEL_VERSION_H_
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070011
Peter Mitsisa0e45682016-01-22 12:38:49 -050012#ifdef __cplusplus
13extern "C" {
14#endif
15
Anas Nashif69c75842018-12-07 09:17:59 -050016/**
17 * @defgroup version_apis Version APIs
18 * @ingroup kernel_apis
19 * @{
20 *
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070021 * The kernel version has been converted from a string to a four-byte
Anas Nashifc61820b2015-06-23 18:52:06 -040022 * quantity that is divided into two parts.
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070023 *
Anas Nashifc61820b2015-06-23 18:52:06 -040024 * Part 1: The three most significant bytes represent the kernel's
25 * numeric version, x.y.z. These fields denote:
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070026 * x -- major release
27 * y -- minor release
Anas Nashifc61820b2015-06-23 18:52:06 -040028 * z -- patchlevel release
Paul Sokolovskyfb9185c2016-10-21 14:58:43 +030029 * Each of these elements must therefore be in the range 0 to 255, inclusive.
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070030 *
Anas Nashifc61820b2015-06-23 18:52:06 -040031 * Part 2: The least significant byte is reserved for future use.
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070032 */
Anas Nashifad459cb2018-01-04 00:04:12 -050033#define SYS_KERNEL_VER_MAJOR(ver) (((ver) >> 24) & 0xFF)
34#define SYS_KERNEL_VER_MINOR(ver) (((ver) >> 16) & 0xFF)
35#define SYS_KERNEL_VER_PATCHLEVEL(ver) (((ver) >> 8) & 0xFF)
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070036
Allan Stephens11dcaf22015-05-25 11:10:30 -040037/* kernel version routines */
38
Anas Nashif69c75842018-12-07 09:17:59 -050039/**
40 * @brief Return the kernel version of the present build
41 *
42 * The kernel version is a four-byte value, whose format is described in the
43 * file "kernel_version.h".
44 *
45 * @return kernel version
46 */
Kumar Galaa1b77fd2020-05-27 11:26:57 -050047extern uint32_t sys_kernel_version_get(void);
Allan Stephens11dcaf22015-05-25 11:10:30 -040048
Anas Nashif69c75842018-12-07 09:17:59 -050049/**
50 * @}
51 */
52
Peter Mitsisa0e45682016-01-22 12:38:49 -050053#ifdef __cplusplus
54}
55#endif
56
Flavio Ceolin67ca1762018-09-14 10:43:44 -070057#endif /* ZEPHYR_INCLUDE_KERNEL_VERSION_H_ */