Commit Graph

19 Commits

Author SHA1 Message Date
Randall Spangler
fe660aa372 Standardize concatenation macros
To create a token by concatenating already-defined macros and new
text, it's necessary to use multiple levels of macro.  We'd already
done that in several places in the code such as STM32_CAT; this now
standardizes it into a single place.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=Build all platforms; examine ec.RO.map to see that irq_*_handler and prio_* symbols
     evaluated the same as before.  (Other macro evaluations would simply fail to compile
     if they were incorrect, since the concatenated tokens wouldn't fully expand.)

Change-Id: Ic9bf11d27881a84507fe7b6096dab6217c6c6dc7
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63231
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-07-24 14:05:17 -07:00
Randall Spangler
e3c5f77924 link: Fix overflow in hibernate time calculation
The time out value passed to task_wait_event() is signed 32-bit and
thus waiting for 24 hours will cause overflow.  Limit max wait time.

BUG=chrome-os-partner:15797
BRANCH=link

TEST=Disconnect AC, shut down system, and close lid.  From ec console,
do 'hibdelay 8000' and then wait 2.5 hours.  EC should have
hibernated.  (8000 is more than twice the max time for
task_wait_event())

Change-Id: I5fa505554182e8bad6399c12a382ff71bb123d8f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/37095
Reviewed-by: Vic Yang <victoryang@chromium.org>
2012-11-01 10:08:54 -07:00
Randall Spangler
67aadcf614 Clean up core routines - cpu, task, watchdog
No functional changes.

BUG=chrome-os-partner:15579
BRANCH=none
TEST=boot system

Change-Id: I55cf9c60e92177fd441614a8f9fce2d3acca3d0e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36706
2012-10-29 12:02:41 -07:00
Bill Richardson
ef71b1a3e5 Prevent I2C interrupts from consuming pending task events
This manifested as the lightbar task missing transitions between CPU states.
The underlying cause was that when a task talks over the I2C bus, the I2C
communication was using the task scheduler to wait for an interrupt to
signal completed I2C traffic without blocking the other threads, but while
doing so it was not preserving pending events. This CL seems to fix it.

BUG=chrome-os-partner:12431
BRANCH=all
TEST=manual

The original bug is tricky to reproduce without adding some delay to the I2C
task code, but you can do it. Boot the CPU, then from the EC console
repeatedly alternate these two commands:

  lightbar seq s0
  lightbar seq s3

You should see the lightbar pattern turn off and on, but occasionally you'll
type the command and the EC won't change the pattern.

With this change applied, it should *always* work.

Change-Id: Ie6819a4a36162a8760455c71c41ab8a468656af1
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/33805
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-09-21 16:48:54 -07:00
Randall Spangler
d66ef1213d Track current task directly instead of computing from stack pointer
This is a precursor to supporting task-specific task sizes.  I've
benchmarked this vs. the current stack pointer method; no measurable
performance difference.

BUG=chrome-os-partner:13814
TEST=boot EC; taskinfo; if it boots and doesn't print garbage, it worked
BRANCH=all

Change-Id: Ia326c3ab499ac03cce78dbacaa52f735601a171e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/32603
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-09-09 10:33:49 -07:00
Randall Spangler
ef46903dea usleep() chains to udelay() if called before task_start()
...so I can use usleep() for eeprom delays in the CL coming next...

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:10200
TEST=if it boots, it worked

Change-Id: I564578f24452a4ac39abe79ff28cfff4b665ad2f
2012-05-29 09:38:58 -07:00
Randall Spangler
1aa57e140e Watchdog fixes
1) When frequency changes, reload the watchdog timer right away, or it
may expire before the next reload.  (Only matters when re-enabling the
PLL.)

2) Split out the timer/task debug output used by the watchdog into
their own routines, instead of assuming it's safe to call the command
handlers.  Also make the flushes in those print routines safe to call
from interrupt level.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=waitms 1500; should print task dump again

Change-Id: I07e0ed24a526ae499566dab0bbeb0f5755cd5be6
2012-04-25 14:49:49 -07:00
Randall Spangler
0d19c59aba Implement task profiling
Also tracks the distribution of IRQs, so we can see what's triggering
interrupts.

Task profiling is optional, enabled via CONFIG_TASK_PROFILING.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7464
TEST=taskinfo

Change-Id: I266f2b49bff9648cda446210d5a302b460fec244
2012-04-24 12:54:29 -07:00
Randall Spangler
f411bbbe19 Re-enable watchdog in watchdog_reload()
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:8971
TEST=manual

