]> www.infradead.org Git - users/rw/ppcboot.git/commitdiff
* Fix watchdog support when used with IDE / PCMCIA
authorwdenk <wdenk>
Tue, 27 Feb 2001 23:50:37 +0000 (23:50 +0000)
committerwdenk <wdenk>
Tue, 27 Feb 2001 23:50:37 +0000 (23:50 +0000)
* Add KGDB support for IBM 4xx (Anne-Sophie Harnois): configure one
  of the two serial ports for KGDB according to CONFIG_KGDB_SER_INDEX
  variable defined in "include/config_WALNUT405.h"

* 'bootd' recursion checking was broken (did nothing).

* 'run' recursion checking was broken.

* There were some problems with 'run' caused by run_command() not
  being reentrant. This is fixed.

* New configuration options are to make autobooting more dependable
  for production systems. They allow the PPCBoot prompt to time out
  and retry the autoboot, and can make it harder to accidentally stop
  the autoboot. The options and the reasons to use them are explained
  in doc/README.autoboot. (Dave Ellis)

14 files changed:
CHANGELOG
README
common/board.c
common/cmd_bootm.c
common/cmd_ide.c
common/cmd_mem.c
common/command.c
common/main.c
cpu/ppc4xx/serial.c
doc/README.autoboot [new file with mode: 0644]
include/command.h
include/config_SXNI855T.h
include/ppcboot.h
net/bootp.c

index 69e43bd5a0b0d1a668602f2df5d3574b87e39922..c0f6602b883e47e2e9555a172a04c02eabfbf9ad 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -57,6 +57,29 @@ To do:
 * "last user address" is set even if bootp is used without parameters
   (and it uses default address).
 
+======================================================================
+Modifications since 0.8.2:
+======================================================================
+
+* Fix watchdog support when used with IDE / PCMCIA
+
+* Add KGDB support for IBM 4xx (Anne-Sophie Harnois): configure one
+  of the two serial ports for KGDB according to CONFIG_KGDB_SER_INDEX
+  variable defined in "include/config_WALNUT405.h"
+
+* 'bootd' recursion checking was broken (did nothing).
+
+* 'run' recursion checking was broken.
+
+* There were some problems with 'run' caused by run_command() not
+  being reentrant. This is fixed.
+
+* New configuration options are to make autobooting more dependable
+  for production systems. They allow the PPCBoot prompt to time out
+  and retry the autoboot, and can make it harder to accidentally stop
+  the autoboot. The options and the reasons to use them are explained
+  in doc/README.autoboot. (Dave Ellis)
+
 ======================================================================
 Modifications for 0.8.2:
 ======================================================================
diff --git a/README b/README
index fef6aa18b1a8991123cf5da637c299cb12d6c1fc..66eabb8b9d00f498b534947dd127d13fc9f5e868 100644 (file)
--- a/README
+++ b/README
@@ -72,21 +72,21 @@ Directory Hierarchy:
 - cpu/mpc8xx   Files specific to Motorola MPC8xx  CPUs
 - cpu/mpc8240  Files specific to Motorola MPC8240 CPU
 - cpu/mpc8260  Files specific to Motorola MPC8260 CPU
-- cpu/ppc4xx   Files specific to IBM      4xx     CPUs
+- cpu/ppc4xx   Files specific to IBM      4xx     CPUs
 
 - board/adciop Files specific to ADCIOP   boards
 - board/cogent Files specific to Cogent   boards
                (need further configuration)
-- board/cpci405        Files specific to CPCI405  boards
+- board/cpci405 Files specific to CPCI405  boards
 - board/etx094 Files specific to ETX_094  boards
-- board/fads   Files specific to FADS     boards
+- board/fads   Files specific to FADS     boards
 - board/sixnet Files specific to SIXNET   boards
-- board/genietv        Files specific to GENIETV  boards
+- board/genietv Files specific to GENIETV  boards
 - board/hermes Files specific to HERMES   boards
-- board/hymod  Files specific to HYMOD    boards
-- board/ip860  Files specific to IP860    boards
-- board/ivms8  Files specific to IVMS8    boards
-- board/mbx8xx Files specific to MBX      boards
+- board/hymod  Files specific to HYMOD    boards
+- board/ip860  Files specific to IP860    boards
+- board/ivms8  Files specific to IVMS8    boards
+- board/mbx8xx Files specific to MBX      boards
 - board/spd8xx Files specific to SPD8xxTS boards
 - board/sandpoint
                Files specific to Sandpoint boards
@@ -148,15 +148,15 @@ The following options need to be configured:
 
 - CPU Type:    Define exactly one of
                CONFIG_MPC823,  CONFIG_MPC850,  CONFIG_MPC855,  CONFIG_MPC860
-       or      CONFIG_MPC8240, CONFIG_MPC8260
+       or      CONFIG_MPC8240, CONFIG_MPC8260
        or      CONFIG_IOP480
        or      CONFIG_PPC405GP
 
 - Board Type:  Define exactly one of
-               CONFIG_ADCIOP,  CONFIG_COGENT,  CONFIG_CPCI405, CONFIG_ETX094,
-               CONFIG_FADS,    CONFIG_FPS850L, CONFIG_HERMES,  CONFIG_IP860,
+               CONFIG_ADCIOP,  CONFIG_COGENT,  CONFIG_CPCI405, CONFIG_ETX094,
+               CONFIG_FADS,    CONFIG_FPS850L, CONFIG_HERMES,  CONFIG_IP860,
                CONFIG_IVMS8,   CONFIG_MBX,     CONFIG_SM850,   CONFIG_SPD823TS,
-               CONFIG_TQM823L, CONFIG_TQM850L, CONFIG_TQM855L, CONFIG_TQM860L,
+               CONFIG_TQM823L, CONFIG_TQM850L, CONFIG_TQM855L, CONFIG_TQM860L,
                CONFIG_SXNI855T
 --- FIXME --- not tested yet:
                CONFIG_TQM860,  CONFIG_ADS,
@@ -194,19 +194,28 @@ The following options need to be configured:
                CONFIG_8xx_CONS_SMC1, CONFIG_8xx_CONS_SMC2 or
                CONFIG_8xx_CONS_NONE
 
-                Note: if CONFIG_8xx_CONS_NONE is defined, the serial
-                port routines must be defined elsewhere
+               Note: if CONFIG_8xx_CONS_NONE is defined, the serial
+               port routines must be defined elsewhere
                (i.e. serial_init(), serial_getc(), ...)
 
 - Console Baudrate:
                CONFIG_BAUDRATE - in bps
-                Select one of the baudrates listed in
+               Select one of the baudrates listed in
                CFG_BAUDRATE_TABLE, see below.
 
 - Boot Delay:  CONFIG_BOOTDELAY - in seconds
                Delay before automatically booting the default image;
                set to -1 to disable autoboot.
 
+               See doc/README.autoboot for these options that
+               work with CONFIG_BOOTDELAY. None are required.
+               CONFIG_BOOT_RETRY_TIME
+               CONFIG_BOOT_RETRY_MIN
+               CONFIG_AUTOBOOT_KEYED
+               CONFIG_AUTOBOOT_PROMPT
+               CONFIG_AUTOBOOT_DELAY_STR
+               CONFIG_AUTOBOOT_STOP_STR
+
 - Autoboot Command:
                CONFIG_BOOTCOMMAND
                Only needed when CONFIG_BOOTDELAY is enabled;
@@ -223,61 +232,69 @@ The following options need to be configured:
                time on others. This setting #define's the initial
                value of the "loads_echo" environment variable.
 
-- Binary File Download (Kermit mode):
-               CONFIG_LOADB
-               If defined, the "loadb" command will be added which
-               allows to download binary files over the serial line
-               using Kermit protocol.
-
-- Kgdb Serial Baudrate:        (if CFG_CMD_KGDB is defined)
+- Kgdb Serial Baudrate: (if CFG_CMD_KGDB is defined)
                CONFIG_KGDB_BAUDRATE
