From: Stefan E. <se...@us...> - 2004-02-05 18:10:03
|
Update of /cvsroot/blob/blob/src/blob In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15926/src/blob Modified Files: Makefile.am main.c Added Files: autoboot.c Log Message: Factor out autoboot function. This is useful for boards which want to do autoboot unless some special condition is met, such as a GPIO tied to ground or similar. Boards can set a callback for autoboot checking. This callback is initially set to a default function which implements the "old" way of autobooting. --- NEW FILE: autoboot.c --- /********************************************************************** * autoboot.c - check whether or not we have to do an autoboot * * Copyright (C) 1999 2000 2001 * Jan-Derk Bakker (J.D...@it...) and * Erik Mouw (J.A...@it...) * * (C) 2003 by Stefan Eletzhofer <ste...@el...> * * 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: autoboot.c,v 1.1 2004/02/05 18:07:29 seletz Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/arch.h> #include <blob/debug.h> #include <blob/errno.h> #include <blob/error.h> #include <blob/init.h> #include <blob/main.h> #include <blob/serial.h> #include <blob/time.h> #include <blob/util.h> #include <blob/autoboot.h> /********************************************************************** * defines */ /********************************************************************** * globals */ /********************************************************************** * module globals */ static char *version = "$Id: autoboot.c,v 1.1 2004/02/05 18:07:29 seletz Exp $"; #ifdef DEBUG static int dbg = 1; #else static int dbg = 0; #endif check_autoboot_fn blob_autoboot_fn = NULL; void *blob_autoboot_priv = NULL; /********************************************************************* * default_check_autoboot - blobs default autoboot sequence * @priv: here the commandline gets passed */ int default_check_autoboot( void *priv ) { int ret = 1; char *commandline = (char *)priv; if (blob_status.boot_delay > -1) { int i; int retval = 0; /* wait boot_delay seconds before starting autoboot */ printf("Autoboot (%i seconds) in progress, press any key to stop ", blob_status.boot_delay); if (blob_status.boot_delay == 0) { retval = SerialInputBlock(commandline, 1, 0); } else { for(i = 0; i < blob_status.boot_delay; i++) { serial_write('.'); retval = SerialInputBlock(commandline, 1, 1); if(retval > 0) break; } } if ( retval ) { ret = 0; /* command loop */ } } return ret; } /* vim: set ts=8 sw=8 tw=75: */ Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/blob/Makefile.am,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- Makefile.am 10 Nov 2003 17:06:41 -0000 1.48 +++ Makefile.am 5 Feb 2004 18:07:29 -0000 1.49 @@ -60,6 +60,7 @@ trampoline.S \ flashasm.S \ testmem2.S \ + autoboot.c \ bootldrpart.c \ commands.c \ flash.c \ Index: main.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/main.c,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- main.c 4 Dec 2003 21:45:19 -0000 1.55 +++ main.c 5 Feb 2004 18:07:29 -0000 1.56 @@ -54,6 +54,7 @@ #include <blob/util.h> #include <blob/load_kernel.h> #include <blob/partition.h> +#include <blob/autoboot.h> #include <blob/download.h> @@ -62,14 +63,17 @@ blob_status_t blob_status; + static char *version_str = PACKAGE " version " VERSION " for " BOARD_NAME "\n"; + int main(void) { int numRead = 0; char commandline[MAX_COMMANDLINE_LENGTH]; u32 conf = 0; void *params; + int ret; /* initialise status */ blob_status.param.type = fromFlash; @@ -81,6 +85,10 @@ blob_status.cmdline[0] = '\0'; blob_status.boot_delay = 10; + /* default autoboot checker */ + blob_autoboot_fn= default_check_autoboot; + blob_autoboot_priv= commandline; + /* call subsystems (blob_status.* may change) */ init_subsystems(); @@ -128,38 +136,17 @@ if(blob_status.load_ramdisk) do_reload("ramdisk"); - if (blob_status.boot_delay > -1) { - int i; - int retval = 0; - - /* wait boot_delay seconds before starting autoboot */ - printf("Autoboot (%i seconds) in progress, press any key to stop ", - blob_status.boot_delay); - - - if (blob_status.boot_delay == 0) { - retval = SerialInputBlock(commandline, 1, 0); - } else { - for(i = 0; i < blob_status.boot_delay; i++) { - serial_write('.'); - - retval = SerialInputBlock(commandline, 1, 1); - - if(retval > 0) - break; - } - } - + /* check whether or not we should autoboot */ + ret = (*blob_autoboot_fn)( blob_autoboot_priv ); + if ( ret ) { /* no key was pressed, so proceed booting the kernel */ - if(retval == 0) { - commandline[0] = '\0'; - parse_command("boot"); - } - - printf("\nAutoboot aborted\n"); - printf("Type \"help\" to get a list of commands\n"); + commandline[0] = '\0'; + parse_command("boot"); } + printf("\nAutoboot aborted\n"); + printf("Type \"help\" to get a list of commands\n"); + /* the command loop. endless, of course */ for(;;) { DisplayPrompt(NULL); |