Allan Stephens | 11dcaf2 | 2015-05-25 11:10:30 -0400 | [diff] [blame] | 1 | /* kernel version support */ |
Inaky Perez-Gonzalez | 8ddf82c | 2015-04-10 16:44:37 -0700 | [diff] [blame] | 2 | |
| 3 | /* |
| 4 | * Copyright (c) 2015 Wind River Systems, Inc. |
| 5 | * |
David B. Kinder | ac74d8b | 2017-01-18 17:01:01 -0800 | [diff] [blame] | 6 | * SPDX-License-Identifier: Apache-2.0 |
Inaky Perez-Gonzalez | 8ddf82c | 2015-04-10 16:44:37 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
Flavio Ceolin | 67ca176 | 2018-09-14 10:43:44 -0700 | [diff] [blame] | 9 | #ifndef ZEPHYR_INCLUDE_KERNEL_VERSION_H_ |
| 10 | #define ZEPHYR_INCLUDE_KERNEL_VERSION_H_ |
Inaky Perez-Gonzalez | 8ddf82c | 2015-04-10 16:44:37 -0700 | [diff] [blame] | 11 | |
Peter Mitsis | a0e4568 | 2016-01-22 12:38:49 -0500 | [diff] [blame] | 12 | #ifdef __cplusplus |
| 13 | extern "C" { |
| 14 | #endif |
| 15 | |
Anas Nashif | 69c7584 | 2018-12-07 09:17:59 -0500 | [diff] [blame] | 16 | /** |
| 17 | * @defgroup version_apis Version APIs |
| 18 | * @ingroup kernel_apis |
| 19 | * @{ |
| 20 | * |
Inaky Perez-Gonzalez | 8ddf82c | 2015-04-10 16:44:37 -0700 | [diff] [blame] | 21 | * The kernel version has been converted from a string to a four-byte |
Anas Nashif | c61820b | 2015-06-23 18:52:06 -0400 | [diff] [blame] | 22 | * quantity that is divided into two parts. |
Inaky Perez-Gonzalez | 8ddf82c | 2015-04-10 16:44:37 -0700 | [diff] [blame] | 23 | * |
Anas Nashif | c61820b | 2015-06-23 18:52:06 -0400 | [diff] [blame] | 24 | * Part 1: The three most significant bytes represent the kernel's |
| 25 | * numeric version, x.y.z. These fields denote: |
Inaky Perez-Gonzalez | 8ddf82c | 2015-04-10 16:44:37 -0700 | [diff] [blame] | 26 | * x -- major release |
| 27 | * y -- minor release |
Anas Nashif | c61820b | 2015-06-23 18:52:06 -0400 | [diff] [blame] | 28 | * z -- patchlevel release |
Paul Sokolovsky | fb9185c | 2016-10-21 14:58:43 +0300 | [diff] [blame] | 29 | * Each of these elements must therefore be in the range 0 to 255, inclusive. |
Inaky Perez-Gonzalez | 8ddf82c | 2015-04-10 16:44:37 -0700 | [diff] [blame] | 30 | * |
Anas Nashif | c61820b | 2015-06-23 18:52:06 -0400 | [diff] [blame] | 31 | * Part 2: The least significant byte is reserved for future use. |
Inaky Perez-Gonzalez | 8ddf82c | 2015-04-10 16:44:37 -0700 | [diff] [blame] | 32 | */ |
Anas Nashif | ad459cb | 2018-01-04 00:04:12 -0500 | [diff] [blame] | 33 | #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-Gonzalez | 8ddf82c | 2015-04-10 16:44:37 -0700 | [diff] [blame] | 36 | |
Allan Stephens | 11dcaf2 | 2015-05-25 11:10:30 -0400 | [diff] [blame] | 37 | /* kernel version routines */ |
| 38 | |
Anas Nashif | 69c7584 | 2018-12-07 09:17:59 -0500 | [diff] [blame] | 39 | /** |
| 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 Gala | a1b77fd | 2020-05-27 11:26:57 -0500 | [diff] [blame] | 47 | extern uint32_t sys_kernel_version_get(void); |
Allan Stephens | 11dcaf2 | 2015-05-25 11:10:30 -0400 | [diff] [blame] | 48 | |
Anas Nashif | 69c7584 | 2018-12-07 09:17:59 -0500 | [diff] [blame] | 49 | /** |
| 50 | * @} |
| 51 | */ |
| 52 | |
Peter Mitsis | a0e4568 | 2016-01-22 12:38:49 -0500 | [diff] [blame] | 53 | #ifdef __cplusplus |
| 54 | } |
| 55 | #endif |
| 56 | |
Flavio Ceolin | 67ca176 | 2018-09-14 10:43:44 -0700 | [diff] [blame] | 57 | #endif /* ZEPHYR_INCLUDE_KERNEL_VERSION_H_ */ |