-                Select one of the baudrates listed in
+               Select one of the baudrates listed in
                CFG_BAUDRATE_TABLE, see below.
 
 - Monitor Functions:
                CONFIG_COMMANDS
-                Most monitor functions can be selected (or
-                de-selected) by adjusting the definition of
-                CONFIG_COMMANDS; to select individual functions,
-                #define CONFIG_COMMANDS by "OR"ing any of the
-                following values:
+               Most monitor functions can be selected (or
+               de-selected) by adjusting the definition of
+               CONFIG_COMMANDS; to select individual functions,
+               #define CONFIG_COMMANDS by "OR"ing any of the
+               following values:
 
                #define enables commands:
                -------------------------
-               CFG_CMD_BDI     bdinfo
-               CFG_CMD_LOADS   loads
-               CFG_CMD_LOADB   loadb
-               CFG_CMD_IMI     iminfo
-               CFG_CMD_CACHE   icache, dcache
-               CFG_CMD_FLASH   flinfo, erase, protect
-               CFG_CMD_MEMORY  md, mm, nm, mw, cp, cmp, crc, base,
-                               loop, mtest
-               CFG_CMD_NET     bootp, tftpboot, rarpboot
-               CFG_CMD_ENV     saveenv
-               CFG_CMD_KGDB    kgdb
+               CFG_CMD_BDI       bdinfo
+               CFG_CMD_LOADS     loads
+               CFG_CMD_LOADB     loadb
+               CFG_CMD_IMI       iminfo
+               CFG_CMD_CACHE     icache, dcache
+               CFG_CMD_FLASH     flinfo, erase, protect
+               CFG_CMD_MEMORY    md, mm, nm, mw, cp, cmp, crc, base,
+                                 loop, mtest
+               CFG_CMD_NET       bootp, tftpboot, rarpboot
+               CFG_CMD_ENV       saveenv
+               CFG_CMD_KGDB    * kgdb
+               CFG_CMD_PCMCIA  * PCMCIA support
+               CFG_CMD_IDE     * IDE harddisk support
+               CFG_CMD_PCI     * pciinfo
+               CFG_CMD_IRQ     * irqinfo
+               CFG_CMD_BOOTD     bootd
+               CFG_CMD_CONSOLE   coninfo
+               CFG_CMD_EEPROM  * EEPROM read/write support
+               CFG_CMD_ASKENV  * ask for env variable
+               CFG_CMD_RUN       run command in env variable
+               CFG_CMD_ECHO    * echo arguments
+               CFG_CMD_I2C     * I2C serial bus support
+               CFG_CMD_REGINFO * Register dump
                -------------------------
                CFG_CMD_ALL     all
 
-                CFG_CMD_DFL    Default configuration; at the moment
-                                this is defined as
-                               (CFG_CMD_ALL & ~(CFG_CMD_KGDB))
-                               = everything except KGDB
+               CFG_CMD_DFL     Default configuration; at the moment
+                               this is includes all commands, except
+                               the ones marked with "*" in the list
+                               above.
 
                If you don't define CONFIG_COMMANDS it defaults to
-               CFG_CMD_DFL .
+               CFG_CMD_DFL in include/cmd_confdefs.h. A board can
+               override the default settings in the respective
+               include file.
 
                EXAMPLE: If you want all functions except of network
                support you can write:
 
-               #define CONFIG_COMMANDS (CFG_CMD_ALL & ~CFG_CMD_NET)
+               #define CONFIG_COMMANDS (CFG_CMD_ALL & ~CFG_CMD_NET)
 
 - Watchdog:
                CONFIG_WATCHDOG
-                If this variable is defined, it enables watchdog
-                support. There must support in the platform specific
-                code for a watchdog. For the 8xx and 8260 CPUs, the
-                SIU Watchdog feature is enabled in the SYPCR
-                register.
+               If this variable is defined, it enables watchdog
+               support. There must support in the platform specific
+               code for a watchdog. For the 8xx and 8260 CPUs, the
+               SIU Watchdog feature is enabled in the SYPCR
+               register.
 
 
 
@@ -324,10 +341,10 @@ Configuration Settings:
                Physical start address of Flash memory.
 
 - CFG_MONITOR_BASE:
-                Physical start address of boot monitor code (set by
-                make config files to be same as the text base address
-                (TEXT_BASE) used when linking) - same as
-                CFG_FLASH_BASE when booting from flash.
+               Physical start address of boot monitor code (set by
+               make config files to be same as the text base address
+               (TEXT_BASE) used when linking) - same as
+               CFG_FLASH_BASE when booting from flash.
 
 - CFG_MONITOR_LEN:
                Size of memory reserved for monitor code
@@ -336,10 +353,10 @@ Configuration Settings:
                Size of DRAM reserved for malloc() use.
 
 - CFG_BOOTMAPSZ:
-                Maximum size of memory mapped by the startup code of
-                the Linux kernel; all data that must be processed by
-                the Linux kernel (bd_info, boot arguments, eventually
-                initrd image) must be put below this limit.
+               Maximum size of memory mapped by the startup code of
+               the Linux kernel; all data that must be processed by
+               the Linux kernel (bd_info, boot arguments, eventually
+               initrd image) must be put below this limit.
 
 - CFG_MAX_FLASH_BANKS:
                Max number of Flash memory banks
@@ -362,32 +379,32 @@ following configurations:
 
        Define this if the environment is in flash memory.
 
-        a) The environment occupies one whole flash sector, which is
-           "embedded" in the text segment with the PPCBoot code. This
-           happens usually with "bottom boot sector" or "top boot
-           sector" type flash chips, which have several smaller
-           sectors at the start or the end. For instance, such a
-           layout can have sector sizes of 8, 2x4, 16, Nx32 kB. In
-           such a case you would place the environment in one of the
-           4 kB sectors - with PPCBoot code before and after it. With
-           "top boot sector" type flash chips, you would put the
-           environment in one of the last sectors, leaving a gap
-           between PPCBoot and the environment.
+       a) The environment occupies one whole flash sector, which is
+          "embedded" in the text segment with the PPCBoot code. This
+          happens usually with "bottom boot sector" or "top boot
+          sector" type flash chips, which have several smaller
+          sectors at the start or the end. For instance, such a
+          layout can have sector sizes of 8, 2x4, 16, Nx32 kB. In
+          such a case you would place the environment in one of the
+          4 kB sectors - with PPCBoot code before and after it. With
+          "top boot sector" type flash chips, you would put the
+          environment in one of the last sectors, leaving a gap
+          between PPCBoot and the environment.
 
        - CFG_ENV_OFFSET:
 
-           Offset of environment data (variable area) to the
-           beginning of flash memory; for instance, with bottom boot
-           type flash chips the second sector can be used: the offset
-           for this sector is given here.
+          Offset of environment data (variable area) to the
+          beginning of flash memory; for instance, with bottom boot
+          type flash chips the second sector can be used: the offset
+          for this sector is given here.
 
           CFG_ENV_OFFSET is used relative to CFG_FLASH_BASE.
 
        - CFG_ENV_ADDR:
 
-           This is just another way to specify the start address of
-           the flash sector containing the environment (instead of
-           CFG_ENV_OFFSET).
+          This is just another way to specify the start address of
+          the flash sector containing the environment (instead of
+          CFG_ENV_OFFSET).
 
        - CFG_ENV_SECT_SIZE:
 
@@ -400,20 +417,20 @@ following configurations:
 
        - CFG_ENV_SIZE:
 
-           If you use this in combination with CFG_ENV_IS_IN_FLASH
-           and CFG_ENV_SECT_SIZE, you can specify to use only a part
-           of this flash sector for the environment. This saves
-           memory for the RAM copy of the environment.
+          If you use this in combination with CFG_ENV_IS_IN_FLASH
+          and CFG_ENV_SECT_SIZE, you can specify to use only a part
+          of this flash sector for the environment. This saves
+          memory for the RAM copy of the environment.
 
