/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include #include #include #include #include #include #include #include #include "battery.h" #include "comm-host.h" #include "ectool.h" #include "lightbar.h" #include "lock/gec_lock.h" /* Handy tricks */ #define BUILD_ASSERT(cond) ((void)sizeof(char[1 - 2*!(cond)])) #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) /* Don't use a macro where an inline will do... */ static inline int MIN(int a, int b) { return a < b ? a : b; } #define GEC_LOCK_TIMEOUT_SECS 30 /* 30 secs */ const char help_str[] = "Commands:\n" " autofanctrl \n" " Turn on automatic fan speed control.\n" " backlight \n" " Enable/disable LCD backlight\n" " battery\n" " Prints battery info\n" " batterycutoff\n" " Cut off battery output power\n" " chargecurrentlimit\n" " Set the maximum battery charging current\n" " chargedump\n" " Dump the context of charge state machine\n" " chargeforceidle\n" " Force charge state machine to stop in idle mode\n" " chipinfo\n" " Prints chip info\n" " cmdversions \n" " Prints supported version mask for a command number\n" " console\n" " Prints the last output to the EC debug console\n" " echash [CMDS]\n" " Various EC hash commands\n" " eventclear \n" " Clears EC host events flags where mask has bits set\n" " eventclearb \n" " Clears EC host events flags copy B where mask has bits set\n" " eventget\n" " Prints raw EC host event flags\n" " eventgetb\n" " Prints raw EC host event flags copy B\n" " eventgetscimask\n" " Prints SCI mask for EC host events\n" " eventgetsmimask\n" " Prints SMI mask for EC host events\n" " eventgetwakemask\n" " Prints wake mask for EC host events\n" " eventsetscimask \n" " Sets the SCI mask for EC host events\n" " eventsetsmimask \n" " Sets the SMI mask for EC host events\n" " eventsetwakemask \n" " Sets the wake mask for EC host events\n" " fanduty \n" " Forces the fan PWM to a constant duty cycle\n" " flasherase \n" " Erases EC flash\n" " flashinfo\n" " Prints information on the EC flash\n" " flashprotect [now] [enable | disable]\n" " Prints or sets EC flash protection state\n" " flashread \n" " Reads from EC flash to a file\n" " flashwrite \n" " Writes to EC flash from a file\n" " gpioget \n" " Get the value of GPIO signal\n" " gpioset \n" " Set the value of GPIO signal\n" " hello\n" " Checks for basic communication with EC\n" " kbpress\n" " Simulate key press\n" " i2cread\n" " Read I2C bus\n" " i2cwrite\n" " Write I2C bus\n" " keyscan \n" " Test low-level key scanning\n" " lightbar [CMDS]\n" " Various lightbar control commands\n" " port80flood\n" " Rapidly write bytes to port 80\n" " pstoreinfo\n" " Prints information on the EC host persistent storage\n" " pstoreread \n" " Reads from EC host persistent storage to a file\n" " pstorewrite \n" " Writes to EC host persistent storage from a file\n" " pwmgetfanrpm\n" " Prints current fan RPM\n" " pwmgetkblight\n" " Prints current keyboard backlight percent\n" " pwmsetfanrpm \n" " Set target fan RPM\n" " pwmsetkblight \n" " Set keyboard backlight in percent\n" " readtest \n" " Reads a pattern from the EC via LPC\n" " reboot_ec [at-shutdown]\n" " Reboot EC to RO or RW\n" " rtcget\n" " Print real-time clock\n" " rtcset