History log of /optee_os/lib/libutils/ext/include/util.h (Results 1 – 25 of 43)
Revision Date Author Comments
# 44f8cfac 23-Sep-2024 Maxime Méré <maxime.mere@foss.st.com>

libutils: util.h: add usage description to {get,set}_field_u{32,64}()

Add inline description comments to get_bitfield_u32(),
get_bitfield_u64(), set_bitfield_u32() and set_bitfield_u64() to improve

libutils: util.h: add usage description to {get,set}_field_u{32,64}()

Add inline description comments to get_bitfield_u32(),
get_bitfield_u64(), set_bitfield_u32() and set_bitfield_u64() to improve
understanding and reduce errors.

Signed-off-by: Maxime Méré <maxime.mere@foss.st.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>

show more ...


# 383d0594 17-Dec-2024 Etienne Carriere <etienne.carriere@foss.st.com>

libutils: util.h: fix indentation of ROUNDDOWN() macro

Fix indentation of the value defined for ROUNDDOWN() macro
and add inline comment to better highlight the surrounded
macros are defined for ass

libutils: util.h: fix indentation of ROUNDDOWN() macro

Fix indentation of the value defined for ROUNDDOWN() macro
and add inline comment to better highlight the surrounded
macros are defined for assembler and like source files.

Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# 8fd4cad1 17-Dec-2024 Etienne Carriere <etienne.carriere@foss.st.com>

libutils: util.h: fix DIV_ROUND_UP() inline description

Remove trailing space char in inline description comment of
DIV_ROUND_UP() macro.

Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.c

libutils: util.h: fix DIV_ROUND_UP() inline description

Remove trailing space char in inline description comment of
DIV_ROUND_UP() macro.

Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# fa418fcd 18-Dec-2024 Etienne Carriere <etienne.carriere@foss.st.com>

libutils: util.h: Relax ROUNDDOWN() and add ROUNDDOWN2()

Remove constraint on ROUNDDOWN() to have its size argument being a power
of 2 and add new ROUNDDOWN2() macro with that constraint.

The previ

libutils: util.h: Relax ROUNDDOWN() and add ROUNDDOWN2()

Remove constraint on ROUNDDOWN() to have its size argument being a power
of 2 and add new ROUNDDOWN2() macro with that constraint.

The previous implementation of ROUNDDOWN(), optimized for when size
argument is a power of 2, is now used for ROUNDDOWN2() but this latter
also asserts (in debug build mode) that the size argument conforms to
this condition.

The new implementation of ROUNDDOWN() is less optimal but modern
compilers produce the same optimized assembly code with this macro when
the size argument is a constant value known from the compiler so all
use of ROUNDDOWN() with a known constant value do not need move to
ROUNDDOWN2().

Performance sensitive routines should now on use ROUNDDOWN2() to
leverage the power-of-2 rounding optimization.

Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# 8132f3be 18-Dec-2024 Etienne Carriere <etienne.carriere@foss.st.com>

libutils: util.h: Relax ROUNDUP() and add ROUNDUP2()

Remove constraint on ROUNDUP() to have its size argument being a power
of 2 and add new ROUNDUP2() macro with that constraint.

The previous impl

libutils: util.h: Relax ROUNDUP() and add ROUNDUP2()

Remove constraint on ROUNDUP() to have its size argument being a power
of 2 and add new ROUNDUP2() macro with that constraint.

The previous implementation of ROUNDUP(), optimized for when size
argument is a power of 2, is now used for ROUNDUP2() but this latter
also asserts (in debug build mode) that the size argument conforms to
this condition.

The new implementation of ROUNDUP() is less optimal but modern
compilers produce the same optimized assembly code with this macro
when the size argument is a constant value known from the compiler
so all use of ROUNDUP() with a known constant value do not need
move to ROUNDUP2().

Performance sensitive routines should now on use ROUNDUP2() to
leverage the power-of-2 rounding optimization.

Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# c98faf4d 18-Dec-2024 Etienne Carriere <etienne.carriere@foss.st.com>

libutils: util.h: Relax ROUNDUP_OVERFLOW() and add ROUNDUP2_OVERFLOW()

Remove constraint on ROUNDUP_OVERFLOW() to have its size argument being
a power of 2 and add new ROUNDUP2_OVERFLOW() macro with

libutils: util.h: Relax ROUNDUP_OVERFLOW() and add ROUNDUP2_OVERFLOW()

