From 28891eaaab07e873ce5ff21006713ad4f8faf975 Mon Sep 17 00:00:00 2001 From: Eric Caruso Date: Tue, 30 Sep 2014 13:38:52 -0700 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/220589 Reviewed-by: Bill Richardson --- common/lightbar.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'common/lightbar.c') 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); -- cgit v1.2.1