waitms 1500
(see watchdog trace)
waitms 1500
(should see watchdog trace again)
waitms 3000
(should see trace, then system should reboot)

Change-Id: Ieb5009d7a7bc9e1ed795e58efb0cb44a1eeb2706
2012-04-12 12:04:37 -07:00
Randall Spangler
a61d8db3d3 Change task messages to events
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7461
TEST=manual

make BOARD={bds,link,daisy}
make tests
flash link system and make sure it boots

Change-Id: I1241a1895c083e387e38ddab01ac346ca4474eb9
2012-04-06 09:06:53 -07:00
Randall Spangler
b2ac77b37b Support warm reboot from one EC image to another.
This is necessary at init-time for verified boot to jump from RO to
one of the RW images.

It's also used by factory EC update to update one image and then jump
to the updated image to finish the update.  In this case, the x86 does
NOT reboot.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:8449
TEST=manual

1) power on x86 and log in
2) sysjump a  --> system is in a; x86 has not rebooted
3) sysjump ro --> system is back in RO; x86 has not rebooted
4) reboot -> system is in RO; x86 HAS rebooted

Change-Id: I9dbadcf9775e146a0718abfd4ee0758b65350a87
2012-03-19 15:41:14 -07:00
Vic Yang
502613771e FPU control
Implement enable_fpu() and disable_fpu().
enable_fpu() disables interrupt and then enables FPU.
disable_fpu() disables FPU and enables interrupt.
Also added a CONFIG_FPU flag.

BUG=chrome-os-partner:7920
TEST=none

Change-Id: I2d71f396d9c7d7ac4a6a2d525f3d86f8aae87521
Signed-off-by: Vic Yang <victoryang@chromium.org>
2012-02-16 05:42:08 +08:00
Vincent Palatin
5e22f8e51b expand properly the IRQ number for IRQ declaration macro
Expand the macros before building the priority variable name in order to
ensure we have a valid name.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=None
TEST=check manually preprocessor expansion for several combinations.

Change-Id: I926821d42c966ac674e7d24254c9f22779f93ca2
2012-01-30 22:32:39 +00:00
Vincent Palatin
c89bea4a5b Go back to SoC independant IRQ vectors declaration
Preparatory work to introduce a second SoC : 1/5

Instead of putting hardcoded IRQ SoC name in the vector table,
upgrade the DECLARE_IRQ macro to expand its argument.

Also add a parameter to set the size of the NVIC table to save flash
memory.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=None
TEST=run EC on BDS and see timer IRQs firing.

Change-Id: I44fefdabdd37d756492a71f24554979c72c1b50f
2012-01-25 22:47:12 +00:00
Vincent Palatin
16e43a3d0d Initial mutex implementation
They are designed to protect shared hardware resources (e.g. I2C
controller).
Please refrain using them as a general purpose synchronization primitive
for the tasks to avoid unintended slippery effects (e.g. priority inversion),
use the provided message-passing functions instead for that purpose.

The mutex variable (ie the "struct mutex") should be initially filled
with 0, but this is the default compiler behavior if you declare it as a
global variable.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=None
TEST=make qemu-tests

Change-Id: I328f7eadf5257560944dbbbeda0b99d5b24520e8
2012-01-25 18:23:48 +00:00
Randall Spangler
37dcc1ab56 Handle all GPIO IRQs. Interrupts no longer enabled by default.
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7456
TEST=if it runs, it works

Change-Id: Ib82afab7d53203af31eefc9887feb98679266ac1
2012-01-17 15:21:20 -08:00
Randall Spangler
84a286b1f4 Use #defined constants for IRQ names
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=none

Change-Id: If07ac671cef6b9d0e9fe0a96bf04455a3d2626ff
2011-12-19 13:48:05 -08:00
Randall Spangler
1ce694189a Add IRQ constants, and task functions to enable/disable/trigger IRQs.
The constants don't work with the DECLARE_IRQ() macro yet, because it
relies on stringizing the IRQ number.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=none

Change-Id: Ie6ddecd79e28c319b095089131579ba994a17da3
(cherry picked from commit e24904644a977f2618f51629cc066b93a3d53595)
2011-12-12 14:23:04 -08:00
Vincent Palatin
e24fa592d2 Initial sources import 3/3
source files mainly done by Vincent.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

Change-Id: Ic2d1becd400c9b4b4a14d4a243af1bdf77d9c1e2
2011-12-07 19:10:02 +00:00