-           It may also save flash memory if you decide to use this
-           when your environment is "embedded" within PPCBoot code,
-           since then the remainder of the flash sector could be used
-           for PPCBoot code. It should be pointed out that this is
-           STRONGLY DISCOURAGED from a robustness point of view:
-           updating the environment in flash makes it always
-           necessary to erase the WHOLE sector. If something goes
-           wrong before the contents has been restored from a copy in
-           RAM, your target system will be dead.
+          It may also save flash memory if you decide to use this
+          when your environment is "embedded" within PPCBoot code,
+          since then the remainder of the flash sector could be used
+          for PPCBoot code. It should be pointed out that this is
+          STRONGLY DISCOURAGED from a robustness point of view:
+          updating the environment in flash makes it always
+          necessary to erase the WHOLE sector. If something goes
+          wrong before the contents has been restored from a copy in
+          RAM, your target system will be dead.
 
 
 BE CAREFUL! Any changes to the flash layout, and some changes to the
@@ -423,17 +440,17 @@ accordingly!
 
 - CFG_ENV_IS_IN_NVRAM:
 
-        Define this if you have some non-volatile memory device
-        (NVRAM, battery buffered SRAM) which you want to use for the
-        environment.
+       Define this if you have some non-volatile memory device
+       (NVRAM, battery buffered SRAM) which you want to use for the
+       environment.
 
        - CFG_ENV_ADDR:
        - CFG_ENV_SIZE:
 
-          These two #defines are used to determin the memory area you
-          want to use for environment. It is assumed that this memory
-          can just be read and written to, without any special
-          provision.
+         These two #defines are used to determin the memory area you
+         want to use for environment. It is assumed that this memory
+         can just be read and written to, without any special
+         provision.
 
 BE CAREFUL! The first access to the environment happens quite early
 in PPCboot initalization (when we try to get the setting of for the
@@ -448,14 +465,14 @@ to save the current settings.
 
 - CFG_ENV_IS_IN_EEPROM:
 
-        Use this if you have an EEPROM or similar serial access
-        device and a driver for it.
+       Use this if you have an EEPROM or similar serial access
+       device and a driver for it.
 
        - CFG_ENV_OFFSET:
        - CFG_ENV_SIZE:
 
-          These two #defines specify the offset and size of the
-          environment area within the total memory of your EEPROM.
+         These two #defines specify the offset and size of the
+         environment area within the total memory of your EEPROM.
 
 
 Please note that the environment is read-only as long as the monitor
@@ -580,32 +597,39 @@ Monitor Commands - Overview:
 ============================
 
 go     - start application at address 'addr'
+run    - run commands in an environment variable
 bootm  - boot application image from memory
 bootp  - boot image via network using BootP/TFTP protocol
 tftpboot- boot image via network using TFTP protocol
               and env variables ipaddr and serverip
 rarpboot- boot image via network using RARP/TFTP protocol
+diskboot- boot from IDE devicebootd   - boot default, i.e., run 'bootcmd'
 loads  - load S-Record file over serial line
+loadb  - load binary file over serial line (kermit mode)
 md     - memory display
 mm     - memory modify (auto-incrementing)
 nm     - memory modify (constant address)
 mw     - memory write (fill)
 cp     - memory copy
+cmp    - memory compare
 crc32  - checksum calculation
 base   - print or set address offset
 printenv- print environment variables
 setenv - set environment variables
 saveenv - save environment variables to persistent storage
-bdinfo - print Board Info structure
+protect - enable or disable FLASH write protection
+erase  - erase FLASH memory
 flinfo - print FLASH memory information
+bdinfo - print Board Info structure
 iminfo - print header information for application image
-erase  - erase FLASH memory
-protect - enable or disable FLASH write protection
+coninfo - print console devices and informations
+ide    - IDE sub-system
 loop   - infinite loop on address range
 mtest  - simple RAM test
 icache - enable or disable instruction cache
 dcache - enable or disable data cache
 reset  - Perform RESET of the CPU
+echo   - echo args to console
 version - print monitor version
 help   - print online help
 ?      - alias for 'help'
@@ -645,45 +669,51 @@ Some configuration options can be set using Environment Variables:
   bootfile     - Name of the image to load with TFTP
 
   autoload     - if set to "no" (any string beginning with 'n'),
-                  "bootp" will just load perform a lookup of the
-                  configuration from the BOOTP server, but not try to
-                  load any image using TFTP
+                 "bootp" will just load perform a lookup of the
+                 configuration from the BOOTP server, but not try to
+                 load any image using TFTP
 
   autostart    - if set to "yes", an image loaded using the "bootp",
-                  "rarpboot", "tftpboot" or "diskboot" commands will
-                  be automatically started (by internally calling
-                  "bootm")
+                 "rarpboot", "tftpboot" or "diskboot" commands will
+                 be automatically started (by internally calling
+                 "bootm")
 
   initrd_high  - restrict positioning of initrd images:
-                  If this variable is not set, initrd images will be
-                  copied to the highest possible address in RAM; this
-                  is usually what you want since it allows for
-                  maximum initrd size. If for some reason you want to
-                  make sure that the initrd image is loaded below the
-                  CFG_BOOTMAPSZ limit, you can set this environment
-                  variable to a value of "no" or "off" or "0".
-                  Alternatively, you can set it to a maximum upper
-                  address to use (PPCBoot will still check that it
-                  does not overwrite the PCBoot stack and data).
-
-                  For instance, when you have a system with 16 MB
-                  RAM, and want to reseve 4 MB from use by Linux,
-                  you can do this by adding "mem=12M" to the value of
-                  the "bootargs" variable. However, now you must make
-                  sure, that the initrd image is placed in the first
-                  12 MB as well - this can be done with
+                 If this variable is not set, initrd images will be
+                 copied to the highest possible address in RAM; this
+                 is usually what you want since it allows for
+                 maximum initrd size. If for some reason you want to
+                 make sure that the initrd image is loaded below the
+                 CFG_BOOTMAPSZ limit, you can set this environment
+                 variable to a value of "no" or "off" or "0".
+                 Alternatively, you can set it to a maximum upper
+                 address to use (PPCBoot will still check that it
+                 does not overwrite the PCBoot stack and data).
+
+                 For instance, when you have a system with 16 MB
+                 RAM, and want to reseve 4 MB from use by Linux,
+                 you can do this by adding "mem=12M" to the value of
+                 the "bootargs" variable. However, now you must make
+                 sure, that the initrd image is placed in the first
+                 12 MB as well - this can be done with
 
                  setenv initrd_high 00c00000
 
   ipaddr       - IP address; needed for tftpboot command
 
   loadaddr     - Default load address for commands like "bootp",
-                  "rarpboot", "tftpboot" or "diskboot"
+                 "rarpboot", "tftpboot" or "diskboot"
 
   loads_echo   - see CONFIG_LOADS_ECHO
 
   serverip     - TFTP server IP address; needed for tftpboot command
 
+  bootretry    - see CONFIG_BOOT_RETRY_TIME
+
+  bootdelaykey - see CONFIG_AUTOBOOT_DELAY_STR
+
+  bootstopkey  - see CONFIG_AUTOBOOT_STOP_STR
+
 
 The following environment variables may be used and automatically
 updated by the network boot commands ("bootp" and "rarpboot"),
@@ -840,7 +870,7 @@ from a "data file" which is used as image payload:
          -n ==> set image name to 'name'
          -d ==> use image data from 'datafile'
 
-Right now, all Linux kernels use the same load address  (0x00000000),
+Right now, all Linux kernels use the same load address (0x00000000),
 but the entry point address depends on the kernel version:
 
 - 2.2.x kernels have the entry point at 0x0000000C,
index 654de3d945a1367f47efc00aecf201b6846742bb..10b1dc17c2e169b2196dcfed4cbc1f5ca8cc16a6 100644 (file)
@@ -560,10 +560,11 @@ void    board_init_r  (bd_t *bd, ulong dest_addr)
 
     /* Initialization complete - start the monitor */
 
-    main_loop (bd);
+    /* main_loop() can return to retry autoboot, if so just run it again. */
+    for (;;) 
+       main_loop (bd);
 
-    /* NOTREACHED - start_main does not return; just in case: loop here */
-    for (;;);
+    /* NOTREACHED - no way out of command loop except booting */
 }
 
 void hang(void)
