summaryrefslogtreecommitdiff
path: root/core/riscv-rv32i/task.c
Commit message (Collapse)AuthorAgeFilesLines
* tasks: Only report stack overflow if task is enabledRob Barnes2023-05-151-3/+5
| | | | | | | | | | | | | | | | | Don't report stack overflow on a task that has been disabled. Without this change, system safe mode will fail to recover from a stackoverflow because the stackoverflow will be detected again, even though the task has already been disabled. BUG=b:278792557 TEST=System safe mode starts on boten after a stackoverflow Change-Id: I59ab579c296d108dcd8c5aba9cb32bba6c7bbf54 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4455298 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Boris Mittelberg <bmbm@google.com>
* tasks: Add task_enabled functionRob Barnes2023-04-241-0/+5
| | | | | | | | | | | | | Add task_enabled function that simply check if a task is enabled or not. BUG=b:278792557 BRANCH=None TEST=Manually tested Change-Id: I0faccec603bc6d0226ad2ecbde2d90a6c233dd74 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4455297 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* tree: Replace "unsigned" with "unsigned int"Andrea Grandi2023-01-041-1/+1
| | | | | | | | | | | | | | | | | Fix checkpatch error: > Prefer 'unsigned int' to bare use of 'unsigned' BUG=b:262047616 TEST=./util/compare_build.sh -b all -j 120 => MATCH BRANCH=none Change-Id: Ibf82332a1e1ea0a0a03d3993336e24883e495e05 Signed-off-by: Andrea Grandi <agrandi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4126483 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* tree: Remove CONFIG_SOFTWARE_PANICTom Hughes2022-10-121-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | It's always enabled in the core/<core>/core_config.h files. The following script demonstrates that it's enabled in all boards: for board in `make print-boards`; do make print-configs board="${board}" | grep -q CONFIG_SOFTWARE_PANIC if [ $? -ne 0 ]; then echo "${board} failed" exit 1 fi done BRANCH=none BUG=none TEST=make buildall Cq-Depend: chromium:3943248 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: If683b244f17b48bedf3699f2b24e83b5ad6e849e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3933255 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* Update license boilerplate text in source code filesMike Frysinger2022-09-121-1/+1
| | | | | | | | | | | | | | | 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>
* tree-wide: const-ify argv for console commandsCaveh Jalali2022-09-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | This updates the API for console commands from "int cmd(int argc, char **argv)" to "int cmd(int argc, const char **argv)" which is more accurate and in line with common convention. BRANCH=none BUG=b:244387210 TEST="make buildall" passes TEST="zmake build -a" passes TEST="util/compare_build.sh -b all" passes TEST="./twister -v -T zephyr/test" passes Cq-Depend: chrome-internal:4960125 Cq-Depend: chrome-internal:4959932 Change-Id: I57de9f35b85b8f3c7119df36aefb2abf25d2625f Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3863941 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* util: remove unused includesYuval Peress2022-08-051-0/+2
| | | | | | | | | | | | | | | | Remove these includes as they're not needed in this header. Instead, the includes should go where they're actually being used. BRANCH=none BUG=b:240574048 TEST=make buildall -j TEST=zmake build -a Signed-off-by: Yuval Peress <peress@google.com> Change-Id: I64b10af3216654b2a20caa1cabd267661a0bca39 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3791980 Reviewed-by: Tristan Honscheid <honscheid@google.com> Commit-Queue: Tristan Honscheid <honscheid@google.com>
* core/riscv-rv32i/task.c: Format with clang-formatJack Rosenthal2022-07-011-59/+48
| | | | | | | | | | | BUG=b:236386294 BRANCH=none TEST=none Change-Id: I509b44ee511e472d3952d0a5b31c838a57f9908b Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729738 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* task: change task_set_event return type to voidFabio Baltieri2022-06-021-3/+1
| | | | | | | | | | | | | | | No implementation does nothing other than return 0 on task_set_event(), change the return type to void so that the API is clear. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I88b20f53aa6dffa291ce78f4776888b21985f57f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3683769 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* atomic: fix printing atomic_t typeDawid Niedzwiecki2022-01-061-4/+4
| | | | | | | | | | | | | | | | | | | After changing the atomic_t type from long to int the print format was changed to %l, but the CrosEC print function doesn't support the 'l' format if long is 4 bytes wide. Cast the atomic_t to int and print it as a normal int variable. BUG=b:207082842 TEST=make buildall && zmake testall && make sure the 'taskinfo' work BRANCH=main Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I8643d8b843720e3583a29d83fc143d8e103e79c4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3359425 Tested-by: Patryk Duda <pdk@semihalf.com> Reviewed-by: Patryk Duda <patrykd@google.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Commit-Queue: Patryk Duda <patrykd@google.com>
* atomic: change atomic_t to longDawid Niedzwiecki2021-12-171-4/+4
| | | | | | | | | | | | | | | | | | | | | Change the atomic_t type from int to long. For all chips used for EC, this change shouldn't impact the generated code, except for the string needed fot the print function. For the host build keep int, because EC codebase assumes that the atomic_t type is 4-byte wide. The change caused by a change in Zephyr upstream (atomic_t from int to long). BUG=b:207082842 Cq-Depend: chromium:3330355 TEST=make buildall && zmake testall BRANCH=main Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: Id4b6f8b60e73bdef741a530e3ed614b67b48720f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3330201 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Commit-Queue: Dawid Niedzwiecki <dawidn@google.com>
* task: use atomic_t for some variablesDawid Niedzwiecki2021-12-071-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Use the atomic_t variable type for tasks_ready, tasks_enabled and waiters in struct mutex. The generated asm code is different around the line: char is_ready = ((uint32_t)tasks_ready & BIT(i)) ? 'R' : ' '; for all cores, so cast tasks_ready to an unsigned variable to make sure is works as intended regardless of architecture. The change will be useful for incoming commits related to modifying atomic_t caused by a change in Zephyr upstream (atomic_t from int to long). BUG=b:207082842 TEST=make buildall && zmake testall BRANCH=main Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I0a55c71947401e4137b30fc62adba84d867f56f8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3301710 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Dawid Niedzwiecki <dawidn@google.com>
* task: change task events bitmask to atomic_tDawid Niedzwiecki2021-11-291-2/+2
| | | | | | | | | | | | | | | | | | | | The events bitmask is used only with atomic_* functions or for reading, so change to variable type to atomic_t. It shouldn't change the generated code. It will be useful for incoming commits related to modifying atomic_t caused by a change in Zephyr upstream (atomic_t from int to long). BUG=b:207082842 TEST=make buildall && zmake testall && build_compare.sh -b all BRANCH=main Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: Ia0ff4a20f9ed6c3728b1bd8b6cab3b32ebfcc36b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3300321 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* task: Use bool for truthy return typesTom Hughes2021-11-091-4/+4
| | | | | | | | | | | | | | | | Using bool makes it clear that the function returns "true" or "false", rather than any integer. It also avoids the need to use "!!" to set the value to 0 or 1, since the compiler ensures that "bool" is always a 0 or 1, even if another value is assigned. BRANCH=none BUG=b:172020503 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I164e5c03c23fa2f0ffb61e87f5613e080814ce10 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262593 Reviewed-by: Keith Short <keithshort@chromium.org>
* tree: Make all console commands staticTom Hughes2021-10-151-1/+1
| | | | | | | | | | | | | | Almost all of the console commands were already static. This change makes all of them static for consistency. BRANCH=none BUG=b:172020503 TEST=make buildall -j Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I0ac46358b6fbafa65504c648ce4de0365cdbf723 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3224372 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* Provide 'is_interrupt_enabled' function for all coresPatryk Duda2021-09-061-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a function that will provide information if interrupts are enabled. This information will be used to fix shortcomings in common code for UART buffering and usleep(). BUG=b:190597666 BRANCH=none TEST=make -j buildall TEST=make runhosttests TEST=Note for running tests: this patch only adds function implementation so, to test this it is necessary to add some code which uses the function eg. console command which prints information if interrupt is enabled. Minute-ia core: It is necessary to compile firmware for ISH (Intel Sensor Hub) which is available on drallion board (eg. chromeos6-row1-rack9-host19). Firmware must be placed in /lib/firmware/intel/drallion_ish.bin (partition must be writeable, if not use /usr/share/vboot/bin/make_dev_ssd.sh on DUT tu unlock it, don't forget about reboot). After copying firmware to /lib/firmware/intel/ it is necessary to reboot DUT. After reboot use `ectool --name=cros_ish version` to check if correct version is running. NDS32 core. This core is used in it8320dx chip which is present in ampton (octopus family). EC can be compiled using 'make BOARD=ampton' and flashed using 'chromeos-firmwareupdate -e ec.bin', but EC software sync needs to be disabled using 'set_gbb_flags.sh 0x200' Riscv-rv32i core, hayato (asurada family) uses it81202 as EC which is based on risc-v. EC can be compiled using 'make BOARD=hayato' and flashed using 'chromeos-firmwareupdate -e ec.bin', but EC software sync needs to be disabled using 'set_gbb_flags.sh 0x200' Cortex-M, this is the most common core. Just compile EC for platform which contains Cortex-M core (eg. bloonchipper) and test if it works. Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I502553cd57e6ce897d5845a3aad01a44a9058405 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2953227 Commit-Queue: Marcin Wojtas <mwojtas@google.com> Tested-by: Patryk Duda <patrykd@google.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* riscv-rv32i/task: Remove the remove_me functionDino Li2021-04-081-12/+0
| | | | | | | | | | | | | BUG=none BRANCH=none TEST=buildall. Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Change-Id: I2cd176556f2294de304eca3d2e3d29f68cff85dc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2531769 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* core/riscv-rv32i: set in_interrupt at beginning of exception handlerTzung-Bi Shih2021-02-191-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are 3 paths when receiving an excaption in core/riscv-rv32i/init.S: 1. __irq_handler 2. excep_handler 3. unhandled_interrupt Originally, in_interrupt_context() returns true only if it goes to 1st path. However, the rest paths are also in interrupt context, especially some function may rely on in_interrupt_context(), for example, uart_flush_output() in common/uart_buffering.c. Note that, only the 1st goes back to normal context. The rest of paths are all going to panic and reset. Sets in_interrupt at the beginning of exception handler instead of start_irq_handler() so that the flag is ON when receiving an exception. BRANCH=none BUG=b:180571536 BUG=b:163300760 TEST=make BOARD=asurada_scp Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org> Change-Id: Iba689c506c02c4b5bb1668766f1d7ab5f86f72a4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2702999 Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
* riscv-rv32i: store EC interrupt number in panic infoDino Li2021-02-041-19/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change stores EC INT number in panic info (TP register) if the number isn't valid. For CPU interrupt and exception code, we can check mcause register in panic info. BUG=b:179206540 BRANCH=none TEST=fire an invalid EC INT (eg, number 188) and checking panic info to see if the number is stored in TP: === EXCEPTION: MCAUSE=8000000b === S11 00000000 S10 00000000 S9 00000000 S8 00000000 S7 00000000 S6 00000000 S5 ffe17b7f S4 fff0bdc0 S3 0000fffe S2 00000000 S1 00000000 S0 00000000 T6 00000000 T5 00000000 T4 00000058 T3 00000009 T2 00000000 T1 00000010 T0 00000800 A7 00000000 A6 00000001 A5 80026860 A4 ffffffff A3 00000008 A2 80109be8 A1 00000000 A0 0000f304 TP bad000bc GP 80103930 RA 80000f2c SP 80106bb8 MEPC 80000dee Exception type: Environment call from M-mode Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Change-Id: If4ead38266d1c5b3453d5dd5e5f65de5af793f57 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2638998 Commit-Queue: Eric Yilun Lin <yllin@chromium.org> Reviewed-by: Tzung-Bi Shih <tzungbi@chromium.org> Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
* core/riscv-rv32i: correct inline assembly constraint modifierTzung-Bi Shih2021-01-141-1/+1
| | | | | | | | | | | | | | | | | | | To make compiler translate the inline assembly well, use '&' modifier to tell compiler that the `locked' variable is written before the instruction is finished using the input operands[1]. [1]: https://gcc.gnu.org/onlinedocs/gcc/Modifiers.html#Modifiers BRANCH=none BUG=b:176959740 BUG=b:177287581 TEST=make BOARD=asurada_scp Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org> Change-Id: I3f6e5741afeaf98bf8f8e736c6d8db58daac6a17 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2623869 Reviewed-by: Dino Li <Dino.Li@ite.com.tw> Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
* task_set_event: remove the wait argumentDawid Niedzwiecki2020-12-141-6/+15
| | | | | | | | | | | | | | | | | | | | There is an option in the task_set_event function which force the calling task to wait for an event. However, the option is never used thus remove it. This also will help in the Zephyr migration process. BUG=b:172360521 BRANCH=none TEST=make buildall Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: Ic152fd3d6862d487bcc0024c48d136556c0b81bc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2521599 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
* atomic: rename atomic_read_clear to atomic_clearDawid Niedzwiecki2020-11-021-1/+1
| | | | | | | | | | | | | | | | | Rename atomic_read_clear to atomic_clear to be consistent with the rest of the atomic functions, which return the previous value of the variable. BUG=b:169151160 BRANCH=none TEST=buildall Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I2588971bd7687879a28ec637cf5f6c3d27d393f4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2505143 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* tree: Use new atomic_* implementationDawid Niedzwiecki2020-10-271-11/+10
| | | | | | | | | | | | | | | | | | | | | | | It is done as a part of porting to Zephyr. Since the implementation of atomic functions is done for all architectures use atomic_* instead of deprecated_atomic_*. Sometimes there was a compilation error "discards 'volatile' qualifier" due to dropping "volatile" in the argument of the functions, thus some pointers casts need to be made. It shouldn't cause any issues, because we are sure about generated asm (store operation will be performed). BUG=b:169151160 BRANCH=none TEST=buildall Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I98f590c323c3af52035e62825e8acfa358e0805a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2478949 Tested-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* core: rename atomic_clear to atomic_clear_bitsDawid Niedzwiecki2020-10-061-4/+4
| | | | | | | | | | | | | | | | | | Change the name of atomic_clear to atomic_clear_bits to make to name more clear - the function clears only selected bits, but the name may suggest that it clears the whole variable. It is done as a part of porting to Zephyr, where atomic_clear zeros the variable. BUG=b:169151160 BRANCH=none TEST=buildall Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I7b0b47959c6c54af40f61bca8d9baebaa0375970 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2428943 Reviewed-by: Jett Rink <jettrink@chromium.org>
* tree: rename atomic_* functions to deprecated_atomic_*Jack Rosenthal2020-09-291-10/+11
| | | | | | | | | | | | | | | | We will move to an API compatible with Zephyr's API. See the bug for complete rationale and plan. BUG=b:169151160 BRANCH=none TEST=buildall Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Id611f663446abf00b24298a669f2ae47fef7f632 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427507 Tested-by: Dawid Niedźwiecki <dn@semihalf.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* it83xx: read_clear_int_mask() read and clear interrupt bit.Dino Li2020-09-241-8/+8
| | | | | | | | | | | | | | | | | | This change pulled the operation of interrupt disable into read_clear_int_mask(). Because riscv core supports instruction csrrc to atomic read and clear bit in CSR register. With this change, we won't need to separate operations of reading and clearing interrupt bit on riscv core. BUG=none BRANCH=none TEST=read_clear_int_mask() is able to disable interrupt and return saved interrupt bit on both nds32 and riscv cores. Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Change-Id: I871aab747b950b7948cdeb7911fcf8c09d55df5d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2419739 Reviewed-by: Jett Rink <jettrink@chromium.org>
* core: nds32/riscv-rv32i: fix issue of time in exceptions is negativeDino Li2020-07-241-7/+8
| | | | | | | | | | | | | | | | | | | | If 32-bit counter is overflowed in ISR, the high word of the system time (clksrc_high) can't be updated until return from interrupt. So we will get a negative delta time if the overflow occurs between getting start time and end time. This patch fixes the issue. BUG=b:161768286 BRANCH=none TEST=Making a overflow emulation to see what delta time we will get: s = __hw_clock_source_read() = 0xfffffff0; e = __hw_clock_source_read() = 123; e - s = 139; Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Change-Id: I91e6c4d83de3e074388c1a4fc926b05e791b7b47 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2311997 Reviewed-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* ec: change usage of "sane" per inclusive languagePaul Fagerburg2020-07-221-1/+1
| | | | | | | | | | | | | | | | Google is working to change its source code to use more inclusive language. To that end, replace the terms "sane", "sanity check", and similar with inclusive/non-stigmatizing alternatives. BUG=b:161832469 BRANCH=None TEST=`make buildall -j` succeeds. `grep -Eir "sane|sanity" .` shows results only in third-party code or documentation. Signed-off-by: Paul Fagerburg <pfagerburg@chromium.org> Change-Id: I29e78ab27f84f17b1ded75cfa10868fa4e5ae88c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2311169 Reviewed-by: Jett Rink <jettrink@chromium.org>
* riscv-rv32i: correct printf formatEric Yilun Lin2020-07-221-7/+7
| | | | | | | | | | | | | | unsigned integer should use '%u' rather than '%d' BUG=b:161768286 TEST=make BOARD=asurada BRANCH=none Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Change-Id: I84a5419ce813a4378657c4fbfeba967262faef3f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2310220 Reviewed-by: Tzung-Bi Shih <tzungbi@chromium.org> Commit-Queue: Tzung-Bi Shih <tzungbi@chromium.org>
* core/riscv-rv32i: set volatile for in_interruptTzung-Bi Shih2020-06-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | Given that: - in_interrupt is modified in interrupt context. - Some normal task context call in_interrupt_context() and in_soft_interrupt_context(). To safely share the variable, sets it to volatile. BRANCH=none BUG=b:146213943 BUG=b:157521370 BUG=b:156223049 TEST=1. make BOARD=asurada 2. flash_ec --board=asurada --image build/asurada/ec.bin 3. (EC console)> version Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org> Change-Id: Ibd1bf9556d8376f6f6389a17cc792a6f21227d4f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2237495 Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
* core/riscv-rv32i: add error handling for chip_get_ec_int()Tzung-Bi Shih2020-06-041-1/+10
| | | | | | | | | | | | | | | | | | chip_get_ec_int() returns -1 if it cannot find the corresponding interrupt source. BRANCH=none BUG=b:146213943 BUG=b:157521370 TEST=1. make BOARD=asurada 2. flash_ec --board=asurada --image build/asurada/ec.bin 3. (EC console)> version Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org> Change-Id: I5021ed80f50a99b15d9b9a90a9181077f63bd4be Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2227777 Reviewed-by: Dino Li <Dino.Li@ite.com.tw> Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
* core/riscv-rv32i: add in_soft_interrupt_context()Tzung-Bi Shih2020-06-031-0/+6
| | | | | | | | | | | | | | BRANCH=none BUG=b:146213943 BUG=b:156218912 TEST=1. make BOARD=asurada 2. flash_ec --board=asurada --image build/asurada/ec.bin 3. (EC console)> version Change-Id: If8df1fb768ea9c83f025d8bd17010481389d7aa1 Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2217596 Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
* core/riscv-rv32i: remove get_sw_int()Tzung-Bi Shih2020-05-291-9/+1
| | | | | | | | | | | | | | | | Inline the function definition. BRANCH=none BUG=b:146213943 BUG=b:157521370 TEST=1. make BOARD=asurada 2. flash_ec --board=asurada --image build/asurada/ec.bin 3. (EC console)> version Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org> Change-Id: Icfde6399b2dd560924128f9e7fbeb54efaa9c14c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2217595 Reviewed-by: Jett Rink <jettrink@chromium.org>
* core/riscv-rv32i: add default __idle()Tzung-Bi Shih2020-05-191-0/+4
| | | | | | | | | | | | | | | Adds default __idle() implementation. BRANCH=none BUG=b:151897847 TEST=1. make BOARD=asurada 2. flash_ec --board=asurada --image build/asurada/ec.bin 3. (EC console)> version Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org> Change-Id: Ie4711b568f8d1880eb933027c10fc43672871d23 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2178701 Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
* core/riscv-rv32i: clean up header inclusionsTzung-Bi Shih2020-05-191-4/+4
| | | | | | | | | | | | | | | | | | | | Removes unneeded header inclusions. Especially chip-specific ones: - hwtimer_chip.h - intc.h - registers.h Other rv32i-based boards do not need to provide the headers. BRANCH=none BUG=b:151897847 TEST=1. make BOARD=asurada 2. flash_ec --board=asurada --image build/asurada/ec.bin 3. (EC console)> version Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org> Change-Id: I6d158568fb6b626d96215bbd263b66cd8b7ebd57 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2178700 Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
* core/riscv-rv32i: do not expose get_sw_int()Tzung-Bi Shih2020-05-191-1/+1
| | | | | | | | | | | | | | | Do not expose get_sw_int(). BRANCH=none BUG=b:151897847 TEST=1. make BOARD=asurada 2. flash_ec --board=asurada --image build/asurada/ec.bin 3. (EC console)> version Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org> Change-Id: I9a5bbeec152780b54b4dd6ce07f2390633c64366 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2178699 Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
* core/riscv-rv32i: move interrupt details to IT83XX specificTzung-Bi Shih2020-05-191-9/+2
| | | | | | | | | | | | | | | | Getting source interrupt number is chip specific. Moves the details to chip implementation. BRANCH=none BUG=b:151897847 TEST=1. make BOARD=asurada 2. flash_ec --board=asurada --image build/asurada/ec.bin 3. (EC console)> version Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org> Change-Id: Ia72acf8ec9c09cb329f8d7c92d22476512ffa669 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2114951 Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
* Remove uses of %lEvan Green2019-10-051-4/+4
| | | | | | | | | | | | | | | | | | | | | | | This change removes uses of %l from the EC side of the EC codebase. This is done because the semantics of %l within printf have changed, and there are concerns that new calls to printf will be cherry-picked into old firmware branches without the printf changes. So, in preparation for disallowing %l in master, remove occurrences of %l. This change was done by manually fixing up anything found under the EC directory with the following regex: %[0-9*.-]*l[^l] Remember that anything on the host machine is fine as-is, since the host printf never changed. BUG=chromium:984041 TEST=make -j buildall BRANCH=None Change-Id: I2a97433ddab5bfb8a6031ca4ff1d3905289444e2 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1834603 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* core/riscv-rv32i: misc fixesDino Li2019-10-021-30/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. The end of text section is 4-byte aligned. We found that rodata section will be shifted 2 bytes in binary file if compressed instruction (16-bit instruction) is enabled. So we fix it. 2. Ensure the scratchpad is behind system stack. So the guard value in scratchpad that we filled in at task initialization would not get overwrite on first context switch (Because we will change to use system stack in ISR if SP is greater than the end of system stack). 3. Put some task functions into __ram_code section to fill up the gap. BUG=none BRANCH=none TEST=This change saves 1408 bytes space at RO image and improves ~10ms boot time. Before the change: 173516 bytes in flash still available on it83xx_evb RO > [0.028248 low power idle task started] After the change: 174924 bytes in flash still available on it83xx_evb RO > [0.018774 low power idle task started] Change-Id: I32506383aa63424f12794fb543c51b0485bace8f Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1831931 Reviewed-by: Jett Rink <jettrink@chromium.org>
* task: Add task_enable_task() and task_disable_task()Yilun Lin2019-08-221-0/+13
| | | | | | | | | | | | | | | Provide API to disable/enable tasks. All the tasks are marked enabled after hook_task starts. We need a way to control the tasks when it shouldn't run in some states. BUG=b:136240895 TEST=Disable the tasks and see it won't be scheudled when task_wake(). BRANCH=None Change-Id: I2662f3619b22ed28387fe3c783001ba2a745620c Signed-off-by: Yilun Lin <yllin@google.com> Signed-off-by: Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1753562
* core:RISC-V / chip:IT83202Dino Li2019-06-111-0/+716
The IT83202 is an embedded controller with RISC-V core. It supports maximum ram size to 256KB and internal flash to 1MB. BUG=none BRANCH=none TEST=EC boots and test console commands (eg: taskinfo, version, sysjump...) on it83202 EVB. Change-Id: I424c0d2878beb941c816363b5c7a3f57fda9fd13 Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1588300 Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>