diff --git a/porting/liteos_a/toys/other/reboot.c b/porting/liteos_a/toys/other/reboot.c index 77693be6a76e57254447f17c821bbe2e4e7d636c..432b17facd37bc7d3bbb88ec72fdb22d831897ac 100644 --- a/porting/liteos_a/toys/other/reboot.c +++ b/porting/liteos_a/toys/other/reboot.c @@ -2,34 +2,32 @@ * * Copyright 2013 Elie De Brauwer -USE_REBOOT(NEWTOY(reboot, "fn", TOYFLAG_SBIN|TOYFLAG_NEEDROOT)) -USE_REBOOT(OLDTOY(halt, reboot, TOYFLAG_SBIN|TOYFLAG_NEEDROOT)) -USE_REBOOT(OLDTOY(poweroff, reboot, TOYFLAG_SBIN|TOYFLAG_NEEDROOT)) +USE_RESET(NEWTOY(reset, "n", TOYFLAG_SBIN|TOYFLAG_NEEDROOT)) +USE_RESET(OLDTOY(halt, reset, TOYFLAG_SBIN|TOYFLAG_NEEDROOT)) +USE_RESET(OLDTOY(poweroff, reset, TOYFLAG_SBIN|TOYFLAG_NEEDROOT)) -config REBOOT - bool "reboot" +config RESET + bool "reset" default y help - usage: reboot/halt/poweroff [-fn] + usage: reset/halt/poweroff [-n] Restart, halt or powerdown the system. - -f Don't signal init -n Don't sync before stopping the system */ -#define FOR_reboot +#define FOR_reset #include "toys.h" #include -void reboot_main(void) +void reset_main(void) { int types[] = {RB_AUTOBOOT, RB_HALT_SYSTEM, RB_POWER_OFF}, sigs[] = {SIGTERM, SIGUSR1, SIGUSR2}, idx; - if (!*toys.optargs) help_exit("missing argument"); if (!(toys.optflags & FLAG_n)) sync(); - + idx = stridx("hp", *toys.which->name)+1; - if (toys.optflags & FLAG_f) toys.exitval = reboot(types[idx]); + toys.exitval = reboot(types[idx]); } diff --git a/porting/liteos_a/toys/other/reset.c b/porting/liteos_a/toys/other/reset.c new file mode 100644 index 0000000000000000000000000000000000000000..c65d27eb0ad1da91bbec5a93a954d5cfee5f0474 --- /dev/null +++ b/porting/liteos_a/toys/other/reset.c @@ -0,0 +1,26 @@ +/* reset.c - reset the terminal. + * + * Copyright 2015 Rob Landley + * + * No standard. + +USE_FLUSH(NEWTOY(flush, 0, TOYFLAG_USR|TOYFLAG_BIN)) + +config FLUSH + bool "flush" + default y + help + usage: flush + + Flush the terminal. +*/ +#include "toys.h" + +void flush_main(void) +{ + int fd = tty_fd(); + + // man 4 console_codes: reset terminal is ESC (no left bracket) c + // DEC private mode set enable wraparound sequence. + xwrite(fd<0 ? 1 : fd, "\033c\033[?7h", 2); +}