summaryrefslogtreecommitdiff
path: root/common/lightbar.c
diff options
context:
space:
mode:
authorEric Caruso <ejcaruso@chromium.org>2014-09-30 13:38:52 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-10-01 01:47:39 +0000
commit28891eaaab07e873ce5ff21006713ad4f8faf975 (patch)
tree856817f626ee3bde72f898f428ed2ada6ddc4277 /common/lightbar.c
parent85d2d1f503ae8ad43094672910130df18e4a7d13 (diff)
downloadchrome-ec-28891eaaab07e873ce5ff21006713ad4f8faf975.tar.gz
lightbar: treat HALT like a normal opcode
This removes the special casing around HALT. It saves us a string literal and some logic. In total, we gain about 50 bytes and a little cleanup for this. BUG=None BRANCH=ToT TEST=Tried a program that uses HALT (i.e. red-green-blink) in simulator and on hardware. Change-Id: Iffee1b559983fd1ecd385cc6b8967f72a6b968a0 Signed-off-by: Eric Caruso <ejcaruso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/220589 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'common/lightbar.c')
-rw-r--r--common/lightbar.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/common/lightbar.c b/common/lightbar.c
index 6d6e62be20..e903cc5a5b 100644
--- a/common/lightbar.c
+++ b/common/lightbar.c
@@ -333,6 +333,8 @@ static inline int cycle_npn(uint16_t i)
static uint32_t pending_msg;
/* And here's the task event that we use to trigger delivery. */
#define PENDING_MSG 1
+/* When a program halts, return this. */
+#define PROGRAM_FINISHED 2
/* Interruptible delay. */
#define WAIT_OR_RET(A) do { \
@@ -1235,13 +1237,20 @@ static uint32_t lightbyte_CYCLE(void)
return EC_SUCCESS;
}
+/* HALT - return with success
+ * Show's over. Go back to what you were doing before.
+ */
+static uint32_t lightbyte_HALT(void)
+{
+ return PROGRAM_FINISHED;
+}
+
#undef GET_INTERP_VALUE
#define OP(X) X
#include "lightbar_opcode_list.h"
enum lightbyte_opcode {
LIGHTBAR_OPCODE_TABLE
- HALT,
MAX_OPCODE
};
#undef OP
@@ -1257,7 +1266,6 @@ static uint32_t (*lightbyte_dispatch[])(void) = {
#include "lightbar_opcode_list.h"
static const char * const lightbyte_names[] = {
LIGHTBAR_OPCODE_TABLE
- "HALT"
};
#undef OP
@@ -1283,11 +1291,7 @@ static uint32_t sequence_PROGRAM(void)
if (decode_8(&next_inst) != EC_SUCCESS)
return EC_RES_INVALID_PARAM;
- if (next_inst == HALT) {
- CPRINTS("LB PROGRAM pc: 0x%02x, halting", old_pc);
- lb_set_brightness(saved_brightness);
- return 0;
- } else if (next_inst >= MAX_OPCODE) {
+ if (next_inst >= MAX_OPCODE) {
CPRINTS("LB PROGRAM pc: 0x%02x, "
"found invalid opcode 0x%02x",
old_pc, next_inst);