Remove constraint on ROUNDUP_OVERFLOW() to have its size argument being
a power of 2 and add new ROUNDUP2_OVERFLOW() macro with that constraint.

The previous implementation of ROUNDUP_OVERFLOW(), optimized for when
size argument is a power of 2, is now used for ROUNDUP2_OVERFLOW() but
this latter also asserts (in debug build mode) that the size argument
conforms to this condition.

Performance sensitive routines should now on use ROUNDUP2_OVERFLOW() to
leverage the power-of-2 rounding optimization.

The new implementation of ROUNDUP_OVERFLOW() is less optimal but modern
compilers produce the same optimized assembly code with this macro
when the size argument is a constant value known from the compiler
so all use of ROUNDUP_OVERFLOW() with a known constant value do not need
move to ROUNDUP2_OVERFLOW().

By the way, fix the indentation in the macro implementation for
consistency of the header file implementation and extend the inline
description comment.

Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# 4879d4c0 16-Dec-2024 Etienne Carriere <etienne.carriere@foss.st.com>

libutils: util.h: Relax ROUNDUP_DIV() and add ROUNDUP2_DIV()

Remove constraint on ROUNDUP_DIV() to have its size argument being a
power of 2 and add new ROUNDUP2_DIV() macro with that constraint.

T

libutils: util.h: Relax ROUNDUP_DIV() and add ROUNDUP2_DIV()

Remove constraint on ROUNDUP_DIV() to have its size argument being a
power of 2 and add new ROUNDUP2_DIV() macro with that constraint.

The previous implementation of ROUNDUP_DIV(), optimized for when size
argument is a power of 2, is now used for ROUNDUP2_DIV() but this latter
also asserts (in debug build mode) that the size argument conforms to
this condition.

Performance sensitive routines should now on use ROUNDUP2_DIV() to
leverage the power-of-2 rounding optimization.

The new implementation of ROUNDUP_DIV() is less optimal but modern
compilers produce the same optimized assembly code with this macro
when the size argument is a constant value known from the compiler
so all use of ROUNDUP_DIV() with a known constant value do not need
move to ROUNDUP2_DIV().

By the way, fix the indentation in the macro implementation for
consistency of the header file implementation.

Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# fd0b115a 16-Dec-2024 Etienne Carriere <etienne.carriere@foss.st.com>

libutils: util.h: fix ROUND*() macros description argument constraint

Correct inline description comment for ROUNDUP(), ROUNDUP_OVERFLOW(),
ROUNDDOWN() where the second argument is expected to be a

libutils: util.h: fix ROUND*() macros description argument constraint

Correct inline description comment for ROUNDUP(), ROUNDUP_OVERFLOW(),
ROUNDDOWN() where the second argument is expected to be a power of 2,
not a multiple of 2.

Add an inline description comment to ROUNDUP_OVERFLOW() to state
this requirement.

Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# fa4b4621 12-Jul-2024 Etienne Carriere <etienne.carriere@foss.st.com>

libutils: qsort helper for standard types

Add qsort_int(), qsort_uint(), qsort_u32() and friends as qsort() helper
functions to sort standard typed arrays.

Signed-off-by: Etienne Carriere <etienne.

libutils: qsort helper for standard types

Add qsort_int(), qsort_uint(), qsort_u32() and friends as qsort() helper
functions to sort standard typed arrays.

Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# e716d498 10-Apr-2024 Tony Han <tony.han@microchip.com>

libutils: util.h: fix the GENMASK_32(h, l) macro

The macro has a problem when it is used in an assembly file:
.e.g ".word GENMASK_32(15, 8)" will be compiled to ".word 0xffffff00"

The issue is caus

libutils: util.h: fix the GENMASK_32(h, l) macro

The macro has a problem when it is used in an assembly file:
.e.g ".word GENMASK_32(15, 8)" will be compiled to ".word 0xffffff00"

The issue is caused by the compiler always treating ~0 as a 64-bit
value. Fix it by replacing '~UINT32_C(0)' with 'UINT32_C(0xffffffff)'.

Signed-off-by: Tony Han <tony.han@microchip.com>
Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# 546e296f 04-Jul-2023 Jens Wiklander <jens.wiklander@linaro.org>

libutils: add {high,low}32_from_64() helper

Adds two helper functions high32_from_64() and low32_from_64() used for
retrieving the upper and lower halves of a uint64_t.

