summaryrefslogtreecommitdiff
path: root/builtin
Commit message (Collapse)AuthorAgeFilesLines
* builtin: Add math.hTom Hughes2021-08-311-0/+11
| | | | | | | | | | | | | | | | | | | | Add a "math.h" to "builtin" and rename "math.h" in the "core" directories to "fpu.h". "builtin" is the directory containing headers that mirror those in the standard library and is used for device builds. The host builds exclude the "builtin" directory and use the standard library. Without this change, building host tools such as "ectool" and attempting to include "math.h" would result in incorrectly picking up the "math.h" from the device "core" directory, not the standard library version. BRANCH=none BUG=b:144959033 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Id6b2df42cb0ff5ec2cfc07aa8f29861da6804bdf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3130625 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* assert: Fix ASSERT() when !CONFIG_DEBUG_ASSERT_REBOOTSKeith Short2021-07-301-6/+20
| | | | | | | | | | | | | | | | | | | | | | The option CONFIG_DEBUG_ASSERT_REBOOTS can be undefined to save code size and generate a software breakpoint to recovery. Fix this code path to support the RISC-V and NDS32 architectures. This also fixes an incorrect usage of __builtin_unreachable() which caused all ASSERT() calls to generate an unconditional return. BUG=none BRANCH=none TEST=Disable CONFIG_DEBUG_ASSERT_REBOOTS, run "crash assert" on hayato (RISC-V architecture) and lazor (ARM architecture). TEST=Disable CONFIG_DEBUG_ASSERT_REBOOTS on boten (NDS32 architecture) and verfiy code compiles Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Iff2455fd209355d4276488b48f7b1dfe52cc35b5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3061077 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* panic: Tidy up the #ifdefsSimon Glass2021-02-101-6/+11
| | | | | | | | | | | | | | | | Move the common code into a separate function. Add comments to the nesting. Use IS_ENABLED() where possible and drop the outer #ifdef around the C code, since the linker will throw it away automatically if it is not called. BUG=b:177604307 BRANCH=none TEST=verified no code-size change on volteer Change-Id: I61065d37fb6267097a2078493a4edfcdeea23819 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2686248 Reviewed-by: Keith Short <keithshort@chromium.org>
* touchpad_elan: add support for CoachZ touchpadTing Shen2020-11-181-0/+4
| | | | | | | | | | | | | | | | Port probe / update logic from linux driver code (drivers/input/mouse/elan_i2c_i2c.c), and support different page size. BUG=b:169651794 TEST=flash fw successfully on Zed. BRANCH=none Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I2aa7316219d235e28e446de13b0d24fe3c6dac15 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2537415 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org>
* Replace __attribute__((noreturn)) with noreturnTom Hughes2020-08-171-5/+5
| | | | | | | | | | | | | | | _Noreturn was added in C11 and the convenience macro "noreturn" is specified by stdnoreturn.h: https://en.cppreference.com/w/c/language/_Noreturn. BRANCH=none BUG=none TEST=make buildall -j Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I30361bb5290cea1c776a7356f7e3a68edf1f8e39 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2324816 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* builtin: Add stdnoreturn.hTom Hughes2020-08-171-0/+20
| | | | | | | | | | | | | | | | | | _Noreturn was added in C11 and the convenience macro "noreturn" is specified by stdnoreturn.h: https://en.cppreference.com/w/c/language/_Noreturn. We need our own implementation of the header since we don't include the compiler's builtins. BRANCH=none BUG=none TEST=make buildall -j Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ie6c83e5ed0c331fc14a7f6092dae6220ba20cd54 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2324815 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* third_party/incbin: Add public domain incbinKeith Short2020-07-101-0/+11
| | | | | | | | | | | | | | | Add the public domain incbin library used to include binary files directly into C code. The UNLICENSE file confirms the code can be treated as unencumbered. BUG=none BRANCH=none TEST=make buildall Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I6107737cdb5a94e71e5325943b2d1d2627659f85 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2289214 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* assert.h: clang-formatCaveh Jalali2019-10-231-11/+15
| | | | | | | | | | | | | | | this is just a minor cosmetic fix of assert.h courtesy of clang-format. BRANCH=none BUG=none TEST=make buildall passes Change-Id: Ic503c22f1d29e0511a3b5ecbf697c5940c93d18c Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1864424 Commit-Queue: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* builtin: Introduce and use inttypes.hEvan Green2019-10-051-0/+12
| | | | | | | | | | | | | | | | | | | | | In order to pass the right printf format specifiers for certain types that are compiled both in 32-bit EC and 64-bit host environments, standard macros PRIx64 and PRId64 must be introduced. These specify the correct printf format specifier in the given compilation environment for printing a 64-bit value. On the host, inttypes.h already exists. Add an inttypes.h for the EC codebase so that these macros can be used where they're needed. BUG=chromium:984041 TEST=make -j buildall BRANCH=none Change-Id: I76e3bdc88aef7da6e5234d5b86b595f7138ea9a1 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1819642 Reviewed-by: caveh jalali <caveh@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* chip/mt_scp: support software gainTzung-Bi Shih2019-09-191-0/+3
| | | | | | | | | | | | | | | | | | | Multiply the audio data by a gain value. Note that it get muted when gain is 0. BRANCH=none BUG=b:122027734, b:123268236 TEST=1. define CONFIG_AUDIO_CODEC in board.h 2. define CONFIG_AUDIO_CODEC_DMIC in board.h 3. define CONFIG_AUDIO_CODEC_DMIC_SOFTWARE_GAIN in board.h 4. define CONFIG_AUDIO_CODEC_DMIC_MAX_SOFTWARE_GAIN in board.h 5. define CONFIG_AUDIO_CODEC_WOV in board.h 6. make BOARD=kukui_scp -j Change-Id: I8c308ffb6d7c8f5bd378524bdffc980d7b9948fa Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1683028 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* build: add centroiding C++ supportRong Chang2019-01-241-0/+3
| | | | | | | | | | | | | | | | Centroiding source is in C++. This CL removes -W flags only for building C files from CFLAGS and also prevents typedef existing C++ keyword wchar_t. BUG=b:120961468 BRANCH=none TEST=make buildall Change-Id: Ifb8793a8e7e69b26a742b7dbf70289747a0ee7b3 Signed-off-by: Rong Chang <rongchang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1372874 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Tai-Hsu Lin <sheckylin@chromium.org>
* cr50: Add extern "C" to headers used by future fuzzing target.Allen Webb2018-11-153-0/+23
| | | | | | | | | | | BRANCH=None BUG=None TEST=make -j buildall Change-Id: Icf2cfb6a2657064c10721c0e527d24fbb3be6ab3 Signed-off-by: Allen Webb <allenwebb@google.com> Reviewed-on: https://chromium-review.googlesource.com/1330102 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* fuzz: Hide conflicts with cstdlib and use clang++ for linking.Allen Webb2018-09-071-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | This creates a build target called libec.a by setting the visibility of functions that conflict with cstdlib to hidden. It then links those symbols locally into one large object file that makes up libec.a Fuzzing targets are linked against libec.a so that they can invoke ec functionality while depending on outside libraries that need cstdlib. When linking a particular object against cstdlib, to avoid conflicting function declarations put the following before any includes from the ec codebase: #define __stdlib_compat(...) The fuzzing targets are now linked using clang++, so that c++ libraries and objects can be used as part of the fuzzers. BRANCH=none BUG=chromium:876582 TEST=make -j buildfuzztests && ./build/host/host_command_fuzz/host_command_fuzz.exe Change-Id: Ifdfdc6a51c6ef23b4e192b013ca993bf48a4411b Signed-off-by: Allen Webb <allenwebb@google.com> Reviewed-on: https://chromium-review.googlesource.com/1180401 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* assert/panic: mark noreturn to inform the compilerPatrick Georgi2018-07-121-2/+4
| | | | | | | | | | | | | BUG=b:65441143 BRANCH=none TEST=buildall with gcc8.1 stops failing on this family of functions Change-Id: I44f9d643e46f955ea0cd0b5893c2806a4e3f52b0 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://chromium-review.googlesource.com/1126315 Commit-Ready: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
* Add uint_(least|fast)*_t typesJeff Andersen2017-08-071-1/+22
| | | | | | | | | | | | | | | | This commit adds typedefs for signed and unsigned variants of the _fast and _least integer types. BUG=None BRANCH=None TEST=make buildall -J Change-Id: Idefc8f9529d22f17af57859be3c25c36a7f8ec25 Reviewed-on: https://chromium-review.googlesource.com/602870 Commit-Ready: Jeff Andersen <jeffandersen@google.com> Tested-by: Jeff Andersen <jeffandersen@google.com> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* Add #defines for UINT62_MAX and INT64_MAX.Jeff Andersen2017-04-251-0/+7
| | | | | | | | | | | | | | | | | Some files being included in firmware expect <stdint.h> to provide these definitions. BUG=none BRANCH=none TEST=make buildall Change-Id: I7313f05d9925a8fdfc4d1d0e8eea6ebcf999802e Reviewed-on: https://chromium-review.googlesource.com/484119 Commit-Ready: Jeff Andersen <jeffandersen@google.com> Tested-by: Carl Hamilton <carlh@chromium.org> Tested-by: Jeff Andersen <jeffandersen@google.com> Reviewed-by: Carl Hamilton <carlh@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* curve25519: strip-down, build and testVincent Palatin2017-02-231-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | Keep only the most compact version of the curve25519 code and remove the remaining unused code for easier compilation. Do the minimal changes to make it compile in the EC code base, there should be no real functional changes. Re-use the wording from BoringSSL include/openssl/curve25519.h for the header. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:62991 TEST=run x25519 on host (ie 'make run-x25519') and the STM32L4 target: make BOARD=eve_fp PROJECT=x25519 TEST_BUILD=y ./util/flash_ec --board=eve_fp --image=build/eve_fp/x25519.bin execute 'runtest' in the console. Change-Id: I13dbe453eff39b461effb1b3ffa549afc1749fef Reviewed-on: https://chromium-review.googlesource.com/444187 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Adam Langley <agl@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* builtin: Expands string.h / stdint.hNadim Taha2017-02-172-0/+12
| | | | | | | | | | | | | | Declares UINT8_MAX, INT8_MAX and defines strnlen(), strncpy(), strncmp() & memchr(). Needed by a module I'm integrating into cr51. BRANCH=none BUG=none TEST=make buildall -j Change-Id: I894b0297216df1b945b36fc77cd3bc5c4ef8aa2b Signed-off-by: Nadim Taha <ntaha@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/436786 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Adding offsetof macro to stddef.h.Johnnie Chan2016-10-261-0/+9
| | | | | | | | | | | | | | | | | This duplicates the macro definition that exists in compile_time_macros.h. Adding it is okay since they are both guarded by a #ifndef #endif check. This is needed by code being pulled in from google3 which expects the macro to be defined in the standard place. BUG=none BRANCH=none TEST=make BOARD=haven_dev Change-Id: Ibddefcd8bbfe0d121b3ce65950ce979e65778761 Reviewed-on: https://chromium-review.googlesource.com/403573 Commit-Ready: Johnnie Chan <johnniec@google.com> Tested-by: Johnnie Chan <johnniec@google.com> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Added "stdbool.h" and definition of uint_least8_t to "stdint.h".Carl Hamilton2016-10-172-0/+15
| | | | | | | | | | | | | | | | | | | The two types added, bool and uint_least8_t, are needed by the nanopb common header file "pb.h". The file added and the file modified are EC versions of files that are normally provided by the compiler. This change follows the approach already take to provide our own, mimimalist versions of these files. BUG=none BRANCH=none TEST=make buildall -j Change-Id: I892e25b14f7cbe3ecca6f60d6a2955d4d628e3a9 Reviewed-on: https://chromium-review.googlesource.com/398921 Commit-Ready: Carl Hamilton <carlh@chromium.org> Tested-by: Carl Hamilton <carlh@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* CR50: remove dependence of assert.h on util.hnagendra modadugu2016-05-251-1/+33
| | | | | | | | | | | | | | | | | | | | | Third party code includes standard system headers, but may not have include paths configured for the platform. Remove the dependency between assert.h and platform headers util.h, and panic.h. BRANCH=none BUG=chrome-os-partner:43025,chrome-os-partner:47524 TEST=make buildall succeeds Change-Id: Ic8d4dc1944765d2f0f80782afa574d7b8e54eb0f Signed-off-by: nagendra modadugu <ngm@google.com> Reviewed-on: https://chromium-review.googlesource.com/347080 Commit-Ready: Nagendra Modadugu <ngm@google.com> Tested-by: Nagendra Modadugu <ngm@google.com> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* Move include/byteorder.h -> builtin/endian.hnagendra modadugu2016-04-221-0/+38
| | | | | | | | | | | | | | | | Move endian routines to builtin/ so that portable third_party code may build without glibc. BRANCH=none BUG=chrome-os-partner:43025,chrome-os-partner:47524 TEST=none Change-Id: Icb900d1e9c56dc68ec1ef4b536ebc9dcf6ebcd69 Signed-off-by: nagendra modadugu <ngm@google.com> Reviewed-on: https://chromium-review.googlesource.com/340432 Commit-Ready: Nagendra Modadugu <ngm@google.com> Tested-by: Nagendra Modadugu <ngm@google.com> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* Add the memmove() function prototype to builtin/string.hnagendra modadugu2016-04-221-0/+1
| | | | | | | | | | | | | | | | | Add memmove() to builtin/string.h so that portable third_party code may build without glibc. BRANCH=none BUG=chrome-os-partner:43025,chrome-os-partner:47524 TEST=none Change-Id: I8c165d71d9c01d2f869329b3600aac0970f41e71 Signed-off-by: nagendra modadugu <ngm@google.com> Reviewed-on: https://chromium-review.googlesource.com/340293 Commit-Ready: Nagendra Modadugu <ngm@google.com> Tested-by: Nagendra Modadugu <ngm@google.com> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Stefan Reinauer <reinauer@google.com>
* Add the memcmp() function prototype to builtin/string.hnagendra modadugu2016-04-211-0/+1
| | | | | | | | | | | | | | | | | Add memcmp() to builtin/string.h so that portable third_party code may build without glibc. BRANCH=none BUG=chrome-os-partner:43025,chrome-os-partner:47524 TEST=none Signed-off-by: nagendra modadugu <ngm@google.com> Change-Id: Id52c9c76fceac94bf1998958b43f42ad5d5298d3 Reviewed-on: https://chromium-review.googlesource.com/339878 Commit-Ready: Nagendra Modadugu <ngm@google.com> Tested-by: Nagendra Modadugu <ngm@google.com> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Bill Richardson <wfrichar@google.com>
* Enforce compilation without system headersStefan Reinauer2016-02-036-0/+133
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>