diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-07-12 14:26:20 -0700 |
---|---|---|
committer | Randall Spangler <rspangler@chromium.org> | 2012-07-12 18:22:24 -0700 |
commit | 7946a3eb3d982cd489c35f9cfb16f3e61a27d197 (patch) | |
tree | a064fe2ae64ea57a376192ff964355d67f1ebd5a /common/host_event_commands.c | |
parent | 89049421a6f2681f517373338a0f601beae7c737 (diff) | |
download | chrome-ec-7946a3eb3d982cd489c35f9cfb16f3e61a27d197.tar.gz |
Simplify host event processing
Now both copies of the event state live in host_event_commands.c, and
lpc / memmap just shadows the main copy.
BUG=chrome-os-partner:11172
TEST=manual
Boot system. should see events 0x2000, 0x80, 0x08 get set and then cleared.
At U-boot prompt, type on keyboard. Should set event 0x1000 get set,
but only on the first keypress (because U-boot doesn't consume that
event).
Then from EC console,
hostevent clear 0x1000 -> see event 0x1000 clear
hostevent clear 0x1000 -> no debug output (it's already clear)
hostevent clearb 0x1000 -> see event copy B 0x1000 clear
hostevent clearb 0x1000 -> no debug output (copy B is already clear)
Change-Id: I855c035865649ba1490cd9027157d5bcdcc9895f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27321
Diffstat (limited to 'common/host_event_commands.c')
-rw-r--r-- | common/host_event_commands.c | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/common/host_event_commands.c b/common/host_event_commands.c index b4a161068a..670212c430 100644 --- a/common/host_event_commands.c +++ b/common/host_event_commands.c @@ -12,41 +12,59 @@ #include "lpc.h" #include "util.h" -/* Copy B of current events mask. +/* Console output macros */ +#define CPUTS(outstr) cputs(CC_EVENTS, outstr) +#define CPRINTF(format, args...) cprintf(CC_EVENTS, format, ## args) + +/* + * Maintain two copies of the events that are set. + * + * The primary copy is mirrored in mapped memory and used to trigger interrupts + * on the host via ACPI/SCI/SMI/GPIO. * - * This is separate from the main copy, which affects ACPI/SCI/SMI/wake. + * The secondary (B) copy is used to track events at a non-interrupt level (for + * example, so a user-level process can find out what events have happened + * since the last call, even though a kernel-level process is consuming events + * from the first copy). * - * Setting an event sets both copies. Copies are cleared separately. */ + * Setting an event sets both copies. Copies are cleared separately. + */ +static uint32_t events; static uint32_t events_copy_b; uint32_t host_get_events(void) { -#ifdef CONFIG_LPC - return lpc_get_host_events(); -#else - uint32_t *mapped_raw_events = - (uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS); - return *mapped_raw_events; -#endif + return events; } void host_set_events(uint32_t mask) { + /* Only print if something's about to change */ + if ((events & mask) != mask || (events_copy_b & mask) != mask) + CPRINTF("[%T event set 0x%08x]\n", mask); + + atomic_or(&events, mask); atomic_or(&events_copy_b, mask); #ifdef CONFIG_LPC - lpc_set_host_events(mask); + lpc_set_host_event_state(events); #else - *(uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) |= mask; + *(uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) = events; #endif } void host_clear_events(uint32_t mask) { + /* Only print if something's about to change */ + if (events & mask) + CPRINTF("[%T event clear 0x%08x]\n", mask); + + atomic_clear(&events, mask); + #ifdef CONFIG_LPC - lpc_clear_host_events(mask); + lpc_set_host_event_state(events); #else - *(uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) &= ~mask; + *(uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) = events; #endif } @@ -58,6 +76,10 @@ void host_clear_events(uint32_t mask) */ static void host_clear_events_b(uint32_t mask) { + /* Only print if something's about to change */ + if (events_copy_b & mask) + CPRINTF("[%T event clear B 0x%08x]\n", mask); + atomic_clear(&events_copy_b, mask); } |