index d6f7dea6b18f6c3b8dfee907b8b638568e25f416..7bada73a5a2da9a48780f7a53c5d87b34e028b29 100644 (file)
@@ -32,7 +32,6 @@
 #include <zlib.h>
 
 int  gunzip (void *, int, unsigned char *, int *);
-void run_command (const char *cmd, cmd_tbl_t *cmdtp, bd_t *bd, int flag);
 
 static void *zalloc(void *, unsigned, unsigned);
 static void zfree(void *, void *, unsigned);
@@ -416,7 +415,7 @@ void do_bootm (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
 #if (CONFIG_COMMANDS & CFG_CMD_BOOTD)
 void do_bootd (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
 {
-       run_command ("bootcmd", cmdtp, bd, flag);
+       run_command (getenv ("bootcmd"), bd, flag);
 }
 #endif
 
index 942b4ce7aa20b6768be75a4d89b2e04fd974ffc5..cde0b74b980655a4fe5b2004305184f0221d1001 100644 (file)
@@ -425,6 +425,9 @@ void ide_init (bd_t *bd)
 #ifdef CONFIG_IDE_PCCARD
        extern int pcmcia_on (void);
 
+# if defined(CONFIG_WATCHDOG)
+       watchdog_reset ();
+# endif        /* CONFIG_WATCHDOG */
        /* initialize the PCMCIA IDE adapter card */
        if (pcmcia_on())
                return;
@@ -432,6 +435,10 @@ void ide_init (bd_t *bd)
        puts ("  ");
 #endif
 
+#if defined(CONFIG_WATCHDOG)
+       watchdog_reset ();
+#endif /* CONFIG_WATCHDOG */
+
        /* Initialize PIO timing tables */
        for (i=0; i <= IDE_MAX_PIO_MODE; ++i) {
            pio_config_clk[i].t_setup  = PCMCIA_MK_CLKS(pio_config_ns[i].t_setup,
@@ -478,12 +485,21 @@ void ide_init (bd_t *bd)
 
                /* Select device
                 */
+#if defined(CONFIG_WATCHDOG)
+               watchdog_reset ();
+#endif /* CONFIG_WATCHDOG */
                udelay (100000);                /* 100 ms */
                outb (dev, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(dev));
+#if defined(CONFIG_WATCHDOG)
+               watchdog_reset ();
+#endif /* CONFIG_WATCHDOG */
                udelay (100000);                /* 100 ms */
 
                i = 0;
                do {
+#if defined(CONFIG_WATCHDOG)
+                       watchdog_reset ();
+#endif /* CONFIG_WATCHDOG */
                        udelay (10000);         /* 10 ms */
 
                        c = inb (dev, ATA_STATUS);
@@ -506,6 +522,9 @@ void ide_init (bd_t *bd)
                        puts ("OK  ");
                        ide_bus_ok[bus] = 1;
                }
+#if defined(CONFIG_WATCHDOG)
+               watchdog_reset ();
+#endif /* CONFIG_WATCHDOG */
        }
        putc ('\n');
 
@@ -529,6 +548,9 @@ void ide_init (bd_t *bd)
                        curr_device = i;
                }
        }
+#if defined(CONFIG_WATCHDOG)
+       watchdog_reset ();
+#endif /* CONFIG_WATCHDOG */
 }
 
 /* ------------------------------------------------------------------------- */
@@ -974,12 +996,19 @@ static void ide_reset (void)
 #error IDE reset pin not configured
 #endif /* CFG_PC_IDE_RESET */
 
+#if defined(CONFIG_WATCHDOG)
+       watchdog_reset ();
+#endif /* CONFIG_WATCHDOG */
+
 #ifdef CFG_PB_12V_ENABLE
        /* We must wait at least 500 ms for the voltage to stabilize;
         */
        for (i=0; i<50; ++i) {
                udelay (10000);
        }
+#if defined(CONFIG_WATCHDOG)
+       watchdog_reset ();
+#endif /* CONFIG_WATCHDOG */
        immr->im_cpm.cp_pbdat |=   CFG_PB_12V_ENABLE;   /* 12V Enable output ON */
        immr->im_cpm.cp_pbpar &= ~(CFG_PB_12V_ENABLE);
        immr->im_cpm.cp_pbodr &= ~(CFG_PB_12V_ENABLE);
@@ -1003,10 +1032,18 @@ static void ide_reset (void)
        }
 #endif /* CFG_PB_IDE_MOTOR */
 
+#if defined(CONFIG_WATCHDOG)
+       watchdog_reset ();
+#endif /* CONFIG_WATCHDOG */
+
        /* wait 250 ms */
        for (i=0; i<25; ++i) {
                udelay (10000);
        }
+
+#if defined(CONFIG_WATCHDOG)
+       watchdog_reset ();
+#endif /* CONFIG_WATCHDOG */
 }
 
 #endif /* CONFIG_IDE_RESET */
