From: Erik M. <er...@us...> - 2001-10-03 19:55:37
|
Update of /cvsroot/blob/blob/src In directory usw-pr-cvs1:/tmp/cvs-serv14750 Modified Files: Makefile.am help.c main.c reboot.c terminal.c Log Message: Cleanups: move a couple of commands to separate files so main.c becomes shorter and hence cleaner. Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/Makefile.am,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- Makefile.am 2001/10/03 17:17:15 1.9 +++ Makefile.am 2001/10/03 19:55:34 1.10 @@ -61,6 +61,7 @@ command.c \ error.c \ flash.c \ + help.c \ icache.c \ init.c \ led.c \ @@ -68,7 +69,9 @@ main.c \ memory.c \ param_block.c \ + reboot.c \ serial.c \ + terminal.c \ time.c \ util.c \ uucodec.c Index: help.c =================================================================== RCS file: /cvsroot/blob/blob/src/help.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- help.c 2001/10/03 19:26:10 1.1 +++ help.c 2001/10/03 19:55:34 1.2 @@ -0,0 +1,76 @@ +/* + * help.c: Help for commands + * + * Copyright (C) 2001 Erik Mouw (J.A...@it...) + * + * $Id$ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ident "$Id$" + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "command.h" +#include "errno.h" +#include "error.h" +#include "serial.h" +#include "util.h" + + + + +static int help(int argc, char *argv[]) +{ + commandlist_t *cmd; + + /* help on a command? */ + if(argc >= 2) { + for(cmd = commands; cmd != NULL; cmd = cmd->next) { + if(strcmp(cmd->name, argv[1]) == 0) { + SerialOutputString("Help for '"); + SerialOutputString(argv[1]); + SerialOutputString("':\n\nUsage: "); + SerialOutputString(cmd->help); + return 0; + } + } + + printerror(EINVAL, argv[1]); + return 0; + } + + /* generic help */ + SerialOutputString("Help for " PACKAGE " " VERSION ", the bootloader\n"); + SerialOutputString("The following commands are supported:"); + + for(cmd = commands; cmd != NULL; cmd = cmd->next) { + SerialOutputString("\n* "); + SerialOutputString(cmd->name); + } + + SerialOutputString("\nUse \"help command\" to get help on a specific command\n"); + + return 0; +} + +static char helphelp[] = "help\n" +"Get this help\n"; + +__commandlist(help, "help", helphelp); Index: main.c =================================================================== RCS file: /cvsroot/blob/blob/src/main.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- main.c 2001/10/03 17:19:25 1.17 +++ main.c 2001/10/03 19:55:34 1.18 @@ -348,48 +348,6 @@ -static int PrintHelp(int argc, char *argv[]) -{ - commandlist_t *cmd; - - /* help on a command? */ - if(argc >= 2) { - for(cmd = commands; cmd != NULL; cmd = cmd->next) { - if(strcmp(cmd->name, argv[1]) == 0) { - SerialOutputString("Help for '"); - SerialOutputString(argv[1]); - SerialOutputString("':\n\nUsage: "); - SerialOutputString(cmd->help); - return 0; - } - } - - printerror(EINVAL, argv[1]); - return 0; - } - - /* generic help */ - SerialOutputString("Help for " PACKAGE " " VERSION ", the LART bootloader\n"); - SerialOutputString("The following commands are supported:"); - - for(cmd = commands; cmd != NULL; cmd = cmd->next) { - SerialOutputString("\n* "); - SerialOutputString(cmd->name); - } - - SerialOutputString("\nUse \"help command\" to get help on a specific command\n"); - - return 0; -} - -static char helphelp[] = "help\n" -"Get this help\n"; - -__commandlist(PrintHelp, "help", helphelp); - - - - static int SetDownloadSpeed(int argc, char *argv[]) { if(argc < 2) @@ -517,28 +475,6 @@ -static int ResetTerminal(int argc, char *argv[]) -{ - int i; - - SerialInit(blob_status.terminalSpeed); - SerialOutputString(" c"); - for(i = 0; i < 100; i++) - SerialOutputByte('\n'); - - SerialOutputString("c"); - - return 0; -} - -static char resethelp[] = "reset\n" -"Reset terminal\n"; - -__commandlist(ResetTerminal, "reset", resethelp); - - - - static int do_reload(char *what) { u32 *dst = 0; @@ -641,46 +577,3 @@ break; } } - - - - -static int Reboot(int argc, char *argv[]) -{ - SerialOutputString("Rebooting...\n\n"); - - msleep(500); - - RCSR = 0; - RSRR = 1; - - /* never reached, but anyway... */ - return 0; -} - -static char reboothelp[] = "reboot\n" -"Reboot system\n"; - -__commandlist(Reboot, "reboot", reboothelp); - - - - -int Reblob(int argc, char *argv[]) -{ - void (*blob)(void) = (void (*)(void))BLOB_RAM_BASE; - - SerialOutputString("Restarting blob from RAM...\n\n"); - - msleep(500); - - blob(); - - /* never reached, but anyway... */ - return 0; -} - -static char reblobhelp[] = "reblob\n" -"Restart blob from RAM\n"; - -__commandlist(Reblob, "reblob", reblobhelp); Index: reboot.c =================================================================== RCS file: /cvsroot/blob/blob/src/reboot.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- reboot.c 2001/10/03 19:26:10 1.1 +++ reboot.c 2001/10/03 19:55:34 1.2 @@ -0,0 +1,77 @@ +/* + * reboot.c: Reboot board + * + * Copyright (C) 2001 Erik Mouw (J.A...@it...) + * + * $Id$ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ident "$Id$" + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "command.h" +#include "main.h" +#include "serial.h" +#include "sa1100.h" +#include "time.h" + + + + +static int reboot(int argc, char *argv[]) +{ + SerialOutputString("Rebooting...\n\n"); + + msleep(500); + + RCSR = 0; + RSRR = 1; + + /* never reached, but anyway... */ + return 0; +} + +static char reboothelp[] = "reboot\n" +"Reboot system\n"; + +__commandlist(reboot, "reboot", reboothelp); + + + + +static int reblob(int argc, char *argv[]) +{ + void (*blob)(void) = (void (*)(void))BLOB_RAM_BASE; + + SerialOutputString("Restarting blob from RAM...\n\n"); + + msleep(500); + + blob(); + + /* never reached, but anyway... */ + return 0; +} + +static char reblobhelp[] = "reblob\n" +"Restart blob from RAM\n"; + +__commandlist(reblob, "reblob", reblobhelp); Index: terminal.c =================================================================== RCS file: /cvsroot/blob/blob/src/terminal.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- terminal.c 2001/10/03 19:53:55 1.1 +++ terminal.c 2001/10/03 19:55:34 1.2 @@ -0,0 +1,54 @@ +/* + * terminal.c: terminal reset functions + * + * Copyright (C) 1999 2000 2001 Erik Mouw (J.A...@it...) + * + * $Id$ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ident "$Id$" + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "command.h" +#include "main.h" +#include "serial.h" + + + + +static int reset_terminal(int argc, char *argv[]) +{ + int i; + + SerialInit(blob_status.terminalSpeed); + SerialOutputString(" c"); + for(i = 0; i < 100; i++) + SerialOutputByte('\n'); + + SerialOutputString("c"); + + return 0; +} + +static char resethelp[] = "reset\n" +"Reset terminal\n"; + +__commandlist(reset_terminal, "reset", resethelp); |