Signed-off-by: Jens Wiklande

libutils: add {high,low}32_from_64() helper

Adds two helper functions high32_from_64() and low32_from_64() used for
retrieving the upper and lower halves of a uint64_t.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>

show more ...


# d3ed98ee 20-Oct-2022 Clement Faure <clement.faure@nxp.com>

libutils: util.h: fix the ROUNDUP_OVERFLOW() macro

Some parenthesis are missing in the ROUNDUP_OVERFLOW expression.
The macro can only return false.

Fixes: 2e48af989133 ("util.h: add the macro ROUN

libutils: util.h: fix the ROUNDUP_OVERFLOW() macro

Some parenthesis are missing in the ROUNDUP_OVERFLOW expression.
The macro can only return false.

Fixes: 2e48af989133 ("util.h: add the macro ROUNDUP_OVERFLOW()")
Signed-off-by: Clement Faure <clement.faure@nxp.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# 8dc184e5 18-Jul-2022 Marouene Boubakri <marouene.boubakri@nxp.com>

libutils: util.h: add get_field_u{32,64}() and set_field_u{32,64}()

This commit defines macros for getting and setting bit fields.

Signed-off-by: Marouene Boubakri <marouene.boubakri@nxp.com>
Revie

libutils: util.h: add get_field_u{32,64}() and set_field_u{32,64}()

This commit defines macros for getting and setting bit fields.

Signed-off-by: Marouene Boubakri <marouene.boubakri@nxp.com>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>

show more ...


# 1b4b9334 15-Jun-2021 Clément Léger <clement.leger@bootlin.com>

ext: include: add DIV_ROUND_UP function

Export DIV_ROUND_UP from mbedtls files to be used by clock drivers.

Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Clément Léger

ext: include: add DIV_ROUND_UP function

Export DIV_ROUND_UP from mbedtls files to be used by clock drivers.

Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Clément Léger <clement.leger@bootlin.com>

show more ...


# be501eb1 05-Oct-2021 Jorge Ramirez-Ortiz <jorge@foundries.io>

util: rename ALIGNMENT_IS_OK to IS_ALIGNED_WITH_TYPE

Implement the renamed macro using the IS_ALIGNED definition.

Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
Reviewed-by: Etienne Carrie

util: rename ALIGNMENT_IS_OK to IS_ALIGNED_WITH_TYPE

Implement the renamed macro using the IS_ALIGNED definition.

Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# 6d777f26 05-Oct-2021 Jorge Ramirez-Ortiz <jorge@foundries.io>

util: define IS_ALIGNED macro

Keep a single version of the macro definition.

Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Revi

util: define IS_ALIGNED macro

Keep a single version of the macro definition.

Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# 355fa095 24-Sep-2020 Jorge Ramirez-Ortiz <jorge@foundries.io>

libutils: do not redefine ARRAY_SIZE

Do not redefine ARRAY_SIZE if it is already defined

Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
Reviewed-by: Etienne Carriere <etienne.carriere@lina

libutils: do not redefine ARRAY_SIZE

Do not redefine ARRAY_SIZE if it is already defined

Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Jerome Forissier <jerome@forissier.org>

show more ...


# a73ebd47 19-Mar-2020 Jens Wiklander <jens.wiklander@linaro.org>

util.h: add ROUNDUP_DIV(x, y) macro

Adds the ROUNDUP_DIV(x, y) macro which Rounds up to the nearest multiple
of y and then divides by y. Safe against overflow, y has to be a
multiple of 2 just as in

util.h: add ROUNDUP_DIV(x, y) macro

Adds the ROUNDUP_DIV(x, y) macro which Rounds up to the nearest multiple
of y and then divides by y. Safe against overflow, y has to be a
multiple of 2 just as in the other two ROUNDUP*() macros.

This macro is intended to be used to convert from "number of bytes" to
"number of pages" or similar units. Example:
num_pages = ROUNDUP_DIV(num_bytes, SMALL_PAGE_SIZE);

Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Jerome Forissier <jerome@forissier.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# 2e48af98 04-Sep-2019 Jens Wiklander <jens.wiklander@linaro.org>

util.h: add the macro ROUNDUP_OVERFLOW()

Adds the macro ROUNDUP_OVERFLOW() which rounds up like ROUNDUP() but also
checks the result for overflow and returns true on overflow.

Reviewed-by: Etienne

util.h: add the macro ROUNDUP_OVERFLOW()

Adds the macro ROUNDUP_OVERFLOW() which rounds up like ROUNDUP() but also
checks the result for overflow and returns true on overflow.

Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Jerome Forissier <jerome@forissier.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# 757331fc 21-Aug-2019 Jens Wiklander <jens.wiklander@linaro.org>

Replace ASM with compiler-builtin __ASSEMBLER__

The C preprocessor predefines __ASSEMBLER__ with value 1 when when
preprocessing assembly language, see [1]. Instead of using a special
defines, let's

Replace ASM with compiler-builtin __ASSEMBLER__

The C preprocessor predefines __ASSEMBLER__ with value 1 when when
preprocessing assembly language, see [1]. Instead of using a special
defines, let's use the define already provided.

Link: [1] https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# 78e8a97d 23-May-2019 Jens Wiklander <jens.wiklander@linaro.org>

Move reg_pair_*() to util.h

Moves the two functions reg_pair_to_64() and reg_pair_from_64() from the
core only .h file <kernel/misc.h> to the libutils .h file util.h to make
the functions available

Move reg_pair_*() to util.h

Moves the two functions reg_pair_to_64() and reg_pair_from_64() from the
core only .h file <kernel/misc.h> to the libutils .h file util.h to make
the functions available from TAs.

Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# e72ad0e2 07-Mar-2019 Etienne Carriere <etienne.carriere@st.com>

libutil: add UDIV_ROUND_NEAREST() macro

Default integer division rounds down. Here the interest is
to round to the nearest unsigned integer.

This is inspired from [1].

Link: [1] https://chromium.g

libutil: add UDIV_ROUND_NEAREST() macro

Default integer division rounds down. Here the interest is
to round to the nearest unsigned integer.

This is inspired from [1].

Link: [1] https://chromium.googlesource.com/chromiumos/platform/ec/+/master/include/util.h

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
Signed-off-by: Nicolas Le Bayon <nicolas.le.bayon@st.com>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>

show more ...


# 8a076f79 20-Jun-2018 Jens Wiklander <jens.wiklander@linaro.org>

Use inttypes.h over stdint.h on some .h files

Uses inttypes.h over stdint.h on some .h files to be nice to U-boot.

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wikla

Use inttypes.h over stdint.h on some .h files

Uses inttypes.h over stdint.h on some .h files to be nice to U-boot.

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# cf1dc544 27-Jun-2018 Etienne Carriere <etienne.carriere@linaro.org>

libutils: introduce MAX_UNSAFE() and MIN_UNSAFE()

This change allows one to use MAX_UNSAFE() and MIN_UNSAFE() macros
in particular conditions where MAX()/MIN() macros fail to build
from C source fil

libutils: introduce MAX_UNSAFE() and MIN_UNSAFE()

This change allows one to use MAX_UNSAFE() and MIN_UNSAFE() macros
in particular conditions where MAX()/MIN() macros fail to build
from C source file implementation with error traces as below:

In file included from core/arch/arm/include/arm.h:8:0,
from core/arch/arm/include/kernel/thread.h:11,
from core/arch/arm/kernel/asm-defines.c:7:
lib/libutils/ext/include/util.h:24:16: error: missing binary operator before token "("
(__extension__({ __typeof__(a) _a = (a); \
^
core/arch/arm/plat-stm/./platform_config.h:190:25: note: in expansion of macro ‘MAX’
#define STM_SECDDR_END MAX(TZSRAM_BASE + TZSRAM_SIZE, \
^~~
core/arch/arm/plat-stm/./platform_config.h:204:6: note: in expansion of macro ‘STM_SECDDR_END’
#if (STM_SECDDR_END < 0x80000000ULL)
^~~~~~~~~~~~~~
make: *** [out/core/include/generated/.asm-defines.s] Error 1

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


# dc0f4ec2 16-May-2018 Etienne Carriere <etienne.carriere@st.com>

Remove license notice from STMicroelectronics files

Since a while the source files license info are defined by SPDX
identifiers. We can safely remove the verbose license text from the
files that are

Remove license notice from STMicroelectronics files

Since a while the source files license info are defined by SPDX
identifiers. We can safely remove the verbose license text from the
files that are owned by either only STMicroelectronics or only both
Linaro and STMicroelectronics.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

show more ...


12