index 3ce424fdba9c269084f0f3f0a4729d745253c9e8..f4a1e8f5a13b714e7e42e277f9b667e14148c591 100644 (file)
@@ -70,7 +70,7 @@ void do_mem_md    (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
        }
 
        if ((flag & CMD_FLAG_REPEAT) == 0) {
-               /* New command specified.  Check for a size spefication.
+               /* New command specified.  Check for a size specification.
                 * Defaults to long if no or incorrect specification.
                 */
                size = 4;
@@ -475,9 +475,12 @@ static void
 mod_mem(int incrflag, int flag, int argc, char *argv[])
 {
        ulong   addr, size, i;
-       uint    nbytes;
+       int     nbytes;
        extern char console_buffer[];
 
+#ifdef CONFIG_BOOT_RETRY_TIME
+       reset_cmd_timeout();    /* got a good command to get here */
+#endif
        /* We use the last specified parameters, unless new ones are
         * entered.
         */
@@ -485,7 +488,7 @@ mod_mem(int incrflag, int flag, int argc, char *argv[])
        size = mm_last_size;
 
        if ((flag & CMD_FLAG_REPEAT) == 0) {
-               /* New command specified.  Check for a size spefication.
+               /* New command specified.  Check for a size specification.
                 * Defaults to long if no or incorrect specification.
                 */
                size = 4;
@@ -514,21 +517,34 @@ mod_mem(int incrflag, int flag, int argc, char *argv[])
                        printf(" %04x", *((ushort *)addr));
                else
                        printf(" %02x", *((u_char *)addr));
-               nbytes = readline (" ? ");
 
-               /* If <CR> is pressed as only input, don't modify current
-                * location and move to next.
-                */
-               if (!nbytes) {
+               nbytes = readline (" ? ");
+               if (nbytes == 0) {
+                       /* <CR> pressed as only input, don't modify current
+                        * location and move to next.
+                        */
                        if (incrflag)
                                addr += size;
                        nbytes = 1;
+#ifdef CONFIG_BOOT_RETRY_TIME
+                       reset_cmd_timeout(); /* good enough to not time out */
+#endif
+               }
+#ifdef CONFIG_BOOT_RETRY_TIME
+               else if (nbytes == -2) {
+                       break;  /* timed out, exit the command  */
                }
+#endif
                else {
                        char *endp;
                        i = simple_strtoul(console_buffer, &endp, 16);
                        nbytes = endp - console_buffer;
                        if (nbytes) {
+#ifdef CONFIG_BOOT_RETRY_TIME
+                               /* good enough to not time out
+                                */
+                               reset_cmd_timeout();
+#endif
                                if (size == 4)
                                        *((uint   *)addr) = i;
                                else if (size == 2)
index 61528d61b72ae0454f996d9b8bc8ec7a02e6e3c0..62e54a82144862b9877b2b412699f747e8b34523 100644 (file)
@@ -136,31 +136,45 @@ do_help (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
         * command help (long version)
         */
        for (i=1; i<argc; ++i) {
-               for (cmdtp=&cmd_tbl[0]; cmdtp->name; cmdtp++) {
-                       if (strncmp(argv[i], cmdtp->name, cmdtp->lmin) == 0) {
+               if ((cmdtp = find_cmd(argv[i])) != NULL) {
 #ifdef CFG_LONGHELP
-                               /* found - print (long) help info */
-                               puts (cmdtp->name);
-                               putc (' ');
-                               if (cmdtp->help) {
-                                       puts (cmdtp->help);
-                               } else {
-                                       puts ("- No help available.\n");
-                               }
-                               putc ('\n');
+                       /* found - print (long) help info */
+                       puts (cmdtp->name);
+                       putc (' ');
+                       if (cmdtp->help) {
+                               puts (cmdtp->help);
+                       } else {
+                               puts ("- No help available.\n");
+                       }
+                       putc ('\n');
 #else  /* no long help available */
-                               if (cmdtp->usage)
-                                       puts (cmdtp->usage);
+                       if (cmdtp->usage)
+                               puts (cmdtp->usage);
 #endif /* CFG_LONGHELP */
-                               goto done;
-                       }
                }
-               printf ("Unknown command '%s' - try 'help'"
-                       " without arguments for list of all known commands\n\n",
-                       argv[i]
-               );
-done:          ;
+               else {
+                       printf ("Unknown command '%s' - try 'help'"
+                               " without arguments for list of all"
+                               " known commands\n\n",
+                               argv[i]
+                       );
+               }
+       }
+}
+
+/***************************************************************************
+ * find command table entry for a command
+ */
+cmd_tbl_t *find_cmd(const char *cmd)
+{
+       cmd_tbl_t *cmdtp;
+
+       /* Search command table - Use linear search - it's a small table */
+       for (cmdtp = &cmd_tbl[0]; cmdtp->name; cmdtp++) {
+               if (strncmp (cmd, cmdtp->name, cmdtp->lmin) == 0)
+                       return cmdtp;
        }
+       return NULL;    /* not found */
 }
 
 cmd_tbl_t cmd_tbl[] = {
index ad24f26ea449404cb5b1026cafdd8713d3778f5e..41339d6f58f908ff8da0b45ac564411a36cc30e2 100644 (file)
 
 #include <ppcboot.h>
 #include <command.h>
-
-int  readline (const char *const prompt);
-void run_command (const char *cmd, cmd_tbl_t *cmdtp, bd_t *bd, int flag);
+#include <cmd_nvedit.h>
+#include <cmd_bootm.h>
 
 static char * delete_char (char *buffer, char *p, int *colp, int *np, int plen);
 static int parse_line (char *, char *[]);
+#if (CONFIG_BOOTDELAY >= 0)
+static int abortboot(int);
+#endif
 
 char        console_buffer[CFG_CBSIZE];                /* console I/O buffer   */
 
 static char erase_seq[] = "\b \b";             /* erase sequence       */
 static char   tab_seq[] = "        ";          /* used to expand TABs  */
 
-#if (CONFIG_COMMANDS & CFG_CMD_RUN)
-void do_run (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]);
+#ifdef CONFIG_BOOT_RETRY_TIME
+static uint64_t endtime = 0;  /* must be set, default is instant timeout */
+static int      retry_time;
 #endif
 
-/****************************************************************************/
+#define        endtick(seconds) (get_ticks() + (uint64_t)(seconds) * get_tbclk())
 
-void main_loop(bd_t *bd)
-{
-       cmd_tbl_t *cmdtp;
+#ifndef CONFIG_BOOT_RETRY_MIN
+#define CONFIG_BOOT_RETRY_MIN CONFIG_BOOT_RETRY_TIME
+#endif
+
+
+/***************************************************************************
+ * Watch for 'delay' seconds for autoboot stop or autoboot delay string.
+ * returns: 0 -  no key string, allow autoboot
+ *          1 - got key string, abort
+ */
 #if (CONFIG_BOOTDELAY >= 0)
-       char *s = getenv ("bootdelay");
-       int bootdelay = s ? (int)simple_strtoul(s, NULL, 10) : 0;
-       int autoboot  = 1;
+# if defined(CONFIG_AUTOBOOT_KEYED)
+static __inline__ int abortboot(int bootdelay)
+{
+       int abort = 0;
+       char ch;
+       uint64_t etime = endtick(bootdelay);
+       char* delaykey = getenv ("bootdelaykey");
+       char* delaymatch;
+       char* stopkey = getenv ("bootstopkey");
+       char* stopmatch;
+
+#  ifdef CONFIG_AUTOBOOT_PROMPT
+       printf (CONFIG_AUTOBOOT_PROMPT, bootdelay);
+#  endif
+
+#  ifdef CONFIG_AUTOBOOT_DELAY_STR
+       if (delaykey == NULL)
+               delaykey = CONFIG_AUTOBOOT_DELAY_STR;
+#  endif
+#  ifdef CONFIG_AUTOBOOT_STOP_STR
+       if (stopkey == NULL)
+               stopkey = CONFIG_AUTOBOOT_STOP_STR;
+#  endif
+
+#  if DEBUG_BOOTKEYS
+       printf("delay key:<%s>\n",delaykey?delaykey:"NULL");
+       printf("stop key:<%s>\n",stopkey?stopkey:"NULL");
+#  endif
+       delaymatch = delaykey;
+       stopmatch = stopkey;
+
+       /* In order to keep up with incoming data, check timeout only
+        * when catch up.
+        */
+       while (!abort && get_ticks() <= etime) {
+               /* abort if matched all of one of the keys */
+               if (delaymatch && !*delaymatch) {
+#  if DEBUG_BOOTKEYS
+                       printf("got delaykey\n");
+#  endif
+                       abort = 1;
+               }
+               if (stopmatch && !*stopmatch) {
+#  if DEBUG_BOOTKEYS
+                       printf("got stopkey\n");
+#  endif
+#  ifdef CONFIG_BOOT_RETRY_TIME
+                       /* don't retry auto boot */
+                       retry_time = -1;
+#  endif
+                       abort = 1;
+               }
+               if (tstc()) {
+                       ch = getc();    /* get the incoming char */
+
+                       if (stopmatch) {
+                               if (*stopmatch != ch)
+                                       stopmatch = stopkey;    /* start over */
+                               if (*stopmatch == ch)
+                                       ++stopmatch;    /* matched 1 more */
+                       }
 
-       if (getenv ("bootcmd") == NULL) {       /* don't try to autoboot */
-               bootdelay = 0;
-               autoboot  = 0;
+                       if (delaymatch) {
+                               if (*delaymatch != ch)
+                                       delaymatch = delaykey;  /* start over */
+                               if (*delaymatch == ch)
+                                       ++delaymatch;   /* matched 1 more */
+                       }
+               }
        }
+#  if DEBUG_BOOTKEYS
+       if (!abort)
+               printf("key timeout\n");
+#  endif
 
-#endif /* CONFIG_BOOTDELAY */
+       return abort;
+}
 
-#if 0
-       printf ("### main_loop entered:\n\n");
-#endif
+# else /* !defined(CONFIG_AUTOBOOT_KEYED) */
 
-       /*
-        * Main Loop for Monitor Command Processing
-        */
+static __inline__ int abortboot(int bootdelay)
+{
+       int abort = 0;
 
-       for (;;) {
-               int flag = 0;
-               int len;
+       printf("Hit any key to stop autoboot: %2d ", bootdelay);
 
-#if (CONFIG_BOOTDELAY >= 0)
+       while (bootdelay > 0) {
+               int i;
 
-               if (autoboot)
-                       printf ("Hit any key to stop autoboot: %2d ", bootdelay);
+               --bootdelay;
+               /* delay 100 * 10ms */
+               for (i=0; !abort && i<100; ++i) {
+                       if (tstc()) {   /* we got a key press   */
+                               abort  = 1;     /* don't auto boot      */
+                               bootdelay = 0;  /* no more delay        */
+                               (void) getc();  /* consume input        */
+                               break;
+                       }
+                       udelay (10000);
+               }
 
-               while (bootdelay > 0) {
-                       int i;
+               printf ("\b\b\b%2d ", bootdelay);
+       }
 
-                       --bootdelay;
-                       /* delay 100 * 10ms */
-                       for (i=0; i<100; ++i) {
-                               if (tstc()) {   /* we got a key press   */
-                                       bootdelay = 0;  /* no more delays       */
-                                       autoboot  = 0;  /* don't auto boot      */
-                                       (void) getc();  /* consume input */
-                                       break;
-                               }
-                               udelay (10000);
-                       }
+       putc ('\n');
 
-                       printf ("\b\b\b%2d ", bootdelay);
-               }
+       return abort;
+}
+# endif        /* CONFIG_AUTOBOOT_KEYED */
+#endif /* CONFIG_BOOTDELAY >= 0 */
 
-               putc ('\n');
+/****************************************************************************/
 
-               if (autoboot) {
-                       autoboot = 0;
+void main_loop(bd_t *bd)
+{
+       static char lastcommand[CFG_CBSIZE] = { 0, };
+       int len;
+       int rc = 1;
+       int flag;
 
-                       run_command ("bootcmd", cmdtp, bd, flag);
+#if (CONFIG_BOOTDELAY >= 0)
+       char *s = getenv ("bootdelay");
+       int bootdelay = s ? (int)simple_strtoul(s, NULL, 10) : 0;
 
-                       continue;
-               }
-               else                    /* No autoboot: read input              */
+#if 0
+       printf ("### main_loop entered:\n\n");
+#endif
+
+# ifdef CONFIG_BOOT_RETRY_TIME
+       s = getenv ("bootretry");
+       if (s != NULL)
+               retry_time = (int)simple_strtoul(s, NULL, 10);
+       else
+               retry_time =  CONFIG_BOOT_RETRY_TIME;
+       if (retry_time >= 0 && retry_time < CONFIG_BOOT_RETRY_MIN)
+               retry_time = CONFIG_BOOT_RETRY_MIN;
+# endif        /* CONFIG_BOOT_RETRY_TIME */
+
+       s = getenv ("bootcmd");
+       if (bootdelay >= 0 && s && !abortboot (bootdelay))
+               run_command (s, bd, 0);
 #endif /* CONFIG_BOOTDELAY */
-               if ((len = readline (CFG_PROMPT)) < 0) {
+
+       /*
+        * Main Loop for Monitor Command Processing
+        */
+       for (;;) {
+#ifdef CONFIG_BOOT_RETRY_TIME
+               if (rc >= 0) {
+                       /* Saw enough of a valid command to
+                        * restart the timeout.
+                        */
+                       reset_cmd_timeout();
+               }
+#endif
+               len = readline (CFG_PROMPT);
+               
+               flag = 0;       /* assume no special flags for now */
+               if (len > 0)
+                       strcpy (lastcommand, console_buffer);
+               else if (len == 0)
+                       flag |= CMD_FLAG_REPEAT;
+#ifdef CONFIG_BOOT_RETRY_TIME
+               else if (len == -2) {
+                       /* -2 means timed out, retry autoboot
+                        */
+                       printf("\nTimed out waiting for command\n");
+                       return;         /* retry autoboot */
+               }
+#endif
+
+               if (len == -1)
                        printf ("<INTERRUPT>\n");
-                       continue;
+               else
+                       rc = run_command (lastcommand, bd, 0);
+
+               if (rc <= 0) {
+                       /* invalid command or not repeatable, forget it */
+                       lastcommand[0] = 0;
                }
-               run_command (len ? NULL : "", cmdtp, bd, flag);
        }
 }
 
+/***************************************************************************
+ * reset command line timeout to retry_time seconds
+ */
+#ifdef CONFIG_BOOT_RETRY_TIME
+void reset_cmd_timeout(void)
+{
+       endtime = endtick(retry_time);
+}
+#endif
+
 /****************************************************************************/
 
 /*
  * Prompt for input and read a line.
- * Return number of read characters
+ * If  CONFIG_BOOT_RETRY_TIME is defined and retry_time >= 0,
+ * time out when time goes past endtime (timebase time in ticks).
+ * Return:     number of read characters
+ *             -1 if break
+ *             -2 if timed out
  */
 int readline (const char *const prompt)
 {
@@ -130,6 +272,12 @@ int readline (const char *const prompt)
        col = plen;
 
        for (;;) {
+#ifdef CONFIG_BOOT_RETRY_TIME
+               while (!tstc()) {       /* while no incoming data */
+                       if (retry_time >= 0 && get_ticks() > endtime)
+                               return (-2);    /* timed out */
+               }
+#endif
                c = getc();
 
                /*
@@ -143,6 +291,7 @@ int readline (const char *const prompt)
                        return (p - console_buffer);
 
                case 0x03:                              /* ^C - break           */
+                       console_buffer[0] = '\0';       /* discard input */
                        return (-1);
 
                case 0x15:                              /* ^U - erase line      */
@@ -350,27 +499,39 @@ static void process_macros (char *input, char *output)
 #endif
 }
 
-/****************************************************************************/
-
-
-static int process_separators (char *s, int len,
-                              cmd_tbl_t *cmdtp, bd_t *bd, int flag)
+/****************************************************************************
+ * returns:
+ *     1  - command executed, repeatable
+ *     0  - command executed but not repeatable, interrupted commands are
+ *          always considered not repeatable
+ *     -1 - not executed (unrecognized, bootd recursion or too many args)
+ *           (If cmd is NULL or "" it is considered unrecognized)
+ */
+int run_command (const char *cmd, bd_t *bd, int flag)
 {
-       extern void do_bootd (cmd_tbl_t *, bd_t *, int, int, char *[]);
-
+       cmd_tbl_t *cmdtp;
        char token[CFG_CBSIZE];
        char finaltoken[CFG_CBSIZE];
-       char *str = s;
+       const char *str = cmd;
        char *argv[CFG_MAXARGS + 1];    /* NULL terminated      */
        int argc;
-       int found;
        int repeatable = 1;
 
+#ifdef DEBUG_PARSER
+       printf ("[RUN_COMMAND] cmd=\"%s\"\n", cmd ? cmd : "NULL");
+#endif
+       if (!cmd || !*cmd)
+               return -1;      /* empty command, do nothing */
+
+       /* Process separators and check for invalid
+        * repeatable commands
+        */
+
 #ifdef DEBUG_PARSER
        printf ("[PROCESS_SEPARATORS] %s\n", s);
 #endif
-       while (*s) {
-               char *sep;
+       while (*str) {
+               const char *sep;
                char *t;
 
                /*
@@ -397,61 +558,50 @@ static int process_separators (char *s, int len,
                printf ("token: \"%s\"\n", token);
 #endif
 
-               /* Process macros into this token and replace them */
+               /* find macros in this token and replace them */
                process_macros (token, finaltoken);
 
                /* Extract arguments */
                argc = parse_line (finaltoken, argv);
 
-               /* Search command table - Use linear search - it's a small table */
-               found = 0;
-               for (cmdtp = &cmd_tbl[0]; (!found) && cmdtp->name; cmdtp++) {
-                       if (strncmp (argv[0], cmdtp->name, cmdtp->lmin) == 0) {
-                               /* found - check max args */
-                               if (argc > cmdtp->maxargs) {
-                                       printf ("Usage:\n%s\n", cmdtp->usage);
-                                       return 0;
-                               }
+               /* Look up command in command table */
+               if ((cmdtp = find_cmd(argv[0])) == NULL) {
+                       printf ("Unknown command '%s' - try 'help'\n", argv[0]);
+                       return -1;      /* give up after bad command */
+               }
+
+               /* found - check max args */
+               if (argc > cmdtp->maxargs) {
+                       printf ("Usage:\n%s\n", cmdtp->usage);
+                       return -1;
+               }
 
 #if (CONFIG_COMMANDS & CFG_CMD_BOOTD)
-                               /* avoid "bootd" recursion */
-                               if ((len == -1) && (cmdtp->cmd == do_bootd)) {
+               /* avoid "bootd" recursion */
+               if (cmdtp->cmd == do_bootd) {
 #ifdef DEBUG_PARSER
-                                       printf ("[%s]\n", finaltoken);
+                       printf ("[%s]\n", finaltoken);
 #endif
-                                       printf ("'bootd' recursion detected\n");
-                                       return 0;
-                               }
+                       if (flag & CMD_FLAG_BOOTD) {
+                               printf ("'bootd' recursion detected\n");
+                               return -1;
+                       }
+                       else
+                               flag |= CMD_FLAG_BOOTD;
+               }
 #endif /* CFG_CMD_BOOTD */
 
-#if (CONFIG_COMMANDS & CFG_CMD_RUN)
-                               /* avoid "run" recursion */
-                               if ((len == -2) && (cmdtp->cmd == do_run)) {
-#ifdef DEBUG_PARSER
-                                       printf ("[%s]\n", finaltoken);
-#endif
-                                       printf ("'run' recursion detected\n");
-                                       return 0;
-                               }
-#endif /* CFG_CMD_RUN */
-                               /* OK - call function */
-                               (cmdtp->cmd) (cmdtp, bd, flag, argc, argv);
+               /* OK - call function to do the command */
+               (cmdtp->cmd) (cmdtp, bd, flag, argc, argv);
 
-                               repeatable &= cmdtp->repeatable;
-                               found = 1;
-                       }
-               }
-               if (!found)
-                       printf ("Unknown command '%s' - try 'help'\n", argv[0]);
+               repeatable &= cmdtp->repeatable;
 
                /* Did the user stop this? */
                if (tstc ())
-                       return 0;
-
-               if (*sep == '\0')
-                       break;
+                       return 0;       /* if stopped then not repeatable */
 
-               str = sep + 1;
+               if (*sep != '\0')
+                       ++str;
        }
 
        return repeatable;
@@ -459,56 +609,6 @@ static int process_separators (char *s, int len,
 
 /****************************************************************************/
 
-/*
- * "cmd" is used to indicate if we are executing normal user input
- * (cmd == NULL), re-executing the last command when the user presses
- * only ENTER (cmd != NULL && strlen(cmd) == 0), or running a command
- * stored in an environment variable ("cmd" contains the name of that
- * variable).
- */
-
-void run_command (const char *cmd,
-                 cmd_tbl_t *cmdtp, bd_t *bd, int flag)
-{
-       static char lastcommand[CFG_CBSIZE] = { 0, };
-       static const char *last_cmd;
-
-       if (cmd) {
-               if (*cmd) {     /* got the name of a variable to run */
-                       char *str = getenv ((char *)cmd);
-
-                       if (!str)
-                               return;
-
-                       strcpy (lastcommand, str);
-                       last_cmd = cmd;
-               } else {        /* re-executing previous command */
-
-                       /* Check if we have a valid command stored */
-                       if (lastcommand[0] == 0)
-                               return;
-
-                       flag |= CMD_FLAG_REPEAT;
-                       last_cmd = "";
-               }
-       } else {                /* cmd == NULL: process user input */
-               strcpy (lastcommand, console_buffer);
-               last_cmd = NULL;
-       }
-#ifdef DEBUG_PARSER
-       printf ("[RUN_COMMAND] last_cmd=\"%s\" -> %s\n",
-               last_cmd ? last_cmd : "NULL", lastcommand);
-#endif
-       /* Process separators and check for non-valid repeatable commands       */
-       if (process_separators (lastcommand, strlen(lastcommand),
-                               cmdtp, bd, flag) == 0) {
-               lastcommand[0] = 0;
-               last_cmd = "";
-       }
-}
-
-/****************************************************************************/
-
 #if (CONFIG_COMMANDS & CFG_CMD_RUN)
 void do_run (cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc, char *argv[])
 {
@@ -520,7 +620,7 @@ void do_run (cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc, char *argv[])
        }
 
        for (i=1; i<argc; ++i) {
-               run_command (argv[i], cmdtp, bd, flag);
+               run_command (getenv (argv[i]), bd, flag);
        }
 }
 #endif
index e2aee5a52d7cd0aa2a3e5c1f76ef9328bdd2dfeb..3bd4a9dcfec5a213052b7ae51252a538d7b1bf8f 100644 (file)
@@ -426,6 +426,94 @@ serial_tstc()
 }
 
 #if (CONFIG_COMMANDS & CFG_CMD_KGDB) 
+/* 
+   AS HARNOIS : according to CONFIG_KGDB_SER_INDEX kgdb uses serial port 
+   number 0 or number 1 
+   - if CONFIG_KGDB_SER_INDEX = 1 => serial port number 0 : 
+   configuration has been already done
+   - if CONFIG_KGDB_SER_INDEX = 2 => serial port number 1 : 
+   configure port 1 for serial I/O with rate = CONFIG_KGDB_BAUDRATE
+*/
+#if (CONFIG_KGDB_SER_INDEX & 2)
+void
+kgdb_serial_init(void)
+{
+  volatile char val;
+  unsigned short br_reg;
+  ulong cpu_clk;
+
+  cpu_clk = get_gclk_freq ();
+  br_reg = (((((cpu_clk/16)/18) * 10) / CONFIG_KGDB_BAUDRATE) + 5) / 10 ;
+  /*
+   * Init onboard 16550 UART
+   */
+  out8(UART1_BASE + UART_LCR, 0x80);  /* set DLAB bit */
+  out8(UART1_BASE + UART_DLL, (br_reg & 0x00ff));  /* set divisor for 9600 baud */
+  out8(UART1_BASE + UART_DLM, ((br_reg & 0xff00) >> 8));  /* set divisor for 9600 baud */
+  out8(UART1_BASE + UART_LCR, 0x03);  /* line control 8 bits no parity */
+  out8(UART1_BASE + UART_FCR, 0x00);  /* disable FIFO */
+  out8(UART1_BASE + UART_MCR, 0x00);  /* no modem control DTR RTS */
+  val = in8(UART1_BASE + UART_LSR);   /* clear line status */
+  val = in8(UART1_BASE + UART_RBR);   /* read receive buffer */
+  out8(UART1_BASE + UART_SCR, 0x00);  /* set scratchpad */
+  out8(UART1_BASE + UART_IER, 0x00);  /* set interrupt enable reg */
+}
+
+
+void putDebugChar
+(const char c)
+{
+  if (c == '\n')
+    serial_putc ('\r');
+  
+  out8(UART1_BASE + UART_THR, c);    /* put character out */
+  
+  /* check THRE bit, wait for transfer done */
+  while ((in8(UART1_BASE + UART_LSR) & 0x20) != 0x20)
+    ;
+}
+
+
+void
+putDebugStr (const char *s)
+{
+  while (*s)
+    {
+      serial_putc (*s++);
+    }
+}
+
+
+int 
+getDebugChar(void)
+{
+  unsigned char        status=0;
+  
+  while(1)
+    {
+      status = in8(UART1_BASE + UART_LSR);
+      if ((status&asyncLSRDataReady1)!=0x0)
+        {
+          break;
+        }
+      else if ((status&(asyncLSRFramingError1|asyncLSROverrunError1|
+                        asyncLSRParityError1|asyncLSRBreakInterrupt1))!=0)
+        {
+          out8(UART1_BASE + UART_LSR, asyncLSRFramingError1|asyncLSROverrunError1|
+               asyncLSRParityError1|asyncLSRBreakInterrupt1);
+        }
+    }
+  return(0x000000ff&(int)in8(UART1_BASE));
+}
+
+
+void
+kgdb_interruptible(int yes)
+{
+return;
+}
+
+#else 
 
 void
 kgdb_serial_init(void)
@@ -456,6 +544,7 @@ kgdb_interruptible (int yes)
 {
        return;
 }
+#endif
 #endif /* CFG_CMD_KGDB */
 
 #endif  /* CONFIG_PPC405 */
diff --git a/doc/README.autoboot b/doc/README.autoboot
new file mode 100644 (file)
index 0000000..d95d987
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ * (C) Copyright 2001
+ * Dave Ellis, SIXNET, dge@sixnetio.com
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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
+ */
+
+Using autoboot configuration options
+====================================
+
+The basic autoboot configuration options are documented in the main
+PPCBoot README. See it for details. They are:
+
+  bootdelay
+  bootcmd
+  CONFIG_BOOTDELAY
+  CONFIG_BOOTCOMMAND
+
+Some additional options that make autoboot safer in a production
+product are documented here.
+
+Why use them?
+-------------
+
+The basic autoboot feature allows a system to automatically boot to
+the real application (such as Linux) without a user having to enter
+any commands. If any key is pressed before the boot delay time
+expires, PPCBoot stops the autoboot process, gives a PPCBoot prompt
+and waits forever for a command. That's a good thing if you pressed a
+key because you wanted to get the prompt.
+
+It's not so good if the key press was a stray character on the
+console serial port, say because a user who knows nothing about
+PPCBoot pressed a key before the system had time to boot. It's even
+worse on an embedded product that doesn't have a console during
+normal use. The modem plugged into that console port sends a
+character at the wrong time and the system hangs, with no clue as to
+why it isn't working.
+
+You might want the system to autoboot to recover after an external
+configuration program stops autoboot. If the configuration program
+dies or loses its connection (modems can disconnect at the worst
+time) PPCBoot will patiently wait forever for it to finish.
+
+These additional configuration options can help provide a system that
+boots when it should, but still allows access to PPCBoot.
+
+What they do
+------------
+
+  CONFIG_BOOT_RETRY_TIME
+  CONFIG_BOOT_RETRY_MIN
+
+  bootretry environment variable
+
+        These options determine what happens after autoboot is
+        stopped and PPCBoot is waiting for commands.
+
+        CONFIG_BOOT_RETRY_TIME must be defined to enable the boot
+        retry feature. If the environment variable 'bootretry' is
+        found then its value is used, otherwise the retry timeout is
+        CONFIG_BOOT_RETRY_TIME. CONFIG_BOOT_RETRY_MIN is optional and
+        defaults to CONFIG_BOOT_RETRY_TIME. All times are in seconds.
+
+        If the retry timeout is negative, the PPCBoot command prompt
+        never times out. Otherwise it is forced to be at least
+        CONFIG_BOOT_RETRY_MIN seconds. If no valid PPCBoot command is
+        entered before the specified time the boot delay sequence is
+        restarted. Each command that PPCBoot executes restarts the
+        timeout.
+
+        If CONFIG_BOOT_RETRY_TIME < 0 the feature is there, but
+        doesn't do anything unless the environment variable
+        'bootretry' is >= 0.
+
+  CONFIG_AUTOBOOT_KEYED
+  CONFIG_AUTOBOOT_PROMPT
+  CONFIG_AUTOBOOT_DELAY_STR
+  CONFIG_AUTOBOOT_STOP_STR
+
+  bootdelaykey environment variable
+  bootstopkey  environment variable
+
+        These options give more control over stopping autoboot. When
+        they are used a specific character or string is required to
+        stop or delay autoboot.
+
+       Define CONFIG_AUTOBOOT_KEYED (no value required) to enable
+       this group of options.  CONFIG_AUTOBOOT_DELAY_STR,
+       CONFIG_AUTOBOOT_STOP_STR or both should be specified (or
+       specified by the corresponding environment variable),
+       otherwise there is no way to stop autoboot.
+
+        CONFIG_AUTOBOOT_PROMPT is displayed before the boot delay
+        selected by CONFIG_BOOTDELAY starts. If it is not defined
+        there is no output indicating that autoboot is in progress.
+        If "%d" is included, it is replaced by the number of seconds
+        remaining before autoboot will start, but it does not count
+        down the seconds. "autoboot in %d seconds\n" is a reasonable
+        prompt.
+
+        If CONFIG_AUTOBOOT_DELAY_STR or bootdelaykey is specified and
+        this string is received from console input before autoboot
+        starts booting, PPCBoot gives a command prompt. The PPCBoot
+        prompt will time out if CONFIG_BOOT_RETRY_TIME is used,
+        otherwise it never times out.
+
+        If CONFIG_AUTOBOOT_STOP_STR or bootstopkey is specified and
+        this string is received from console input before autoboot
+        starts booting, PPCBoot gives a command prompt. The PPCBoot
+        prompt never times out, even if CONFIG_BOOT_RETRY_TIME is
+        used.
+
+        The string recognition is not very sophisticated. If a
+        partial match is detected, the first non-matching character
+        is checked to see if starts a new match. There is no check
+        for a shorter partial match, so it's best if the first
+        character of a key string does not appear in the rest of the
+        string.
+
index 7715cd1e183ad13cc23202792327688999077d87..8386e9a95a63dea97149d403b985059a32ab8200 100644 (file)
@@ -61,7 +61,8 @@ extern        cmd_tbl_t cmd_tbl[];
                                { name, lmin, maxargs, rep, cmd, usage }
 #endif
 
-
+/* common/command.c */
+cmd_tbl_t *find_cmd(const char *cmd);
 
 /*
  * Monitor Command
@@ -79,6 +80,7 @@ typedef       void    command_t (cmd_tbl_t *, bd_t *, int, int, char *[]);
  * Command Flags:
  */
 #define CMD_FLAG_REPEAT                0x0001  /* repeat last command          */
+#define CMD_FLAG_BOOTD         0x0002  /* command is from bootd        */
 
 /*
  * Configurable monitor commands definitions have been moved
index 8ad2b470dc16e4a8c7136812d8854a984540a4cf..0d82ed8a04032e8fe5fa57479a7c2282e7f6e552 100644 (file)
 /* Atmel 24C64 has 32-byte page write mode using last 5 bits of the address */
 #define        CFG_EEPROM_PAGE_WRITE_BITS      5
 
-#if 0
-#define CONFIG_BOOT_RETRY_TIME 120     /* boot if no command in 120 seconds */
+#if 1
+#define CONFIG_BOOT_RETRY_TIME 60      /* boot if no command in 60 seconds */
+#endif
+
+#if 1
+#define CONFIG_AUTOBOOT_KEYED          /* use key strings to stop autoboot */
+#define CONFIG_AUTOBOOT_PROMPT         "autoboot in %d seconds\n"
+#define CONFIG_AUTOBOOT_DELAY_STR      "delayabit"
+#define CONFIG_AUTOBOOT_STOP_STR       " " /* easy to stop for now */
 #endif
 
 #endif /* __CONFIG_H */
index 56df84328cfb450b4e8f35cb8ff5669a48ba897c..17c833ccc5924b921d1718bc389505f5ccfdca47 100644 (file)
@@ -140,8 +140,6 @@ typedef     struct  init_data {
 /*
  * Function Prototypes
  */
-
-void   main_loop     (bd_t *);
 void   hang          (void);
 
 
@@ -150,8 +148,10 @@ long int initdram (int);
 void   display_options  (void);
 
 /* common/main.c */
-int    readline      (const char *const prompt);
-void   command_repeat_off (void);
+void   main_loop       (bd_t *bd);
+int    run_command     (const char *cmd, bd_t *bd, int flag);
+int    readline        (const char *const prompt);
+void   reset_cmd_timeout(void);
 
 /* common/board.c */
 void   board_init_f  (ulong);
index f67c49eb5b02791d1e8d408391603670292ea845..16ae6f4d3001142760bcd7a83a802b074a6455eb 100644 (file)
@@ -305,7 +305,7 @@ static int BootpExtended (u8 *e)
      e  += 32;
 #endif
 
-    *e = 255;          /* End of the list */
+    *e++ = 255;                /* End of the list */
     
     return e - start ;
 }