summaryrefslogtreecommitdiff
path: root/include/compile_time_macros.h
Commit message (Collapse)AuthorAgeFilesLines
* compile_time_macros: Make _IS_ARRAY work with C++Tom Hughes2021-05-031-0/+8
| | | | | | | | | | | BRANCH=none BUG=b:144959033 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I199f05eabad1182ca2da4489361426d04da06691 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2864513 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* compile_time_macros: Make _STATIC_ASSERT work with C++Tom Hughes2021-05-031-1/+7
| | | | | | | | | | | BRANCH=none BUG=b:144959033 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ia17dd2339bb132e72c296bf5062e90b9503d7e2f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2864512 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* zephyr: Avoid duplicate definition of GENMASK, etc.Simon Glass2020-12-241-1/+1
| | | | | | | | | | | | | | These two macros are defined by Zephyr after this header is included. Avoid this with an #ifdef. BUG=b:175434113 BRANCH=none TEST=build zephyr for volteer Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: Iaa802de3e49bbdbb68bf9044be28a93bd095c7de Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2600227 Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: make compile_time_macros.h compatible with ZephyrJack Rosenthal2020-10-011-0/+14
| | | | | | | | | | | | | | | Include sys/util.h in Zephyr, which provides the same definition of most of these macros. Guard the platform/ec implementations where appropriate. BUG=b:167590251 BRANCH=none TEST=compiles Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Icba8e1f7d846cc731ec3acf4f3472e108e4cd6f4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427091 Reviewed-by: Jett Rink <jettrink@chromium.org>
* common: make ARRAY_SIZE, ARRAY_BEGIN, ARRAY_END type safeJack Rosenthal2020-01-141-3/+18
| | | | | | | | | | | | | | | | | | | | ARRAY_SIZE (and family) used to allow pointers to be passed to the macro, which would cause a value of one for the array size. This is a really easy accidental programming error. This change causes ARRAY_SIZE and ARRAY_END to divide by zero (using BUILD_CHECK_INLINE) if a pointer is passed. ARRAY_BEGIN will cause a BUILD_ASSSERT to fail if a pointer is passed. BUG=none BRANCH=none TEST=buildall Change-Id: Ibdd0efcc9fc46c43d46f2bd06529cc76df910f2e Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1993915 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Scott Collyer <scollyer@chromium.org>
* compile_time_macros: Add GENMASK and GENMASK_ULLCraig Hesling2019-12-201-0/+16
| | | | | | | | | | | | | | | BRANCH=all BUG=none TEST=make buildall TEST=make run-compile_time_macros Change-Id: I586e009dac20e33701ded9a05c51ee806e466cae Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1974356 Tested-by: Craig Hesling <hesling@chromium.org> Auto-Submit: Craig Hesling <hesling@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* build_assert: use _Static_assertJett Rink2019-12-061-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We have compiler support for _static_assert, so we should use it. Also allow for an option message in BUILD_ASSERT that will display as a part of the failure. Here is an example of a compile failure with the optional message ... CC RW/chip/npcx/gpio.o CC RW/chip/npcx/header.o In file included from include/common.h:13, from include/adc.h:11, from board/phaser/board.c:8: include/compile_time_macros.h:13:2: error: static assertion failed: "board/phaser/board.c:74: Size mismatch" _Static_assert(cond, file ":" #line ": " msg) ... BRANCH=none BUG=none TEST=verified by manually update BUILD_ASSERTS and viewing output. Change-Id: I6421084868ea81be8b3fa6ad0613730f4e4e149b Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1950820 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* include: De-longify BIT() macroEvan Green2019-10-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | The BIT() macro was recently introduced to make things more comfortable to upstream Linux. However, there's no need for it to be a long. Change the macro back to being an int (int and long are the same on 32-bit platforms, which all of our ECs are), so that we can reduce the number of %l specifiers. The semantics of %l have changed, we are deprecating its use on master to reduce the risk that we accidentally cherry-pick one of those printfs to an old firmware branch. BUG=chromium:984041 TEST=make -j buildall BRANCH=None Change-Id: I95b9cd49895cc67998dcb1de9bab5b5591d93243 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1834601 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: caveh jalali <caveh@chromium.org>
* LICENSE: remove unnecessary (c) after CopyrightTom Hughes2019-06-191-1/+1
| | | | | | | | | | | | | | | | Ran the following command: git grep -l 'Copyright (c)' | \ xargs sed -i 's/Copyright (c)/Copyright/g' BRANCH=none BUG=none TEST=make buildall -j Change-Id: I6cc4a0f7e8b30d5b5f97d53c031c299f3e164ca7 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1663262 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* common: Add BIT macroGwendal Grignou2019-03-261-0/+6
| | | | | | | | | | | | | | | As requested for integration in kernel mfd subsystem, use BIT(...) instead of (1 << ... ). Add the macros, apply just to ec_commands.h for now. BUG=None BRANCH=None TEST=Compile Change-Id: I8509f1e8dc966799c3c4f0269b15f1ccc4138c07 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1518658 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* ec: Add macro to check if constant index is too largeGwendal Grignou2018-10-231-0/+6
| | | | | | | | | | | | | | | | | BUILD_ASSERT can only be used for declarative code, add a macro to check if a condition resolved at build time is true or not. Take advantage of compiler detection of division by zero error message. [-Werror=div-by-zero] BUG=none BRANCH=eve,nocturne TEST=compile, check error is detected when condition is not true. Change-Id: I4ab1ad4ae516c00c9e30e778dd81f18893ef1673 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1283969 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* ec: Make it possible to build tests using clangNicolas Boichat2018-06-281-2/+0
| | | | | | | | | | | | | | | | | | We might want to try out address sanitizer/fuzzer on some host tests: make it possible to build host tests using clang. Board builds are broken, and there is no intention to fix them, at least for now. BRANCH=none BUG=chromium:854924 TEST=make buildall -j TEST=make CC=clang runtests -j Change-Id: Id49a1b8537bc403d53437a2245f4fab6ceae89ac Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1107522 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* usb_update: Add handler for pairing challenge commandNicolas Boichat2017-06-151-0/+2
| | | | | | | | | | | | | | | | | | Handle UPDATE_EXTRA_CMD_PAIR_CHALLENGE command, where the lid sends a random x25519 public key, and nonce, and the base replies with its own (stable) x25519 public key, and computes a shared secret using its private key to verify its identity. BRANCH=none BUG=b:38486828 TEST=Flash hammer, ./usb_updater2 -c always reports the same device public key, and authenticator is correct. Change-Id: Ida60ffa7476794ee92669951c740dbe35950fb9c Reviewed-on: https://chromium-review.googlesource.com/532475 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* NPCX: Refactor GPIO driver for functionality and sizeAnton Staaf2016-03-021-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Body 5678901234567890123456789012345678901234567890123456789012345678901 Previously the GPIO driver used quite redundant encodings for its WUI and DEVALT mapping tables. This refactor compresses those tables significantly, while adding the ability to represent an inverted DEVALT bit. The resulting RO firmware image for Wheatley is 384 bytes smaller. This commit also corrects the interpretation of the func parameter to gpio_set_alternate_function. Any non-negative func should be interpreted as a request to switch a pin to an alternate mode. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Ran on Wheatley, manually verified basic functionality Change-Id: I3a56a4b56d13a70a30c388e7e2c77dd7acd3838a Reviewed-on: https://chromium-review.googlesource.com/329761 Commit-Ready: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Mulin Chao <mlchao@nuvoton.com> Reviewed-by: Shawn N <shawnn@chromium.org>
* Enforce compilation without system headersStefan Reinauer2016-02-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces HOST_CPPFLAGS to be used for all objects being compiled with HOSTCC rather then the target compiler. Since glibc is not linked into the EC, no glibc include files should be included in the EC code base. Hence, create local definitions for clock_t and wchar_t that match what the glibc include would have done, and remove some unneeded includes. Due to very eager optimization, we have to give gcc a little notch to not kick out memset. Signed-off-by: Stefan Reinauer <reinauer@chromium.org> BUG=chrome-os-partner:43025 BUG=chrome-os-partner:49517 BRANCH=none TEST=compile tested Change-Id: Idf3a2881fa8352756b0927b09c6a97473358f239 Reviewed-on: https://chromium-review.googlesource.com/322435 Commit-Ready: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
* cleanup: fix all the header guardsBill Richardson2015-06-181-3/+3
| | | | | | | | | | | | | | | This unifies all the EC header files to use __CROS_EC_FILENAME_H as the include guard. Well, except for test/ util/ and extra/ which use __TEST_ __UTIL_ and __EXTRA_ prefixes respectively. BUG=chromium:496895 BRANCH=none TEST=make buildall -j Signed-off-by: Bill Richardson <wfrichar@chromium.org> Change-Id: Iea71b3a08bdec94a11239de810a2b2e152b15029 Reviewed-on: https://chromium-review.googlesource.com/278121 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Improved the BUILD_ASSERT macro to work outside of functions.Bill Richardson2013-04-291-0/+26
This will let us check the size of static array initializers. Also moved this macro definition and ARRAY_SIZE into a new "tricks.h" header, so that userspace utils can use it too. BUG=none BRANCH=none TEST=manual Built everything, tested on Link. Tried various assertions. Change-Id: I612891108ea37dbca3572e0f25ab54a7bc0ed860 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/49417 Reviewed-by: Randall Spangler <rspangler@chromium.org>