summaryrefslogtreecommitdiff
path: root/builtin
Commit message (Collapse)AuthorAgeFilesLines
* Update license boilerplate text in source code filesMike Frysinger2022-09-1219-19/+19
| | | | | | | | | | | | | | | Normally we don't do this, but enough changes have accumulated that we're doing a tree-wide one-off update of the name & style. BRANCH=none BUG=chromium:1098010 TEST=`repo upload` works Change-Id: Icd3a1723c20595356af83d190b2c6a9078b3013b Signed-off-by: Mike Frysinger <vapier@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3891203 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* test: Add basic tests exercising the panic output APIYuval Peress2022-08-311-3/+5
| | | | | | | | | | | | | | | | | Exercise some of the panic output API. Some of the basic printing API cannot yet be fully tested. But a fix upstream is coming to allow us to use the 'console' harness features to parse the output log and pass/fail the test based on output. BRANCH=none BUG=none TEST=twister -s zephyr/test/drivers/drivers.default Signed-off-by: Yuval Peress <peress@google.com> Change-Id: I8e56e8bcdaa0e095891c38a26e56ced8f3a8d4d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3855593 Reviewed-by: Simon Glass <sjg@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* tree: Move printf declarations to stdio.hTom Hughes2022-07-192-0/+129
| | | | | | | | | | | | | | | | | The "builtin" directory is EC's copy of the C standard library headers. Move the declarations for printf functions that are provided by the standard library to the "builtin" directory. This change makes it easier for future changes to optionally build with the C standard library instead of the standalone EC subset. BRANCH=none BUG=b:172020503, b:234181908, b:237823627 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I4a5b4f8b98b972e86c4cca65d4910b5aa07ec524 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3712034 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* builtin: Move ssize_t to sys/types.hTom Hughes2022-07-192-6/+7
| | | | | | | | | | | | | | | | | According to POSIX ssize_t should be defined in sys/types.h, not stddef.h: https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/basedefs/sys_types.h.html BRANCH=none BUG=b:234181908 TEST=./util/compare_build.sh -b all => MATCH Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I027a2b26dc183c506d691d483c86644d04db9282 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3765450 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* common: Conditionally support printf %l and %i modifiersBobby Casey2022-07-071-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The libfp library prints some values with PRIx32 or PRId32 format specifiers which, in their compilation environment, output "%lx" and "%ld". Unfortunately, support for printing any '%l' format in EC code was deprecated in issuetracker.google.com/issues/172210614 after changing it from it being treated as a hard-coded 64-bit length. There was concern that new code using %l with 32-bit values would be cherry-picked to older branches without the updated printf. In these cases, the older code would interpret that %l as 64-bit argument, causing it to over-ingest arguments and potentially behave in an undefined manner. Printing 32-bit values with "%l" or "%i" is safe as long as we can guarantee no legacy code will attempt to print using "%l" with a 64-bit value. The logic here is protected by a config flag that is only enabled for FPMCU and FPMCU doesn't use long running release branches. A printf test is also added to ensure that only dartmonkey and bloonchipper boards have long32 enabled. BRANCH=none BUG=b:234781655 BUG=b:234143158 TEST=./test/run_device_tests.py -b dartmonkey -t printf TEST=./test/run_device_tests.py -b bloonchipper -t printf TEST=make runhosttests Signed-off-by: Bobby Casey <bobbycasey@google.com> Change-Id: If432f507a31cc12a4c5c4bdcd07c6141407bd70d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3707743 Reviewed-by: Andrea Grandi <agrandi@google.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* util: Move stdlib declarations to builtin directoryTom Hughes2022-07-075-5/+70
| | | | | | | | | | | | | | | | | | The "builtin" directory is EC's copy of the C standard library headers. Move the declarations for functions that are provided by the standard library to the "builtin" directory. This change makes it easier for future changes to optionally build with the C standard library instead of the standalone EC subset. BRANCH=none BUG=b:172020503, b:234181908 TEST=./util/compare_build.sh -b all -j 120 => MATCH Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I4822e49677e0c0e1b092711b533f2aaa762cb4e3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3712033 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* tree: Move stdlib implementation to builtin directoryTom Hughes2022-07-072-0/+393
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Keeping all of the standard library implementation in a single directory makes it easier to choose between EC's implementation or the implementation from the toolchain. BRANCH=none BUG=b:234181908, b:172020503 TEST=make buildall -j TEST=Using icetower v0.1, Segger J-Trace, and servo micro: ./test/run_device_tests.py -b dartmonkey Test "aes": PASSED Test "cec": PASSED Test "cortexm_fpu": PASSED Test "crc": PASSED Test "flash_physical": PASSED Test "flash_write_protect": PASSED Test "fpsensor_hw": PASSED Test "fpsensor_spi_ro": PASSED Test "fpsensor_spi_rw": PASSED Test "fpsensor_uart_ro": PASSED Test "fpsensor_uart_rw": PASSED Test "mpu_ro": PASSED Test "mpu_rw": PASSED Test "mutex": PASSED Test "pingpong": PASSED Test "printf": PASSED Test "queue": PASSED Test "rollback_region0": PASSED Test "rollback_region1": PASSED Test "rollback_entropy": PASSED Test "rtc": PASSED Test "sha256": PASSED Test "sha256_unrolled": PASSED Test "static_if": PASSED Test "system_is_locked_wp_on": PASSED Test "system_is_locked_wp_off": PASSED Test "timer_dos": PASSED Test "utils": PASSED Test "utils_str": PASSED Test "panic_data_dartmonkey_v2.0.2887": PASSED Test "panic_data_nocturne_fp_v2.2.64": PASSED Test "panic_data_nami_fp_v2.2.144": PASSED Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I75f8591e87a9076d47208eb598186a391c77966d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3724488 Reviewed-by: Edward Hill <ecgh@chromium.org>
* builtin/stdint.h: Format with clang-formatJack Rosenthal2022-07-011-30/+30
| | | | | | | | | | | BUG=b:236386294 BRANCH=none TEST=none Change-Id: Ia466cfd84e1886e3cce6401b7656b00e4be91d0c Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729126 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* builtin/stddef.h: Format with clang-formatJack Rosenthal2022-07-011-1/+1
| | | | | | | | | | | BUG=b:236386294 BRANCH=none TEST=none Change-Id: I8d3fd22aa1b5feee8beffa23f2df46f2e02856a9 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729125 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* builtin/stdarg.h: Format with clang-formatJack Rosenthal2022-07-011-4/+4
| | | | | | | | | | | BUG=b:236386294 BRANCH=none TEST=none Change-Id: I7884b63a2dac266c8aff5a52d1f67f4162bb102e Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729124 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* builtin/endian.h: Format with clang-formatJack Rosenthal2022-06-281-3/+3
| | | | | | | | | | | BUG=b:236386294 BRANCH=none TEST=none Change-Id: I694fb45a5eebb5049d0c7709d84615d1627e0bf0 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729144 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* builtin/stdnoreturn.h: Format with clang-formatJack Rosenthal2022-06-281-1/+2
| | | | | | | | | | | BUG=b:236386294 BRANCH=none TEST=none Change-Id: Id4fc89c0e89c67a5dfd49a218fa583ba10a16da3 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729146 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* builtin/stdbool.h: Format with clang-formatJack Rosenthal2022-06-281-3/+3
| | | | | | | | | | | BUG=b:236386294 BRANCH=none TEST=none Change-Id: Ic40cf953745bb9064bf2f0b9b49374aab60462e9 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729145 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* timer.h: Avoid redefining clock_t when compiling with libcTom Hughes2022-06-091-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | Move the clock_t typedef to the "builtin" directory, which the directory containing headers that mirror those in the C standard library. The "builtin" directory can then be excluded when building with the standard library. include/timer.h:31:14: error: typedef redefinition with different types ('long' vs 'unsigned long') typedef long clock_t; ^ /usr/armv7m-cros-eabi/include/sys/types.h:107:19: note: previous definition is here typedef _CLOCK_T_ clock_t; ^ BRANCH=none BUG=b:234181908 TEST=./util/compare_build.sh -b all -j 120 => MATCH Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ib2381664535781035b367b414c5f00639ce9b9af Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3691958 Reviewed-by: Edward Hill <ecgh@chromium.org>
* assert.h: Remove unnecessary externTom Hughes2022-06-091-3/+3
| | | | | | | | | | | | | | | | | | | | Functions in C are extern by default; it's not necessary in a header file. The extern combined with noreturn causes a compiler error when building with C++: ./builtin/assert.h:33:8: error: an attribute list cannot appear here extern noreturn void panic_assert_fail(const char *msg, const char *func, ^~~~~~~~ BRANCH=none BUG=b:234181908 TEST=./util/compare_build.sh -b all -j 120 => MATCH Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I7a2a86e57569bc90bb1ab93d5703217eabc042a4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3691957 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* math: Introduce isnan and isinf functionsPatryk Duda2022-02-011-0/+11
| | | | | | | | | | | | | | | | | | | | This patch adds functions responsible for checking if floating point operation result is NaN or infinity. Minute-ia specific functions were removed, because generic version should be used. To test added functions, 'fp' unit test was extended. BUG=b:215606535 BRANCH=none TEST=make buildall TEST=make runhosttests Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I68f46e91491b4a221beccde4275fd27a5424a048 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3423529 Reviewed-by: Bobby Casey <bobbycasey@google.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* TCPMv2: Support 64 timersAbe Levkoy2021-10-261-0/+2
| | | | | | | | | | | | | | | | | Use arrays of 32-bit fields to store PD timer status for each port. Provide a mechanism to perform atomic operations on the appropriate fields for each timer. BUG=b:141363146 TEST=make run-usb_pe_drp BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I23bb4aa9df569cec7088f5b9e451e86372eaabb7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3171334 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* 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>