summaryrefslogtreecommitdiff
path: root/ecos/packages/redboot
diff options
context:
space:
mode:
authorMichael Gielda <mgielda@antmicro.com>2014-04-03 14:53:04 +0200
committerMichael Gielda <mgielda@antmicro.com>2014-04-03 14:53:04 +0200
commitae1e4e08a1005a0c487f03ba189d7536e7fdcba6 (patch)
treef1c296f8a966a9a39876b0e98e16d9c5da1776dd /ecos/packages/redboot
parentf157da5337118d3c5cd464266796de4262ac9dbd (diff)
Added the OS files
Diffstat (limited to 'ecos/packages/redboot')
-rw-r--r--ecos/packages/redboot/current/ChangeLog4264
-rw-r--r--ecos/packages/redboot/current/cdl/redboot.cdl1350
-rw-r--r--ecos/packages/redboot/current/doc/.cvsignore11
-rw-r--r--ecos/packages/redboot/current/doc/makefile54
-rw-r--r--ecos/packages/redboot/current/doc/redboot.sgml734
-rw-r--r--ecos/packages/redboot/current/doc/redboot_cmds.sgml4090
-rw-r--r--ecos/packages/redboot/current/doc/redboot_epilogue.sgml3
-rw-r--r--ecos/packages/redboot/current/doc/redboot_installing.sgml6832
-rw-r--r--ecos/packages/redboot/current/doc/redboot_main.sgml117
-rw-r--r--ecos/packages/redboot/current/doc/redboot_rebuilding.sgml372
-rw-r--r--ecos/packages/redboot/current/include/elf.h703
-rw-r--r--ecos/packages/redboot/current/include/fis.h107
-rw-r--r--ecos/packages/redboot/current/include/flash_config.h109
-rw-r--r--ecos/packages/redboot/current/include/fs/disk.h172
-rw-r--r--ecos/packages/redboot/current/include/fs/e2fs.h198
-rw-r--r--ecos/packages/redboot/current/include/fs/fileio.h60
-rw-r--r--ecos/packages/redboot/current/include/fs/ide.h103
-rw-r--r--ecos/packages/redboot/current/include/net/bootp.h316
-rw-r--r--ecos/packages/redboot/current/include/net/http.h71
-rw-r--r--ecos/packages/redboot/current/include/net/net.h644
-rw-r--r--ecos/packages/redboot/current/include/net/tftp.h141
-rw-r--r--ecos/packages/redboot/current/include/net/tftp_support.h99
-rw-r--r--ecos/packages/redboot/current/include/redboot.h526
-rw-r--r--ecos/packages/redboot/current/include/sib.h142
-rw-r--r--ecos/packages/redboot/current/src/alias.c172
-rw-r--r--ecos/packages/redboot/current/src/caches.c99
-rw-r--r--ecos/packages/redboot/current/src/cksum.c94
-rw-r--r--ecos/packages/redboot/current/src/decompress.c314
-rw-r--r--ecos/packages/redboot/current/src/dump.c156
-rw-r--r--ecos/packages/redboot/current/src/fconfig.c1201
-rw-r--r--ecos/packages/redboot/current/src/flash.c2012
-rw-r--r--ecos/packages/redboot/current/src/flash_load.c182
-rw-r--r--ecos/packages/redboot/current/src/flash_load.h68
-rw-r--r--ecos/packages/redboot/current/src/fs/disk.c439
-rw-r--r--ecos/packages/redboot/current/src/fs/e2fs.c614
-rw-r--r--ecos/packages/redboot/current/src/fs/fileio.c765
-rw-r--r--ecos/packages/redboot/current/src/fs/ide.c527
-rw-r--r--ecos/packages/redboot/current/src/gunzip.c119
-rw-r--r--ecos/packages/redboot/current/src/io.c858
-rw-r--r--ecos/packages/redboot/current/src/iomem.c170
-rw-r--r--ecos/packages/redboot/current/src/load.c912
-rw-r--r--ecos/packages/redboot/current/src/main.c787
-rw-r--r--ecos/packages/redboot/current/src/mcmp.c133
-rw-r--r--ecos/packages/redboot/current/src/mcopy.c133
-rw-r--r--ecos/packages/redboot/current/src/mfill.c111
-rw-r--r--ecos/packages/redboot/current/src/misc_funs.c80
-rw-r--r--ecos/packages/redboot/current/src/net/arp.c210
-rw-r--r--ecos/packages/redboot/current/src/net/bootp.c397
-rw-r--r--ecos/packages/redboot/current/src/net/cksum.c123
-rw-r--r--ecos/packages/redboot/current/src/net/dns.c327
-rw-r--r--ecos/packages/redboot/current/src/net/enet.c247
-rw-r--r--ecos/packages/redboot/current/src/net/http_client.c258
-rw-r--r--ecos/packages/redboot/current/src/net/icmp.c125
-rw-r--r--ecos/packages/redboot/current/src/net/inet_addr.c117
-rw-r--r--ecos/packages/redboot/current/src/net/ip.c214
-rw-r--r--ecos/packages/redboot/current/src/net/net_io.c950
-rw-r--r--ecos/packages/redboot/current/src/net/ping.c246
-rw-r--r--ecos/packages/redboot/current/src/net/pktbuf.c166
-rw-r--r--ecos/packages/redboot/current/src/net/tcp.c937
-rw-r--r--ecos/packages/redboot/current/src/net/tftp_client.c316
-rw-r--r--ecos/packages/redboot/current/src/net/timers.c134
-rw-r--r--ecos/packages/redboot/current/src/net/udp.c266
-rw-r--r--ecos/packages/redboot/current/src/parse.c492
-rw-r--r--ecos/packages/redboot/current/src/syscall.c654
-rw-r--r--ecos/packages/redboot/current/src/ticks.c75
-rw-r--r--ecos/packages/redboot/current/src/time_date.cxx123
-rw-r--r--ecos/packages/redboot/current/src/version.c96
-rw-r--r--ecos/packages/redboot/current/src/xyzModem.c595
-rw-r--r--ecos/packages/redboot/current/src/xyzModem.h82
69 files changed, 38314 insertions, 0 deletions
diff --git a/ecos/packages/redboot/current/ChangeLog b/ecos/packages/redboot/current/ChangeLog
new file mode 100644
index 0000000..e8b934f
--- /dev/null
+++ b/ecos/packages/redboot/current/ChangeLog
@@ -0,0 +1,4264 @@
+2012-03-06 Grant Edwards <grant.b.edwards@gmail.com>
+
+ * src/net/net_io.c:
+ * cdl/redboot.cdl: Added new CDL option
+ CYGPKG_REDBOOT_NETWORKING_BOOTP to control whether BOOTP/DHCP
+ support is built into Redboot. Moved "DEFAULT_NO_BOOTP" option
+ into the new package.
+ [ Bugzilla 1001177 ]
+
+ * src/net/bootp.c:
+ * cdl/redboot.cdl: Re-wrote BOOTP/DHCP client code to fix retry
+ mechanism and to fix race conditions that were corrupting the
+ received IP configuration data. Added verbose BOOTP/DHCP output
+ CDL option.
+ [ Bugzilla 1001177 ]
+
+
+2011-12-02 John Dallaway <john@dallaway.org.uk>
+
+ * cdl/redboot.cdl: Fix typographical error. Issue reported by
+ Keith Smith. [ Bugzilla 1001403 ]
+
+2010-04-23 John Dallaway <john@dallaway.org.uk>
+
+ * src/net/dns.c: Initialise DNS domain with an empty string to
+ avoid possible invalid memory access. Issue reported by
+ Kirill Berezin.
+
+2009-06-24 Nick Garnett <nickg@ecoscentric.com>
+
+ * cdl/redboot.cdl:
+ * src/main.c (cyg_start): Added options and code to reinitialize
+ the heap, if it exists, to an arena cut off the end of the
+ workspace.
+ [Imported from eCosPro sources, mainly to support use of
+ filesystems in RedBoot].
+
+2009-06-02 Ross Younger <wry@ecoscentric.com>
+
+ * redboot.cdl: REDBOOT_IO_FILEIO requires CYGPKG_IO
+
+2009-04-20 Andrew Lunn <andrew@lunn.ch>
+
+ * src/net/tcp.c (__tcp_abort): Ensure the connection is closed
+ before returning. This fixes a race condition which Ilko Iliev
+ <iliev@ronetix.at> found when performing two back to back http
+ transfers.
+
+2009-04-02 Rene Schipp von Branitz Nielsen <rbn@vitesse.com>
+
+ * src/flash.c: Fix compilation warnings when redundant FIS
+ is selected.
+
+2009-03-25 Sergei Gavrikov <sergei.gavrikov@gmail.com>
+
+ * src/main.c: Move platform info behind GPL banner.
+ [ Bugzilla 1000688 ]
+
+2009-03-20 John Dallaway <john@dallaway.org.uk>
+
+ * doc/redboot_cmds.sgml: Add note concerning the termination of
+ ELF downloads once all relevant sections have been transferred.
+ [ Bugzilla 1000711 ]
+
+ * doc/redboot_main.sgml: Update copyright notice.
+
+ * src/main.c (do_baud_rate): Wait for 10s when changing serial
+ baud to accommodate terminal emulators which do not provide
+ rapid access to this parameter.
+
+ * src/main.c (do_version): Tidy RAM availability message.
+ [ Bugzilla 1000712 ]
+
+2009-03-09 Gary Thomas <gary@mlbassoc.com>
+
+ * src/io.c: Better handling of history - commands now have
+ a [fixed] virtual number over time. This makes !nn work correctly.
+ Fixes BZ#1000714
+
+2009-03-04 Gary Thomas <gary@mlbassoc.com>
+
+ * src/fconfig.c (get_config): Simplify memcpy() call to
+ work around GCC 4.3 code generation error. BZ#1000672
+
+2009-02-20 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/flash.c (do_flash_init): Call cyg_flash_init() with
+ NULL argument.
+
+2009-02-19 John Dallaway <john@dallaway.org.uk>
+
+ * src/main.c: Update copyright notice.
+
+2009-02-19 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/flash.c (do_flash_init): Update for minor flash API
+ mod to call cyg_flash_set_global_printf() to set printf
+ function.
+
+2009-02-06 John Dallaway <john@dallaway.org.uk>
+
+ * cdl/redboot.cdl: Fix documentation reference.
+
+2008-11-20 Bart Veer <bartv@ecoscentric.com>
+
+ * src/fconfig.c (flash_lookup_config): add a sanity check to
+ reduce the risk of RedBoot going into an infinite loop.
+
+2008-11-16 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * cdl/redboot.cdl, src/flash.c, src/fconfig.c:
+ Flash-related eCosCentric changes to these files (including a
+ merge of the flashv2 work) have been merged. Changes have been
+ directly interleaved below on the correct dates.
+
+2008-11-14 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/flash.c (fis_lock): Revert patch of 2005-10-05 which disabled
+ locking entirely if FIS was disabled. Was better fixed by patch of
+ 2006-02-17.
+ (fis_list): Revert patch of 2007-04-03 to avoid skipping entries
+ at 0x0. Replaced by anoncvs patch of 2007-06-02 for consistency.
+
+2008-09-11 Nick Garnett <nickg@ecoscentric.com>
+
+ * src/flash.c (fis_create, fis_write, fis_erase): Change alignment
+ test to cope with flash blocks that are not a power of 2 in size.
+
+2008-06-18 Bart Veer <bartv@ecoscentric.com>
+
+ * src/fconfig.c, src/flash.c, src/io.c, src/load.c, src/main.c,
+ src/xyzModem.c, include/redboot.h: more signed vs. unsigned char
+ issues.
+
+2008-05-20 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/fs/e2fs.c (e2fs_mount): Avoid compiler strict aliasing
+ problem.
+
+ * include/fis.h (struct fis_image_desc): Make fis name be
+ signed char to reduce warnings.
+ * include/flash_config.h (struct _config): Make config_data
+ be signed char to reduce warnings.
+ * include/redboot.h: mon_write_char and mon_read_char_with_timeout
+ take unsigned char, to reduce warnings.
+ * src/parse.c: Add const to err_printf format.
+ * src/fconfig.c: Many signed/unsigned warning cleanups.
+ * src/io.c: Ditto.
+ * src/xyzModem.c: Ditto.
+ * src/load.c: Ditto.
+ * src/flash.c: Ditto.
+
+2007-11-21 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/flash.c (fis_create): Allow length to be inferred if same
+ mem address given as prior load address.
+
+2007-08-28 Gary Thomas <gary@mlbassoc.com>
+
+ * src/flash.c (do_flash_init): Memory allocation was slightly
+ incorrect - 'workspace_end' should always be used to find
+ the end of available memory.
+
+2007-08-08 Peter Korsgaard <peter.korsgaard@barco.com>
+
+ * include/net/http.h:
+ * src/net/http_client.c: Add HTTP_FORBIDDEN error code for 403
+ Forbidden response.
+
+2007-06-03 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * src/net/net_io.c: (do_ip_addr): Option to set domain name.
+ * doc/redboot_cmds.sgml: Document new option.
+
+2007-06-03 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
+
+ * cdl/redboot.cdl: CDL to control the use of DNS domain name.
+ * src/net/bootp.c: Get the domain name from the reply.
+ * src/net/dns.c: Domain name from CDL, fconfig and DHCP.
+
+2007-06-02 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
+
+ * src/flash.c: (fis_list): fis list will now list an image
+ which happens to start at address 0.
+
+2007-04-11 Gary Thomas <gary@mlbassoc.com>
+2007-04-11 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/fs/fileio.c: Temporary kludge to treat flash correctly if either
+ flash v1 or flash v2 used with this file.
+ (do_mount): silence warning. Include accidentally omitted printf arg.
+ (do_list): silence warning.
+
+2007-04-03 Bart Veer <bartv@ecoscentric.com>
+
+ * src/flash.c (fis_list): don't skip entries at location 0x0
+
+2007-01-22 Peter Korsgaard <peter.korsgaard@barco.com>
+
+ * src/load.c (do_load): Reset entry address before load so
+ go/exec commands will fail after an incomplete upload.
+
+2006-12-18 John Dallaway <jld@ecoscentric.com>
+
+ * src/flash.c, src/fconfig.c: Eliminate some compiler warnings.
+
+2006-12-06 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/flash.c (find_free): When eliminating collapsed free chunks,
+ don't decrement num_chunks as a side effect every loop!
+
+2006-12-04 Bart Veer <bartv@ecoscentric.com>
+
+ * src/flash.c, src/main.c: eliminate some compiler warnings.
+
+2006-11-28 David Fernandez <dfernandez@cct.co.uk>
+
+ * cdl/redboot.cdl: Modified to change the option
+ CYGDAT_REDBOOT_DEFAULT_NETWORK_DEVICE to make it independent of
+ CYGSEM_REDBOOT_FLASH_CONFIG, changes in net_io.c will allow to
+ specify a default interface in terms of the name and its position
+ in the table of interfaces for the driver.
+
+ * src/net/net_io.c: Modified to allow
+ CYGDAT_REDBOOT_DEFAULT_NETWORK_DEVICE to be used even with no flash
+ available.
+ Bug regarding CYGSEM_REDBOOT_NETWORK_INIT_ONE_DEVICE fixed, so that
+ when working with several network interfaces, and the default one
+ fails to initialize, only the first successfully initialized one is
+ used.
+
+2006-11-19 Andrew Lunn <lunn@laptop.lunn.ch>
+
+ * src/load.c: Only call valid_address() if
+ CYGSEM_REDBOOT_VALIDATE_USER_RAM_LOADS is enabled.
+
+2006-11-01 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/flash.c (fis_create): Ensure flash_addr is always inferred
+ to come from unused space if not set.
+
+2006-10-19 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/flash.c (fis_create): If not copying, no reason to insist
+ on a flash address being set.
+
+2006-09-06 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * cdl/redboot.cdl: Fix description of CYGSEM_REDBOOT_DISK_IDE.
+ Error pointed out by Wang Cui
+
+2006-08-28 Sergei Gavrikov <w3sg@SoftHome.net>
+
+ * src/net/tftp_client.c (tftp_error_ack): Fix compiler warnings.
+
+2006-07-21 David Ho <davidkwho@gmail.com>
+
+ * src/flash.c (fis_start_update_directory): Fix build error when
+ redundant FIS selected and locking is not enabled/supported.
+
+2006-06-16 Nick Garnett <nickg@ecoscentric.com>
+
+ * src/flash.c (flash_reserved): Value for the macro used when this
+ feature is disabled should be false not true.
+
+2006-06-09 Nick Garnett <nickg@ecoscentric.com>
+
+ * cdl/redboot.cdl:
+ * src/flash.c (flash_reserved): Added config option,
+ CYGNUM_REDBOOT_FLASH_RESERVED_DEVICES, and code to check for a
+ list of reserved flash devices that should not be used for FIS
+ file allocation.
+
+2006-05-24 Gary Thomas <gary@mlbassoc.com>
+
+ * src/net/net_io.c (do_ip_addr): Bail out if no networking.
+
+2006-05-23 Gary Thomas <gary@mlbassoc.com>
+
+ * src/flash.c (fis_update_directory): Fix problems building on systems
+ with no FLASH locking.
+
+2006-04-19 Alexander Neundorf <alexander.neundorf@jenoptik.com>
+ * src/flash.c, src/main.c, src/fconfig.c:
+ * include/fis.h, include/redboot.h:
+ * cdl/redboot.cdl:
+ add support for redundant FIS tables, configurable via
+ CYGOPT_REDBOOT_REDUNDANT_FIS
+
+2006-04-07 Grant Edwards <grante@visi.com>
+
+ * src/net/net_io.c (net_io_getc_nonblock):
+ Handle TELNET_WILL (reject same as TELNET_DO)
+
+2006-04-03 Lars Povlsen <lpovlsen@vitesse.com>
+
+ * src/flash.c (fis_update_directory): Fixed flash region size when
+ CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG is enabled.
+
+2006-03-27 Gary Thomas <gary@mlbassoc.com>
+
+ * src/net/tcp.c (__tcp_write_block): Fix calculation of actual
+ total number of bytes sent (from Wolfgang Koebler)
+
+2006-03-21 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/flash.c (find_free): Fix typo in last change.
+
+2006-03-16 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/flash.c (find_free): Fix indentation.
+ Trivial optimisation when free chunk collapsed.
+ When splitting chunks, be sure to insert not overwrite - there may be
+ a subsequent free chunk.
+ Even if out of free chunks when splitting, be sure to mark end of this
+ chunk as used, to avoid it inappropriately being reported as free.
+
+2006-03-10 Bart Veer <bartv@ecoscentric.com>
+
+ * src/flash.c (find_free): fix boundary condition when an fis img
+ is right at the end of memory.
+
+2006-02-25 Oliver Munz <munz@speag.ch>
+ Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
+ * src/flash_load.c (NEW): Implements access to flash
+ * src/load.c: Allow load command to load directly into flash
+ * cdl/redboot.c (CYGBLD_REDBOOT_LOAD_INTO_FLASH) Control new
+ feature, disabled by default.
+ * cdl/main.c (cyg_start): Assert check to see if we have
+ overflowed the workspace.
+ * doc/redboot_cmds.sgml: Document new flag.
+
+2006-02-24 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/fs/fileio.c (do_list): Use getcwd for current directory,
+ rather than "." which may not be implemented in the FS.
+
+2006-02-17 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * src/flash.c (fis_lock & fis_unlock): Allow compilation without
+ FIS being enabled.
+ * src/flash.c (fis_update_directory): When reading/writing flash
+ use the full size of the fis directory, not just one block.
+
+2006-01-26 John Dallaway <jld@ecoscentric.com>
+
+ * src/flash.c (_flash_info): Tidy presentation of flash block info.
+
+2006-01-17 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/flash.c (fis_init): Default data_length = FIS partition
+ size for special partitions.
+
+2005-12-22 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/flash.c (find_free): adjust base only for appropriate device.
+ (fis_free): Fix up case for !CYGDAT_REDBOOT_FIS_MAX_FREE_CHUNKS
+ to correctly scan for blank regions.
+ Remove obsolete version of same.
+ (fis_find_free): Adapt fis_free changes for this.
+
+2005-12-12 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/flash.c (fis_free): Rewrite to improve support
+ for multiple flash devices. Still not really right - needs
+ wider changes.
+ (fis_find_free): Better support multiple flash devices.
+ Far from perfect yet though. Minor improvement on what
+ was there before though.
+
+2005-11-23 Peter Korsgaard <peter.korsgaard@barco.com>
+
+ * src/gunzip.c (do_gunzip): Fixed diag_printf format string warnings.
+
+2005-10-17 Gary Thomas <gary@mlbassoc.com>
+
+ * src/iomem.c (do_iopeek): Correct number of options.
+
+2005-10-05 Nick Garnett <nickg@ecoscentric.com>
+
+ * src/flash.c: Changes to various ifdefs to allow FCONFIG to be
+ used independently of FIS. It was always intended that this be
+ possible, but over time it suffered a little bitrot.
+
+2005-09-30 Nick Garnett <nickg@ecoscentric.com>
+
+ * cdl/redboot.cdl: Move CYGNUM_REDBOOT_FLASH_BASE out of
+ CYGPKG_REDBOOT_FLASH component so that it can be used from RBL
+ when CYGPKG_REDBOOT_FLASH is disabled.
+
+2005-09-26 Bart Veer <bartv@ecoscentric.com>
+
+ * src/flash.c: put flag into .bss rather than .data, avoids
+ problems if soft reset involves branching to the entry point and
+ .data does not get reinitialized.
+
+2005-09-13 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/parse.c (redboot_exec): Conditionalise use of
+ __mem_fault_handler to only be when stubs are included.
+ (error_handler): Ditto for this function.
+
+ * src/main.c (cyg_start): Conditionalise use of
+ __mem_fault_handler to only be when stubs are included.
+ (do_go): Ditto.
+ (error_handler): Ditto for this function.
+
+ * cdl/redboot.cdl: RedBoot always needs to claim the virtual
+ vector comms, so express that explicitly.
+
+2005-09-09 Andrew Dyer <adyer@righthandtech.com>
+
+ * src/load.c: add calls to redboot_getc_terminate before exiting
+ load_elf_image() in various error scenarios, change the final call
+ to redboot_getc_terminate to have the error flag set. This will
+ cause a tftp nak and close down the connection since for ELF files
+ we don't read the whole content but end the connection when the
+ runnable parts are in.
+
+ * src/net/tftp_client.c: add tftp_error() to send an error back to
+ the server. define tftp_stream_terminate() and pass it into the
+ redboot interface.
+
+2005-09-08 Gary Thomas <gary@mlbassoc.com>
+
+ * src/io.c:
+ * include/redboot.h:
+ * doc/redboot.sgml:
+ * cdl/redboot.cdl: Add support for ANSI keyboard cursor keys
+ such as HOME/END/Arrows
+
+2005-09-08 Stefan Sommerfeld <sommerfeld@mikrom.com>
+ * src/flash.c: Fix usage of "fis create", more arguments are optional
+ Set mem_base to mem_addr instead of flash_addr for a loaded image
+
+2005-09-03 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * cdl/redboot.cdl: White space changes to aid readability.
+
+2005-09-03 Isaac Claymore <iclaymore@gmail.com>
+
+ * src/flash.c (fis_create): Print an error if the FIS directory is
+ full when we try to create a new entry.
+
+2005-08-17 David Vrabel <dvrabel@arcom.com>
+
+ * cdl/redboot.cdl (CYGNUM_REDBOOT_DEFAULT_NETWORK_DEVICE): Removed
+ since isn't used anywhere.
+ * cdl/redboot.cdl (CYGDAT_REDBOOT_DEFAULT_NETWORK_DEVICE): New option
+ to specify the name of the default network device.
+
+ * src/net/net_io.c: Use CYGDAT_REDBOOT_DEFAULT_NETWORK_DEVICE as
+ the default to the net_device config option.
+
+2005-08-15 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/fconfig.c (flash_write_config): Warning cleanup.
+ * src/net/net_io.c (do_ip_addr): Warning cleanup.
+ * src/flash.c (fis_create): Warning cleanup.
+
+2005-08-09 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * include/net/net.h: Include redboot.h for tick functions.
+
+2005-08-05 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * include/net/net.h: Pull tick functions into redboot.h as they
+ are used more widely than the net stack.
+ * include/redboot.h: Declare tick functions.
+ * src/main.c (cyg_start): Correctly compute workspace_end so it
+ works even on high RAM values [bug #1000202].
+ Don't use workspace_end directly for context init - it gets
+ modified.
+ (do_go): Don't use workspace_end directly for context init -
+ it gets modified.
+
+2005-07-06 Isaac Claymore <iclaymore@gmail.com>
+
+ * src/fconfig.c: (get_config): Verify the length of the script is
+ less than MAX_SCRIPT_LENGTH.
+
+2005-06-29 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * doc/redboot_cmds.sgml:
+ * src/dump.c: Fix the usage for dump and x command.
+
+2005-06-29 Peter Korsgaard <jacmet@sunsite.dk>
+
+ * src/flash.c (find_free): Maintain sort order when splitting
+ chunks.
+
+2005-06-27 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * src/net/enet.c (ntohs): Return type is a short.
+
+2005-06-22 Peter Korsgaard <jacmet@sunsite.dk>
+
+ * src/flash.c (fis_list, fis_free, fis_create):
+ * src/iomem.c (do_iopeek): Fixed compiler warnings about formats
+ strings for diag_printf.
+
+2005-06-09 David Vrabel <dvrabel@arcom.com>
+
+ * src/xyzModem.c: Use the Ymodem length field by #define'ing
+ USE_YMODEM_LENGTH.
+ (xyzModem_stream_read): Only discard runs of ^Z's if we're using
+ Xmodem or the Ymodem length field is 0. This allows binary files
+ with runs of ^Z's to be transferred.
+
+2005-06-07 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * src/flash.c (_flash_info): Fixed a warning about a diag_printf
+ format string.
+
+2005-05-27 David Vrabel <dvrabel@arcom.com>
+
+ * src/main.c (cyg_start): Expand aliases even if
+ CYGSEM_REDBOOT_FLASH_ALIASES is not enabled since there are some
+ hardcoded aliases (e.g., FREEMEMLO).
+
+2005-05-04 David Vrabel <dvrabel@arcom.com>
+
+ * src/alias.c (lookup_alias): The expansion of FREEMEMLO and
+ FREEMEMHI needs a leading '0x' so they're recognized as hex.
+
+2005-04-21 Ian Campbell <icampbell@arcom.com>
+
+ * src/net/net_io.c (net_init): Don't initialize the network if we
+ don't have an IP address.
+
+ * src/net/net_io.c (do_ip_addr): Add a '-b' option to obtain IP
+ address using BOOTP/DHCP.
+
+ * doc/redboot_cmds.sgml: Document the new '-b' option to the
+ 'ip_address' command.
+
+ * src/decompress.c (zcfree): Remove unnecessary variable
+ reinitialisation.
+
+
+2005-04-17 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * src/alias.c (lookup_alias): Fix compiler warnings about formats
+ * src/cksum.c (do_cksum): Ditto
+ * src/dump.c (do_dump): Ditto
+
+2005-04-11 Peter Korsgaard <jacmet@sunsite.dk>
+
+ * src/flash.c (find_free): Correctly split chunks in two when
+ not final chunk.
+
+2005-04-07 Peter Korsgaard <jacmet@sunsite.dk>
+
+ * cdl/redboot.cdl, doc/redboot_cmds.sgml, src/gunzip.c: Added
+ gunzip command to uncompress GZIP compressed data.
+
+2005-03-07 Alexander Neundorf <alexander.neundorf@jenoptik.com>
+
+ * src/net/arp.c: use correct sizeof(rt->enet_addr) in
+ __arp_lookup()
+
+2005-02-17  Bart Veer  <bartv@ecoscentric.com>
+
+ * src/flash.c (fis_create): if -r is not specified, set the ram
+ base address in the fis directory to the current load address.
+ This assumes the data is currently in the right place, as should
+ be the case after e.g. loading an elf executable.
+
+2005-02-11 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/flash.c (find_free): Correct fis free calculations to account
+ for chunk regions ending 1 byte before fis fis regions.
+ (fis_find_free): Allow for difference of end from start being one
+ less than size of region.
+
+2005-01-26 Nick Garnett <nickg@ecoscentric.com>
+
+ * src/fs/fileio.c (do_mkdir, do_deldir, do_del, do_write): Added
+ some extra argument checking to these functions.
+
+2005-01-22 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * src/main.c (cyg_start): Fix compiler warning with
+ HAL_THREAD_INIT_CONTEXT and the worspace end address.
+ * src/fs/disk.c (find_dos_partitions): Removed unused variable.
+
+2005-01-19 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/fs/fileio.c (do_mount): Only support -f with "legacy" flash
+ block devices.
+ Clear mount table on failure.
+ (do_move): Silence rename undefined warning.
+ (do_write): Silence warnings.
+ (do_info): Support longer device names.
+
+ * src/decompress.c (ZLIB_COMPRESSION_OVERHEAD):
+ Increase substantially if jffs2 is present.
+
+2005-01-05 David Vrabel <dvrabel@arcom.com>
+
+ * src/fs/fileio.c (do_ls): Remove useless "getcwd" message.
+ * src/net/bootp.c (__bootp_find_local_ip): Only print the
+ "waiting for BOOTP" message when after first retry.
+
+2004-12-17 Nick Garnett <nickg@ecoscentric.com>
+
+ * src/fs/fileio.c: Fixed some bugs in handling of mounts. The
+ strings used in the mount table must be copied, otherwise the
+ mount table is corrupted by later commands. Also toughened up some
+ error testing.
+
+2004-12-16 Nick Garnett <nickg@ecoscentric.com>
+
+ * doc/redboot_cmds.sgml: Added file mode documentation to load
+ command.
+
+2004-12-01 Andrea Michelotti <amichelotti@atmel.com>
+
+ * main.c :
+ * mfill.c:
+ * mcmp.c : Changes required for use with GCC v4 - cast as lvalue
+ is no longer supported.
+
+2004-11-26 Nick Garnett <nickg@ecoscentric.com>
+
+ * doc/redboot_cmds.sgml: Added documentation of filesystem access
+ commands.
+
+ * src/fs/fileio.c (do_write): Added O_TRUNC to the open call to
+ ensure that the file is resized to fit the new data.
+
+2004-11-24 Bart Veer <bartv@ecoscentric.com>
+
+ * Merge from flash V2 branch
+
+ 2004-11-21 Bart Veer <bartv@ecoscentric.com>
+
+ * src/flash.c (check_code_overlaps): cyg_flash_code_overlaps() has
+ been removed, so use a RedBoot-specific function instead
+
+ 2004-11-20 Bart Veer <bartv@ecoscentric.com>
+
+ * src/flash.c (do_flash_init): info.end already holds the last
+ flash byte, no need to adjust.
+
+ 2004-10-07 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * src/flash.c (do_flash_init): Fix compiler warning about an
+ unused variable.
+
+ 2004-10-06 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * src/flash.c (do_flash_init): We need info independent of
+ CYGNUM_REDBOOT_FLASH_BASE being set or not.
+
+ 2004-09-14 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * cdl/redboot.cdl: Change CYGNUM_REDBOOT_FLASH_BASE to a booldata
+ so we don't always look at address 0 for the flash!
+
+ 2004-08-21 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * src/flash.c (do_flash_init): cyg_flash_get_limits has been removed.
+ Reimplement this functionality using other calls.
+
+ 2004-08-13 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * cdl/redboot.cdl: Fixed the type of CYGNUM_REDBOOT_FLASH_BASE
+ * src/flash.c (fis_[un]lock): Fix compiler warnings
+
+ 2004-08-06 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * src/flash.c (do_flash_init): Removed the MIPS br0ken condition
+ which i wrongly added. My problem was actually a / 0. This roundup
+ is needed otherwise the workspace goes off the end of the RAM.
+
+ 2004-08-05 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * src/flash.c:
+ * src/fconfig.c: Make use of the new flash API.
+
+2004-11-24 Nick Garnett <nickg@ecoscentric.com>
+
+ * src/fs/fileio.c: Significantly reorganized to present an
+ interface similar to the fis commands. Added a variety of command
+ to manipulate files and directories in a filesystem.
+
+ * src/parse.c: Added redboot_exec() to provide an internal
+ interface for executing RedBoot commands. Added err_printf() which
+ allows an error message to be printed before longjumping out to an
+ enclosing call to redboot_exec(). Where redboot_exec() is not
+ involved, it just behaves like diag_printf().
+
+ * src/main.c: Removed unnecessary delay during startup. Changed
+ diag_printf() in do_go() into err_printf().
+
+ * src/load.c: Changed some calls to diag_printf() to err_printf().
+
+ * src/net/net_io.c: Changed init priority to RedBoot_INIT_NET.
+
+ * include/redboot.h: Added some extra initialization
+ priorities. Added prototypes for redboot_exec() and err_printf().
+
+2004-11-11 Bart Veer <bartv@ecoscentric.com>
+
+ * src/flash.c (find_free): allow for flash blocks larger than the
+ RedBoot MIN_IMAGE_SIZE
+
+2004-11-09 Ian Campbell <icampbell@arcom.com>
+
+ * cdl/redboot.cdl, doc/redboot_cmds.sgml, src/iomem.c: Add support
+ for iopeek and iopoke commands to allow access to the I/O regions.
+
+2004-11-09 David Vrabel <dvrabel@arcom.com>
+
+ * cdl/redboot.cdl (CYGBLD_REDBOOT_MIN_IMAGE_SIZE): Correct the
+ description to match what the option is actually used for.
+
+ * src/flash.c (find_free, fis_free, fis_find_free): Don't ignore
+ an extra CYGBLD_REDBOOT_MIN_IMAGE_SIZE amount from the start.
+ This fixes the case where nothing uses the start of flash.
+
+2004-11-05 John Dallaway <jld@ecoscentric.com>
+
+ * src/flash.c (fis_create): Eliminate MIPS compiler workaround
+ which causes problems with multiple use of flash blocks and appears
+ to be unnecessary with GCC 3.2.1.
+
+ * src/flash.c (fis_write): Eliminate MIPS compiler workaround.
+
+2004-11-04 Peter Korsgaard <jacmet@sunsite.dk>
+
+ * src/fconfig.c (flash_write_config): Removed compiler warning
+ when building redboot with combined FIS and config.
+
+2004-10-10 Iztok Zupet <iz@elsis.si>
+
+ * cdl/redboot.cdl: added CYGSEM_REDBOOT_DISK_IDE_VMWARE option.
+ * src/fs/ide.c : skip reset IDE commands if running under VMware.
+
+2004-10-08 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * doc/redboot_installing.sgml: Added links to the tools for the
+ Atmel AT91 JTST board.
+
+2004-09-27 Mark Salter <msalter@redhat.com>
+
+ * src/fs/ide.c (ide_presence_detect): New function.
+ * src/fs/disk.c (u32_unaligned): New function to read unaligned words.
+ (find_dos_partitions): Use u32_unaligned instead of memcpy.
+
+2004-9-25 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * doc/redboot_install.sgml: Added installation information for the
+ Atmel AT91 JTST board provided by Andrea Michelotti
+
+2004-9-23 Bob Koninckx <bob.koninckx@o-3s.com>
+
+ * src/net/tc.c: Removed unneccesary call to MS_TICKS_DELAY
+
+2004-09-19 Mark Salter <msalter@redhat.com>
+
+ * cdl/redboot.cdl: Add CYGSEM_REDBOOT_NETWORK_INIT_ONE_DEVICE
+ * src/net/net_io.c (net_init): Initialize only one network
+ device if CYGSEM_REDBOOT_NETWORK_INIT_ONE_DEVICE defined.
+
+2004-09-19 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * src/load.c (do_load): Removed compiler warning when building
+ reboot without networking.
+
+2004-09-05 Mark Salter <msalter@redhat.com>
+
+ * doc/redboot_installing.sgml: Add mb93091 and mb93093.
+
+2004-09-02 Mark Salter <msalter@redhat.com>
+
+ * doc/redboot_cmds.sgml: Add -x option to exec command.
+
+2004-09-01 Mark Salter <msalter@redhat.com>
+
+ * cdl/redboot.cdl (CYGOPT_REDBOOT_FLASH_BYTEORDER): New option.
+ * include/redboot.h: Define FLASH_{READ,PROGRAM} macros.
+ Define REDBOOT_FLASH_REVERSE_BYTEORDER if appropriate.
+ * src/flash.c: Add support for CYGOPT_REDBOOT_FLASH_BYTEORDER.
+ Use FLASH_{READ,PROGRAM} macros instead of flash driver api.
+ * src/fconfig.c: Ditto.
+
+ * src/main.c (do_version): Update copyright message.
+
+2004-08-31 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/flash.c (fis_init): Avoid potentially unnecessary erase
+ attempt at end of flash.
+
+2004-08-27 Peter Korsgaard <jacmet@sunsite.dk>
+
+ * doc/redboot_cmds.sgml: Fixed a minor typo with fis list
+
+2004-08-17 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * cdl/redboot.cdl:
+ * src/net/net_io.c: added CDL to allow the default server to
+ be configured. Also respect the CYGSEM_REDBOOT_DEFAULT_NO_BOOTP
+ setting.
+
+2004-08-16 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * cdl/redboot.cdl:
+ * src/load.c: Added cdl to control the size of the buffer used
+ by getc. The size can have significant affect on load speed
+ when loading from a filesystem.
+
+2004-08-13 Jani Monoses <jani@iv.ro>
+
+ * src/net/http_client.c: Fix off-by-one error in checking
+ the HTTP response header, so the ending CRLF-CRLF is detected
+ even if it's the last 4 bytes in the buffer.
+
+2004-08-10 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * cdl/redboot.cdl
+ * src/load.c (load_elf_image): Added a CDL option to configure
+ if the physical or virtual address in the headers should be used
+ when loading the image.
+
+2004-08-09 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * cdl/redboot.cdl
+ * src/fs/fileio.c (do_ls) Added an ls command so we can see what
+ is inside the mounted filesystem.
+
+2004-06-25 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * src/flash.c (find_free): fix endless loop when removing a
+ collapsed chunk from chunk table. Found by Laurent Gonzalez
+ (fis_load): Fixed a compiler warning.
+
+2004-06-11 Nick Garnett <nickg@ecoscentric.com>
+
+ * src/flash.c (fis_create): Made unlock/lock operations dependent
+ on CYGHWR_IO_FLASH_BLOCK_LOCKING.
+
+2004-05-31 Jani Monoses <jani@iv.ro>
+
+ * src/main.c:
+ * include/redboot.h: Get rid of unused workspace_size.
+
+2004-05-16 Andrew Dyer <adyer@righthandtech.com>
+2004-05-27 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/fs/ide.c: make sure IDE_STAT_BSY is 0 before checking other
+ bits in the status register
+
+2004-05-21 Ian Campbell <icampbell@arcom.com>
+
+ * src/main.c: Make it build without CYGSEM_REDBOOT_FLASH_ALIASES.
+
+2004-05-07 Nick Garnett <nickg@ecoscentric.com>
+
+ * src/flash.c (fis_create): Added unlock and lock operations
+ around programming of flash region. Some flash parts power up with
+ all locks on, so we have to unlock, and we might as well play safe
+ and keep everything locked.
+
+2004-05-05 Gary Thomas <gary@mlbassoc.com>
+
+ * src/flash.c (fis_load): CRC check on load was broken (the CDL
+ option changed names)
+
+2004-04-29 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * doc/redboot_epilogue.sgml: Comment out </part> to reflect change
+ of 2004-04-19.
+
+2004-04-23 Gary Thomas <gary@mlbassoc.com>
+
+ * src/main.c:
+ * src/fs/fileio.c:
+ * src/net/net_io.c:
+ * src/load.c:
+ * src/flash.c:
+ * include/redboot.h: Add asserts to check that option arrays
+ are not overrun (when used with variable number of options).
+
+2004-04-23 Gary Parnes <garyp@logicpd.com>
+
+ * src/net/tftp_client.c: The port, if specified by the user,
+ is now corrected for endianness issues.
+
+2004-04-19 Gary Thomas <gary@mlbassoc.com>
+
+ * src/fs/fileio.c: Can't test for CYGPKG_IO_FLASH_BLOCK_DEVICE without
+ first testing for CYGPKG_IO_FLASH and including it's pkgconf file.
+
+2004-04-19 John Dallaway <jld@ecoscentric.com>
+
+ * doc/makefile, doc/redboot_main.sgml: New files to build the RedBoot
+ User's Guide as a self-contained document.
+
+ * doc/redboot.sgml: Eliminate <part> tag to build the RedBoot User's
+ Guide as a self-contained document.
+
+2004-03-30 Mark Salter <msalter@redhat.com>
+
+ * src/net/udp.c (__udp_recvfrom_handler): Protect against back-to-back
+ duplicate packets.
+
+2004-03-17 Thomas Koeller <thomas.koeller@baslerweb.com>
+
+ * src/fs/fileio.c: Only include IO package headers if required.
+
+2004-03-02 Andrew Dyer <adyer@righthandtech.com>
+
+ * src/load.c: add -p option to help string and only print it and -h if
+ CYGPKG_REDBOOT_NETWORKING is enabled. Add a CR to the end of the
+ SHORT_DATA message string
+
+2004-02-27 Jani Monoses <jani@iv.ro>
+
+ * src/net/http_client.c: Close connection with abort instead of
+ friendly close since for ELF files we don't read the whole content
+ but end the connection when the runnable parts are in. The server
+ interprets close as it has nothing more to receive, but it still wants
+ to send the rest of the file and does that until it times out.
+
+2004-02-26 Jani Monoses <jani@iv.ro>
+
+ * src/load.c:
+ * src/net/http_client.c: Allow overriding the default HTTP port.
+
+2004-02-25 Gratian Crisan <nelu@iv.ro>
+
+ * src/xyzModem.c: Do not read an information header for XModem
+ in xyzModem_stream_open(). XModem does not have a file information
+ header and this caused in the previous implementation a retransmission
+ of the first data block (it was read and ignored in the open function).
+
+2004-02-24 Gary Thomas <gary@mlbassoc.com>
+
+ * cdl/redboot.cdl: net_io needs to be in libextras to enable network
+ support (failed if network debug was disabled)
+
+2004-02-23 Uwe Kindler <uwe_kindler@web.de>
+
+ * src/cksum.c:
+ * src/dump.c:
+ * src/fconfig.c:
+ * src/flash.c:
+ * src/load.c:
+ * src/main.c:
+ * src/mcmp.c:
+ * src/mcopy.c:
+ * src/mfill.c:
+ * src/net/net_io.c:
+ * src/net/ping.c: Minor cleanups to remove warnings.
+
+2004-02-20 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * doc/redboot.sgml: Document lowering security level for TFTP to
+ work on more recent Red Hat Linux.
+
+2004-02-19 Jani Monoses <jani@iv.ro>
+
+ * src/xyzModem.c: Start with sending a 'C', do not wait until the
+ first packet from the sender.This allows download to start quicker.
+
+2004-02-16 Andrew Dyer <adyer@righthandtech.com>
+
+ * src/main.c: add 'go' options to help string
+
+2004-02-11 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * cdl/redboot.cdl: Bring CYGNUM_REDBOOT_LOAD_ZLIB_BUFFER under
+ CYGBLD_BUILD_REDBOOT_WITH_ZLIB. Add CYGPRI_REDBOOT_ZLIB_FLASH to
+ control whether decompression can be used with flash images.
+ * src/flash.c: Use CYGPRI_REDBOOT_ZLIB_FLASH instead of
+ CYGPKG_COMPRESS_ZLIB.
+ * src/load.c: Use CYGBLD_BUILD_REDBOOT_WITH_ZLIB in place of
+ CYGPKG_COMPRESS_ZLIB.
+ * src/main.c: only set fis_zlib_common_buffer if
+ CYGPRI_REDBOOT_ZLIB_FLASH.
+
+ * src/main.c (set_comm_baud_rate): Get current rate with GETBAUD
+ not SETBAUD!
+
+2004-02-04 Gary Thomas <gary@mlbassoc.com>
+
+ * cdl/redboot.cdl: Do not build with "common" interrupt stack
+ support. This can cause problems when running programs (via
+ the "go" command) as interrupts will corrupt RedBoot's stack.
+
+2004-01-18 Gary Thomas <gary@mlbassoc.com>
+
+ * src/main.c: Fix build problem if GDB stubs are not included.
+ Minor warning cleanup (cast on NO_MEMORY).
+
+2003-12-21 Gary Thomas <gary@mlbassoc.com>
+
+ * src/net/tcp.c (tcp_send): Add [restore] delay into TCP write
+ path. Sadly, there seems to be some issue where some ACK packets
+ get lost unless this is present (at least on some hardware).
+ n.b. a small delay here is definitely preferable to the horrendous
+ delays imposed by TCP retries if this condition occurs.
+
+ * src/fconfig.c:
+ * include/flash_config.h: New functions for get/set/enumerate
+ config data which can be used via virtual vector interface.
+
+2003-12-12 Jani Monoses <jani@iv.ro>
+
+ * src/net/tcp.c: Cancel retransmission timer when SYN is acked
+ otherwise an open active connection which doesn't send data
+ eventually resends the SYN resulting in reset from the peer.
+
+2003-12-08 Gary Thomas <gary@mlbassoc.com>
+
+ * cdl/redboot.cdl: Better handling of GDB stubs support. This
+ should be automatically included if the platform supports GDB.
+ Disabling CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS (in the common HAL)
+ will fully disable GDB support.
+
+2003-12-05 Gary Thomas <gary@mlbassoc.com>
+
+ * src/decompress.c (gzip_init): Memory pool initialization should
+ only be done in _zlib_init().
+
+2003-12-05 Ian Campbell <icampbell@arcom.com>
+
+ * src/decompress.c: Ensure that free'd blocks are returned to the
+ free pool and that adjacent free blocks are merged. Initialise the
+ pool in _zlib_init() so that things are initialised even when
+ gzip_init hasn't been called.
+
+2003-12-05 Gary Thomas <gary@mlbassoc.com>
+
+ * src/io.c (_rb_gets_preloaded): ^A could have moved the cursor to
+ the wrong location on the screen if ^F/^B had been used.
+
+2003-12-03 David Vrabel <dvrabel@arcom.com>
+
+ * src/time_date.cxx (do_time_date): Use YYYY/MM/DD HH:MM:SS format
+ throughout (instead of the American specific format). Expand
+ range of valid years to 1970 - 2034 (instead of 2000 - 2034).
+
+2003-11-27 David Woodhouse <dwmw2@redhat.com>
+
+ * cdl/redboot.cdl, fs/fileio.c, include/fs/fileio.h, src/load.c:
+ Support for mounting and loading files from fileio file systems
+ such as JFFS2.
+
+2003-11-25 John Dallaway <jld@ecoscentric.com>
+
+ * src/fconfig.c (load_flash_config):
+ Fix typo in output string.
+
+2003-11-24 Gary Thomas <gary@mlbassoc.com>
+
+ * src/net/bootp.c (__bootp_find_local_ip):
+ Suppress diagnostic message that DNS info found.
+
+2002-11-24 Jani Monoses <jani@iv.ro>
+
+ * src/flash.c: Remove references to FLASH_MIN_WORKSPACE.
+
+2003-11-21 David Vrabel <dvrabel@arcom.com>
+
+ * src/net/bootp.c (bootp_handler): Scan for DHCP Message Type tag
+ as it isn't always the first tag.
+
+ * include/net/bootp.h: New #define's for DHCP message types
+ (DHCP_MESSAGE_TYPE_DISCOVER etc.).
+
+2002-11-20 Jani Monoses <jani@iv.ro>
+
+ * src/flash.c: flash_init() no longer takes three args.
+
+2003-11-19 David Woodhouse <dwmw2@redhat.com>
+
+ * src/main.c: Restore correct old baud rate if changing fails.
+
+2003-11-13 Gary Thomas <gary@mlbassoc.com>
+
+ * src/main.c (do_go): Need to stop catching exceptions when running a
+ user program, otherwise GDB will never run when the program fails, gets
+ a ^C interrupt, etc. Also, clean up [remove] some cache debug code.
+
+2003-11-12 Gary Thomas <gary@mlbassoc.com>
+
+ * misc/redboot_XXX.ecm: Removed - since it was only a source of confusion.
+
+2003-11-07 Gary Thomas <gary@mlbassoc.com>
+
+ * src/net/dns.c:
+ * src/net/bootp.c:
+ * include/net/net.h: Use DNS server address from DHCP if provided.
+ Inspired by John Newlin <jnewlin@rawbw.com>
+
+ * src/flash.c (fis_init): Take out misleading warning - since the
+ new [default] behaviour of "fis free" means free space need not
+ be necessarily erased on the device.
+
+2003-11-04 Gary Thomas <gary@mlbassoc.com>
+
+ * src/flash.c (find_free): Better handling of end address - otherwise
+ list of free blocks could be incorrect. Thanks to Chris Garry.
+
+2003-11-01 Gary Thomas <gary@mlbassoc.com>
+
+ * cdl/redboot.cdl: Reorg to allow disk operations on other than
+ IDE drives.
+
+2003-10-23 Gary Thomas <gary@mlbassoc.com>
+
+ * src/main.c (cyg_start): Try to catch illegal memory accesses and
+ other abort conditions during command execution.
+
+2003-10-17 Gary Thomas <gary@mlbassoc.com>
+
+ * src/load.c: Only examine loadable segments when scanning to determine
+ lowest loadable address (only used when -b XXX option used). Otherwise,
+ an offset into space could be chosen.
+
+2003-10-16 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * doc/redboot_installing.sgml: Fix eb40 flash install instructions.
+
+2003-10-15 Gary Thomas <gary@mlbassoc.com>
+
+ * src/flash.c:
+ * src/fconfig.c: Better handling of layout of fconfig and fis
+ data within the FLASH. Should work for even flash devices with
+ very smal block sizes.
+
+ * include/redboot.h (RedBoot_INIT_SECOND):
+ Finer initialization control.
+
+ * cdl/redboot.cdl: Combine FIS directory and FCONFIG database
+ by default. This results in better FLASH utilization. Also define
+ number of FIS directory slots. This will allow support for FLASH
+ devices with very small block sizes.
+
+2003-10-12 Gary Thomas <gary@mlbassoc.com>
+
+ * src/flash.c (fis_create): Verify that any hard FLASH addresses
+ (given via -f XXX) are known to be free.
+
+2003-10-11 Gary Thomas <gary@mlbassoc.com>
+
+ * src/flash.c:
+ * cdl/redboot.cdl: Change 'fis free' to use the directory structure
+ to determine what space is free in the FLASH. This is controlled
+ by the CDL option CYGDAT_REDBOOT_FIS_MAX_FREE_CHUNKS so the old
+ behaviour can still be defined if desired.
+
+2003-10-09 Gary Thomas <gary@mlbassoc.com>
+
+ * src/flash.c (fis_create): Check whole length of image, not just
+ effective size, when validating addresses.
+
+ * src/net/net_io.c (net_init):
+ * include/net/net.h: Rework handling of multiple network devices. All
+ devices will now be initialized, with either the first or the default
+ device actually used for I/O.
+
+2003-10-06 Gary Thomas <gary@mlbassoc.com>
+
+ * src/net/net_io.c:
+ * src/net/bootp.c: Fix some compile problems if GATEWAY support is disabled.
+
+ * src/flash.c (fis_list): Display FIS directory entries in FLASH
+ address (sorted) order.
+
+2003-10-03 Gary Thomas <gary@mlbassoc.com>
+
+ * src/flash.c (fis_delete): 'fconfig' data only shows up in FIS if
+ the data is stored in FLASH - account for this. Also, make sure
+ FLASH gets initialized if built without 'fconfig' enabled.
+
+2003-10-02 Gary Thomas <gary@mlbassoc.com>
+
+ * src/fconfig.c:
+ * cdl/redboot.cdl: Allow platforms to provide a function to validate
+ ethernet station addresses.
+
+2003-09-30 Gary Thomas <gary@mlbassoc.com>
+
+ * src/fconfig.c (do_flash_config): Fix typo in error message.
+
+2003-09-30 David Vrabel <dvrabel@arcom.com>
+
+ * src/net/tcp.c: Include missing <cyg/infra/diag.h>.
+
+ * include/redboot.h, src/parse.c (init_opts, scan_opts): Remove
+ the excessive level of indirection in the handling of option
+ arguments.
+
+2003-09-29 Gary Thomas <gary@mlbassoc.com>
+
+ * src/load.c (load_elf_image): Use LMA (loader memory address), instead
+ of VMA (virtual memory address) to load code. If LMA != VMA, it's up
+ to the loaded program to figure it out.
+ Inspired by Artur Lipowski <LAL@pro.onet.pl>
+
+2003-09-26 Nick Garnett <nickg@balti.calivar.com>
+
+ * doc/redboot_installing.sgml: Fixed bogus memory sizes in AT91
+ EB42/55 description.
+
+2003-09-26 Gary Thomas <gary@mlbassoc.com>
+
+ * src/flash.c (fis_free, fis_find_free):
+ Fix some problems introduced with the new FLASH interfaces (used by
+ NAND devices)
+
+ * src/fconfig.c: Honor FLASH/FIS configury.
+
+ * src/net/bootp.c:
+ * src/fs/ide.c: Clean up some compiler warnings.
+
+2003-09-25 Gary Thomas <gary@mlbassoc.com>
+
+ * src/net/bootp.c: Rework DHCP process to handle really stubborn
+ servers.
+
+2003-09-24 Gary Thomas <gary@mlbassoc.com>
+
+ * src/net/bootp.c (__bootp_find_local_ip): Forgot to unregister
+ UDP handler - could cause serious problems later! Also, fix
+ problem with retries after DHCP discovery phase.
+
+2003-09-23 Gary Thomas <gary@mlbassoc.com>
+
+ * src/net/bootp.c (__bootp_find_local_ip): Handle retries on DHCP
+ requests better.
+
+2003-09-22 Gary Thomas <gary@mlbassoc.com>
+
+ * cdl/redboot.cdl: Fix compile error for systems with no FLASH.
+
+2003-09-21 Gary Thomas <gary@mlbassoc.com>
+
+ * cdl/redboot.cdl: Make DNS truly optional (remove from template).
+ BUG #57316
+
+2003-09-20 Gary Thomas <gary@mlbassoc.com>
+
+ * src/fs/ide.c: Improve IDE handling by having init function return
+ actual number of controllers detected. This avoids really long times
+ for startup if the controller is missing.
+
+ * src/net/bootp.c: Rework to use full DHCP protocol. Previously,
+ once an offer came in, RedBoot was happy, without actually making
+ the address reservation and waiting for the final acknowledgement.
+ Also, added CDL to enable/disable DHCP. BUG #1000053
+
+2003-09-20 Chris Garry <cgarry@sweeneydesign.co.uk>
+
+ * src/main.c: Modified the way multiple "RAM" segments are reported.
+
+ * src/fconfig.c: Variables 'stat' and '*err_addr' in function
+ flash_write_config() are now defined regardless of whether
+ CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG is defined of not.
+
+2003-09-19 Gary Thomas <gary@mlbassoc.com>
+
+ * src/net/timers.c (__timer_poll): Need to call MS_TICKS_DELAY() or
+ else time will never progress. This can cause a missed TCP packet
+ to cause the stack to freeze. BUG #23006
+
+ * src/net/tftp_client.c: Make timeout on very first transaction really
+ long - again since some servers are just slow/ill mannered.
+
+ * src/net/net_io.c: Allow default server IP to be always enabled, thus
+ it can override what is provided by BOOTP/DHCP (since some DHCP servers
+ don't provide this properly).
+
+ * src/time_date.cxx: New file - support "date" command for platforms
+ with battery backed up clocks.
+
+ * src/fconfig.c: New file - split out from flash.c
+
+ * src/main.c:
+ * src/load.c:
+ * src/flash.c:
+ * src/alias.c:
+ * include/redboot.h:
+ * cdl/redboot.cdl: Support multiple "RAM" segments (known writable
+ memory). Also rearrange FLASH & FCONFIG, separating them as much
+ as possible and supporting FCONFIG data stored in some other sort
+ of device, like EEPROM.
+
+2003-09-09 Gary Thomas <gary@mlbassoc.com>
+
+ * src/flash.c (flash_config_insert_value): Default value was
+ wrong for ESA type.
+
+2003-09-08 David Vrabel <dvrabel@arcom.com>
+
+ * src/net/bootp.c (__bootp_find_local_ip): Adds Option 55 Parameter
+ Request List) to the DHCP request (requests: Subnet Mask; Router;
+ Domain Name server).
+
+2003-08-19 Gary Thomas <gary@mlbassoc.com>
+
+ * src/net/udp.c (__udp_recvfrom): Rework loop so delay only happens
+ if no packet is immediately available - improves network throughput.
+
+ * src/ticks.c:
+ * cdl/redboot.cdl: Add control over granularity of timers used
+ by RedBoot and the network stack.
+
+2003-08-05 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * doc/redboot_installing.sgml: Fix brain fart in last change to
+ AT91 instructions. Also clarify instructions a bit, including
+ documenting better for windows users.
+
+2003-07-23 Patrick Doyle <wpd@dtccom.com>
+
+ * src/flash.c (fis_find_free)
+ * src/flash.c (fis_free): Do not search areas reserved for RedBoot
+ when scanning for free space.
+
+2003-07-16 Gary Thomas <gary@mlbassoc.com>
+
+ * src/net/ping.c:
+ * src/net/bootp.c: Allow ^C to abort.
+
+ * src/io.c:
+ * include/redboot.h: New function _rb_break() used to test for ^C
+ on the console. Used to break out of long operations like BOOTP.
+
+2003-07-15 Gary Thomas <gary@mlbassoc.com>
+
+ * src/net/bootp.c: Use correct options for DHCP discover. This has
+ the added bonus that when BOOTP & GATEWAY options are enabled, then
+ RedBoot can get it's address via normal DHCP. Of course, DHCP leases
+ will be ignored by RedBoot, so some caution is warranted.
+
+ * include/net/net.h:
+ * src/net/arp.c (__arp_request): Allow ARP of self - used during
+ initialization to "broadcast" that an IP address is in use.
+
+ * src/net/net_io.c (net_init): When using a static IP, send an
+ initial ARP to see if any other node is using this address.
+ Also, some minor cosmetic cleanups to remove warnings.
+
+2003-07-15 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * doc/redboot_installing.sgml (AT91): Tell users to switch JP1
+ (or SW1 for EB40) when installing, and warn them in no
+ uncertain terms the consequences of failing to do so.
+
+2003-07-01 Mark Salter <msalter@redhat.com>
+
+ * cdl/redboot.cdl (CYGBLD_BUILD_REDBOOT_WITH_MCOPY): New option.
+ * src/mcopy.c: New file adding mcopy command.
+ * doc/redboot_cmds.sgml: Add mcopy.
+
+2003-06-26 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * doc/redboot_installing.sgml: Clarify use of correct cables with
+ serial ports with AT91 boards.
+
+2003-06-24 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * doc/redboot_cmds.sgml (IP): Clarify last change a bit and fix typos
+ and markup.
+
+2003-05-20 David Vrabel <dvrabel@arcom.com>
+2003-05-20 Ian Campbell <icampbell@arcom.com>
+
+ * src/net/net_io.c: Add the ability to specify a netmask length to
+ the ip_address command
+ * doc/redboot_cmds.sgml: Document the above.
+
+2003-06-24 Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
+2003-06-24 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/net/tftp_client.c: Define tftp_stream.last_good_block to
+ permit downloads > 32MB.
+ (tftp_ack): Allow last_good_block to wrap.
+ (tftp_stream_read): Ditto.
+
+ * src/net/bootp.c: Use correct DHCP message type for DHCPREQUEST.
+
+2003-05-20 Mark Salter <msalter@redhat.com>
+
+ * cdl/redboot.cdl (CYGBLD_REDBOOT_CMD_LINE_HISTORY): New option.
+ * src/io.c: Support history command and history expansion.
+ * doc/redboot.sgml: Document command history support.
+
+2003-05-14 Mark Salter <msalter@redhat.com>
+
+ * src/flash.c (flash_get_config): Add CONFIG_NETPORT case.
+
+2003-05-13 Nick Garnett <nickg@balti.calivar.com>
+
+ * doc/redboot_installing.sgml: Added installation instructions for
+ Atmel EB40A, EB42 and EB55 boards.
+
+2003-05-06 Mark Salter <msalter@redhat.com>
+
+ * src/main.c (cyg_start): Clear gdb_active when returning from stub.
+
+2003-05-06 Pierre Habraken <Pierre.Habraken@imag.fr>
+
+ * cdl/redboot.cdl: Added option
+ CYGOPT_REDBOOT_BSP_SYSCALLS_EXIT_WITHOUT_TRAP for enabling (possibly
+ single shot) programs to exit and return a termination status as
+ their normal behavior (i.e. without raising a SIGTRAP).
+ * src/syscall.c (__do_syscall): Added conditionally compiled code
+ to SYS_exit for returning to RedBoot main loop without raising a
+ SIGTRAP, even when the calling program is not being debugged.
+ * src/main.c (cyg_start): Added code (following Jonathan Larmour's
+ and Mark Salter's suggestions) to RedBoot main loop: a (context)
+ savepoint is created before the thread of control is transferred to
+ gdb stubs (through a trampoline procedure). This savepoint enables
+ the stubs to return control back to the main loop by calling the
+ return_to_redboot procedure (macro CYGACC_CALL_IF_MONITOR_RETURN).
+ Procedure go_trampoline and variables go_saved_context and
+ go_return_status have been respectively renamed to trampoline,
+ saved_context and return_status.
+
+2003-04-23 Chris Garry <cgarry@sweeneydesign.co.uk>
+
+ * src/flash.c: Only perform RAM check in fis load command when
+ CYGSEM_REDBOOT_VALIDATE_USER_RAM_LOADS = 1
+
+2003-04-18 Gary Thomas <gary@mlbassoc.com>
+
+ * src/net/tftp_client.c: Arrange to ACK last good packet when closing.
+ Without this, the host can be left tryint to send that packet forever.
+
+2003-04-14 Jani Monoses <jani@iv.ro>
+
+ * src/load.c:
+ Change #else if to #elif so it compiles when TFTP is disabled.
+
+2003-04-08 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/main.c (do_go): Silence unused variable warning when no net.
+
+2003-04-04 Mark Salter <msalter@redhat.com>
+
+ * src/main.c (do_go): Add -n switch to optionally stop network
+ device. Mask interrupts on all comm channels.
+ Don't scan for -n unless ethernet configured in.
+ * doc/redboot_cmds.sgml: Update go command info.
+
+2003-04-03 Gary Thomas <gary@mlbassoc.com>
+
+ * src/load.c: Better handling of default download mode. Also
+ display information when I/O errors occor (was silent).
+ (do_load): Handle case when X-modem protocol is disabled.
+
+ * src/net/http_client.c:
+ * include/net/http.h: Improve parsing of HTTP responses for errors.
+
+2003-03-28 Gary Thomas <gary@mlbassoc.com> inspired by
+2003-03-28 Jani Monoses <jani@iv.ro>
+
+ * src/load.c:
+ * cdl/redboot.cdl: Make TFTP download protocol optional.
+
+2003-03-20 Mark Salter <msalter@redhat.com>
+
+ * include/flash_config.h (CONFIG_NETPORT): New config option.
+ * src/flash.c: Support CONFIG_NETPORT.
+ * cdl/redboot.cdl: New option to select default ethernet device.
+ * src/net/net_io.c: Support multiple ethernet devices.
+ * include/net/net.h: Add externs for net_devname and net_devindex.
+
+2002-03-19 John Dallaway <jld@ecoscentric.com>
+
+ * doc/redboot_installing.sgml: Update Atmel AT91EB40 RedBoot
+ installation instructions.
+
+2003-03-18 Mark Salter <msalter@redhat.com>
+
+ * doc/redboot_installing.sgml: Add XScale IXDP425 and GRG.
+
+2003-03-05 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/main.c (do_version): Test for CYGPKG_REDBOOT_FLASH as
+ CYGPKG_IO_FLASH can be loaded with no underlying hardware drivers!
+
+2003-03-03 Gary Thomas <gary@mlbassoc.com>
+
+ * src/main.c (set_console_baud_rate): Avoid "unused" warning.
+
+2003-03-03 Knud Woehler <knud.woehler@microplex.de>
+
+ * src/flash.c: fis_work_block was not initialized in do_flash_init()
+ thus fis_lookup() does not work if called via the virtual vector table.
+
+2003-02-24 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * doc/redboot.sgml: De-vendorise a little.
+ Fix extraneous <para>.
+
+ * cdl/redboot.cdl: Add doc links.
+
+2003-02-14 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * cdl/redboot.cdl: Put virtually all options inside
+ CYGBLD_BUILD_REDBOOT. And indent accordingly.
+
+2003-02-04 Gary Thomas <gary@mind.be>
+
+ * src/fs/ide.c: Print more info if failed to identify IDE device.
+
+ * src/fs/e2fs.c: Improved debug output.
+
+2003-02-04 Mark Salter <msalter@redhat.com>
+2003-02-04 Brian Murphy <brian@murphy.dk>
+
+ * src/main.c (return_to_redboot): Add CYGARC_HAL_RESTORE_GP.
+
+2003-01-31 Mark Salter <msalter@redhat.com>
+
+ * src/main.c: Add support to allow programs started by go to
+ return to RedBoot.
+
+ * src/syscall.c (__do_syscall): Return to monitor on program exit
+ if gdb not active.
+ (sys_timer_isr): Return CYG_ISR_HANDLED.
+
+2003-01-10 Patrick Doyle <wpd@delcomsys.com>
+
+ * src/load.c (do_load): Don't abort and complain about overwriting
+ the end of RAM when loading raw data files and we already asked
+ the user if it was ok to write outside what we believe to be RAM.
+
+2002-12-31 Patrick Doyle <wpd@delcomsys.com>
+
+ * src/decompress.c (gzip_close): Don't complain that decompression
+ didn't complete when the stream reaches its end.
+
+2002-12-18 David Mazur <david@mind.be>
+2002-12-18 Mark Salter <msalter@redhat.com>
+
+ * src/fs/e2fs.c (e2fs_get_gdesc): Fixed handling of group descriptor
+ cache misses.
+
+2002-12-03 Gary Thomas <gthomas@ecoscentric.com>
+
+ * src/main.c: Export version string via virtual vector table.
+
+2002-11-05 Jonathan Larmour <jifl@eCosCentric.com>
+
+ * src/io.c (_rb_gets_preloaded): Null terminate when buffer full.
+
+2002-10-24 Gary Thomas <gthomas@ecoscentric.com> (inspired by)
+2002-10-24 Jay Foster <jay@systech.com>
+
+ * include/net/bootp.h (BP_MIN_VEND_SIZE):
+ * src/net/bootp.c (__bootp_find_local_ip): Require a minimum vendor
+ area to always be sent (to keep some servers happy).
+
+ * src/flash.c: Fix typo for "FIS DELETE"
+
+2002-09-16 Mark Salter <msalter@redhat.com>
+
+ * src/main.c (set_console_baud_rate): Handle CYGPKG_REDBOOT_ANY_CONSOLE.
+ (set_comm_baud_rate): New function.
+
+2002-09-13 Mark Salter <msalter@redhat.com>
+
+ * src/decompress.c: Move error handling back into gzip_close to
+ fix xyzmodem loads.
+
+2002-09-12 Mark Salter <msalter@redhat.com>
+
+ * src/decompress.c (gzip_inflate): Fix error return so that upper
+ doesn't quit on Z_STREAM_END.
+ (gzip_close): Move error handling into gzip_inflate.
+
+ * src/load.c (do_load): Fix printing of address range for raw loads.
+
+2002-09-11 Mark Salter <msalter@redhat.com>
+
+ * src/main.c (do_go): Turn on line flushes before jumping to function.
+ * src/net/net_io.c (net_io_control): Support flushes at end of lines.
+
+2002-09-03 Yoshinori Sato <qzb04471@nifty.ne.jp>
+2002-09-03 Mark Salter <msalter@redhat.com>
+
+ * include/fs/disk.h (__SWAB32): Fix incorrect masking.
+ * src/fs/e2fs.c (e2fs_inode_block): Fix endianess of block numbers.
+
+2002-08-29 Mark Salter <msalter@redhat.com>
+
+ * src/net/net_io.c (net_init): Initialize dns before showing addresses.
+
+2002-08-26 Thomas Koeller <thomas@koeller.dyndns.org>
+
+ * src/flash.c: Do not warn about overwriting image data if
+ -n option is used with 'fis create'. For 'fis load',
+ perform load size check based on actual data length, not
+ image size.
+
+2002-08-22 Mark Salter <msalter@redhat.com>
+
+ * src/net/net_io.c (net_io_putc): Don't flush on every \n.
+ * src/syscall.c (__do_syscall): Allow fileio support to fall back
+ to non-fileio behavior if program is not being run by gdb.
+
+2002-08-20 Thomas Koeller <thomas@koeller.dyndns.org>
+
+ * cdl/redboot.cdl:
+ * include/redboot.h:
+ * src/main.c:
+ * src/flash.c:
+ * src/decompress.c: Use a common buffer for FIS directory
+ manipulation and zlib workspace to conserve RAM.
+
+2002-08-20 Thomas Koeller <thomas@koeller.dyndns.org>
+
+ * cdl/redboot.cdl:
+ * include/fis.h: Allow control of FIS descriptor padding.
+
+2002-08-16 Jani Monoses <jani@iv.ro>
+
+ * src/io.c: Do not add empty lines to command history.
+ * src/net/http_client.c: Read all data when in CLOSE_WAIT
+ otherwise if the server closes quickly enough nothing is
+ received.
+
+2002-08-09 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * src/crc.c: Removed. Replaced with the CRC package.
+ * src/cksum.c: Removed the posix_crc function.
+ * src/flash.c: Use the crc package crc functions.
+ * src/xyzModem.c: Ditto
+ * include/redboot.h: Use the crc package include file.
+ * cdl/redboot.cdl: removed crc.c
+
+2002-08-09 Jani Monoses <jani@iv.ro>
+
+ * src/net/http_client.c: use standard HTTP GET request ('/'
+ instead of ' ' in HTTP/1.0) to work with all servers
+
+2002-08-08 Jani Monoses <jani@iv.ro>
+
+ * src/flash.c: fis delete should mark the slot as reusable
+ not just delete the area of flash used by the file.
+
+2002-08-08 Gary Thomas <gthomas@ecoscentric.com>
+2002-08-08 Motoya Kurotsu <kurotsu@allied-telesis.co.jp>
+
+ * src/load.c (do_load): Make sure 'io_tab' is set before using it.
+
+2002-08-07 Gary Thomas <gary@chez-thomas.org>
+
+ * src/net/tftp_client.c:
+ * include/net/tftp.h: Make block numbers unsigned to handle files
+ larger than 16MB.
+
+2002-08-06 Gary Thomas <gary@chez-thomas.org>
+
+ * src/crc.c: POSIX crc code is now separate.
+
+ * src/mfill.c:
+ * src/mcmp.c:
+ * src/dump.c:
+ * src/cksum.c:
+ * src/caches.c: New (split out) file(s).
+
+ * src/main.c:
+ * cdl/redboot.cdl: Split major CLI functionality to separate
+ files, more easily controlled by CDL - inspired by Andrew.
+
+2002-08-06 Andrew Lunn <Andrew.Lunn@ascom.ch>
+
+ * src/io.c: Fix the parsing of boot scripts to allow the use
+ of aliases. This was broken when the ability to do startup
+ type specific scripting was added.
+
+2002-08-05 Andrew Lunn <Andrew.Lunn@ascom.ch>
+
+ * src/main.c: Made more of the commands conditionally compilable
+ * cdl/redboot.cdl: CDL code to control the compilation.
+
+2002-07-30 Gary Thomas <gary@chez-thomas.org>
+
+ * src/net/net_io.c: Handle broadcast/mask setup better (failed if
+ not found in FLASH). Also print on network info line.
+
+2002-07-18 Gary Thomas <gary@chez-thomas.org>
+
+ * src/net/tftp_client.c:
+ * src/net/http_client.c:
+ * src/fs/disk.c:
+ * src/xyzModem.c:
+ * src/load.c:
+ * include/redboot.h: Rework load/mode information tables so that
+ load I/O methods can detect actual mode (e.g. X-modem vs Y-modem)
+
+2002-07-16 Hendrik Ruijter <Hendrik.Ruijter@axis.com>
+2002-07-16 Mark Salter <msalter@redhat.com>
+
+ * include/net/net.h: Add __tcp_abort prototype.
+
+ * src/net/icmp.c: The default handler can be replaced by a
+ user defined handler which handles all ICMP segments.
+
+ * src/net/ping.c
+ (handle_icmp): Only ICMP Echo Reply segments must be counted and
+ ICMP Echo Requests are handled in the user defined handler.
+
+ * src/net/tcp.c
+ (do_abort, __tcp_abort): Send an RST flag in order to abort a
+ connection. May use a delay to send the flag.
+
+2002-07-15 Mark Salter <msalter@redhat.com>
+
+ * src/net/net_io.c: Increase size of out_buf to 1024 bytes.
+
+2002-07-11 Gary Thomas <gary@chez-thomas.org>
+
+ * src/io.c (mon_read_char_with_timeout): Ensure interrupts are
+ disabled on all I/O channels, except for the current console.
+ This is done when selecting a console, as this process causes
+ the interrupt state to be inherited from the current console.
+
+2002-07-09 Gary Thomas <gary@chez-thomas.org>
+2002-07-09 Grant Edwards <grante@visi.com>
+
+ * src/net/udp.c:
+ * src/net/net_io.c:
+ * src/net/ip.c:
+ * src/net/bootp.c:
+ * src/net/arp.c:
+ * include/net/net.h:
+ * include/net/bootp.h:
+ * cdl/redboot.cdl: Add basic support for non-local networking
+ using a single gateway. Based on contribution from Grant Edwards.
+
+2002-07-01 Gary Thomas <gary@chez-thomas.org>
+
+ * src/net/tftp_client.c:
+ * src/net/http_client.c:
+ * src/fs/disk.c:
+ * src/xyzModem.h:
+ * src/xyzModem.c:
+ * src/load.c:
+ * include/net/tftp_support.h:
+ * include/net/http.h:
+ * include/redboot.h:
+ * cdl/redboot.cdl: Make 'load' command stream I/O table driven.
+
+2002-05-31 Jesper Skov <jskov@redhat.com>
+
+ * doc/redboot_installing.sgml: Updated the remaining installation
+ instructions (well, the top mode details anyway).
+
+2002-05-29 Jesper Skov <jskov@redhat.com>
+
+ * doc/redboot_cmds.sgml: Changed format of fis commands.
+
+ * doc/redboot_installing.sgml: Updated installation instructions
+ for all targets up to PowerPC.
+
+2002-05-28 Gary Thomas <gthomas@redhat.com>
+
+ * src/load.c (load_elf_image): Improve loading of ELF files with
+ multiple physical segments.
+
+2002-05-27 Jesper Skov <jskov@redhat.com>
+
+ * doc/redboot_rebuilding.sgml: Added some guimenu tags.
+
+ * doc/redboot_installing.sgml: Updating more board instructions.
+ More updates. Changing most programlisting keywords to screen.
+ Converted remaining rebuild instructions. More mode descriptions
+ updated. iPAQ converted as well.
+
+2002-05-24 Gary Thomas <gthomas@redhat.com>
+
+ * src/load.c (load_elf_image): Improve loading where ELF image
+ actually overlaps headers [old COFF style files].
+
+2002-05-24 Jesper Skov <jskov@redhat.com>
+
+ * doc/redboot_installing.sgml: Updated another 3 boards'
+ instructions.
+
+ * doc/redboot.sgml: Changes due to comments from Jifl.
+ * doc/redboot_rebuilding.sgml: Same.
+
+ * doc/redboot.sgml: Fix wording.
+
+ * doc/redboot_installing.sgml: Reordered the platform sections
+ according to CPU architecture/variant and board manufacturer.
+
+2002-05-23 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/net/dns.c (store_hent): New function. DNS package now requires
+ this instead of the cyg_thread_get_data calls.
+ (free_stored_hent): New function. Ditto.
+
+2002-05-23 Gary Thomas <gthomas@redhat.com>
+
+ * doc/redboot_cmds.sgml: Document new HTTP download mode.
+
+ * src/net/tcp.c: Improve some interfaces. Add support for
+ outgoing (__tcp_open) connections.
+
+ * src/net/net_io.c (net_io_flush): Use improved TCP interfaces.
+
+ * src/main.c (_mon_write_char): Map '\n' => '\r\n'. This used
+ to be done by diag_printf(), but that was the wrong place for it.
+
+ * include/net/net.h: Add support for TCP outgoing connections.
+
+ * src/net/http_client.c:
+ * include/net/http.h: New file(s) - HTTP client support.
+
+ * src/load.c:
+ * cdl/redboot.cdl: Support HTTP download mode.
+
+2002-05-23 Jesper Skov <jskov@redhat.com>
+
+ * doc/redboot.sgml: Moved the editing and resource sections to
+ this document. Added new section on RedBoot (startup) modes.
+ * doc/redboot_cmds.sgml: Removed the editing and resource
+ sections.
+ * doc/redboot_installing.sgml: Changed a couple of platform
+ descriptions.
+ * doc/redboot_rebuilding.sgml: Make use of mode/config
+ consistent. Removed mode section.
+
+2002-05-22 Jesper Skov <jskov@redhat.com>
+
+ * doc/redboot_rebuilding.sgml: Added a note about redboot growing
+ beyond its slot limits.
+ Rewrote the RedBoot rebuilding documentation.
+
+ * src/flash.c (fis_create): Clarify error message. Get rid of bool
+ flag slot_found that only duplicated fis variable state.
+
+2002-05-21 Gary Thomas <gthomas@redhat.com>
+
+ * src/xyzModem.h:
+ * src/xyzModem.c:
+ * src/load.c: Purge mention of Z-modem until it's implemented.
+
+2002-05-21 Jesper Skov <jskov@redhat.com>
+
+ * src/flash.c (fis_create): Removed one of the three questions to
+ verify.
+ * doc/redboot_rebuilding.sgml: Removed the query lines from the
+ docs.
+
+ * doc/redboot_installing.sgml: Removed all the free RAM related
+ resource descriptions. Left in a few timer resource descriptions.
+ * doc/redboot_cmds.sgml: Refer to platform sections for additional
+ platform-specific resource usage.
+
+ * doc/redboot_installing.sgml: Removed all platform specific
+ references to the updating section which told the user to use
+ specific flash paramemters. All this is now handled
+ automagically.
+
+ * src/alias.c (lookup_alias): FREEMEMHI is just the high address
+ masked to 1KB alignment.
+
+ * doc/redboot_cmds.sgml: Added load disk example.
+ Added section on RedBoot resources.
+
+2002-05-18 Gary Thomas <gthomas@redhat.com>
+
+ * src/main.c (do_baud_rate): Improve safety by asking for verification
+ after actually changing the rate, before updating fconfig data. This
+ reduces the chance of making a "brick" by setting a bad baud rate.
+
+ * src/flash.c (load_flash_config): Fix set_console_baud_rate prototype.
+
+ * src/io.c (verify_action_with_timeout):
+ * include/redboot.h: New function verify_action_with_timeout().
+ Returns false if no response within XX ms (or ^C).
+
+2002-05-17 Gary Thomas <gthomas@redhat.com>
+
+ * src/main.c (do_help):
+ * src/flash.c:
+ * include/redboot.h: Support nested command structures, like "fis",
+ better.
+
+2002-05-17 Jesper Skov <jskov@redhat.com>
+
+ * doc/redboot_rebuilding.sgml: Rewrote update procedure to become
+ truly generic. Some minor tweaks.
+
+ * doc/redboot_cmds.sgml: Added id to cksum command.
+
+ * src/shex.c (load_shex_image): Set entry address to be base
+ address.
+ * src/load.c (do_load): Same.
+
+ * src/flash.c (fis_create): Infer correct exec and entry
+ addresses.
+
+ * src/load.c (load_elf_image): Save load_address/end.
+
+ * src/flash.c: Made fis lock/unlock support optional image name
+ instead of addresses. Made a few places of the code use fis_lookup
+ instead of scanning the table by steam.
+ (do_flash_config): Update flash after configuration has been
+ initialized.
+
+2002-05-16 Jesper Skov <jskov@redhat.com>
+
+ * doc/redboot_cmds.sgml: Updated text on cksum to show the new
+ output format.
+
+ * src/xyzModem.c (xyzModem_stream_read): Fix build breakage.
+
+ * doc/redboot.sgml: Some minor tweaks.
+
+ * src/alias.c (lookup_alias): Renamed freemem aliases.
+
+2002-05-15 Jesper Skov <jskov@redhat.com>
+
+ * src/io.c (verify_action): Replaced 'are you sure' with
+ 'continue'.
+ * doc/redboot.sgml: Same.
+
+ * src/xyzModem.c: Let Y-modem load correct length. Don't remove
+ assumed padding bytes since they may well be actual data. Don't
+ read anything after the EOF package is received.
+ Disabled the Y-modem header stuff again; it still needs the
+ padding culling code. So in the end, only the EOF-package read
+ was at fault.
+
+ * src/main.c: Tweak cksum output.
+
+ * src/flash.c (fis_create): language tweaks.
+
+ * src/main.c: Always call expand_aliases - leave it to that
+ function to look for flash aliases when appropriate.
+
+ * src/flash.c: Moved basic alias expansion into separate file.
+ * src/alias.c: New file. Always provide FREE_LOW & FREE_HIGH
+ aliases, but also call flash_lookup_alias when defined.
+
+ * include/redboot.h: Added declarations for alias functions. Added
+ getc_t and terminate_t types.
+
+ * src/load.c: Use getc_t/terminate_t types. Made raw load abort if
+ user tries to load a file too big for memory.
+
+ * cdl/redboot.cdl: Compile alias.c.
+
+2002-05-14 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/version.c: Clarify comments.
+
+2002-05-14 Gary Thomas <gthomas@redhat.com>
+
+ * include/redboot.h:
+ * src/net/net_io.c:
+ * src/net/dns.c: Merge generic "ip" command with "dns" for
+ more homogenous interface.
+
+2002-05-13 Gary Thomas <gthomas@redhat.com>
+
+ * cdl/redboot.cdl: Disable CYGOPT_REDBOOT_FIS_REDBOOT_BACKUP
+ by default, since its use is currently unclear.
+
+ * src/flash.c (load_flash_config): Check for adequate FIS space
+ was incorrect [when FIS directory and FCONFIG are combined].
+ (fis_lookup): Image name lookup is case insensitive.
+
+2002-05-10 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c: Lots of restructuring in support of combined
+ FIS and FCONFIG data.
+
+ * cdl/redboot.cdl:
+ Add new option CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG
+ to allow FIS directory and FCONFIG data to share the same
+ physical FLASH block.
+
+2002-05-03 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c (load_flash_config): Adjust fconfig database
+ address - necessary if FLASH blocks are very small.
+
+2002-05-02 Gary Thomas <gthomas@redhat.com>
+
+ * src/load.c: Rework how decompression is done (with changes
+ noted below). Now turning on decompression works by pushing
+ the decompress code into the stream I/O.
+
+ * src/flash.c (fis_load):
+ * src/decompress.c (gzip_inflate):
+ * include/redboot.h: Make decompression code more generalized.
+
+2002-05-01 Gary Thomas <gthomas@redhat.com>
+
+ * include/elf.h: New file.
+
+ * cdl/redboot.cdl:
+ * src/load.c (load_elf_image): Support [simple] ELF images.
+
+2002-04-24 Yoshinori Sato <qzb04471@nifty.ne.jp>
+
+ * src/xyzModem.c (xyzModem_stream_terminate): Increase time for
+ cleanup from 100ms to 250ms.
+
+2002-04-23 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/syscall.c (__do_syscall): Rename EIO to NEWLIB_EIO to
+ pre-empt any potential conflict. Add definition of
+ NEWLIB_ENOSYS and use it in place of ENOSYS.
+
+2002-04-22 Jonathan Larmour <jlarmour@redhat.com>
+
+ * doc/redboot.sgml: Document iq80321 switch settings.
+
+ * include/redboot.h: Add gettimeofday, rename, isatty and system
+ syscall numbers.
+
+ * src/syscall.c (__do_syscall): Handle above new syscalls in a
+ "default" way.
+ Take new extra signal argument.
+ When required, handle file I/O syscalls, by passing into HAL.
+
+2002-04-21 Paul Fine <pfine@delcomsys.com>
+
+ * src/flash.c (flash_get_config, load_flash_config): Save a
+ pointer to the configuration structure in FLASH. If
+ flash_get_config fails to find a config item, check to make sure
+ that the config structure in RAM has not been trashed. If it has
+ been trashed, set the pointer to the "readonly" version in FLASH
+ and try to read the config item again.
+
+ * cdl/redboot.cdl (CYGSEM_REDBOOT_FLASH_CONFIG_READONLY_FALLBACK):
+ Added this flash config option to control the readonly fallback in
+ flash.c
+
+2002-04-16 Yoshinori Sato <qzb04471@nifty.ne.jp>
+2002-04-16 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/xyzModem.c: Don't return ACKs too early.
+
+2002-04-16 Gary Thomas <gthomas@redhat.com>
+
+ * src/net/bootp.c: Readjust timeouts - more, shorter. Better response.
+
+2002-04-12 Gary Thomas <gthomas@redhat.com>
+
+ * src/net/bootp.c: Increase timeouts for slower networks.
+
+2002-04-11 Nick Garnett <nickg@redhat.com>
+
+ * doc/redboot.sgml: Changed some misplaced <term>s into
+ <literal>s.
+
+2002-04-08 Nick Garnett <nickg@redhat.com>
+
+ * doc/redboot.sgml: Added full LED code desription, revised memory
+ layout and miscellaneous other fixes for 80321.
+
+2002-04-03 Gary Thomas <gthomas@redhat.com>
+
+ * src/main.c (do_mfill):
+ (do_mcmp): New routines for fill/compare random buffers.
+
+ * cdl/redboot.cdl: CDL to control mfill, mcmp, cksum commands.
+
+ * src/net/net_io.c (do_ip_addr):
+ * doc/redboot.sgml: Add new command 'ip_addr', used to set/show the
+ local and host [server] addresses.
+
+2002-04-02 Jesper Skov <jskov@redhat.com>
+
+ * redboot.sgml: excalibur: Updated memory map details, added
+ information about REDBOOT startup mode.
+
+2002-03-07 Mark Salter <msalter@redhat.com>
+
+ * src/net/tcp.c: Fix missing acks of resent segments pointed out
+ by Hendrik Ruijter.
+
+2002-03-06 Nick Garnett <nickg@redhat.com>
+
+ * doc/redboot.sgml: Added Integrator details.
+
+2002-03-06 Mark Salter <msalter@redhat.com>
+
+ * src/net/tcp.c (__tcp_handler): Slight rework of Hendrik Ruijter's
+ fix for FIN_WAIT_1 to TIME_WAIT transition.
+
+2002-03-06 Jesper Skov <jskov@redhat.com>
+
+ * doc/redboot.sgml: Updated iq80310 details.
+ Updated iq80321 details.
+ Updated e7t details.
+
+2002-03-05 Jesper Skov <jskov@redhat.com>
+
+ * doc/redboot.sgml: Updated ebsa285 details.
+ Updated ipaq details.
+ Updated edb7312 details.
+
+2002-03-05 Gary Thomas <gthomas@redhat.com>
+2002-02-25 Hendrik Ruijter <Hendrik.Ruijter@axis.com>
+
+ * include/net/net.h: Add 'reuse' flag.
+
+ * src/net/tcp.c
+ (tcp_send): Adjust socket close time to allow for faster re-use.
+ (__tcp_handler): Statetransitions to TIME_WAIT on active close
+ when FIN,ACK receivedsimultaneously.
+ (__tcp_so_reuseaddr): New function - select fast re-use.
+
+2002-03-05 Jesper Skov <jskov@redhat.com>
+
+ * doc/redboot.sgml: Add something about updating RedBoot on
+ platforms using ROMRAM-startup type RedBoot. Also mention that fis
+ create can get some of its information from the fis directory.
+ Updated assabet details.
+
+2002-03-01 Mark Salter <msalter@redhat.com>
+
+ * redboot.sgml: Add diag docs and switch setting info for 80321.
+
+2002-02-28 Hugo Tyson <hmt@redhat.com>
+
+ * src/flash.c (do_flash_config): Add "-d" to the help info.
+
+ * doc/redboot.sgml: Docuement the "-d" option for dumb terminals
+ with fconfig - so you're not forced to use line editing.
+
+2002-02-28 Jesper Skov <jskov@redhat.com>
+
+ * src/syscall.c: Moved SYS_ value definitions to the header file.
+ * include/redboot.h: Same.
+
+2002-02-27 David Howells <dhowells@redhat.com>
+
+ * sgml/redboot.sgml: Removed extraneous </para>.
+
+2002-02-26 David Howells <dhowells@redhat.com>
+
+ * doc/redboot.sgml: Updated the ASB2305 notes to be more complete
+ with respect to having two flash chips.
+
+2002-02-19 Mark Salter <msalter@redhat.com>
+
+ * src/net/net_io.c (net_io_init): Remove ISR installation. This
+ was wrong way to fix problem.
+
+2002-02-15 Mark Salter <msalter@redhat.com>
+
+ * src/net/net_io.c (net_io_init): Install default ISR for ethernet.
+
+2002-02-14 Patrick Doyle <wpd@delcomsys.com>
+
+ * src/fs/disk.c (disk_stream_read): Modified to return the number
+ of bytes read instead of -1 when such number is less than was
+ requested.
+
+2002-02-06 Mark Salter <msalter@redhat.com>
+
+ * src/syscall.c (sys_write): Call __flush after last __putc.
+ (__flush): New function to flush console output.
+
+2002-02-05 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/net/net_io.c (net_init): Set use_bootp and net_debug defaults
+ properly.
+
+2002-01-31 Gary Thomas <gthomas@redhat.com>
+
+ * src/fs/ide.c (ide_packet_read_sectors): Pass errors on read.
+ (ide_init): Ignore ATAPI devices that are not CDROM (like ZIP).
+
+2002-01-30 Hugo Tyson <hmt@redhat.com>
+
+ * src/net/net_io.c (start_console): Pick up config items to choose
+ a console for special debug messages. If it's not set, select
+ channel 0 regardless, like it used to.
+ (info_console_force, info_console_number): New fconfig options to
+ control this channel *plus* forcing application special debug out
+ to a particular serial. This is crucial for debugging debugging
+ itself, or debugging a networked app over the network when you're
+ liable to get such messages popping out from the app as well as
+ from RedBoot.
+
+ * cdl/redboot.cdl (CYGDBG_REDBOOT_NET_DEBUG_CONSOLE_NUMBER):
+ Option deleted, because this is now controlled by fconfig items.
+
+2002-01-25 Hugo Tyson <hmt@redhat.com>
+
+ * src/syscall.c (sys_profile_reset): New routine - doesn't do
+ much, just NULLs the callback. Useful placeholder in case more is
+ needed in future, eg. reset the clock also.
+ (__do_syscall): Calls the reset on syscall 2003.
+
+2002-01-21 Hugo Tyson <hmt@redhat.com>
+
+ * src/flash.c (do_flash_config): Enable a "dumb terminal" mode for
+ fconfig, which does not pre-fill the buffer for editing, but
+ merely prompts for a new value (or RET for old, for non-string
+ values). This is because telnet/kermit-like network terminal apps
+ are not by default configured to pass all characters through.
+
+2002-01-18 Hugo Tyson <hmt@redhat.com>
+
+ * src/syscall.c (sys_timer_ticks): Change this to a cyg_uint64 to
+ give better range for times() sanity in case we run the hardware
+ clock ticking at a faster rate, or want to last > 8 days.
+
+2002-01-16 Hugo Tyson <hmt@redhat.com>
+
+ * src/syscall.c (sys_profile_frequency): Change frequency that is
+ passed around to signed, so that we can enquire using -ve values.
+ Re-order the logic a little so as to permit enquiries which do not
+ modify what's set up in the hardware. Adjust the times() counter
+ when its HZ rate changes so it tells the truth.
+
+2002-01-15 David Woodhouse <dwmw2@cambridge.redhat.com>
+
+ * src/flash.c: Better default for 'fis cr' - if we're programming
+ an existing flash image, take img_size from the last-loaded image
+ but length from the one that's already on the flash.
+
+2002-01-14 David Woodhouse <dwmw2@cambridge.redhat.com>
+
+ * src/main.c: Useful defaults for cksum command.
+ * src/flash.c: Useful defaults for fis create command.
+ * src/load.c: Slight cleanup of file type detection.
+
+2002-01-14 Jesper Skov <jskov@redhat.com>
+
+ * src/net/cksum.c: Added volatile keyword to union members to
+ prevent compiler optimization messing things up.
+
+2002-01-10 Hugo Tyson <hmt@redhat.com>
+
+ * src/syscall.c (sys_timer_isr): Add CYGARC_HAL_SAVE_GP(); and
+ CYGARC_HAL_RESTORE_GP(); around the callback invocation to protect
+ ourselves from whatever the app routine might do along those lines.
+
+2002-01-10 Hugo Tyson <hmt@redhat.com>
+
+ * src/syscall.c (sys_timer_ticks): Explicitly initialize this.
+ (sys_timer_isr): Call periodic callback function, with PC and SP
+ of interrupted context, if set.
+ (sys_profile_call_back): New routine to support
+ gprof profiling of GNUPro/newlib apps via BSP_SYSCALLS. Sets the
+ periodic callback function, returning the old value.
+ (sys_profile_frequency): Ditto, sets the frequency of the call, if
+ possible, or zero => a mere inquiry.
+ (sys_timer_init, sys_times): Be prepared for a dynamic non-default
+ clock rate.
+ (__do_syscall): Handle new case arms.
+
+ * cdl/redboot.cdl (CYGSEM_REDBOOT_BSP_SYSCALLS): Changed to a
+ component; want to add stuff in here later.
+ (CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF): New option
+ to control inclusion of histogram profiling callback syscalls.
+
+2002-01-10 Jesper Skov <jskov@redhat.com>
+
+ * src/main.c (do_version): Added year 2002.
+
+2002-01-07 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c (lookup_alias): Remove warning.
+
+2002-01-03 Gary Thomas <gthomas@redhat.com>
+
+ * src/xyzModem.c (xyzModem_stream_read): BUG 57497
+ Try and detect (and remove) ^Z characters placed at end of stream.
+ This data confuses higher processing, like the zlib decompression
+ routines.
+
+2001-12-16 Mark Salter <msalter@redhat.com>
+
+ * src/fs/ide.c: Add ATAPI support.
+ * include/fs/ide.h: Add ATAPI defines.
+ * src/fs/disk.c (disk_stream_open): Fix support for IDE CDROMs.
+ (disk_parse_filename): Ditto.
+
+2001-12-12 Hugo Tyson <hmt@redhat.com>
+
+ * cdl/redboot.cdl (CYGDBG_REDBOOT_NET_DEBUG_CONSOLE_NUMBER): New
+ option to control the console number for network debug messages.
+ For platforms where serial0 is supported (due to common variant
+ HAL code) but not connected; serial1 is all you get, say.
+
+ * src/net/net_io.c (start_console): Use it.
+
+2001-12-10 Nick Garnett <nickg@redhat.com>
+
+ * src/net/cksum.c (__pseudo_sum): Fixed method of adding protocol
+ field to checksum. Some compilers optimize some of this away to
+ give a bogus result.
+
+2001-12-06 Jesper Skov <jskov@redhat.com>
+
+ * src/load.c (do_load): Fix warning.
+ * src/main.c: Added support for dumping memory in 16 and 32 bit
+ units. Based on patch from Warren Jasper <warrenj@bops.com>.
+
+2001-12-05 Hugo Tyson <hmt@redhat.com>
+
+ * src/flash.c (get_config): If we are editing an IP address, and
+ it is 0.0.0.0 (as you get at "fco -i" time) suppress using that as
+ the initial value of the string, it is unhelpful as a starting
+ point for line editing.
+
+ If we were given a value on the CLI eg. "fco bootp false" because
+ the new value was copied into the holding string, it was not
+ recognized as a change, so the flash was not updated. Bug! The
+ fix is to change the order of the strcpy()s so that holdline is
+ before line.
+
+ If the input line for a new value is completely blank, and the
+ type is not string, take this to mean don't change the value.
+ Otherwise typing in an empty line to an IP address goes off and
+ tries to DNS resolve it there and then, looks like a hang.
+
+ (do_flash_config): If we print the message "** invalid entry" do
+ not just loop; set onevalue = NULL so that the user is prompted
+ for a good value. Otherwise it loops forever trying the same
+ value if you typed "fco bootp goat" (goat being a bad boolean).
+
+ * src/parse.c (parse_bool): Check for (partial) rest of the word
+ either "true" or "false" and nothing extra. Thus we reject
+ "truefalse" as is all to easy to type in by accident. "TRU" "T"
+ "tRuE" are all OK of course.
+
+ * src/net/inet_addr.c (inet_aton): Do not accept terminating the
+ dot-quad address with a final dot. Else typing on the end of a
+ provided-for-editing string is accepted. Also reject units > 255.
+ Allow typing in either exactly one (large) number or 4 small ones;
+ reject intermediates. Thus we reject "10.16.19.1110.16.19.33" and
+ "0.0.0.010.16.19.11" as are all to easy to type in by accident,
+ and things like 10.0.0xffff which used to be accepted. 0x0a00ffff
+ is OK though. This change also prevents the pointer s running off
+ the end of the string if you just entered eg. "1".
+
+2001-12-04 Richard Sandiford <rsandifo@redhat.com>
+
+ * include/net/net.h (ETH_MAX_PKTLEN): Increase to match definition
+ of MAX_ETH_MSG.
+
+2001-12-04 Richard Sandiford <rsandifo@redhat.com>
+
+ * src/net/tcp.c (__tcp_poll): Call MS_TICKS_DELAY before __timer_poll.
+ * src/net/net_io.c (net_io_getc): Remove MS_TICKS_DELAY from here...
+ (net_io_getc_nonblock): ...and from here.
+
+2001-11-30 Jesper Skov <jskov@redhat.com>
+
+ * src/net/net_io.c (net_init): Print ESA for device even if bootp
+ fails.
+
+2001-11-29 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/net/dns.c: Rename index -> ptdindex to avoid conflict with BSD
+ index() function.
+
+2001-11-29 Jesper Skov <jskov@redhat.com>
+
+ * src/net/tftp_client.c (tftp_stream_open): Clear from_addr's
+ sin_port so multiple loads are possible.
+
+2001-11-26 Jesper Skov <jskov@redhat.com>
+
+ * misc/redboot_XXX.ecm: Added. Replaced the _RAM, _ROM, and
+ _ROMRAM variants.
+
+ * misc/redboot_ROM.ecm: Added configuration with all packages
+ relevant for a full RedBoot configuration. Whenever new (optional)
+ RedBoot peer packages are added, they should be added to these
+ files and not the RedBoot template.
+ * misc/redboot_ROMRAM.ecm: Same.
+ * misc/redboot_RAM.ecm: Same.
+
+2001-11-15 Jesper Skov <jskov@redhat.com>
+
+ * include/redboot.h: Added load_address and load_address_end
+ variables to hold bounds of a loaded image.
+ * src/load.c: Fill load_address and load_address_end after srec
+ and binary loads.
+ * src/flash.c: Same.
+ * src/main.c (do_go): removed unneeded cast.
+
+2001-11-14 Gary Thomas <gthomas@redhat.com>
+
+ * src/io.c (_rb_gets_preloaded): More correct timeout handling.
+ n.b. in practice, this changes nothing, but it is more "correct".
+
+2001-11-05 Gary Thomas <gthomas@redhat.com>
+
+ * src/load.c: Minor typo in help string.
+
+ * src/io.c (_rb_gets_preloaded): Clear buffer if ^C.
+
+2001-11-02 Jesper Skov <jskov@redhat.com>
+
+ * src/flash.c (fis_init): Fix warning.
+
+2001-11-01 Jesper Skov <jskov@redhat.com>
+
+ * src/flash.c (fis_init): tweaks to the SIB protection code.
+
+2001-11-01 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c (fis_init): Need to init block fully, otherwise old
+ images can persist after init.
+
+2001-10-31 Jesper Skov <jskov@redhat.com>
+
+ * include/sib.h: Contains information about ARM Boot Monitor flash
+ block information.
+
+ * cdl/redboot.cdl: Added CYGOPT_REDBOOT_FIS_DIRECTORY_ARM_SIB_ID
+ option.
+
+ * src/flash.c (fis_init): Added code to add ARM Boot Monitor
+ footer on FIS block.
+
+2001-10-30 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/flash.c (fis_delete): Prototype arm_fis_delete in correct place.
+ (fis_list): Fix compilation problem - this isn't C++!
+
+2001-10-30 Philippe Robin <Philippe.Robin@arm.com>
+2001-10-30 Jonathan Larmour <jlarmour@redhat.com>
+
+ * cdl/redboot.cdl: Add CYGINT_REDBOOT_ARM_FLASH_SIB_SUPPORTED and
+ CYGHWR_REDBOOT_ARM_FLASH_SIB to indicate support for, and a request
+ to provide ARM flash block structure support.
+
+ * src/flash.c (fis_list): Call out to driver for ARM block FIS listing.
+ (fis_delete): Call out to driver for ARM block FIS deletion.
+
+2001-10-29 Gary Thomas <gthomas@redhat.com>
+
+ * src/main.c (cyg_start): New pseudo-commands, useful for scripts.
+ '# anything' - treated like a comment.
+ '= anything' - comment, but prints command line on console.
+
+ * src/flash.c (expand_aliases): Don't expand aliases which are
+ quoted, but only on the command line. This allows aliases to
+ expand into other aliases which are within quoted strings.
+
+ * include/redboot.h:
+ * src/io.c (_rb_gets_preloaded): New function which allows for a
+ buffer to be displayed and edited in place. This is extremely
+ useful for 'fconfig', now that better line editing functions are
+ supported.
+
+ * src/flash.c (get_config): Using new function _rb_gets_preloaded(),
+ which supports edit-in-place for data items.
+
+2001-10-28 Gary Thomas <gthomas@redhat.com>
+
+ * src/main.c (cyg_start):
+ * src/io.c (_rb_gets):
+ * include/redboot.h: Add new global control 'cmd_history' which is
+ used to enable/disable command history collection. This keeps the
+ history from being cluttered with things like 'y' (answers to simple
+ questions).
+
+2001-10-26 Gary Thomas <gthomas@redhat.com>
+
+ * src/io.c (_rb_gets): Fix ^A editing - was timing out, thus erasing
+ buffer [silently].
+
+2001-10-25 Gary Thomas <gthomas@redhat.com>
+
+ * src/io.c:
+ * cdl/redboot.cdl: Add command line history and edit functions.
+ Controlled by CYGNUM_REDBOOT_CMD_LINE_EDITING option which defines
+ the depth of the history buffer.
+
+2001-10-22 Jonathan Larmour <jlarmour@redhat.com>
+
+ * include/redboot.h: Declare net_debug here.
+
+2001-10-18 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/net/net_io.c (net_init): Set cyg_io_eth_net_debug from net_debug.
+ * include/net/net.h: Declare cyg_io_eth_net_debug.
+
+2001-10-18 David Howells <dhowells@redhat.com>
+
+ * src/syscall.c: Added support for the times() syscall and marked
+ the utime() syscall as being implemented incorrectly.
+
+2001-10-18 Gary Thomas <gthomas@redhat.com>
+
+ * src/io.c (_rb_gets): Fix parsing of \" in strings.
+
+2001-10-16 Jesper Skov <jskov@zoftcorp.adsl.dk>
+
+ * cdl/redboot.cdl: Require ISOINFA.
+
+2001-10-16 Jesper Skov <jskov@redhat.com>
+
+ * src/net/dns.c (send_recv): Clear from_addr before passing it to
+ __udp_recvfrom. Fixed return value.
+
+2001-10-16 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c (_do_flash_init):
+ Add wrapper function for do_flash_init() to avoid compiler warning.
+
+ * src/io.c (_rb_gets):
+ Use sub-timeouts when calling mon_read_char_with_timeout() as it
+ was intended that this routine should timeout quickly to allow
+ for other processing to take place if no data is available. In
+ practice this won't make any difference unless the global "idle"
+ timeout value is changed to be something quite large.
+
+ * src/decompress.c: Improve memory allocators. Also use 'init'
+ style function so that this is the only file that knows anything
+ of the details of the decompression process or packaging.
+
+ * src/main.c:
+ * include/redboot.h:
+ * cdl/redboot.cdl: Rework decompression to be totally encapsulated.
+ This keeps the details of this functionality in a single file, rather
+ than scattered throughout RedBoot.
+
+2001-10-15 David Howells <dhowells@redhat.com>
+
+ * src/xyzModem.c: put semicolon between goto-label and close curly.
+
+2001-10-15 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c (_expand_aliases): Change around some ambiguous code.
+
+ * src/main.c:
+ * src/decompress.c:
+ * include/redboot.h:
+ * cdl/redboot.cdl: Provide RedBoot specific memory allocators
+ for ZLIB. Allows much finer control over memory map.
+
+ * src/main.c (do_dump): Add option "-s" to dump data as S-records.
+
+2001-10-11 Gary Thomas <gthomas@redhat.com>
+
+ * src/net/enet.c (__enet_poll): Suppress warning messages.
+
+2001-10-10 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/flash.c (do_flash_init): Only set __flash_init when init is
+ successful.
+
+2001-10-04 Jesper Skov <jskov@redhat.com>
+
+ * src/fs/disk.c: Fix ISO9660 build error.
+
+ * src/main.c: Added x as an alias for the dump command.
+
+ * src/net/dns.c: Fixed some messages (DNS -> DNS server).
+
+2001-10-02 Gary Thomas <gthomas@redhat.com>
+
+ * src/xyzModem.h:
+ * src/xyzModem.c (xyzModem_stream_open):
+ * src/load.c (do_load): Add new option "-c <N>" to let the user
+ specify the I/O channel to use - xyModem only.
+
+2001-10-01 Gary Thomas <gthomas@redhat.com>
+
+ * src/net/udp.c (__udp_recvfrom): Don't change server address (returned
+ by this function) until a packet has been received with no timeout.
+
+2001-09-28 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/flash.c (fis_create): if not copying, still update directory.
+
+2001-09-28 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c (_expand_aliases): Properly null terminate expanded
+ string - failed if alias was at end of line.
+
+2001-09-27 Jesper Skov <jskov@redhat.com>
+
+ * src/net/dns.c: Include tracing header.
+
+2001-09-26 Jesper Skov <jskov@redhat.com>
+
+ * src/net/dns.c: Removed errno hacks.
+ Reduce size of string buffers. Make sure they suffice (or fail).
+
+ * include/redboot.h: Added DNS h_errno definitions.
+
+ * include/redboot.h: Fix for building on targets wo network.
+
+ * src/load.c (do_load): Make sure host can be reached - and print
+ appropriate error message if not.
+
+ * src/net/net_io.c (net_init): Call DNS init when appropriate.
+
+ * src/net/inet_addr.c (inet_aton): Made s argument const.
+
+ * src/net/dns.c: Added UDP driven DNS support.
+
+ * src/net/bootp.c: Fixed warnings.
+
+ * src/flash.c: Replaced inet_aton with _gethostbyname.
+ * src/load.c: Same.
+ * src/net/ping.c: Same.
+
+ * include/net/net.h: Fix warning.
+
+ * include/redboot.h: Added DNS stuff, including some string
+ helpers.
+
+ * cdl/redboot.cdl: Added DNS support options.
+
+2001-09-14 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/version.c: Simplify _CERTIFICATE handling.
+
+2001-09-13 Fabrice Gautier <Fabrice_Gautier@sdesigns.com>
+
+ * cdl/redboot.cdl: Added configuration options to deactivate BOOTP and
+ enable net debug.
+ * src/net/net_io.c (net_init): Use them.
+
+2001-09-13 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c: Cleanups - removing some redundant code.
+
+2001-09-12 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/flash.c (do_flash_init): Only allocate fis block when
+ CYGOPT_REDBOOT_FIS enabled.
+ Conditionalize fis_work_block and fisdir_size.
+
+2001-09-12 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c (load_flash_config): Use additional space in the
+ FLASH work area (at end of RAM) for 'fconfig' data. This reduces
+ overall stack requirements as there is no need for 'fconfig' data
+ to be held on the stack anymore.
+
+ * src/flash.c:
+ * include/fis.h: Define flash addresses using CYG_ADDRESS which
+ is more portable than (unsigned long).
+
+2001-09-11 Jonathan Larmour <jlarmour@redhat.com>
+
+ * cdl/redboot.cdl (CYGPKG_REDBOOT_FLASH): Be conditional on an
+ actual flash device, not just the generic flash layer.
+
+2001-09-11 Gary Thomas <gthomas@redhat.com>
+
+ * src/version.c (_CERTIFICATE): Add information about product
+ certification (either Red Hat certified or not).
+
+ * src/flash.c (fis_delete): Deny user deleting "reserved" images.
+
+2001-09-07 Andrew Lunn <andrew.lunn@ascom.ch>
+ * src/flash.c: Extend the alias handling to allow configuration
+ information to be access using alias. Fixed alias expansion
+ when the alias is bigger than the replacement.
+ * src/parse.c: A semi colon can be used to separate multiple
+ commands on one line.
+
+2001-09-06 Jonathan Larmour <jlarmour@redhat.com>
+
+ * include/redboot.h: Include string function prototype header.
+
+2001-09-06 Jesper Skov <jskov@redhat.com>
+
+ * src/fs/ide.c (ide_read_sectors): Use diag_(s)printf.
+ * src/fs/disk.c (do_disks): Same.
+
+2001-08-27 Andrew Lunn <andrew.lunn@ascom.ch>
+ * src/flash.c: Allow the flash blocks used for FIS directory and
+ config information to be user configured. Generalise the fis_init
+ function to deal with the blocks in any order.
+ * cdl/redboot.cdl: Added the configury needed to specify which
+ flash blocks to use.
+
+2001-08-27 Mark Salter <msalter@redhat.com>
+
+ * src/syscall.c (HZ): Should be 60 for ARM, also.
+
+2001-08-24 Tim Smith <tsmith@redhat.com>
+ * src/xyzModem.c
+ * src/xyzModem.h
+ Provide xyzModem_stream_terminate() function to abort/clean up
+ XYZmodem download on normal termination or after errors.
+
+ * src/load.c
+ Use aforementioned function to abort downloads on SREC errors,
+ stop load_srec_image() from injecting stuff into the XYZmodem
+ stream and confusing things.
+
+2001-08-24 Mark Salter <msalter@redhat.com>
+
+ * src/net/net_io.c: Don't close connections if there is
+ data left to read or write.
+
+ * src/syscall.c: Add support for utimes syscall.
+
+2001-08-22 Gary Thomas <gthomas@redhat.com>
+
+ * src/net/udp.c:
+
+ * src/net/pktbuf.c:
+
+ * src/net/ping.c:
+
+ * src/net/net_io.c:
+
+ * src/net/inet_addr.c:
+
+ * src/net/enet.c:
+
+ * src/fs/e2fs.c:
+
+ * src/xyzModem.c:
+ * src/parse.c:
+ * src/misc_funs.c:
+ * src/main.c:
+ * src/load.c:
+ * src/io.c:
+ * src/flash.c:
+ * include/net/net.h:
+ * include/redboot.h:
+ printf() is no longer a part of RedBoot. Thus all programs
+ must use diag_printf() and related functions instead. Also
+ renamed the non-standard function gets() to be _rb_gets()
+ since there was some confusion about it because of it's
+ rather standard name.
+
+ * cdl/redboot.cdl: Lots of changes based on moving all printf()
+ functionality into "infra" and only using it as diag_XXX().
+
+2001-08-17 Gary Thomas <gthomas@redhat.com>
+
+ * src/version.c: Augment version information with startup mode.
+
+ * src/flash.c (fis_find_free): Fix error in size comparisons.
+ (load_flash_config): Fix 'fconfig' alignment now that it's
+ size is no longer fixed.
+
+2001-08-16 Jesper Skov <jskov@redhat.com>
+ [from branch]
+ * cdl/redboot.cdl: Also behave as ROM monitor in ROMRAM
+ configurations.
+
+ * src/load.c (do_load): Fix handling of conditional options.
+
+ * src/flash.c (fis_load): Fix handling of conditional options.
+ (fis_delete): Fix behavior on failure.
+
+ * src/flash.c (fis_write): Fix output.
+ (fis_create): Only update directory when programming succeeded.
+
+2001-08-17 Jonathan Larmour <jlarmour@redhat.com>
+
+ * cdl/redboot.cdl (CYGSEM_REDBOOT_VARIABLE_BAUD_RATE): Default
+ on, but only if platform supports it.
+
+2001-08-15 Mark Salter <msalter@redhat.com>
+
+ * src/io.c: Add support for "{...}" notation in boot scripts.
+
+2001-08-14 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/io.c (gets): Allow $'s and +'s to be escaped.
+
+2001-08-10 Jesper Skov <jskov@redhat.com>
+
+ * src/flash.c (do_flash_init): Print error message instead of
+ error code on init failure.
+ Don't print error codes where error messages are printed. Make
+ failure reporting strings look consistent.
+ CYGHWR_IO_FLASH_BLOCK_LOCKING flavor changed to booldata.
+
+2001-08-08 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/io.c (gets): Match $ as indicating GDB anywhere in a line.
+
+2001-08-07 Julian Smart <julians@redhat.com>
+
+ * src/version.c: added commented-out CYGDAT_REDBOOT_CUSTOM_VERSION
+ define that can be replaced using the RedBoot release script by
+ a specific version in a customer branch.
+
+2001-08-06 Jesper Skov <jskov@redhat.com>
+
+ * src/fs/disk.c: Simple fix for DISK_IDE_CDROM partition type.
+
+ * cdl/redboot.cdl: Added (unused) CYGSEM_REDBOOT_DISK_ISO9660 option.
+
+2001-08-03 David Howells <dhowells@redhat.com>
+
+ * src/net/net_io.c: Show the MAC address of the ethernet device
+ amongst the boot banners.
+
+2001-08-01 Mark Salter <msalter@redhat.com>
+
+ * src/fs/ide.c (ide_reset): Check for bogus status and timeout. Add
+ return value to indicate success.
+ (ide_init): Check ide_reset() return value.
+
+2001-07-31 Mark Salter <msalter@redhat.com>
+
+ * src/fs/disk.c (find_dos_partitions): Fix extended partitions.
+ * src/fs/ide.c (ide_init): Rework the test for device presence.
+
+2001-07-27 Gary Thomas <gthomas@redhat.com>
+
+ * src/load.c (load_srec_image, do_load):
+ * cdl/redboot.cdl: New option CYGSEM_REDBOOT_VALIDATE_USER_RAM_LOADS
+ which can be used to disable user RAM checks in 'load' command.
+
+ * src/load.c: Fix build problem if no IDE support.
+
+ * src/net/tftp_client.c (tftp_stream_read): Only ACK data when it
+ has been processed and we're ready for the next block. This fixes
+ a race/timing issue which was exacerbated by the "spinner" in 'load'.
+
+2001-07-27 David Howells <dhowells@redhat.com>
+
+ * src/xyzModem.c: Fixed an uninitialised variable warning.
+
+2001-07-27 Mark Salter <msalter@redhat.com>
+
+ * cdl/redboot.cdl (CYGNUM_REDBOOT_MAX_PARTITIONS): New option.
+ Rename CYGBLD_REDBOOT_MAX_DISKS to CYGNUM_REDBOOT_MAX_DISKS.
+
+ * include/fs/disk.h: Exported functions declared "externC".
+ Replace MAX_PARTITIONS with CYGNUM_REDBOOT_MAX_PARTITIONS.
+
+ * src/fs/disk.c: Make exported functions "externC".
+ Rename CYGBLD_REDBOOT_MAX_DISKS to CYGNUM_REDBOOT_MAX_DISKS.
+ Replace MAX_PARTITIONS with CYGNUM_REDBOOT_MAX_PARTITIONS.
+
+ * src/fs/e2fs.c: Add support for symbolic links.
+ * include/fs/e2fs.h: Add dir filetype support.
+
+2001-07-24 Mark Salter <msalter@redhat.com>
+
+ * src/load.c: Add disk load support.
+ * src/fs/disk.c: New file. RedBoot disk management.
+ * src/fs/ide.c: New file. IDE disk I/O.
+ * src/fs/e2fs.c: New file. Linux ext2 filesystem support.
+ * cdl/redboot.cdl: Add options for disk/ide/filesystem support.
+
+2001-07-23 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/main.c (set_console_baud_rate): No need to query the console
+ number if we don't care what it is.
+ (do_baud_rate): Likewise.
+
+2001-07-23 David Howells <dhowells@redhat.com>
+
+ * src/flash.c: Force block-alignment for flash addresses in write
+ and erase functions.
+
+2001-07-20 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/net/net_io.c (net_init): Don't overwrite static IP
+ address when reading flash config if configured to not use BOOTP.
+ Set have_net if not using BOOTP and a default static IP addr is set.
+
+2001-07-19 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c: Be more generic with 'fconfig' layout. In
+ particular, handle case where FLASH block size is too small
+ to hold fconfig data.
+
+ * src/io.c (mon_set_read_char_timeout): Fix dangling else bug.
+
+ * src/flash.c (do_flash_init): Suppress printing info - this
+ will happen when 'version' is called. Also allow flash subsystem
+ to be initialized when there is no 'fconfig' or 'fis' command
+ configured in (but flash support still is present).
+
+ * src/version.c: Display complete version information which
+ reflects such information as the source release, etc.
+
+ * cdl/redboot.cdl: New option CYGDAT_REDBOOT_CUSTOM_VERSION used to
+ allow site-specific version information. Define this via the
+ CDL like this:
+ cdl_option CYGDAT_REDBOOT_CUSTOM_VERSION {
+ user_value 1 "Special test version"
+ };
+
+2001-07-18 Gary Thomas <gthomas@redhat.com>
+
+ * src/net/net_io.c (net_io_putc, net_io_isr):
+ Need CYGARC_HAL_SAVE_GP()/CYGARC_HAL_RESTORE_GP() to support
+ network debugging since different layers of eCos programs are
+ involved.
+
+2001-07-16 Gary Thomas <gthomas@redhat.com>
+
+ * src/main.c (do_version): Use external function _flash_info() to
+ display information about installed FLASH.
+
+ * src/load.c (load_srec_image): Remove extra '\n' on out of range msg.
+
+ * src/flash.c (_flash_info): New function - displays information
+ about FLASH found in system. Used by 'version' command.
+
+2001-07-12 Gary Thomas <gthomas@redhat.com>
+2001-07-12 Fabrice Gautier <gautier@email.enst.fr>
+
+ * cdl/redboot.cdl: Improve some descriptions of options.
+
+2001-07-02 Jesper Skov <jskov@redhat.com>
+
+ * src/io.c (do_channel): Fox build for !CYGPKG_REDBOOT_ANY_CONSOLE
+
+2001-06-28 Jonathan Larmour <jlarmour@redhat.com>
+
+ * cdl/redboot.cdl: Don't have a configured default IP address by
+ default if we have fconfig.
+ * src/net/ip.c: Provide a default ip addr if not defined.
+
+2001-06-28 Jesper Skov <jskov@redhat.com>
+
+ * src/load.c (do_load): Don't allow verbose to be used with serial
+ downloads.
+
+ * src/main.c (do_reset): Reset via VV function.
+
+2001-06-27 Hugo Tyson <hmt@redhat.com>
+
+ * src/io.c: Provide proto for do_channel() to reduce warning.
+
+2001-06-27 Jonathan Larmour <jlarmour@redhat.com>
+
+ * cdl/redboot.cdl (CYGDAT_REDBOOT_DEFAULT_IP_ADDR): Provide a compiled
+ in default IP address.
+ * src/net/ip.c: Initialize __local_ip_addr with it.
+ * src/net/bootp.c: Restore the previous __local_ip_addr if BOOTP fails.
+
+ * include/redboot.h: Fix another VARIBLE_BAUD_RATE typo. Fun this.
+
+2001-06-26 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/io.c (do_channel): New function to display/switch console
+ channel
+
+ * src/main.c: Move define of CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS to
+ * include/redboot.h: ...here
+
+2001-06-26 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c (load_flash_config): Fix another VARIBLE_BAUD_RATE typo.
+
+ * src/xyzModem.c (xyzModem_get_hdr): ACK on EOT was missing.
+
+2001-06-22 Gary Thomas <gthomas@redhat.com>
+
+ * src/load.c (do_load): Move [static] data used by decompression
+ code into this routine where it is used - no longer static.
+
+2001-06-14 Gary Thomas <gthomas@redhat.com>
+
+ * src/xyzModem.c (xyzModem_get_hdr): More resilient header scan,
+ improves error handling capability by avoiding "early" aborts.
+
+ * src/load.c (do_load): Only check TFTP arguments if networking.
+
+ * src/flash.c: Reorg to support new config option (below).
+
+ * cdl/redboot.cdl: New option CYGOPT_REDBOOT_FIS used to enable
+ FIS oriented commands. Other flash commands, e.g. 'fis write',
+ still exist even if disabled.
+
+ * src/main.c (do_dump): 'dump' with no arguments will now "continue"
+ dumping from where the last command left off.
+
+2001-06-13 Gary Thomas <gthomas@redhat.com>
+
+ * src/main.c (cyg_start):
+ * src/io.c (gets):
+ * cdl/redboot.cdl: Support RedBoot without GDB stubs. Later
+ versions may also support alternate debug environments.
+
+2001-06-12 Gary Thomas <gthomas@redhat.com>
+
+ * src/net/net_io.c (net_io_putc): Flush data on '\n'.
+
+2001-06-11 Jonathan Larmour <jlarmour@redhat.com>
+
+ * doc/redboot.ebsa285: Remove, obsolete.
+ * doc/redboot.edb7xxx: Ditto.
+ * doc/users_guide: Ditto.
+
+2001-06-11 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c (fis_create): Remove default for "-s" - too dangerous!
+
+ * include/net/tftp.h: Make sure packet size is valid (was one byte
+ too long).
+
+ * src/net/tftp_client.c (tftp_stream_open): Fix problem when using
+ Windows (3Com at least) servers.
+
+ * src/flash.c: Remove dependency on printf() via user function
+ in flash drivers, provided at 'init' time.
+
+2001-06-08 Gary Thomas <gthomas@redhat.com>
+
+ * src/parse.c (parse): Check for 'argv[]' overruns.
+
+ * src/main.c (ZLIB_COMPRESSION_OVERHEAD): Update - based on observations.
+
+ * src/net/tftp_client.c:
+ * src/net/net_io.c:
+ * src/net/enet.c:
+ * include/redboot.h (MAX_ARGV): Minor memory reduction/tightening.
+
+2001-06-08 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/main.c (do_caches): HAL_DCACHE_IS_ENABLED is not present
+ on all arch's, so conditionalize. Ditto HAL_ICACHE_IS_ENABLED.
+
+2001-06-08 Nick Garnett <nickg@cygnus.co.uk>
+
+ * src/main.c (cyg_start): Added code to disable interrupts on all
+ comm channels before entering GDB. If this is not done then stray
+ interrupts from an otherwise idle ethernet controller can cause
+ mayhem in the application.
+
+ * src/net/net_io.c (net_io_control): Added code to set static
+ vector number in disable case as well as enable case.
+ (net_io_init): Added call to net_io_control() to disable network
+ interrupts initially. Mainly to get current disable state
+ correctly set.
+
+2001-06-07 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/load.c (do_load): Ask confirmation of RAM write addr, rather
+ than automatically denying.
+ (load_srec_image): Ditto.
+
+ * src/io.c (verify_action): Don't ask if we're executing a script.
+
+2001-06-07 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c (expand_aliases): Allow aliases/macros to be nested.
+
+ * src/main.c (set_console_baud_rate):
+ * src/flash.c (do_alias): Force 'fconfig' updates.
+
+ * include/flash_config.h (flash_add_config): New signature.
+ Parameter 'update' controls whether the Flash is updated.
+
+2001-06-07 <gthomas@redhat.com>
+
+ * src/load.c (do_load): Tidy some messages.
+
+ * src/flash.c (fis_load): Print image limits (memory range) when
+ loading a compressed image.
+
+2001-06-06 Mark Salter <msalter@redhat.com>
+
+ * include/net/tftp_support.h (TFTP_TIMEOUT_PERIOD): Increase to 5.
+
+ * src/net/udp.c (__udp_recvfrom): Initialize server source port
+ to zero.
+ (__udp_recvfrom_handler): Validate server source port before
+ accepting packet.
+
+2001-05-29 Jesper Skov <jskov@redhat.com>
+
+ * src/flash.c (fis_load): Fix compiler warning.
+
+2001-05-25 Gary Thomas <gthomas@redhat.com>
+
+ * src/main.c (set_console_baud_rate): Couldn't restore baud
+ rate to default value!
+ (do_baud_rate): Update baud rate in flash config database.
+
+ * src/flash.c (do_flash_config): Add "-i" option to force
+ initialization of entire configuration database.
+ (do_alias): Improve handling of existing aliases.
+
+2001-05-24 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c (get_config):
+ (do_alias): Be more careful about length of strings accepted.
+
+ * cdl/redboot.cdl: Make 'fconfig' data space and strings larger.
+
+ * src/main.c (cyg_start): Expand aliases on input commands.
+
+ * src/flash.c: Add support for aliases (macros). Also update
+ support for 'fconfig' strings.
+
+ * include/flash_config.h (MAX_STRING_LENGTH): Infer from CDL.
+
+ * cdl/redboot.cdl: Add options for [FLASH based] aliases.
+ Also, 'fconfig' now supports strings.
+
+2001-05-23 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c: Fixed typo as below.
+
+2001-05-22 Jonathan Larmour <jlarmour@redhat.com>
+
+ * cdl/redboot.cdl: Fix typo: CYGSEM_REDBOOT_VARIBLE_BAUD_RATE ->
+ CYGSEM_REDBOOT_VARIABLE_BAUD_RATE
+ * src/main.c: Ditto.
+
+2001-05-17 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/net/tftp_client.c: include redboot.h for have_net.
+
+2001-05-17 Dennis Ehlin <Dennis.Ehlin@ecs.ericsson.se>
+ (with minor mods by jlarmour@redhat.com)
+
+ * cdl/redboot.cdl: Split boot script functionality into separate
+ component. Rename some options not to be specific to FLASH.
+ Add default boot script option.
+ * src/main.c (cyg_start): Use default boot script if none provided
+ in FLASH (or indeed no FLASH). Support renamed CDL options.
+ * src/io.c (gets): Support renamed CDL options.
+ (verify_action): Ditto.
+ * src/flash.c: Ditto.
+ * include/redboot.h: Ditto.
+
+2001-05-17 Gary Thomas <gthomas@redhat.com>
+
+ * src/crc.c (crc32): Remove unused variable/warning.
+
+ * src/main.c (set_console_baud_rate, do_baud_rate):
+ * src/flash.c:
+ * include/redboot.h:
+ * cdl/redboot.cdl: Add support for variable, settable, console
+ baud rate.
+
+ * src/net/tftp_client.c (tftp_stream_open): Don't try if no network.
+
+2001-05-10 Gary Thomas <gthomas@redhat.com>
+
+ * cdl/redboot.cdl: Can't build RedBoot without virtual vectors.
+
+2001-05-09 Mark Salter <msalter@redhat.com>
+
+ * src/main.c (cyg_start): Cast CYGACC_CALL_IF_DELAY_US argument
+ to a cyg_int32. Needed when sizeof(int) < sizeof(cyg_int32).
+
+2001-05-07 Gary Thomas <gthomas@redhat.com>
+
+ * src/net/net_io.c (net_io_isr): Interrupt acknowledgement
+ should rightly be done by the driver 'delivery' routine, not here.
+
+2001-04-26 Gary Thomas <gthomas@redhat.com>
+
+ * src/main.c (do_caches): Display cache state if no arguments.
+
+2001-04-13 Gary Thomas <gthomas@redhat.com>
+
+ * src/net/ping.c (do_ping): Tidy message.
+
+2001-04-12 Robin Farine <acnrf@dial.eunet.ch>
+2001-04-12 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/io.c (gets): Checks for buffer overflow and returns buflen
+ if it reaches the end of the buffer.
+ * src/main.c (cyg_start): Cope with gets() return being the
+ buffer length.
+
+2001-04-12 Mark Salter <msalter@redhat.com>
+2001-04-12 Robin Farine <acnrf@dial.eunet.ch>
+
+ * src/net/enet.c (__eth_install_listener): Does not accept a
+ handler for an eth_type less than 0x800.
+ (__enet_poll): Only scan the handlers for a frame type greater
+ than 0x800.
+
+2001-04-09 Mark Salter <msalter@redhat.com>
+
+ * src/printf.c (_vprintf): Fixed some portability problems where
+ sizeof(int) != sizeof(long).
+
+2001-04-09 Hugo Tyson <hmt@redhat.com>
+
+ * src/main.c (do_cksum): Reduce warning absent posix_crc32().
+
+ * src/main.c (cyg_start): Compare ram_end against workspace_end to
+ see if there is *less* SDRAM than the MLT suggested, and shorten
+ workspace et al accordingly. This is needed if some SDRAM is
+ "stolen" for use by eg. a PCI window, and mapped far away.
+
+2001-04-03 Gary Thomas <gthomas@redhat.com>
+
+ * src/load.c (do_load): Fix 'raw' loading to check for valid
+ base address _before_ trying to load anything. Also, some
+ reorg to make raw vs non-raw cleaner.
+
+2001-04-02 Hugo Tyson <hmt@redhat.com>
+
+ * src/flash.c (get_config): Update to support some new syntax:
+ fco -l -n ... lists showing nicknames instead of titles.
+ fco -l -n -f ... lists showing both nicknames and titles.
+ fco nickname ... goes straight to editing only nickname.
+ fco nick value ... sets nickname to value.
+ All then follow the usual flow out, including the question
+ Update RedBoot non-volatile configuration - are you sure (y/n)
+ as it should be if you made a change.
+
+2001-03-29 Mark Salter <msalter@redhat.com>
+
+ * cdl/redboot.cdl (CYGSEM_REDBOOT_FIS_CRC_CHECK): New option to
+ enable (default) or disable CRC checks in FIS images.
+ * src/flash.c: Use CYGSEM_REDBOOT_FIS_CRC_CHECK to decide whether
+ to provide CRC for flash images.
+
+2001-03-28 Mark Salter <msalter@redhat.com>
+
+ * src/net/tcp.c (__tcp_handler): Don't send ACK from TIME_WAIT state
+ unless the FIN comes in again.
+
+2000-03-27 Grant Edwards <grante@visi.com>
+
+ * src/net/tcp.c (__tcp_handler): Fixed sequence number bug seen when
+ doing an active close.
+
+2001-03-23 Gary Thomas <gthomas@redhat.com>
+
+ * src/printf.c (_vprintf): Support %u (unsigned) descriptor.
+
+ * src/main.c (do_cksum): New command to compute and print a POSIX
+ checksum on a range of memory.
+
+ * src/crc.c (posix_crc32): New routine - matches POSIX algorithm.
+
+2001-03-21 Gary Thomas <gthomas@redhat.com>
+
+ * cdl/redboot.cdl: Back off previous change in number of packets.
+ Also change minimum - below this, network debugging fails.
+
+ * src/flash.c (fis_write): New function - support raw writes to FLASH.
+
+ * src/net/enet.c (__enet_poll): Try to continue if out of packets.
+
+ * src/main.c:
+ * src/load.c:
+ * src/flash.c:
+ * include/redboot.h: Keep track of available "user" RAM.
+
+ * cdl/redboot.cdl: Reduce default number of [network] packets.
+
+2001-03-20 Gary Thomas <gthomas@redhat.com>
+
+ * src/net/net_io.c (net_io_test): Change for new calling convention.
+
+ * src/main.c (cyg_start): Idle processing now in I/O routines.
+
+ * src/io.c (gets): Move idle processing into this function.
+
+ * include/net/net.h (net_io_test): Needs idle parameter.
+
+ * include/redboot.h: Change 'idle' functions to take state (idle/not).
+
+2001-03-19 Jesper Skov <jskov@redhat.com>
+
+ * cdl/redboot.cdl: Put version.o file in the public lib directory
+ so other packages can get at it and link redboot.
+
+2001-03-16 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c (fis_create): Preserve memory [load/exec] address
+ when making assumptions [rewriting existing image].
+
+2001-03-16 Mark Salter <msalter@redhat.com>
+
+ * src/main.c (cyg_start): Restore console channel after returning
+ from stub.
+
+2001-03-15 Gary Thomas <gthomas@redhat.com>
+2001-03-15 Grant Edwards <grante@visi.com>
+
+ * src/net/bootp.c (bootp_handler): Guard against buffer overflow.
+
+2001-03-15 Hugo Tyson <hmt@redhat.com>
+
+ * src/flash.c (fis_create): The code was installing a default for
+ img_size from data_length of an extant record. That's zero, so,
+ so whilst the flash was erased, no data was copied in!
+ (fis_list): Added a -d to get the data length field displayed.
+
+2001-03-15 Jesper Skov <jskov@redhat.com>
+
+ * src/main.c: Make use of script variable conditional on flash.
+
+ * include/redboot.h: Changed type of workspace_end to silence
+ warning.
+
+ * src/net/ping.c (do_ping): Fix warning.
+ * src/net/pktbuf.c (__pktbuf_dump): Fix warnings.
+
+2001-03-14 Gary Thomas <gthomas@redhat.com>
+
+ * src/main.c (do_go): Make timeout code consistent with other
+ versions, e.g. script timeout. Also, allow a script to continue
+ if it was in effect when 'go' was called and ^C was typed.
+
+ * src/flash.c (fis_create): Ask for additional user verification
+ if any [important] parameters are being assumed [left out by user].
+ This just adds a level of safety in the presence of assumptions.
+
+2001-03-13 Gary Thomas <gthomas@redhat.com>
+
+ * src/main.c: Define 'workspace' based on MLT files, rather than
+ simply using end of RAM area.
+
+ * src/flash.c: Use 'workspace' for scratch area.
+
+ * include/redboot.h: Define new variables 'workspace_XXX' to specify
+ ares used by RedBoot for scratch, etc.
+
+2001-03-12 Jesper Skov <jskov@redhat.com>
+
+ * src/decompress.c: Removed Z_BAD_CRC hack. zlib does CRC checking
+ now.
+
+2001-03-09 Jesper Skov <jskov@redhat.com>
+
+ * src/misc_funs.c: Added strncpy.
+ * include/redboot.h: And declaration.
+
+2001-03-08 Jesper Skov <jskov@redhat.com>
+
+ * src/load.c (do_load): Added decompression support.
+ * src/flash.c (fis_load): Same.
+
+ * src/decompress.c: Added. Interfaces the zlib API.
+
+ * include/redboot.h: Added some definitions used by decompression
+ code.
+
+ * cdl/redboot.cdl: Added option to control size of zlib bounce
+ buffer.
+
+2001-03-05 Jesper Skov <jskov@redhat.com>
+
+ * src/main.c (cyg_start): Make sure communication channels are
+ initialized.
+
+2001-03-03 Gary Thomas <gthomas@redhat.com>
+
+ * src/main.c (do_idle): New function - all 'idle' handling is here.
+
+ * src/io.c (mon_read_char_with_timeout): Improve timeout handling
+ when scanning for a console by applying the minimum possible value
+ (1 ms) to each channel, accumulating the total value. The previous
+ algorithm was quite poor on systems where there is no buffering,
+ i.e. serial channels with no FIFOs, because each channel would
+ wait for T/N (t = total timeout, N = number channels). This might
+ possibly have been much longer than the devices could tolerate and
+ still return valid data.
+
+2001-03-01 Gary Thomas <gthomas@redhat.com>
+
+ * src/version.c: Add 'bootstrap' to banner so the world can see
+ more of what RedBoot's all about.
+
+2001-02-28 Gary Thomas <gthomas@redhat.com>
+
+ * include/redboot.h: Fix prioritization of 'init' table entries.
+
+2001-02-26 Gary Thomas <gthomas@redhat.com>
+
+ * include/redboot.h (RedBoot_INIT_PRIO): Slight change - avoid
+ arithmetic which C preprocessor doesn't handle anyway. This also
+ fixes prioritizing init entries.
+
+ * src/flash.c (fis_load): Only load actual data [length] when loading
+ an image.
+
+ * cdl/redboot.cdl: Change build rule to always rebuild 'version.o'
+ whenever the application is relinked. Thus the version string will
+ always accurately reflect the actual build date/time.
+
+2001-02-22 Hugo Tyson <hmt@redhat.com>
+
+ * cdl/redboot.cdl: New config options to control default creation
+ of various FIS image files. Also opt for a reserved area at the
+ base of flash, eg. for user's POST or other pre-RedBoot code that
+ we must not interfere with. This isn't the same as the extant
+ boot_offset option, so the two are made to work together.
+ Likewise an offset for the start of a POST-cooperative RedBoot
+ image, if any; the value is of course platform dependent, not
+ simply after the first RedBoot image, if there is one.
+
+ Clarification: a POST-cooperative RedBoot image is a ROM-start
+ image that runs at a higher address in ROM, and which omits some
+ of the hardware initialization because it's already done by
+ whatever came before. Most targets do not have such a thing;
+ those that do, it is created by a config export file, not by a new
+ startup type. A POST Redboot can be tested from a plain ROM
+ redboot by just calling its entrypoint once it is installed in
+ flash; eg. by "go 0x50040044" at the RedBoot prompt.
+
+ * src/flash.c (fis_init): Create additional optional entries for
+ o (reserved) reserved area at start, for preboot or post code.
+ o RedBoot itself now optional
+ o RedBoot[post]
+ o RedBoot[backup]
+ Also initialize their addresses, sizes, accordingly.
+ The default behaviour is unchanged.
+ The flash erase is moved to after the fis table init because the
+ fis table init most conveniently calculates the high water mark of
+ built-in default objects.
+ (fis_create): If creating a file which already exists (most likely
+ one of the preconfigured defaults) pick up Flash address and
+ length (the two required parameters) from there. They're required
+ to be the same to it's no loss of generality, and saves typing,
+ makes the default entries far more useful and so on.
+ (fis_delete): Skip those entries which were
+ preconfigured; we want nobody to be able to delete these.
+ (fis_free): Start searching for free space to list only after the
+ reserved base area - if there is one.
+ (fis_find_free): Start searching for free space only after the
+ reserved base area...
+
+2001-02-22 Jesper Skov <jskov@redhat.com>
+
+ * src/flash.c: Added default case to switch statement.
+
+2001-02-20 Gary Thomas <gthomas@redhat.com>
+
+ * src/load.c: Remove unnecessary \r from usage message.
+
+ * src/printf.c (_vprintf): Ensure CR/LF sequence, not LFCR.
+
+ * src/net/ping.c:
+ * src/flash.c: Better usage messages [no naked linefeeds].
+
+ * src/net/ping.c: Tidy up usage message. Check for reasonable
+ packet lengths.
+
+ * src/load.c: Tidy up usage message.
+
+2001-02-16 Nick Garnett <nickg@cygnus.co.uk>
+
+ * src/flash.c (load_flash_config): Move setting of config_ok to
+ true to before we look for a script to run. Otherwise scripts just
+ don't work.
+
+2001-02-14 Hugo Tyson <hmt@redhat.com>
+
+ * src/load.c (do_load): Wrap the help message at < 80 cols and fix
+ a coupla warnings.
+
+2001-02-13 Hugo Tyson <hmt@redhat.com>
+
+ * src/flash.c: Fix token/string pasting thinko: ## operators are
+ not needed and do confuse some compilers.
+
+2001-02-12 Jesper Skov <jskov@redhat.com>
+
+ * src/main.c: Use CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL instead
+ of CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL.
+
+2001-02-11 Gary Thomas <gthomas@redhat.com>
+
+ * src/net/ping.c (do_ping): Accomodate new MS_TICKS scheme.
+
+2001-02-09 Grant Edwards <grante@visi.com>
+
+ * include/net/net.h (MS_TICKS_DELAY): New macro, different from
+ MS_TICKS() so that MS_TICKS() gets the current tick count, and
+ MS_TICKS_DELAY is used in a delay loop to actually do a delay.
+
+ * src/ticks.c (get_ms_ticks): New function imlementing rework of
+ MS_TICKS
+
+ * src/net/net_io.c (net_io_getc): Use MS_TICKS_DELAY() instead of
+ CYGACC_CALL_IF_DELAY_US() directly
+ (net_io_getc_timeout): Likewise
+
+ * src/net/udp.c (__udp_recvfrom): MS_TICKS -> MS_TICKS_DELAY
+ * src/net/bootp.c (__bootp_find_local_ip): Likewise
+
+2001-02-09 Jonathan Larmour <jlarmour@redhat.com>
+2001-02-09 Grant Edwards <grante@visi.com>
+
+ * src/net/net_io.c (net_io_getc_nonblock): Silence compiler warning
+
+2001-01-31 Gary Thomas <gthomas@redhat.com>
+
+ * include/redboot.h:
+ * cdl/redboot.cdl:
+ * src/flash.c: Use new CRC functions.
+
+ * src/crc.c: New file - supports 16 and 32 bit CRC functions.
+
+2001-01-31 Grant Edwards <grante@visi.com>
+
+ * src/net/net_io.c (net_io_test): Use new idle function to
+ poll for incoming network connections. Removes #if requirements
+ from the main CLI loop.
+
+ * src/main.c (cyg_start):
+ * include/redboot.h (RedBoot_idle): Add new tables to support
+ user defined functions to be called when idle (during command input).
+
+2001-01-31 Gary Thomas <gthomas@redhat.com>
+
+ * include/redboot.h:
+ * src/main.c (cyg_start):
+ * src/net/net_io.c (net_io_getc_nonblock): Forgo TELNET escape
+ processing if GDB is active (requires 8-bit clean connection).
+
+2001-01-31 Nick Garnett <nickg@cygnus.co.uk>
+
+ * src/syscall.c (__do_syscall):
+ Added SYS_meminfo syscall.
+ This is used by the MIPS3264 GNUPro runtime.
+
+ * src/net/net_io.c (net_io_getc_nonblock):
+ Telnet escape processing temporarily disabled because it does not
+ work.
+
+2001-01-31 Grant Edwards <grante@visi.com>
+
+ * include/net/net.h:
+ * src/net/enet.c (__eth_install_listener, __eth_remove_listener):
+ New functions - allow user registerable callout to handle
+ non-standard ethernet packets.
+
+2001-01-30 Gary Thomas <gthomas@redhat.com>
+
+ * src/main.c (do_reset): HAL macro name changed.
+
+ * src/net/ping.c (do_ping): Remove warning.
+
+ * src/main.c (do_help): Only display help for selected topic
+ if provided.
+
+2001-01-24 Jonathan Larmour <jlarmour@redhat.com>
+
+ * src/main.c (cyg_start): Rework last change to use more generic
+ HAL_MEM_REAL_REGION_TOP macro.
+
+2001-01-24 Hugo Tyson <hmt@redhat.com>
+
+ * src/main.c (cyg_start): Take notice of the hal_dram_size
+ variable (only supported on ARMs) to set ram_end. The symbols
+ given by the CYGMEM_REGION_ram symbols are minima or defaults.
+
+2001-01-22 Gary Thomas <gthomas@redhat.com>
+
+ * src/net/inet_addr.c (inet_aton): Fix byte order on big endian
+ systems.
+
+ * src/net/icmp.c (__icmp_install_listener):
+ (__icmp_remove_listener): New functions.
+ (__icmp_handler): Call listener for unhandled packets.
+
+ * include/net/net.h: Add handler for ICMP [incoming] data.
+
+ * cdl/redboot.cdl:
+ * src/net/ping.c: New CLI command - ping a host.
+
+2001-01-18 Gary Thomas <gthomas@redhat.com>
+
+ * include/net/net.h:
+ * src/net/pktbuf.c (__pktbuf_alloc):
+ * src/net/tcp.c (__tcp_listen): Remove obsolete code regarding
+ 'eth_hdr' stored with packet buffer.
+
+2001-01-17 Hugo Tyson <hmt@redhat.com>
+
+ * src/io.c (dump_buf_with_offset): Fix previous change so it
+ compiles; variable names used not same as parm names in func.
+
+2001-01-16 Gary Thomas <gthomas@redhat.com>
+
+ * src/xyzModem.c: Improved debug support - now allows debug
+ trace to be kept in memory and dumped at completion.
+
+ * src/io.c (vdump_buf_with_offset): New function which allows
+ dumping via any generic "print" function.
+
+ * include/redboot.h: Export new print/dump functions.
+
+2001-01-08 Gary Thomas <gthomas@redhat.com>
+
+ * src/net/arp.c: Add special case handling for ARP(self).
+
+2001-01-03 Gary Thomas <gthomas@redhat.com>
+
+ * src/main.c (do_version): Update copyright for 2001.
+
+ * src/io.c (gets): Use timeout provided [was hardcoded to 50ms!]
+
+2000-12-21 Mark Salter <msalter@redhat.com>
+
+ * src/flash.c (fis_init): Use CYGBLD_REDBOOT_FLASH_BOOT_OFFSET to
+ decide where to create default images.
+
+ * cdl/redboot.cdl (CYGBLD_REDBOOT_FLASH_BOOT_OFFSET): Use this
+ to define offset from start of FLASH to start of boot image.
+
+2000-12-15 Gary Thomas <gthomas@redhat.com>
+
+ * src/version.c: Define GDB stubs version here as well. Also
+ add warnings and informationabout how all of this works.
+
+2000-12-13 Gary Thomas <gthomas@redhat.com>
+
+ * src/version.c: New file.
+
+ * src/main.c:
+ * cdl/redboot.cdl: Reorg - main.c is now treated like all other
+ files. New file 'version.c' holds the special stuff used at
+ build time to get interesting version information into the
+ final product.
+
+2000-12-12 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c (get_config): Increase size of input buffer used
+ during 'fconfig' command.
+
+2000-12-11 Gary Thomas <gthomas@redhat.com>
+
+ * src/main.c: Change in HAL layering - need to include proper
+ file to get 'reset' definition.
+
+2000-12-08 Jonathan Larmour <jlarmour@redhat.com>
+
+ * cdl/redboot.cdl: Tweak CYGPKG_REDBOOT_MAX_CMD_LINE description.
+
+2000-12-07 Gary Thomas <gthomas@redhat.com>
+
+ * src/main.c (cyg_start): Make CLI command buffer static.
+ (do_reset): New command - reset platform from CLI.
+
+ * src/io.c (dump_buf_with_offset): Change signature for
+ more generic export.
+
+ * include/redboot.h: Export 'dump_buf_with_offset' function.
+
+ * cdl/redboot.cdl: Define CLI command buffer - static with
+ user specified length - to accomodate some environments which
+ may want excrutiatingly long commands.
+
+2000-12-07 Jesper Skov <jskov@redhat.com>
+
+ * src/misc_funs.c (strlen): NULL ptr string has length 0.
+
+ * src/load.c (load_srec_image): Refuse to load data to a location
+ not in RAM.
+
+ * src/flash.c (fis_create): Hack around another MIPS compiler bug.
+
+2000-12-06 Jesper Skov <jskov@redhat.com>
+
+ * src/load.c: Suppress verbosity when using xyz modem download.
+
+ * src/main.c: Fix warnings.
+ * src/load.c: Fix warnings.
+
+ * src/parse.c (parse_num): Hack around MIPS compiler bug.
+
+2000-12-01 Gary Thomas <gthomas@redhat.com>
+
+ * src/xyzModem.h:
+ * src/xyzModem.c (xyzModem_stream_close): New function - tidy up
+ and print some statistics about the download. Better handling
+ of CAN (cancel) function.
+
+ * src/load.c (load_srec_image): Consume all data, not just to
+ final record. This makes Ymodem happier. Also, call xyzModem_close().
+
+2000-11-30 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c (fis_create): Add new option '-n' which suppresses
+ the copy from RAM to FLASH. Used to simply update the FIS directory.
+ Also misc printf() changes - add 0x everywhere hex is used.
+
+ * src/net/net_io.c (_net_io_getc_nonblock): Abstract function.
+ (net_io_getc_nonblock): Add minimal handling of telnet escape
+ sequences - required to properly handle ^C.
+
+ * src/main.c (cyg_start): Support network connection during
+ boot/startup script. Use new codes from 'gets()'.
+
+ * src/flash.c (fis_create): Cleanup to remove warnings.
+
+ * include/net/net.h (BSPLOG): Update for new start/end_console().
+
+ * src/io.c (gets):
+ * include/redboot.h (_GETS_xxx): Define result codes from
+ 'gets()' function.
+
+2000-11-28 Gary Thomas <gthomas@redhat.com>
+
+ * src/parse.c (parse): Support escaped quote marks inside of
+ quoted string. "ab\"c\"" is 'ab"c"'.
+
+ * src/net/tftp_client.c (tftp_stream_open): Read first datum from
+ file during open to ensure that errors are reported.
+
+2000-11-27 Drew Moseley <dmoseley@redhat.com>
+
+ * src/main.c: Switch to an application stack before running a
+ user-downloaded app.
+
+2000-11-20 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c: Use CYGBLD_REDBOOT_MIN_IMAGE_SIZE.
+
+ * cdl/redboot.cdl(CYGBLD_REDBOOT_MIN_IMAGE_SIZE): Define this to
+ be the minimum size allowed for FIS images.
+
+ * src/xyzModem.c: Tidy up debug support. Fix some synch problems
+ so that X/Y modem protocols now work properly with Windows/Hyperterm.
+
+2000-11-20 Mark Salter <msalter@redhat.com>
+
+ * src/net/net_io.c (net_io_flush): Add __tcp_drain to make sure
+ everything is successfully sent out.
+ (net_io_control): Call net_io_flush for __COMMCTL_FLUSH_OUTPUT.
+
+2000-11-19 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c (fis_create): Print more info when length check fails.
+
+ * src/main.c: Split version display into separate command.
+
+2000-11-06 Mark Salter <msalter@redhat.com>
+
+ * src/syscall.c: New file. Common handling for bsp syscalls.
+
+ * cdl/redboot.cdl: Add CYGSEM_REDBOOT_BSP_SYSCALLS option to
+ turn on BSP syscall support.
+
+2000-11-06 Jesper Skov <jskov@redhat.com>
+
+ * src/net/net_io.c (net_io_flush): Clear interrupt flag before
+ setting breakpoint.
+
+2000-10-30 Gary Thomas <gthomas@redhat.com>
+
+ * src/net/udp.c:
+ * src/net/pktbuf.c:
+ * src/net/net_io.c:
+ * src/net/enet.c:
+ * include/net/net.h: Minor cleanups to remove warnings.
+
+ * cdl/redboot.cdl: Support threads in all but RAM mode. Note:
+ this should allow thread support in ROM and FLOPPY startup mode.
+
+2000-10-27 Gary Thomas <gthomas@redhat.com>
+
+ * src/xyzModem.c (xyzModem_stream_open): Add extra delay during
+ startup - to give the sender time to get started.
+
+ * src/flash.c (fis_load): Add "-c" option to show checksum of
+ image after loading.
+ (fis_list): Add "-c" to display stored checksums.
+
+2000-10-26 Mark Salter <msalter@redhat.com>
+
+ * src/load.c (do_load): Move some local variable declarations
+ needed by xyzmodem support so they can be used when redboot
+ networking not enabled.
+
+2000-10-26 Gary Thomas <gthomas@redhat.com>
+
+ * cdl/redboot.cdl: Improve CDL so CYGSEM_HAL_ROM_MONITOR can
+ be correctly infered (when building ROM versions).
+
+ * cdl/redboot.cdl:
+ * src/load.c: Add support for xyzModem serial download.
+
+ * src/xyzModem.h:
+ * src/xyzModem.c: New file(s).
+
+2000-10-24 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c:
+ * cdl/redboot.cdl: Add new option which supports keeping all
+ important RedBoot data "locked" in FLASH.
+
+2000-10-23 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c (fis_lookup): New exported function.
+ (fis_load): Add memory load option. Also checksum data after copy.
+
+ * include/fis.h: Add 'data_length' member.
+ Prototype for 'fis_lookup()'.
+
+ * src/main.c (bist): New [weak] function. Provide hook for
+ platform specific "builtin tests". This will be overridden by
+ platform based functions.
+
+ * cdl/redboot.cdl:
+ * src/main.c (cyg_start):
+ * src/flash.c: Script timeout now has a configurable resolution.
+
+2000-10-21 Gary Thomas <gthomas@redhat.com>
+
+ * src/net/eth_drv.c: Removed obsolete file - now provided by
+ standard IO/ETH package.
+
+2000-10-20 Gary Thomas <gthomas@redhat.com>
+
+ * src/net/pktbuf.c: Diagnostc - add buffer [list] dumper.
+
+ * src/net/enet.c: Diagnostic - dump when run out of buffers.
+
+ * src/flash.c: Make sure RedBoot flash image size meets
+ certain minimums - currently at least 128K.
+
+2000-10-19 Gary Thomas <gthomas@redhat.com>
+
+ * cdl/redboot.cdl: Add dependency on 'vectors.o'.
+
+ * include/redboot.h:
+ * src/misc_funs.c (strcpy, memcmp):
+ Make function signature [prototype] conform to standards.
+ (memmove, memset): Remove.
+
+2000-10-18 Gary Thomas <gthomas@redhat.com>
+
+ * cdl/redboot.cdl: Improve dependency checking in make rules.
+
+2000-10-17 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c (fis_create): Add new "-s" option to support padded
+ images (data size not the same as image size in FLASH).
+
+ * include/fis.h: New file - make structure available for export.
+
+ * src/parse.c: New file.
+
+ * include/redboot.h:
+ * src/main.c:
+ * cdl/redboot.cdl: Split command line parsing functions to separate
+ file.
+
+2000-10-05 Gary Thomas <gthomas@redhat.com>
+
+ * src/net/net_io.c (net_io_revert_console):
+ (net_io_assume_console):
+ * src/main.c (cyg_start):
+ * src/io.c (gets):
+ * include/redboot.h: Add notion of "console_echo" so that telnet
+ connections don't echo doubly. Note: there is no telnet negotiation
+ at this time, so some things are still not perfect.
+
+2000-09-17 Gary Thomas <gthomas@redhat.com>
+
+ * src/main.c: Display platform/cpu identification strings if available.
+
+ * cdl/redboot.cdl: Improve CDL to include thread support if
+ built in ROM mode. Also, better handling of network option.
+
+2000-09-15 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c (fis_create): Length (and flash address) must match
+ exactly when replacing an image.
+ Only warn of invalid memory addresses, not fail.
+
+2000-09-13 Gary Thomas <gthomas@redhat.com>
+
+ * src/load.c: Better handling of bad data / checksum errors.
+
+ * src/flash.c: Handle case of replacing an image, even if no flash
+ address was given.
+
+ * include/net/tftp_support.h: Modify timeouts, etc, for better response.
+
+2000-09-12 Gary Thomas <gthomas@redhat.com>
+
+ * src/io.c (mon_read_char_with_timeout): Only "select" a console
+ when real data (non-zero) arrives.
+
+2000-09-10 Gary Thomas <gthomas@redhat.com>
+
+ * src/load.c:
+ * src/flash.c: Remove warnings if built without networking.
+
+2000-09-11 Jonathan Larmour <jlarmour@redhat.com>
+
+ * include/redboot.h (_RedBoot_init): Define tables entries as structs
+ with one member rather than just func ptrs, to enforce alignment rules
+ * src/main.c (cyg_start): Change to use struct init_tab_entry per above
+
+2000-09-07 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * src/load.c, include/redboot.h: renamed the getc functions to
+ redboot_getc and made them global so custom boot loaders can use
+ them.
+
+2000-09-06 Gary Thomas <gthomas@redhat.com>
+
+ * doc/users_guide: Add info about region locking/unlocking.
+
+2000-09-04 Jonathan Larmour <jlarmour@redhat.com>
+
+ * include/flash_config.h (struct config_option): Apply
+ CYG_HAL_TABLE_TYPE
+ * include/redboot.h: Ditto for struct cmd and void_fun_ptr
+
+2000-09-01 Hugo Tyson <hmt@cygnus.co.uk>
+
+ * src/flash.c: CYGHWR_IO_FLASH_BLOCK_LOCKING is an interface, so
+ it's always defined; look for > 0 instead.
+
+2000-08-28 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c: Support block locking if available.
+
+2000-08-25 Gary Thomas <gthomas@redhat.com>
+
+ * src/load.c (getc): Fix edge condition when file is an exact multiple
+ of internal buffer size (got stuck at end of file).
+
+2000-08-24 Gary Thomas <gthomas@redhat.com>
+
+ * src/load.c: Fix some prints. Also use command line parse functions
+ instead of ad hoc code.
+
+ * src/flash.c: Better configuration control.
+
+2000-08-23 Gary Thomas <gthomas@redhat.com>
+
+ * src/load.c (do_load): Use paramterized command line parser.
+
+ * include/redboot.h:
+ * src/main.c (scan_opts): Better support for simple flags.
+
+ * src/flash.c: Add "-l" (list only) option to 'fconfig'.
+
+ * src/net/net_io.c: Add handling of ^C via network connections.
+
+ * include/flash_config.h:
+
+ * include/redboot.h: Fully qualify table entries (for proper
+ sorting and order control).
+
+ * cdl/redboot.cdl: Update requirements to support ^C and thread
+ debugging.
+
+2000-08-21 Gary Thomas <gthomas@redhat.com>
+
+ * cdl/redboot.cdl:
+ * src/net/pktbuf.c (MAX_PKTBUF): Add CDL configury for number
+ of network packet buffers.
+
+ * src/net/net_io.c: Change config param names to enforce
+ layout (config fields are sorted by name).
+
+ * src/load.c: Adapt to changes in 'parse_num'.
+
+ * src/main.c (parse_num): Now takes additional arguments which
+ allow a delimiter set and returning the end of number string.
+
+ * include/redboot.h: Augment 'parse_num' to handle strings
+ with more than one number, delimiters, etc.
+
+ * src/flash.c:
+ * include/flash_config.h: Add support for ethernet hardware
+ addresses.
+
+2000-08-20 Gary Thomas <gthomas@redhat.com>
+
+ * include/flash_config.h: New file - configuration data layout.
+
+ * src/flash.c: Restructure config data to be 100% table driven.
+
+ * include/redboot.h:
+ * include/net/bootp.h:
+ * include/net/net.h:
+ * include/net/tftp.h:
+ * include/net/tftp_support.h: New location.
+
+ * src/printf.c:
+ * src/net/arp.c:
+ * src/net/bootp.c:
+ * src/net/cksum.c:
+ * src/net/enet.c:
+ * src/net/icmp.c:
+ * src/net/inet_addr.c:
+ * src/net/ip.c:
+ * src/net/net_io.c:
+ * src/net/pktbuf.c:
+ * src/net/tcp.c:
+ * src/net/tftp_client.c:
+ * src/net/timers.c:
+ * src/net/udp.c: Include files moved.
+
+ * src/redboot.h:
+ * src/net/bootp.h:
+ * src/net/net.h:
+ * src/net/tftp.h:
+ * src/net/tftp_support.h: Files moved.
+
+ * cdl/redboot.cdl: Move .h files to include directory.
+
+2000-08-16 Gary Thomas <gthomas@redhat.com>
+
+ * src/io.c (dump_buf_with_offset): Clean up warnings.
+
+ * src/net/net_io.c: Cosmetic - clean up TCP debug code.
+
+ * src/main.c (cmd_search): Search for ambiguous commands was
+ wrong since layout change (only know the limits, don't rely
+ on "null" entry).
+
+2000-08-14 Gary Thomas <gthomas@redhat.com>
+
+ * cdl/redboot.cdl: Support for plugin (table driven) modules.
+
+ * src/flash.c: Lots of warning cleanups.
+
+ * src/io.c: Fix some flash configury.
+
+ * src/load.c: Make internal buffer unsigned so 'raw' mode
+ works properly. Also, support as a plugin command.
+
+ * src/main.c:
+ * src/redboot.h: Add support for "tableized" entries. In
+ particular, commands and platform initializations can now
+ be handled via anonymous tables.
+
+ * src/net/net.h: Update for changes in network init setup.
+
+ * src/net/net_io.c: Move network initialization here.
+
+2000-08-07 Gary Thomas <gthomas@redhat.com>
+
+ * src/net/net.h:
+ * src/redboot.h:
+ * src/main.c: Cosmetic [warnings] cleanups.
+
+2000-08-03 Gary Thomas <gthomas@redhat.com>
+
+ * cdl/redboot.cdl: Ethernet driver now comes from common
+ I/O package.
+
+ * src/io.c (verify_action): Force normal I/O (no script)
+ to get response.
+
+ * src/main.c: Add script timeout to allow user to abort before
+ script is run on boot.
+
+ * src/printf.c: '%p' implies zero filled long format.
+
+ * src/flash.c:
+ * src/redboot.h: Add TCP socket and script timeouts.
+
+ * src/net/net_io.c: TCP socket for debug is now configurable
+ and settable in FLASH. Better handling of GDB $O packets (less
+ latency). Additional small changes to support network debug.
+
+2000-07-30 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c: Make config data safer with a 'key'. Also, don't
+ erase the config data when doing a full FIS initialization.
+ Finally, ensure that the commands which erase data are not going
+ to erase the current code!
+
+ * src/io.c (gets): Treat 'delete' char like ^H.
+
+2000-07-30 Gary Thomas <gthomas@redhat.com>
+
+ * cdl/redboot.cdl: Add option for FLASH based configuration data.
+
+ * src/flash.c: Lots of changes to support FLASH based configuration
+ data, including routines to read and maintain this data.
+
+ * src/main.c:
+ * src/redboot.h: Many changes for FLASH configuration data support.
+ Also split out table driven option/parameter parsing.
+
+ * src/io.c: Allow ^C to abort input. Fix timeout stuff to
+ work better while waiting for console to be discovered.
+ Add support for boot-time script.
+
+ * src/load.c: Use new IP/INET address functions.
+
+ * src/net/bootp.c: Remove force of net_debug and result print.
+
+ * src/net/inet_addr.c: IP/INET address conversion routines.
+
+ * src/net/net.h: Make 'net_debug' be boolean. Add IP/INET
+ address conversion routine prototypes.
+
+2000-07-29 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c: Misc little cleanups.
+
+ * src/load.c: Print address range of loaded image/file.
+
+2000-07-29 Gary Thomas <gthomas@redhat.com>
+
+ * src/flash.c: Add 'load' command which loads an image into RAM.
+
+ * src/load.c: Add '-raw' switch to allow loading a file without
+ trying to interpret it as an executable image.
+
+ * src/main.c:
+ * src/redboot.h: Make command parsing functions public.
+
+2000-07-29 Gary Thomas <gthomas@redhat.com>
+
+ * src/net/bootp.c: Turn on network debug during address discovery.
+ (Note: this will be optional/configurable in the future).
+
+ * src/net/eth_drv.c: Use 'net_debug' for diagnostic dumps.
+
+ * src/redboot.h: Prototypes for new functions.
+
+ * src/printf.c (vprintf): New function.
+
+ * src/io.c (verify_action): New function.
+
+ * cdl/redboot.cdl: Make FLASH support optional.
+
+ * src/flash.c: New file - implements simple FLASH Image System.
+
+ * src/misc_funs.c (memset):
+ (strcpy): New functions.
+
+ * src/main.c: Split flash functions to separate file.
+
+2000-07-28 Gary Thomas <gthomas@redhat.com>
+
+ * src/load.c: Add "-v" switch to turn on a little 'spinner' while
+ downloading to provide some feedback to the user.
+
+ * src/printf.c: Use only RedBoot I/O to allow console to "float."
+
+ * src/net/bootp.c: Force hardware type to be "original" ethernet.
+
+ * cdl/redboot.cdl:
+ * src/redboot.h:
+ * src/main.c:
+ * src/io.c:
+ * src/net/net_io.c: Support "floating" console, chosen from
+ available serial I/O channels.
+
+2000-07-26 Gary Thomas <gthomas@redhat.com>
+
+ * src/net/tftp_support.h:
+ * src/net/tftp_client.c: Add new stream oriented functions.
+
+ * src/net/net.h: More prototypes.
+
+ * src/redboot.h: Move support functions here. Update interfaces.
+
+ * src/printf.c: Support %l (long) qualifier.
+
+ * src/misc_funs.c: Misc cleanups. Add case insensitive routines.
+
+ * src/main.c: FLASH functionality is now in it's own package.
+
+ * src/net/eth_drv.c:
+ * include/eth_drv.h: Update to new interface conventions.
+
+ * cdl/redboot.cdl: Changes for new files(s).
+
+2000-07-24 Gary Thomas <gthomas@redhat.com>
+
+ * src/net/inet_addr.c: New file. Support for IP address parsing.
+
+ * src/load.c: New file. Split out download functionality.
+ Restructured to support download via stream (zmodem).
+
+ * src/misc_funs.c: Add case insensitive compare functions.
+
+2000-07-22 Gary Thomas <gthomas@redhat.com>
+
+ * src/main.c (do_load): Add proper argument parsing.
+
+2000-07-21 Gary Thomas <gthomas@redhat.com>
+
+ * src/io.c (gets): Treat "\n\r" and "\r\n" as exactluy "\n". This
+ solves problems of simply ignoring "\n" on terminals which can only
+ send that character while still working with telnet/TCP connections.
+
+ * src/net/net_io.c: New file. Supports local I/O via a TCP channel.
+ Additional changes to support TCP channel for GDB debug I/O.
+
+ * cdl/redboot.cdl: Clean up dependencies. Extend network configuration.
+
+ * src/io.c (gets): Ignore blank lines which contain only '\n'.
+ This works fine for terminal I/O since they will have '\r' and it
+ allows reasonable handling when connected via telnet/TCP.
+
+ * src/main.c: Better support for network connections.
+ Also some reworking of FLASH routines [will be moved later].
+ More error checking and better error messages in download code.
+
+ * src/net/net.h: Reorder 'tcp_socket' fields to enforce proper
+ alignment of data buffer [needs to be on dword boundary].
+
+ * src/net/tcp.c: Many small changes getting 'endian'-ness correct.
+
+ * src/net/tftp_client.c (tftp_error): New function - returns a
+ string representing the error code [for humans].
+
+2000-07-16 Gary Thomas <gthomas@redhat.com>
+
+ * cdl/redboot.cdl: Make network support configurable/optional.
+
+ * src/io.c: Add command line input function.
+
+ * src/main.c: Lots of new functions, command line processing, etc.
+
+ * src/misc_funs.c (strcmp, strncmp): New function(s).
+
+ * src/printf.c: Add support for "%p" (pointers).
+
+ * src/redboot.h: Expand, move global vars, here, etc.
+
+ * src/net/eth_drv.c: Make quieter, change "no interface" string.
+
+ * src/net/net.h (__LITTLE_ENDIAN__): Avoid redefining this on platforms
+ where GCC does it for us.
+
+2000-07-12 Gary Thomas <gthomas@redhat.com>
+
+ * cdl/redboot.cdl: New file(s).
+
+//===========================================================================
+// ####GPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+//
+// 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 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., 51 Franklin Street,
+// Fifth Floor, Boston, MA 02110-1301, USA.
+// -------------------------------------------
+// ####GPLCOPYRIGHTEND####
+//===========================================================================
diff --git a/ecos/packages/redboot/current/cdl/redboot.cdl b/ecos/packages/redboot/current/cdl/redboot.cdl
new file mode 100644
index 0000000..8ce6d34
--- /dev/null
+++ b/ecos/packages/redboot/current/cdl/redboot.cdl
@@ -0,0 +1,1350 @@
+# ====================================================================
+#
+# redboot.cdl
+#
+# Redboot package configuration data
+#
+# ====================================================================
+## ####ECOSGPLCOPYRIGHTBEGIN####
+## -------------------------------------------
+## This file is part of eCos, the Embedded Configurable Operating System.
+## Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
+##
+## eCos 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 or (at your option) any later
+## version.
+##
+## eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+##
+## As a special exception, if other files instantiate templates or use
+## macros or inline functions from this file, or you compile this file
+## and link it with other works to produce a work based on this file,
+## this file does not by itself cause the resulting work to be covered by
+## the GNU General Public License. However the source code for this file
+## must still be made available in accordance with section (3) of the GNU
+## General Public License v2.
+##
+## This exception does not invalidate any other reasons why a work based
+## on this file might be covered by the GNU General Public License.
+## -------------------------------------------
+## ####ECOSGPLCOPYRIGHTEND####
+# ====================================================================
+######DESCRIPTIONBEGIN####
+#
+# Author(s): gthomas
+# Original data: gthomas
+# Contributors: Philippe Robin, Andrew Lunn, tkoeller
+# Date: 2000-05-01
+#
+#####DESCRIPTIONEND####
+#
+# ====================================================================
+cdl_package CYGPKG_REDBOOT {
+ display "Redboot ROM monitor"
+ doc redboot-guide/redboot-guide.html
+ define_header redboot.h
+ description "
+ This package supports the Redboot \[stand-alone debug monitor\]
+ using eCos as the underlying board support mechanism."
+
+ # Use of separate interrupt stack causes problems when running
+ # programs as they can end up trashing RedBoot's stack
+ requires { CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK == 0 }
+
+ # Since the CYGDAT_REDBOOT_CONSOLE_DEV setting ends up in the platform
+ # HAL header, we need to include that here (via hal.h).
+ define_proc {
+ puts $::cdl_header "#include <pkgconf/hal.h>"
+ }
+
+ cdl_component CYGSEM_REDBOOT_ELF {
+ flavor bool
+ display "Include support for ELF file format"
+ default_value 1
+
+ cdl_option CYGOPT_REDBOOT_ELF_VIRTUAL_ADDRESS {
+ display "Use the virtual address in the ELF headers"
+ flavor bool
+ default_value 0
+ description "
+ The ELF headers contain both a virtual and a physical address
+ for where code/data should be loaded. By default the physical
+ address is used but sometimes it is necassary to use the
+ virtual address because of bugy toolchains"
+ }
+ }
+
+
+ cdl_interface CYGINT_REDBOOT_LOAD_METHOD {
+ display "Methods of loading images using redboot"
+ }
+
+ cdl_component CYGBLD_BUILD_REDBOOT {
+ display "Build Redboot ROM ELF image"
+ default_value 0
+ requires CYGPKG_INFRA
+ requires CYGPKG_ISOINFRA
+
+ requires ! CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT
+ requires ! CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT
+ requires ! CYGDBG_HAL_COMMON_CONTEXT_SAVE_MINIMUM
+ requires CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
+ requires CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_COMMS
+
+ requires CYGINT_ISO_STRING_MEMFUNCS
+ requires CYGINT_ISO_STRING_STRFUNCS
+ requires CYGINT_REDBOOT_LOAD_METHOD
+
+ cdl_option CYGBLD_BUILD_REDBOOT_WITH_GDB {
+ display "Include GDB support in RedBoot"
+ no_define
+ default_value 1
+ active_if CYGINT_HAL_DEBUG_GDB_STUBS
+ requires CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
+ requires CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
+ description "
+ RedBoot normally includes support for the GDB debugging
+ protocols. This option allows this to be disabled which
+ may yield a substantial savings in terms of code and memory
+ usage by RedBoot."
+ }
+
+ cdl_option CYGBLD_BUILD_REDBOOT_WITH_THREADS {
+ display "Threads debugging support"
+ no_define
+ description "
+ Enabling this option will include special code in the
+ GDB stubs to support debugging of threaded programs. In
+ the case of eCos programs, this support allows GDB to
+ have complete access to the eCos threads in the
+ program."
+ active_if { CYG_HAL_STARTUP != "RAM" }
+ requires CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT
+ }
+
+ cdl_option CYGDAT_REDBOOT_CUSTOM_VERSION {
+ display "Customized version string"
+ flavor booldata
+ default_value 0
+ description "
+ Use this option to define a customized version \"string\" for
+ RedBoot. Note: this value is only cosmetic, displayed by the
+ \"version\" command, but is useful for providing site specific
+ information about the RedBoot configuration."
+ }
+
+ cdl_option CYGNUM_REDBOOT_CMD_LINE_EDITING {
+ display "Enable command line editing"
+ flavor data
+ default_value 16
+ description "
+ If this option is non-zero, RedBoot will remember the
+ last N command lines. These lines may be reused.
+ Enabling this history will also enable rudimentary
+ editting of the lines themselves."
+ }
+
+ cdl_option CYGSEM_REDBOOT_CMD_LINE_ANSI_SEQUENCES {
+ display "Enable command line editing using ANSI arrows, etc"
+ flavor bool
+ default_value 1
+ active_if CYGNUM_REDBOOT_CMD_LINE_EDITING != 0
+ description "
+ If this option is enabled, RedBoot will accept standard ANSI key
+ sequences for cursor movement (along with the emacs style keys)."
+ }
+
+ cdl_option CYGBLD_REDBOOT_CMD_LINE_HISTORY {
+ display "Enable history command and expansion"
+ requires { CYGNUM_REDBOOT_CMD_LINE_EDITING > 0 }
+ flavor bool
+ default_value 1
+ description "
+ Enabling this option will allow RedBoot to provide a
+ history command to list previous commands. Also enables
+ history expansion via '!' character similar to bash
+ shell."
+ }
+
+ cdl_option CYGBLD_REDBOOT_MAX_MEM_SEGMENTS {
+ display "Number of unique RAM segments on platform"
+ flavor data
+ default_value 1
+ description "
+ Change this option to be the number of memory segments which are
+ supported by the platform. If the value is greater than 1, then
+ a platform specific function must provide information about the
+ additional segments."
+ }
+
+ cdl_component CYGBLD_BUILD_REDBOOT_WITH_ZLIB {
+ display "Include support gzip/zlib decompression"
+ active_if CYGPKG_COMPRESS_ZLIB
+ default_value 1
+ implements CYGINT_COMPRESS_ZLIB_LOCAL_ALLOC
+ compile decompress.c
+
+ cdl_option CYGNUM_REDBOOT_LOAD_ZLIB_BUFFER {
+ display "Size of zlib decompression buffer"
+ flavor data
+ default_value 64
+ legal_values 5 to 256
+ description "
+ This is the size of the buffer filled with incoming data
+ during load before calls are made to the decompressor
+ function. For ethernet downloads this can be made bigger
+ (at the cost of memory), but for serial downloads on slow
+ processors it may be necessary to reduce the size to
+ avoid serial overruns. zlib appears to bail out if less
+ than five bytes are available initially so this is the
+ minimum."
+ }
+ cdl_option CYGPRI_REDBOOT_ZLIB_FLASH {
+ display "Support compression of Flash images"
+ active_if CYGPKG_REDBOOT_FLASH
+ active_if !CYGSEM_IO_FLASH_READ_INDIRECT
+ calculated 1
+ description "
+ This CDL indicates whether flash images can
+ be decompressed from gzip/zlib format into RAM."
+ }
+
+ cdl_option CYGBLD_BUILD_REDBOOT_WITH_GUNZIP {
+ display "Include GZIP uncompress command"
+ default_value 0
+ description "
+ Enable this option to include a 'gunzip' command
+ to uncompress GZIP compressed data."
+ compile -library=libextras.a gunzip.c
+ }
+ }
+
+ cdl_option CYGBLD_BUILD_REDBOOT_WITH_XYZMODEM {
+ display "Include support for xyzModem downloads"
+ doc ref/download-command.html
+ no_define
+ default_value 1
+ implements CYGINT_REDBOOT_LOAD_METHOD
+ compile -library=libextras.a xyzModem.c
+ }
+
+ cdl_option CYGBLD_REDBOOT_LOAD_INTO_FLASH {
+ display "Allow the load-command write into Flash."
+ default_value 0
+ active_if CYGPKG_REDBOOT_FLASH
+ requires CYGSEM_REDBOOT_VALIDATE_USER_RAM_LOADS
+ compile flash_load.c
+ description "
+ Write images direct to Flash via the load command.
+ We assume anything which is invalid RAM is flash, hence
+ the requires statement"
+ }
+ cdl_option CYGBLD_BUILD_REDBOOT_WITH_CKSUM {
+ display "Include POSIX checksum command"
+ doc ref/cksum-command.html
+ default_value 1
+ requires CYGPKG_CRC
+ compile -library=libextras.a cksum.c
+ }
+
+ cdl_option CYGBLD_BUILD_REDBOOT_WITH_MFILL {
+ display "Include memory fill command"
+ doc ref/mfill-command.html
+ default_value 1
+ compile -library=libextras.a mfill.c
+ }
+
+ cdl_option CYGBLD_BUILD_REDBOOT_WITH_MCMP {
+ display "Include memory compare command"
+ doc ref/mcmp-command.html
+ default_value 1
+ compile -library=libextras.a mcmp.c
+ }
+
+ cdl_option CYGBLD_BUILD_REDBOOT_WITH_MCOPY {
+ display "Include memory copy command"
+ doc ref/mcopy-command.html
+ default_value 1
+ compile -library=libextras.a mcopy.c
+ }
+
+ cdl_option CYGBLD_BUILD_REDBOOT_WITH_DUMP {
+ display "Include memory dump command"
+ doc ref/dump-command.html
+ default_value 1
+ compile -library=libextras.a dump.c
+ }
+
+ cdl_option CYGBLD_BUILD_REDBOOT_WITH_CACHES {
+ display "Include cache command"
+ doc ref/cache-command.html
+ default_value 1
+ compile -library=libextras.a caches.c
+ }
+
+ cdl_option CYGBLD_BUILD_REDBOOT_WITH_EXEC {
+ display "Include exec command"
+ doc ref/exec-command.html
+ default_value 1
+ # Implemented within the platform HAL
+ }
+
+ cdl_option CYGBLD_BUILD_REDBOOT_WITH_IOMEM {
+ display "Include I/O Memory commands 'iopeek' and 'iopoke'"
+ default_value 0
+ compile -library=libextras.a iomem.c
+ }
+
+ no_define
+ description "
+ This option enables the building of the Redboot ELF image.
+ The image may require further relocation or symbol
+ stripping before being converted to a binary image.
+ This is handled by a rule in the target CDL."
+
+
+ cdl_option CYGDBG_REDBOOT_TICK_GRANULARITY {
+ display "Granularity of timer/ticks"
+ flavor data
+ legal_values { 50 100 250 500 1000 }
+ default_value 250
+ description "
+ This option controls the granularity of the timers.
+ Faster CPUs can afford higher granularity (lower values)
+ which should give higher network performance since the stack
+ is purely polled."
+ }
+
+ compile main.c
+ compile misc_funs.c io.c parse.c ticks.c syscall.c alias.c
+ compile -library=libextras.a load.c
+
+ make -priority 320 {
+ <PREFIX>/bin/redboot.elf : $(PREFIX)/lib/target.ld $(PREFIX)/lib/vectors.o $(PREFIX)/lib/libtarget.a $(PREFIX)/lib/libextras.a
+ @sh -c "mkdir -p $(dir $@)"
+ $(CC) -c $(INCLUDE_PATH) $(ACTUAL_CFLAGS) -o $(PREFIX)/lib/version.o $(REPOSITORY)/$(PACKAGE)/src/version.c
+ $(CC) $(LDFLAGS) -L$(PREFIX)/lib -Ttarget.ld -o $@ $(PREFIX)/lib/version.o
+ }
+
+ cdl_component CYGPKG_REDBOOT_NETWORKING {
+ display "Redboot Networking"
+ flavor bool
+ active_if CYGPKG_IO_ETH_DRIVERS
+ default_value 1
+ implements CYGINT_REDBOOT_LOAD_METHOD
+ compile net/udp.c net/ip.c net/pktbuf.c net/cksum.c
+ compile net/enet.c net/icmp.c net/tcp.c net/timers.c net/arp.c
+ compile net/inet_addr.c
+ compile -library=libextras.a net/ping.c net/net_io.c
+ description "This option includes networking support in RedBoot."
+ define_proc {
+ puts $::cdl_system_header "#define CYGNUM_HAL_VIRTUAL_VECTOR_AUX_CHANNELS 1"
+ }
+
+ cdl_option CYGDBG_REDBOOT_NET_DEBUG {
+ display "Print net debug information"
+ flavor bool
+ default_value 0
+ description "
+ This option is overriden by the configuration stored
+ in flash."
+ }
+
+ cdl_option CYGSEM_REDBOOT_NET_TFTP_DOWNLOAD {
+ display "Support TFTP for download"
+ flavor bool
+ default_value 1
+ compile -library=libextras.a net/tftp_client.c
+ description "
+ This option enables the use of the TFTP protocol for
+ download"
+ }
+
+ cdl_option CYGSEM_REDBOOT_NET_HTTP_DOWNLOAD {
+ display "Support HTTP for download"
+ flavor bool
+ default_value 1
+ compile -library=libextras.a net/http_client.c
+ description "
+ This option enables the use of the HTTP protocol for
+ download"
+ }
+
+ cdl_component CYGDAT_REDBOOT_DEFAULT_IP_ADDR {
+ display "Default IP address"
+ flavor booldata
+ default_value CYGSEM_REDBOOT_FLASH_CONFIG ? 0 : \
+ { "0, 0, 0, 0" }
+ description "
+ This IP address is the default used by RedBoot if
+ a BOOTP/DHCP server does not respond. The numbers
+ should be separated by *commas*, and not dots. If
+ an IP address is configured into the Flash
+ configuration, that will be used in preference."
+
+ cdl_option CYGDAT_REDBOOT_DEFAULT_BOOTP_SERVER_IP_ADDR {
+ display "Default bootp server"
+ flavor booldata
+ default_value CYGSEM_REDBOOT_FLASH_CONFIG ? 0 : \
+ { "0, 0, 0, 0" }
+ description "
+ This IP address is the default server
+ address used by RedBoot if a BOOTP/DHCP
+ server does not respond. The numbers should
+ be separated by *commas*, and not dots. If
+ an IP address is configured into the Flash
+ configuration, that will be used in
+ preference."
+ }
+ }
+
+ cdl_component CYGPKG_REDBOOT_NETWORKING_BOOTP {
+ display "Enable BOOTP/DHCP support"
+ flavor bool
+ default_value 1
+ compile net/bootp.c
+ description "
+ Use BOOTP/DHCP protocol to obtain pertinent IP
+ addresses, such as the client, server, gateway,
+ etc."
+
+ cdl_component CYGSEM_REDBOOT_NETWORKING_DHCP {
+ display "Enable DHCP in addition to BOOTP support"
+ flavor bool
+ default_value 1
+ description "
+ Enables DHCP protocol in addition to BOOTP. If not enabled,
+ only BOOTP will be suported."
+ }
+
+ cdl_component CYGSEM_REDBOOT_NETWORKING_BOOTP_VERBOSE {
+ display "Enable verbose output from BOOTP/DHCP code"
+ flavor bool
+ default_value 0
+ description "
+ Enable more verbose output from BOOTP/DHCP that logs rx/tx
+ packet types and state-machine transitions."
+ }
+
+ cdl_option CYGSEM_REDBOOT_DEFAULT_NO_BOOTP {
+ display "Do not try to use BOOTP/DHCP"
+ flavor bool
+ default_value 0
+ description "
+ By default Redboot tries to use BOOTP/DHCP to
+ get an IP address when BOOTP/DHCP support is
+ present in Redboot. If there's no BOOTP/DHCP
+ server on your network use this option to
+ avoid waiting for the BOOTP/DHCP timeouts and
+ retries. This option is overriden by the
+ configuration stored in flash."
+ }
+ }
+
+ cdl_component CYGSEM_REDBOOT_NETWORKING_USE_GATEWAY {
+ display "Use a gateway for non-local IP traffic"
+ flavor bool
+ default_value 1
+ description "
+ Enabling this option will allow the RedBoot networking
+ stack to use a \[single\] gateway to reach a non-local
+ IP address. If disabled, RedBoot will only be able to
+ reach nodes on the same subnet."
+
+ cdl_component CYGDAT_REDBOOT_DEFAULT_GATEWAY_IP_ADDR {
+ display "Default gateway IP address"
+ flavor booldata
+ default_value CYGSEM_REDBOOT_FLASH_CONFIG ? 0 : \
+ { "0, 0, 0, 0" }
+ description "
+ This IP address is the default used by RedBoot
+ if a BOOTP/DHCP server does not respond. The
+ numbers should be separated by *commas*, and
+ not dots. If an IP address is configured into
+ the Flash configuration, that will be used in
+ preference."
+ }
+
+ cdl_component CYGDAT_REDBOOT_DEFAULT_IP_ADDR_MASK {
+ display "Default IP address mask"
+ flavor booldata
+ default_value CYGSEM_REDBOOT_FLASH_CONFIG ? 0 : \
+ { "255, 255, 255, 0" }
+ description "
+ This IP address mask is the default used by
+ RedBoot if a BOOTP/DHCP server does not
+ respond. The numbers should be separated by
+ *commas*, and not dots. If an IP address is
+ configured into the Flash configuration, that
+ will be used in preference."
+ }
+ }
+
+ cdl_option CYGNUM_REDBOOT_NETWORKING_TCP_PORT {
+ display "TCP port to listen for incoming connections"
+ flavor data
+ default_value 9000
+ description "
+ RedBoot will 'listen' on this port for incoming TCP
+ connections. This allows outside connections to be made
+ to the platform, either for GDB or RedBoot commands."
+ }
+
+ cdl_option CYGNUM_REDBOOT_NETWORKING_MAX_PKTBUF {
+ display "Number of \[network\] packet buffers"
+ flavor data
+ default_value 4
+ legal_values 3 to 8
+ description "
+ RedBoot may need to buffer network data to support
+ various connections. This option allows control
+ over the number of such buffered packets, and in
+ turn, controls the amount of memory used by RedBoot
+ (which is not available to user applications).
+ Each packet buffer takes up about 1514 bytes.
+ Note: there is little need to make this larger than
+ the default."
+ }
+
+ cdl_component CYGPKG_REDBOOT_NETWORKING_DNS {
+ display "DNS support"
+ default_value 1
+ active_if CYGPKG_NS_DNS
+ requires !CYGPKG_NS_DNS_BUILD
+ compile net/dns.c
+ description "
+ When this option is enabled, RedBoot will be built with
+ support for DNS, allowing use of hostnames on the command
+ line."
+
+ cdl_option CYGPKG_REDBOOT_NETWORKING_DNS_IP {
+ display "Default DNS IP"
+ flavor data
+ active_if !CYGSEM_REDBOOT_FLASH_CONFIG
+ default_value { "0.0.0.0" }
+ description "
+ This option sets the IP of the default DNS. The IP can be
+ changed at runtime as well."
+ }
+
+ cdl_option CYGNUM_REDBOOT_NETWORKING_DNS_TIMEOUT {
+ display "Timeout in DNS lookup"
+ flavor data
+ default_value 10
+ description "
+ This option sets the timeout used when looking up an
+ address via the DNS. Default is 10 seconds."
+ }
+
+ cdl_component CYGPKG_REDBOOT_NETWORKING_DNS_WITH_DOMAIN {
+ display "Support the use of a domain name"
+ flavor bool
+ default_value 0
+ description "
+ This option controls if Redboot supports domain
+ names when performing DNS lookups"
+
+ cdl_option CYGPKG_REDBOOT_NETWORKING_DNS_DEFAULT_DOMAIN {
+ display "Default DNS domain"
+ flavor booldata
+ default_value 0
+ description "
+ This option sets the default DNS domain name.
+ This value will be overwritten by the value in
+ flash or a domain returned by DHCP"
+ }
+
+ cdl_option CYGPKG_REDBOOT_NETWORKING_DNS_FCONFIG_DOMAIN {
+ display "Get DNS domain from Flash"
+ flavor bool
+ active_if CYGSEM_REDBOOT_FLASH_CONFIG
+ default_value 0
+ description "
+ This option enables getting the domain name
+ from the flash configuration. This can later be
+ overwritten by a value learnt from DHCP"
+ }
+
+ cdl_option CYGPKG_REDBOOT_NETWORKING_DNS_DHCP_DOMAIN {
+ display "Use DNS domain from DHCP"
+ flavor bool
+ default_value 0
+ description "
+ This option enables the use of the domain name
+ returned by DHCP."
+ }
+
+ cdl_option CYGNUM_REDBOOT_NETWORK_DNS_DOMAIN_BUFSIZE {
+ display "BOOTP/DHCP DNS domain buffer size"
+ flavor data
+ default_value 32
+ description "
+ This options sets the size of the static
+ buffer used by BOOTP/DHCP to store the DNS
+ domain name. The domain name will not be
+ set if the buffer is too small to hold it."
+ }
+ }
+ }
+
+ cdl_option CYGDAT_REDBOOT_DEFAULT_NETWORK_DEVICE {
+ display "Default network device driver"
+ flavor data
+ active_if { CYGHWR_NET_DRIVERS > 1 }
+ default_value { "\"\"" }
+ description "
+ This is the name of the default network device to use."
+ }
+
+ cdl_option CYGSEM_REDBOOT_NETWORK_INIT_ONE_DEVICE {
+ display "Initialize only one net device"
+ flavor bool
+ active_if { CYGHWR_NET_DRIVERS > 1 }
+ default_value 0
+ description "
+ This option tells RedBoot to stop initializing network
+ devices when it finds the first device which is
+ successfully initialized. The default behavior causes
+ all network devices to be initialized."
+ }
+ }
+
+ cdl_option CYGPKG_REDBOOT_ANY_CONSOLE {
+ display "Let RedBoot use any I/O channel for its console."
+ flavor bool
+ default_value 1
+ description "
+ If this option is enabled then RedBoot will attempt to use all
+ defined serial I/O channels for its console device. Once input
+ arrives at one of these channels then the console will use only
+ that port."
+ }
+
+ cdl_option CYGSEM_REDBOOT_VARIABLE_BAUD_RATE {
+ display "Let RedBoot adjust the baud off the serial console."
+ flavor bool
+ default_value 1
+ active_if CYGINT_HAL_VIRTUAL_VECTOR_COMM_BAUD_SUPPORT
+ description "
+ If this option is enabled then RedBoot will support commands
+ to set and query the baud rate on the selected console."
+ }
+
+ cdl_option CYGSEM_REDBOOT_PLF_STARTUP {
+ display "Run a platform specific startup function."
+ flavor bool
+ default_value 0
+ description "
+ If this option is enabled then RedBoot will execute a platform
+ specific startup function before entering into its command line
+ processing. This allows the platform to perform any special
+ setups before RedBoot actually starts running. Note: the entire
+ RedBoot environment will already be initialized at this point."
+ }
+
+ cdl_option CYGSEM_REDBOOT_PLF_ESA_VALIDATE {
+ display "Run a platform specific ESA validation function."
+ flavor bool
+ default_value 0
+ description "
+ If this option is enabled then RedBoot will execute a platform
+ specific function to validate an ethernet ESA. This would be
+ useful if the address must conform to standards set by the
+ hardware manufacturer, etc."
+ }
+
+ cdl_option CYGPKG_REDBOOT_MAX_CMD_LINE {
+ display "Maximum command line length"
+ flavor data
+ default_value 256
+ description "
+ This option allows control over how long the CLI command line
+ should be. This space will be allocated statically
+ rather than from RedBoot's stack."
+ }
+
+ cdl_option CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT {
+ display "Command processing idle timeout (ms)"
+ flavor data
+ default_value 10
+ description "
+ This option controls the timeout period before the
+ command processing is considered 'idle'. Making this
+ number smaller will cause idle processing to take place
+ more often, etc. The default value of 10ms is a reasonable
+ tradeoff between responsiveness and overhead."
+ }
+
+ cdl_option CYGSEM_REDBOOT_VALIDATE_USER_RAM_LOADS {
+ display "Validate RAM addresses during load"
+ flavor bool
+ default_value 1
+ description "
+
+ This option controls whether or not RedBoot will make
+ sure that memory being used by the \"load\" command is
+ in fact in user RAM. Leaving the option enabled makes
+ for a safer environment, but this check may not be valid
+ on all platforms, thus the ability to disable it.
+ ** Disable this only with great care **"
+ }
+
+ cdl_option CYGNUM_REDBOOT_FLASH_BASE {
+ display "Base address of flash device redboot should use"
+ flavor booldata
+ description "
+ This option controls how redboot finds the flash
+ device. Setting this option to an address will
+ cause redboot to use that address as the base of the
+ flash device."
+ }
+
+ cdl_component CYGPKG_REDBOOT_FLASH {
+ display "Allow RedBoot to support FLASH programming"
+ flavor bool
+ default_value 1
+ active_if CYGHWR_IO_FLASH_DEVICE
+ description "
+ If this option is enabled then RedBoot will provide commands
+ to manage images in FLASH memory. These images can be loaded
+ into memory for execution or executed in place."
+ compile -library=libextras.a flash.c
+
+ cdl_option CYGOPT_REDBOOT_FLASH_BYTEORDER {
+ display "Byte order used to store info in flash."
+ flavor data
+ default_value { "NATURAL" }
+ legal_values {"NATURAL" "MSBFIRST" "LSBFIRST" }
+ description "
+ This option controls the byte ordering used to store
+ the FIS directory info and flash config info."
+ }
+
+ cdl_option CYGOPT_REDBOOT_FIS {
+ display "RedBoot Flash Image System support"
+ default_value 1
+ doc ref/flash-image-system.html
+ description "
+ This option enables the Flash Image System commands
+ and support within RedBoot. If disabled, simple Flash
+ access commands such as \"fis write\" will still exist.
+ This option would be disabled for targets that need simple
+ FLASH manipulation, but do not have the need or space for
+ complete image management."
+ }
+
+ cdl_option CYGDAT_REDBOOT_FIS_MAX_FREE_CHUNKS {
+ display "Max number of chunks of free space to manage"
+ flavor booldata
+ default_value 32
+ description "
+
+ If this option is defined then \"fis free\" will
+ rely on the FIS directory to determine what space is
+ free within the FLASH. This option controls the
+ maximum number of free segment which can be handled
+ (typically this number is small). If this option is
+ not enabled, the the archaic behaviour of actually
+ scanning the FLASH for erased sectors (unreliable)
+ will be used to determine what's free and what's
+ not."
+ }
+
+ cdl_component CYGPKG_REDBOOT_FIS_CONTENTS {
+ display "Flash Image System default directory contents"
+ active_if CYGOPT_REDBOOT_FIS
+ calculated 1
+
+ cdl_option CYGNUM_REDBOOT_FIS_DIRECTORY_BLOCK {
+ display "Flash block containing the Directory"
+ flavor data
+ default_value (-1)
+ description "
+ Which block of flash should hold the directory
+ information. Positive numbers are absolute block
+ numbers. Negative block numbers count backwards
+ from the last block. eg 2 means block 2, -2
+ means the last but one block."
+ }
+
+ cdl_component CYGOPT_REDBOOT_REDUNDANT_FIS {
+ display "Redundant Flash Image System Directory Support"
+ default_value 0
+ requires { 0 == CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG }
+ description "
+ This option enables the use of a redundant FIS
+ directory within RedBoot. If enabled a flash block
+ will be reserved for a second copy of the fis
+ directory. Doing this allow for power failure safe
+ updates of the directory by the application."
+
+ cdl_option CYGNUM_REDBOOT_FIS_REDUNDANT_DIRECTORY_BLOCK {
+ display "Flash block containing the backup Directory"
+ flavor data
+ default_value (-3)
+ requires { CYGNUM_REDBOOT_FIS_REDUNDANT_DIRECTORY_BLOCK !=
+ CYGNUM_REDBOOT_FIS_DIRECTORY_BLOCK }
+ description "
+ Which block of flash should hold the redundant
+ directory information. Positive numbers are
+ absolute block numbers. Negative block numbers
+ count backwards from the last block. eg 2 means
+ block 2, -2 means the last but one block."
+ }
+ }
+
+ cdl_option CYGOPT_REDBOOT_FIS_RESERVED_BASE {
+ display "Pseudo-file to describe reserved area"
+ active_if { 0 != CYGNUM_REDBOOT_FLASH_RESERVED_BASE }
+ default_value 1
+ description "
+ If an area of FLASH is reserved, it is informative to
+ have a fis entry describing it. This option controls
+ creation of such an entry by default in the fis init
+ command."
+ }
+
+ cdl_option CYGOPT_REDBOOT_FIS_REDBOOT {
+ display "File to describe RedBoot boot image"
+ default_value 1
+ description "
+ Normally a ROM-startup RedBoot image is first in the
+ FLASH, and the system boots using that image. This
+ option controls creation of an entry describing it in
+ the fis init command. It might be disabled if a
+ platform has an immutable boot image of its own, where
+ we use a POST-startup RedBoot instead, which performs
+ less board initialization."
+ }
+
+ cdl_component CYGOPT_REDBOOT_FIS_REDBOOT_POST {
+ display "File to describe RedBoot POST-compatible image"
+ default_value !CYGOPT_REDBOOT_FIS_REDBOOT
+ description "
+ This option controls creation of an entry describing a
+ POST-startup RedBoot image in the fis init command.
+ Not all platforms support POST-startup. A platform
+ might have both for testing purposes, where the
+ eventual user would substitute their own POST code for
+ the initial ROM-startup RedBoot, and then jump to the
+ POST-compatible RedBoot immediately following."
+ cdl_option CYGNUM_REDBOOT_FIS_REDBOOT_POST_OFFSET {
+ display "Offset of POST image from FLASH start"
+ flavor booldata
+ default_value 0
+ requires { CYGNUM_REDBOOT_FIS_REDBOOT_POST_OFFSET >= \
+ CYGBLD_REDBOOT_FLASH_BOOT_OFFSET }
+ description "
+ This option specifies the offset for a POST image from
+ the start of FLASH. If unset, then the fis entry
+ describing the POST image will be placed where
+ convenient."
+ }
+ }
+
+ cdl_option CYGOPT_REDBOOT_FIS_REDBOOT_BACKUP {
+ display "File to describe RedBoot backup image"
+ default_value 0
+ description "
+ This option controls creation of an entry describing a
+ backup RedBoot image in the fis init command.
+ Conventionally a RAM-startup RedBoot image is kept
+ under this name for use in updating the ROM-based
+ RedBoot that boots the board."
+ }
+
+ cdl_option CYGOPT_REDBOOT_FIS_DIRECTORY_ARM_SIB_ID {
+ display "Include ARM SIB ID in FIS"
+ default_value 0
+ description "
+ If set, this option will cause the last 5 words of
+ the FIS to include the special ID needed for the
+ flash to be recognized as a reserved area for RedBoot
+ by an ARM BootRom monitor."
+ }
+
+ cdl_option CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_SIZE {
+ display "Size of FIS directory entry"
+ flavor data
+ default_value 256
+ description "
+ The FIS directory is limited to one single flash
+ sector. If your flash has tiny sectors, you may wish
+ to reduce this value in order to get more slots in
+ the FIS directory."
+ }
+
+ cdl_option CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_COUNT {
+ display "Number of FIS directory entries"
+ flavor data
+ default_value 8
+ description "
+ The FIS directory normally occupies a single flash
+ sector. Adjusting this value can allow for more than
+ one flash sector to be used, which is useful if your
+ sectors are very small."
+ }
+
+ cdl_option CYGBLD_REDBOOT_MIN_IMAGE_SIZE {
+ display "Maximum RedBoot image size"
+ flavor data
+ default_value { CYGOPT_REDBOOT_FIS_REDBOOT ? 0x20000 : 0 }
+ description "
+ This option controls the maximum length reserved
+ for the RedBoot boot image in the FIS table.
+ This should be a multiple of the flash's erase
+ block size."
+ }
+
+ cdl_option CYGBLD_REDBOOT_FLASH_BOOT_OFFSET {
+ display "Offset from start of FLASH to RedBoot boot image"
+ flavor data
+ default_value CYGNUM_REDBOOT_FLASH_RESERVED_BASE
+ requires { CYGNUM_REDBOOT_FLASH_RESERVED_BASE <= \
+ CYGBLD_REDBOOT_FLASH_BOOT_OFFSET }
+ description "
+ This option controls where the RedBoot boot image is
+ located relative to the start of FLASH."
+ }
+
+ cdl_option CYGNUM_REDBOOT_FLASH_RESERVED_BASE {
+ display "Size of reserved area at start of FLASH"
+ flavor data
+ default_value 0
+ description "
+ This option reserves an area at the start of
+ FLASH where RedBoot will never interfere; it is
+ expected that this area contains
+ (non-RedBoot-based) POST code or some other boot
+ monitor that executes before RedBoot."
+ }
+
+ cdl_option CYGNUM_REDBOOT_FLASH_RESERVED_DEVICES {
+ display "List of Flash devices that are reserved"
+ flavor booldata
+ default_value 0
+ description "This option lists the base addresses of any Flash
+ devices that should not be managed by the flash
+ image system. In particular, this means that these
+ devices will not be considered when looking for free
+ space in which to create new files. It should consist
+ of a comma-separated list of (virtual) addresses."
+ }
+ }
+
+ cdl_option CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL {
+ display "Keep all RedBoot FLASH data blocks locked."
+ flavor bool
+ default_value 1
+ active_if { CYGHWR_IO_FLASH_BLOCK_LOCKING != 0 }
+ description "
+ When this option is enabled, RedBoot will keep configuration
+ data and the FIS directory blocks implicitly locked. While
+ this is somewhat safer, it does add overhead during updates."
+ }
+
+ cdl_option CYGSEM_REDBOOT_FIS_CRC_CHECK {
+ display "Use CRC checksums on FIS images."
+ flavor bool
+ default_value 1
+ requires CYGPKG_CRC
+ description "
+ When this option is enabled, RedBoot will use CRC checksums
+ when reading and writing flash images."
+ }
+
+ cdl_interface CYGINT_REDBOOT_ARM_FLASH_SIB_SUPPORTED {
+ display "ARM FLASH drivers support SIB flash block structure"
+ active_if CYGPKG_HAL_ARM
+ description "This interface is implemented by a flash driver
+ to indicate that it supports the ARM SIB flash
+ block structure"
+ }
+
+ cdl_option CYGHWR_REDBOOT_ARM_FLASH_SIB {
+ display "Use ARM SIB flash block structure"
+ flavor bool
+ active_if CYGINT_REDBOOT_ARM_FLASH_SIB_SUPPORTED
+ default_value 1
+ description "
+ This option is used to interpret ARM Flash System
+ information blocks."
+ }
+ }
+
+ cdl_component CYGSEM_REDBOOT_FLASH_CONFIG {
+ display "Keep RedBoot configuration data in FLASH"
+ flavor bool
+ default_value { CYGPKG_IO_FLASH != 0 }
+ compile fconfig.c
+ description "
+ When this option is enabled, RedBoot will keep configuration
+ data in a separate block of FLASH memory. This data will
+ include such items as the node IP address or startup scripts."
+
+ cdl_option CYGNUM_REDBOOT_FLASH_CONFIG_SIZE {
+ display "Length of configuration data in FLASH"
+ flavor data
+ default_value 4096
+ description "
+ This option is used to control the amount of memory and FLASH
+ to be used for configuration options (persistent storage)."
+ }
+
+ cdl_option CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA {
+ display "Style of media used for persistent data storage"
+ flavor data
+ legal_values { "FLASH" "EEPROM" }
+ default_value { "FLASH" }
+ description "
+ Persistent data storage can either be held in 'norma' FLASH
+ or some other device (represented by the 'EEPROM' choice).
+ The different styles utilize different access methods."
+ }
+
+ cdl_option CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG {
+ display "Merged config data and FIS directory"
+ flavor bool
+ active_if { CYGOPT_REDBOOT_FIS && \
+ (CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA == "FLASH") }
+ default_value 1
+ description "
+ If this option is set, then the FIS directory and FLASH
+ configuration database will be stored in the same physical
+ FLASH block."
+ }
+
+ cdl_option CYGNUM_REDBOOT_FLASH_CONFIG_BLOCK {
+ display "Which block of flash to use"
+ flavor data
+ default_value (-2)
+ description "
+ Which block of flash should hold the configuration
+ information. Positive numbers are absolute block numbers.
+ Negative block numbers count backwards from the last block.
+ eg 2 means block 2, -2 means the last but one block."
+ }
+
+ cdl_option CYGSEM_REDBOOT_FLASH_ALIASES {
+ display "Support simple macros/aliases in FLASH"
+ flavor bool
+ default_value 1
+ description "
+ This option is used to allow support for simple text-based
+ macros (aliases). These aliases are kept in the FLASH
+ configuration data (persistent storage)."
+ }
+
+ cdl_option CYGNUM_REDBOOT_FLASH_STRING_SIZE {
+ display "Length of strings in FLASH configuration data"
+ flavor data
+ default_value 128
+ description "
+ This option is used to control the amount of memory
+ and FLASH to be used for string configuration
+ options (persistent storage)."
+ }
+
+ cdl_option CYGNUM_REDBOOT_FLASH_SCRIPT_SIZE {
+ display "Length of configuration script(s) in FLASH"
+ flavor data
+ default_value 512
+ description "
+ This option is used to control the amount of memory and
+ FLASH to be used for configuration options (persistent
+ storage)."
+ }
+
+ cdl_option CYGSEM_REDBOOT_FLASH_CONFIG_READONLY_FALLBACK {
+ display "Fallback to read-only FLASH configuration"
+ flavor bool
+ default_value { (CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA == "FLASH") }
+ description "
+ This option will cause the configuration information to
+ revert to the readonly information stored in the FLASH.
+ The option only takes effect after
+ 1) the config_ok flag has been set to be true,
+ indicating that at one time the copy in RAM was valid;
+ and
+ 2) the information in RAM has been verified to be invalid"
+
+ }
+ }
+
+ cdl_component CYGPKG_REDBOOT_FILEIO {
+ display "Allow RedBoot to support fileio"
+ flavor bool
+ default_value 1
+ active_if CYGPKG_IO_FILEIO
+ requires CYGPKG_IO
+ description "
+ If this option is enabled then RedBoot will provide commands
+ to load files from fileio file systems such as JFFS2."
+ compile -library=libextras.a fs/fileio.c
+
+ cdl_option CYGBLD_REDBOOT_FILEIO_WITH_LS {
+ display "Include an ls command"
+ flavor bool
+ default_value 1
+ description "
+ If this option is enabled a simple ls command will be
+ included in redboot so the contents of a directory
+ can be listed"
+ }
+ }
+
+ cdl_component CYGPKG_REDBOOT_DISK {
+ display "Allow RedBoot to support disks"
+ flavor bool
+ default_value 1
+ description "
+ If this option is enabled then RedBoot will provide commands
+ to load disk files."
+
+ cdl_option CYGSEM_REDBOOT_DISK {
+ display "Include Redboot commands for disk access"
+ default_value { CYGINT_REDBOOT_DISK_DRIVERS != 0 }
+ compile -library=libextras.a fs/disk.c
+ }
+
+ cdl_interface CYGINT_REDBOOT_DISK_DRIVERS {
+ display "Hardware drivers for disk-type devices"
+ }
+
+ cdl_option CYGNUM_REDBOOT_MAX_DISKS {
+ display "Maximum number of supported disks"
+ flavor data
+ default_value 4
+ description "
+ This option controls the number of disks supported by
+ RedBoot."
+ }
+
+ cdl_option CYGNUM_REDBOOT_MAX_PARTITIONS {
+ display "Maximum number of partitions per disk"
+ flavor data
+ default_value 8
+ description "
+ This option controls the maximum number of supported
+ partitions per disk."
+ }
+
+ cdl_component CYGSEM_REDBOOT_DISK_IDE {
+ display "Support IDE disks."
+ flavor bool
+ default_value 1
+ active_if { CYGINT_HAL_PLF_IF_IDE != 0 }
+ description "
+ When this option is enabled, RedBoot will support IDE disks."
+ compile -library=libextras.a fs/ide.c
+ implements CYGINT_REDBOOT_DISK_DRIVERS
+
+ cdl_option CYGSEM_REDBOOT_DISK_IDE_VMWARE {
+ display "Work with VMware virtual disks"
+ flavor bool
+ default_value 0
+ description "
+ This option controls the disk driver behavior at
+ ide-init"
+ }
+ }
+
+ cdl_component CYGSEM_REDBOOT_DISK_EXT2FS {
+ display "Support Linux second extended filesystems."
+ flavor bool
+ default_value 1
+ description "
+ When this option is enabled, RedBoot will support EXT2
+ filesystems."
+ compile -library=libextras.a fs/e2fs.c
+ }
+
+ cdl_component CYGSEM_REDBOOT_DISK_ISO9660 {
+ display "Support ISO9660 filesystems."
+ flavor bool
+ calculated 0
+ description "
+ When this option is enabled, RedBoot will support ISO9660
+ filesystems."
+ compile -library=libextras.a fs/iso9660fs.c
+ }
+ }
+
+ cdl_component CYGPKG_REDBOOT_BOOT_SCRIPT {
+ display "Boot scripting"
+ doc ref/persistent-state-flash.html
+ flavor none
+ no_define
+ description "
+ This contains options related to RedBoot's boot script
+ functionality."
+
+ cdl_option CYGFUN_REDBOOT_BOOT_SCRIPT {
+ display "Boot scripting enabled"
+ flavor bool
+ active_if { CYGDAT_REDBOOT_DEFAULT_BOOT_SCRIPT || \
+ CYGSEM_REDBOOT_FLASH_CONFIG }
+ calculated 1
+ description "
+ This option controls whether RedBoot boot script
+ functionality is enabled."
+ }
+
+ cdl_option CYGDAT_REDBOOT_DEFAULT_BOOT_SCRIPT {
+ display "Use default RedBoot boot script"
+ flavor booldata
+ default_value 0
+ description "
+ If enabled, this option will tell RedBoot to use the
+ value of this option as a default boot script."
+ }
+
+ cdl_option CYGNUM_REDBOOT_BOOT_SCRIPT_TIMEOUT_RESOLUTION {
+ display "Resolution (in ms) for script timeout value."
+ flavor data
+ default_value 1000
+ description "
+ This option controls the resolution of the script
+ timeout. The value is specified in milliseconds
+ (ms), thus to have the script timeout be defined in
+ terms of tenths of seconds, use 100."
+ }
+
+ cdl_option CYGNUM_REDBOOT_BOOT_SCRIPT_DEFAULT_TIMEOUT {
+ display "Script default timeout value"
+ flavor data
+ default_value 10
+ description "
+ This option is used to set the default timeout for startup
+ scripts, when they are enabled."
+ }
+ }
+
+ cdl_option CYGSEM_REDBOOT_RTC {
+ display "Support RTC for time & date functions"
+ active_if { CYGPKG_IO_WALLCLOCK }
+ default_value 1
+ description "
+ When this option is enabled, RedBoot will support commands to
+ query and set the real time clock (time and date)"
+ compile -library=libextras.a time_date.cxx
+ }
+
+ cdl_option CYGPRI_REDBOOT_ROM_MONITOR {
+ display "Behave like a ROM monitor"
+ active_if { CYG_HAL_STARTUP == "ROM" || \
+ CYG_HAL_STARTUP == "ROMRAM" }
+ requires CYGSEM_HAL_ROM_MONITOR
+ calculated 1
+ no_define
+ description "
+ Enabling this option will allow RedBoot to provide ROM
+ monitor-style services to programs which it executes."
+ }
+
+ cdl_component CYGSEM_REDBOOT_BSP_SYSCALLS {
+ display "Allow RedBoot to handle GNUPro application 'syscalls'."
+ flavor bool
+ default_value 0
+ description "
+ If this option is enabled then RedBoot will install a
+ syscall handler to support debugging of applications
+ based on GNUPro newlib/bsp."
+
+ cdl_option CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF {
+ display "Support additional syscalls for 'gprof' profiling"
+ flavor bool
+ default_value 1
+ active_if { 0 < CYGINT_REDBOOT_BSP_SYSCALLS_GPROF_SUPPORT }
+ description "
+ Support additional syscalls to support a periodic callback
+ function for histogram-style profiling, and an enquire/set
+ of the tick rate.
+ The application must use the GNUPro newlib facilities
+ to set this up."
+ }
+
+ cdl_interface CYGINT_REDBOOT_BSP_SYSCALLS_GPROF_SUPPORT {
+ display "Does the HAL support 'gprof' profiling?"
+ no_define
+ }
+
+ cdl_option CYGOPT_REDBOOT_BSP_SYSCALLS_EXIT_WITHOUT_TRAP {
+ display "Do not raise SIGTRAP when program exits"
+ default_value 0
+ description "
+ For some (single shot) newlib based programs,
+ exiting and returning a termination status may be
+ the normal expected behavior."
+ }
+ }
+
+ cdl_component CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER {
+ display "Use a common buffer for Zlib and FIS"
+ flavor bool
+ active_if { CYGBLD_BUILD_REDBOOT_WITH_ZLIB && \
+ CYGOPT_REDBOOT_FIS }
+ default_value 0
+ description "
+ Use a common memory buffer for both the zlib workspace
+ and FIS directory operations. This can save a substantial
+ amount of RAM, especially when flash sectors are large."
+
+ cdl_option CYGNUM_REDBOOT_FIS_ZLIB_COMMON_BUFFER_SIZE {
+ display "Size of Zlib/FIS common buffer"
+ flavor data
+ default_value 0xc000
+ legal_values 0x4000 to 0x80000000
+ description "
+ Size of common buffer to allocate. Must be at least the
+ size of one flash sector."
+ }
+ }
+
+ cdl_component CYGMEM_REDBOOT_WORKSPACE_HEAP {
+ display "Allocate heap in RedBoot workspace"
+ flavor bool
+ active_if CYGPKG_MEMALLOC
+ active_if CYGPKG_MEMALLOC_MALLOC_ALLOCATORS
+ default_value 0
+ description "
+ If the MEMALLOC package is present, it usually allocates
+ the whole of memory not used by the program to the heap.
+ In RedBoot this is not a good idea, since we need space to
+ load application programs. Setting this option causes RedBoot
+ to allocate the heap at the top of RAM by reserving part of
+ RedBoot's workspace memory, leaving the rest of memory free."
+
+ cdl_option CYGMEM_REDBOOT_WORKSPACE_HEAP_SIZE {
+ display "Size of RedBoot heap"
+ flavor data
+ default_value 0x10000
+ legal_values 0x4000 to 0x80000000
+ description "
+ Size of RedBoot heap. This defines how much memory is to be
+ allocated for the heap."
+ }
+ }
+
+ cdl_option CYGNUM_REDBOOT_GETC_BUFFER {
+ display "Buffer size in getc when loading images"
+ flavor data
+ default_value { CYGPKG_REDBOOT_FILEIO ? 4096 : 256 }
+ description "
+ When loading images a buffer is used between redboot and the
+ underlying storage medium, eg a filesystem, or a socket etc.
+ The size of this buffer can have a big impart on load speed."
+ }
+
+ }
+}
+
+# EOF redboot.cdl
diff --git a/ecos/packages/redboot/current/doc/.cvsignore b/ecos/packages/redboot/current/doc/.cvsignore
new file mode 100644
index 0000000..8a8c385
--- /dev/null
+++ b/ecos/packages/redboot/current/doc/.cvsignore
@@ -0,0 +1,11 @@
+redboot-guide-a4.aux
+redboot-guide-a4.log
+redboot-guide-a4.out
+redboot-guide-a4.pdf
+redboot-guide-a4.tex
+redboot-guide-letter.aux
+redboot-guide-letter.log
+redboot-guide-letter.out
+redboot-guide-letter.pdf
+redboot-guide-letter.tex
+*.html \ No newline at end of file
diff --git a/ecos/packages/redboot/current/doc/makefile b/ecos/packages/redboot/current/doc/makefile
new file mode 100644
index 0000000..7f6e1ad
--- /dev/null
+++ b/ecos/packages/redboot/current/doc/makefile
@@ -0,0 +1,54 @@
+#=============================================================================
+#
+# makefile
+#
+# For building the eCos RedBoot docs
+#
+#=============================================================================
+# ####ECOSGPLCOPYRIGHTBEGIN####
+# -------------------------------------------
+# This file is part of eCos, the Embedded Configurable Operating System.
+# Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+#
+# eCos 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 or (at your option) any later
+# version.
+#
+# eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# As a special exception, if other files instantiate templates or use
+# macros or inline functions from this file, or you compile this file
+# and link it with other works to produce a work based on this file,
+# this file does not by itself cause the resulting work to be covered by
+# the GNU General Public License. However the source code for this file
+# must still be made available in accordance with section (3) of the GNU
+# General Public License v2.
+#
+# This exception does not invalidate any other reasons why a work based
+# on this file might be covered by the GNU General Public License.
+# -------------------------------------------
+# ####ECOSGPLCOPYRIGHTEND####
+#=============================================================================
+#####DESCRIPTIONBEGIN####
+#
+# Author(s): bartv, jlarmour
+# Date: 2001-01-11
+#####DESCRIPTIONEND####
+#=============================================================================
+
+TOPLEVEL := ../../..
+MAIN_SGML := redboot_main.sgml
+MAIN_HTML := redboot-guide.html
+MAIN_PDF := redboot-guide.pdf
+OTHER_SGML := redboot_cmds.sgml redboot_rebuilding.sgml redboot_installing.sgml
+PICTURES :=
+
+include $(TOPLEVEL)/pkgconf/rules.doc
diff --git a/ecos/packages/redboot/current/doc/redboot.sgml b/ecos/packages/redboot/current/doc/redboot.sgml
new file mode 100644
index 0000000..cba3021
--- /dev/null
+++ b/ecos/packages/redboot/current/doc/redboot.sgml
@@ -0,0 +1,734 @@
+<!-- {{{ Banner -->
+
+<!-- =============================================================== -->
+<!-- -->
+<!-- redboot.sgml -->
+<!-- -->
+<!-- RedBoot package -->
+<!-- -->
+<!-- =============================================================== -->
+<!-- ####ECOSDOCCOPYRIGHTBEGIN#### -->
+<!-- =============================================================== -->
+<!-- Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. -->
+<!-- This material may be distributed only subject to the terms -->
+<!-- and conditions set forth in the Open Publication License, v1.0 -->
+<!-- or later (the latest version is presently available at -->
+<!-- http://www.opencontent.org/openpub/) -->
+<!-- Distribution of the work or derivative of the work in any -->
+<!-- standard (paper) book form is prohibited unless prior -->
+<!-- permission obtained from the copyright holder -->
+<!-- =============================================================== -->
+<!-- ####ECOSDOCCOPYRIGHTEND#### -->
+<!-- =============================================================== -->
+<!-- #####DESCRIPTIONBEGIN#### -->
+<!-- -->
+<!-- ####DESCRIPTIONEND#### -->
+<!-- =============================================================== -->
+
+<!-- }}} -->
+
+<!-- uncomment to build this documentation as a DocBook part
+<part id="redboot"><beginpage>
+<title>RedBoot&trade; User's Guide</title>
+-->
+<toc id="Getting-Started-with-Redboot2"></toc>
+<chapter id="Getting-Started-with-RedBoot">
+<title>Getting Started with RedBoot</title>
+<para><indexterm><primary>Red Boot</primary><secondary>getting started</secondary>
+</indexterm>RedBoot&trade; is an acronym for "Red Hat Embedded Debug and Bootstrap",
+and is the standard embedded system debug/bootstrap environment from Red Hat,
+replacing the previous generation of debug firmware: <indexterm><primary>CygMon</primary>
+</indexterm>CygMon and <indexterm><primary>GDB stubs</primary></indexterm>GDB
+stubs. It provides a complete bootstrap environment for a range of embedded
+operating systems, such as embedded Linux&trade; and eCos&trade;, and includes facilities
+such as network downloading and debugging. It also provides a simple flash
+file system for boot images.</para>
+<para>RedBoot provides a wide set of tools for downloading and executing programs
+on embedded target systems, as well as tools for manipulating the target system's
+environment. It can be used for both product development (debug support) and
+for end product deployment (flash and network booting).</para>
+<para>Here are some highlights of <indexterm><primary>RedBoot's capabilities
+</primary></indexterm>RedBoot&rsquo;s capabilities: </para>
+<itemizedlist>
+<listitem><para>Boot scripting support</para>
+</listitem>
+<listitem><para>Simple command line interface for RedBoot configuration and
+management, accessible via serial (terminal) or Ethernet (telnet) </para>
+</listitem>
+<listitem><para>Integrated GDB stubs for connection to a host-based debugger
+via serial or ethernet. (Ethernet connectivity is limited to local network
+only)</para>
+</listitem>
+<listitem><para>Attribute Configuration - user control of aspects such as
+system time and date (if applicable), default Flash image to boot from, default
+failsafe image, static IP address, etc.</para>
+</listitem>
+<listitem><para>Configurable and extensible, specifically adapted to the target
+environment </para>
+</listitem>
+<listitem><para>Network bootstrap support including setup and download, via
+BOOTP, DHCP and TFTP</para>
+</listitem>
+<listitem><para>X/YModem support for image download via serial</para>
+</listitem>
+<listitem><para>Power On Self Test</para>
+</listitem>
+</itemizedlist>
+<para>Although RedBoot is derived from eCos, it may be used as a generalized
+system debug and bootstrap control software for any embedded system and any
+operating system. For example, with appropriate additions, RedBoot could replace
+the commonly used BIOS of PC (and certain other) architectures. Red Hat is
+currently installing RedBoot on all embedded platforms as a standard practice,
+and RedBoot is now generally included as part of all Red Hat Embedded Linux
+and eCos ports. Users who specifically wish to use RedBoot with the eCos operating
+system should refer to the <emphasis>Getting Started with eCos</emphasis>
+document, which provides information about the portability and extendability
+of RedBoot in an eCos environment.</para>
+<sect1 id="redboot-on-the-web">
+<title>More information about RedBoot on the web</title>
+<para>The <ulink url="http://sources.redhat.com/redboot/">RedBoot Net
+Distribution web site</ulink> contains downloadable sources and documentation
+for all publically released targets, including the latest features and updates.
+</para>
+</sect1>
+<sect1 id="installing-redboot">
+<title>Installing RedBoot</title>
+<para><indexterm><primary>installing RedBoot</primary><secondary>general procedures
+</secondary></indexterm><indexterm><primary>RedBoot installation</primary>
+<secondary>general procedures</secondary></indexterm>To install the RedBoot
+package, follow the procedures detailed in the accompanying README. </para>
+<para>Although there are other possible configurations, RedBoot is usually
+run from the target platform&rsquo;s flash boot sector or boot ROM, and is
+designed to run when your system is initially powered on. The method used
+to install the RedBoot image into non-volatile storage varies from platform
+to platform. In general, it requires that the image be programmed into flash
+in situ or programmed into the flash or ROM using a device programmer. In
+some cases this will be done at manufacturing time; the platform being delivered
+with RedBoot already in place. In other cases, you will have to program RedBoot
+into the appropriate device(s) yourself. Installing to flash in situ may require
+special cabling or interface devices and software provided by the board manufacturer.
+The details of this installation process for a given platform will be found
+in Installation and Testing. Once installed, user-specific configuration options
+may be applied, using the <command>fconfig</command> command,
+providing that persistent data storage in flash is present in the relevant
+RedBoot version. See <xref linkend="Configuring-the-RedBoot-Environment">
+for details.</para>
+</sect1>
+<sect1 id="user-interface">
+<title>User Interface</title>
+<para><indexterm><primary>user interface</primary></indexterm><indexterm>
+<primary>ui</primary></indexterm><indexterm><primary>cli</primary></indexterm>RedBoot
+provides a command line user interface (CLI). At the minimum, this interface
+is normally available on a serial port on the platform. If more than one serial
+interface is available, RedBoot is normally configured to try to use any one
+of the ports for the CLI. Once command input has been received on one port,
+that port is used exclusively until the board is reset or the channel
+is manually changed by the
+user. If the platform has networking
+capabilities, the RedBoot CLI is also accessible using the <computeroutput>
+telnet</computeroutput> access protocol. By default, RedBoot runs <computeroutput><indexterm>
+<primary>telnet</primary></indexterm>telnet</computeroutput> on port TCP/9000,
+but this is configurable and/or settable by the user. </para>
+<para>RedBoot also contains a set of <indexterm><primary>GDB stubs</primary>
+</indexterm>GDB "stubs", consisting of code which supports the GDB remote
+protocol. GDB stub mode is automatically invoked when the '$' character appears
+anywhere on a command line unless escaped using the '\' character.
+The platform will remain in GDB
+stub mode until explicitly disconnected (via the GDB protocol). The GDB stub
+mode is available regardless of the connection method; either serial or network.
+Note that if a GDB connection is made via the network, then special care must
+be taken to preserve that connection when running user code. eCos contains
+special network sharing code to allow for this situation, and can be used
+as a model if this methodology is required in other OS environments.</para>
+</sect1>
+
+<sect1 id="RedBoot-Editing-Commands">
+<title>RedBoot Editing Commands</title>
+<para><indexterm><primary>RedBoot</primary><secondary>editing commands</secondary>
+</indexterm><indexterm><primary>editing commands</primary></indexterm><indexterm>
+<primary>commands</primary><secondary>editing</secondary></indexterm>RedBoot
+uses the following line editing commands.
+<note><title>NOTE</title>
+<para>
+In this description, <guibutton>^A</guibutton> means the character formed
+by typing the letter &ldquo;A&rdquo; while holding down the control key.
+</para></note>
+<itemizedlist>
+<listitem><para><guibutton>Delete</guibutton> (0x7F) or
+<guibutton>Backspace</guibutton> (0x08)
+erases the character to the left of the cursor.
+</para></listitem>
+<listitem><para>
+<guibutton>^A</guibutton> or <guibutton>HOME</guibutton>
+moves the cursor (insertion point) to the beginning of the line.
+</para></listitem>
+<listitem><para>
+<guibutton>^K</guibutton>
+erases all characters on the line from the cursor to the end.
+</para></listitem>
+<listitem><para>
+<guibutton>^E</guibutton> or <guibutton>END</guibutton>
+positions the cursor to the end of the line.
+</para></listitem>
+<listitem><para>
+<guibutton>^D</guibutton> or <guibutton>DELETE</guibutton>
+erases the character under the cursor.
+</para></listitem>
+<listitem><para>
+<guibutton>^F</guibutton> or <guibutton>RIGHT-ARROW</guibutton>
+moves the cursor one character to the right.
+</para></listitem>
+<listitem><para>
+<guibutton>^B</guibutton> or <guibutton>LEFT-ARROW</guibutton>
+moves the cursor one character to the left.
+</para></listitem>
+<listitem><para>
+<guibutton>^P</guibutton> or <guibutton>UP-ARROW</guibutton>
+replaces the current line by a previous line from the history buffer.
+A small number of lines
+can be kept as history. Using ^P (and ^N), the current line can be replaced
+by any one of the previously typed lines.
+</para></listitem>
+<listitem><para>
+<guibutton>^N</guibutton> or <guibutton>DOWN-ARROW</guibutton>
+replaces the current line by the next line from the history buffer.
+</para></listitem>
+</itemizedlist></para>
+<para>In the case of the <command>fconfig</command>
+command, additional editing commands are possible.
+As data are entered for this command, the current/previous value
+will be displayed and the cursor placed at the end of that data.
+The user may use the editing keys (above) to move around in the data
+to modify it as appropriate.
+Additionally, when certain
+characters are entered at the end of the current value,
+i.e. entered separately, certain behavior is elicited.</para>
+<para><itemizedlist>
+<listitem>
+<para>^ (caret) switch to editing the previous item in the
+<command>fconfig</command> list. If fconfig edits item A, followed by item B,
+pressing ^ when changing item B, allows you to change item A. This is similar
+to the up arrow.
+Note: ^P and ^N do not have the same meaning while editing
+<command>fconfig</command> data and should not be used.
+</para>
+</listitem>
+<listitem><para>. (period) stop editing any further items. This does not change
+the current item.</para>
+</listitem>
+<listitem><para><guibutton>Return</guibutton> leaves the value
+for this item unchanged. Currently it is not possible to step through the
+value for the start-up script; it must always be retyped.</para>
+</listitem>
+</itemizedlist></para>
+</sect1>
+
+<sect1 id="RedBoot-Command-History">
+<title>RedBoot Command History</title>
+<para>
+<indexterm><primary>RedBoot</primary><secondary>command history</secondary></indexterm>
+<indexterm><primary>command history</primary></indexterm>
+<indexterm><primary>commands</primary><secondary>history</secondary></indexterm>
+RedBoot provides support for listing and repeating previously entered commands. A
+list of previously entered commands may be obtained by typing <command>history</command>
+at the command line:
+<screen>
+RedBoot> <userinput>history</userinput>
+ 0 fis list
+ 1 fconfig -l
+ 2 load -m ymodem
+ 3 history
+</screen>
+</para><para>
+The following history expansions may be used to execute commands in the history list:
+<itemizedlist>
+<listitem><para>
+!! repeats last command.
+</para></listitem>
+<listitem><para>
+!<userinput>n</userinput> repeats command <userinput>n</userinput>.
+</para></listitem>
+<listitem><para>
+!<userinput>string</userinput> repeats most recent command starting with
+<userinput>string</userinput>.
+</para></listitem>
+</itemizedlist>
+</para>
+</sect1>
+
+<sect1 id="startup-mode">
+<title>RedBoot Startup Mode</title>
+<para>
+ <indexterm><primary>RedBoot</primary><secondary>mode</secondary></indexterm>
+ <indexterm><primary>RedBoot</primary><secondary>startup mode</secondary></indexterm>
+</para>
+
+<para>RedBoot can normally be configured to run in a number of startup
+modes (or just "modes" for short), determining its location of
+residence and execution:
+<variablelist>
+ <varlistentry><term>ROM mode</term>
+ <listitem><para>In this mode, RedBoot both resides and executes from
+ ROM memory (flash or EPROM). This mode is used when there are limited
+ RAM resources. The flash commands cannot update the region of flash
+ where the RedBoot image resides. In order to update the RedBoot image
+ in flash, it is necessary to run a RAM mode instance of
+ RedBoot.</para></listitem>
+ </varlistentry>
+
+ <varlistentry><term>ROMRAM mode</term>
+ <listitem><para>In this mode, RedBoot resides in ROM memory (flash or
+ EPROM), but is copied to RAM memory before it starts executing. The
+ RAM footprint is larger than for ROM mode, but there are two
+ advantages to make up for this: it normally runs faster (relevant
+ only on slower boards) and it is able to update the flash region
+ where the image resides.</para></listitem>
+ </varlistentry>
+
+ <varlistentry><term>RAM mode</term>
+ <listitem><para>In this mode, RedBoot both resides and executes from
+ RAM memory. This is used for updating a primary ROM
+ mode image in situ and sometimes as part of the RedBoot installation
+ on the board when there's already an existing (non-RedBoot) boot
+ monitor available.</para>
+
+ <para> You can only use ROM and ROMRAM mode images for booting a
+ board - a RAM mode image cannot run unless loaded by another ROM
+ monitor. There is no need for this startup mode if a RedBoot ROMRAM
+ mode image is the primary boot monitor. When this startup mode is
+ programmed into flash (as a convenience as it's fast to load from
+ flash) it will generally be named as "RedBoot[RAM]" in the FIS
+ directory. </para></listitem>
+ </varlistentry>
+</variablelist>
+
+The chosen mode has influence on flash and RAM resource usage (see
+<xref linkend="resource-usage">) and the procedure of an in situ update
+of RedBoot in flash (see <xref linkend="Updating-Redboot">).</para>
+
+<para>The startup mode is controlled by the option CYG_HAL_STARTUP
+which resides in the platform HAL. Some platforms provide only some of
+the RAM, ROM, and ROMRAM modes, others provide additional
+modes.</para>
+
+<para>To see mode of a currently executing RedBoot, issue the
+<command>version</command> command, which prints the RedBoot banner,
+including the startup mode (here ROM):
+<screen>RedBoot><userinput>version</userinput>
+
+RedBoot(tm) bootstrap and debug environment <emphasis>[ROM]</emphasis>
+Non-certified release, version UNKNOWN - built 13:31:57, May 17 2002
+</screen>
+</para>
+
+</sect1>
+
+<sect1 id="resource-usage">
+<title>RedBoot Resource Usage</title>
+<para>
+ <indexterm><primary>RedBoot</primary><secondary>resource usage</secondary></indexterm>
+</para>
+
+<para>RedBoot takes up both flash and RAM resources depending on its
+startup mode and number of enabled features. There are also other
+resources used by RedBoot, such as timers. Platform-specific resources
+used by RedBoot are listed in the platform specific parts of this
+manual.</para>
+
+<para>Both flash and RAM resources used by RedBoot depend to some
+degree on the features enabled in the RedBoot configuration. It is
+possible to reduce in particular the RAM resources used by RedBoot by
+removing features that are not needed. Flash resources can also be
+reduced, but due to the granularity of the flash (the block sizes),
+reductions in feature size do not always result in flash resource
+savings.</para>
+
+
+<sect2>
+<title>Flash Resources</title>
+<para>On many platforms, a ROM mode RedBoot image resides in the first
+flash sectors, working as the board's primary boot monitor. On these
+platforms, it is also normal to reserve a similar amount of flash for
+a secondary RAM mode image, which is used when updating the primary
+ROM mode image.</para>
+<para>On other platforms, a ROMRAM mode RedBoot image is used as the
+primary boot monitor. On these platforms there is not normally
+reserved space for a RAM mode RedBoot image, since the ROMRAM mode
+RedBoot is capable of updating the primary boot monitor image.</para>
+<para>Most platforms also contain a FIS directory (keeping track of
+available flash space) and a RedBoot config block (containing RedBoot
+board configuration data).</para>
+<para>To see the amount of reserved flash memory, run the <command>fis
+list</command> command:
+<screen>RedBoot> <userinput>fis list</userinput>
+Name FLASH addr Mem addr Length Entry point
+RedBoot 0x00000000 0x00000000 0x00020000 0x00000000
+RedBoot[RAM] 0x00020000 0x06020000 0x00020000 0x060213C0
+RedBoot config 0x0007F000 0x0007F000 0x00001000 0x00000000
+FIS directory 0x00070000 0x00070000 0x0000F000 0x00000000
+</screen>
+</para>
+
+<para>To save flash resources, use a ROMRAM mode RedBoot, or if using
+a ROM mode RedBoot, avoid reserving space for the RedBoot[RAM] image
+(this is done by changing the RedBoot configuration) and download the
+RAM mode RedBoot whenever it is needed. If the RedBoot image takes up
+a fraction of an extra flash block, it may be possible to reduce the
+image size enough to free this block by removing some features.</para>
+
+</sect2>
+
+<sect2>
+<title>RAM Resources</title>
+
+<para>RedBoot reserves RAM space for its run-time data, and such
+things as CPU exception/interrupt tables. It normally does so at the
+bottom of the memory map. It may also reserve space at the top of the
+memory map for configurable RedBoot features such as the net stack
+and zlib decompression support.</para>
+<para>To see the actual amount of reserved space, issue the
+<command>version</command> command, which prints the RedBoot banner,
+including the RAM usage:
+<screen>RedBoot> <userinput>version</userinput>
+
+RedBoot(tm) bootstrap and debug environment [ROM]
+Non-certified release, version UNKNOWN - built 13:31:57, May 17 2002
+
+Platform: FooBar (SH 7615)
+Copyright (C) 2000, 2001, 2002, Free Software Foundation, Inc.
+
+<emphasis>RAM: 0x06000000-0x06080000, 0x06012498-0x06061000 available</emphasis>
+FLASH: 0x00000000 - 0x00080000, 8 blocks of 0x00010000 bytes each.
+</screen>
+</para>
+
+<para>To simplify operations that temporarily need data in free
+memory, the limits of free RAM are also available as aliases (aligned
+to the nearest kilo-byte limit). These are named
+<indexterm><primary>FREEMEMLO</primary></indexterm>FREEMEMLO and
+<indexterm><primary>FREEMEMHI</primary></indexterm>FREEMEMHI, and can
+be used in commands like any user defined alias:
+<screen>RedBoot> <userinput>load -r -b %{FREEMEMLO} file</userinput>
+Raw file loaded 0x06012800-0x06013e53, assumed entry at 0x06012800
+</screen>
+<screen>
+RedBoot> <userinput>x -b %{FREEMEMHI}</userinput>
+06061000: 86 F5 EB D8 3D 11 51 F2 96 F4 B2 DC 76 76 8F 77 |....=.Q.....vv.w|
+06061010: E6 55 DD DB F3 75 5D 15 E0 F3 FC D9 C8 73 1D DA |.U...u]......s..|
+</screen>
+</para>
+
+<para>To reduce RedBoot's RAM resource usage, use a ROM mode
+RedBoot. The RedBoot features that use most RAM are the net stack, the
+flash support and the gunzip support. These, and other features, can
+be disabled to reduce the RAM footprint, but obviously at the cost of
+lost functionality.</para>
+
+</sect2>
+</sect1>
+
+<sect1 id="Configuring-the-RedBoot-Environment">
+<title>Configuring the RedBoot Environment</title>
+<para><indexterm><primary>configuring the RedBoot environment</primary><secondary></secondary>
+</indexterm><indexterm><primary>RedBoot </primary><secondary>environment configuration
+</secondary></indexterm><indexterm><primary>environment configuration</primary>
+</indexterm>Once installed, RedBoot will operate fairly generically. However,
+there are some features that can be configured for a particular installation.
+These depend primarily on whether <indexterm><primary>flash and/or networking
+support</primary></indexterm><indexterm><primary>networking and/or flash support
+</primary></indexterm>flash and/or networking support are available. The remainder
+of this discussion assumes that support for both of these options is included
+in RedBoot.</para>
+<sect2 id=target-network-configuration>
+<title>Target Network Configuration</title>
+<para><indexterm><primary>target network configuration</primary></indexterm><indexterm>
+<primary>network configuration</primary></indexterm><indexterm><primary>configuration
+</primary><secondary>secondary</secondary></indexterm>Each node in a networked
+system needs to have a unique address. Since the network support in RedBoot
+is based on <indexterm><primary>TCP/IP</primary></indexterm>TCP/IP, this address
+is an IP (Internet Protocol) address. <indexterm><primary>IP address type
+</primary></indexterm>There are two ways for a system to &ldquo;know&rdquo;
+its IP address. First, it can be stored locally on the platform. This is known
+as having a static IP address. Second, the system can use the network itself
+to discover its IP address. This is known as a dynamic IP address. RedBoot
+supports this dynamic IP address mode by use of the <indexterm><primary>BOOTP
+</primary></indexterm>BOOTP (a subset of <indexterm><primary>DHCP</primary>
+</indexterm>DHCP) protocol. In this case, RedBoot will ask the network (actually
+some generic server on the network) for the IP address to use.</para>
+<note><title>NOTE</title>
+<para>Currently, RedBoot only supports BOOTP. In future releases, DHCP may
+also be supported, but such support will be limited to additional data items,
+not lease-based address allocation.</para>
+</note>
+<para>The choice of <indexterm><primary>IP address type</primary></indexterm>IP
+address type is made via the <indexterm><primary>fconfig command</primary>
+</indexterm><command>fconfig</command> command. Once a selection
+is made, it will be stored in flash memory. RedBoot only queries the flash
+configuration information at reset, so any changes will require restarting
+the platform.</para>
+<para>Here is an example of the RedBoot <command>fconfig</command>
+command, showing network addressing: </para>
+<programlisting>RedBoot> <userinput>fconfig -l</userinput>
+Run script at boot: false
+Use BOOTP for network configuration: false
+Local IP address: 192.168.1.29
+Default server IP address: 192.168.1.101
+DNS server IP address: 192.168.1.1
+GDB connection port: 9000
+Network debug at boot time: false </programlisting>
+<para>In this case, the board has been configured with a static IP address
+listed as the Local IP address. The default server IP address specifies which
+network node to communicate with for TFTP service. This address can be overridden
+directly in the <indexterm><primary>TFTP commands</primary></indexterm>TFTP
+commands.</para>
+<para>The <computeroutput>DNS server IP address</computeroutput> option
+controls where RedBoot should make DNS lookups<indexterm><primary>DNS
+lookups</primary></indexterm>. A setting of 0.0.0.0 will disable DNS
+lookups. The DNS server IP address can also be set at runtime.</para>
+<para>If the selection for <computeroutput>Use BOOTP for network configuration
+</computeroutput> had been <computeroutput>true</computeroutput>, these IP
+addresses would be determined at boot time, via the BOOTP protocol. The final
+number which needs to be configured, regardless of IP address selection mode,
+is the <indexterm><primary>GDB connection port</primary></indexterm><computeroutput>
+GDB connection port</computeroutput>. RedBoot allows for incoming commands
+on either the available serial ports or via the network. This port number
+is the TCP port that RedBoot will use to accept incoming connections. </para>
+<para>These connections can be used for GDB sessions, but they can also be
+used for generic RedBoot commands. In particular, it is possible to communicate
+with RedBoot via the <indexterm><primary>telnet</primary></indexterm>telnet
+protocol. For example, on Linux&reg;: </para>
+<programlisting>% telnet redboot_board 9000
+Connected to redboot_board
+Escape character is &lsquo;^]&rsquo;.
+RedBoot> </programlisting>
+</sect2>
+<sect2>
+<title>Host Network Configuration</title>
+<para><indexterm><primary>host network configuration</primary></indexterm><indexterm>
+<primary>network configuration</primary><secondary>host</secondary></indexterm><indexterm>
+<primary>configuration</primary><secondary>network</secondary></indexterm>RedBoot
+may require three different classes of service from a network host: </para>
+<itemizedlist>
+<listitem><para>dynamic IP address allocation, using BOOTP </para>
+</listitem>
+<listitem><para>TFTP service for file downloading </para>
+</listitem>
+<listitem><para>DNS server for hostname lookups </para>
+</listitem>
+</itemizedlist>
+<para>Depending on the host system, these services may or may not be available
+or enabled by default. See your system documentation for more details.</para>
+<para>In particular, on Red Hat Linux, neither of these services will be configured
+out of the box. The following will provide a limited explanation of how to
+set them up. These configuration setups must be done as <computeroutput>root
+</computeroutput> on the host or server machine.</para>
+<sect3>
+<title>Enable TFTP on Red Hat Linux 6.2</title>
+<procedure>
+<step><para><indexterm><primary>TFTP</primary><secondary>enabling on Red Hat
+Linux 6.2</secondary></indexterm><indexterm><primary>Red Hat Linux</primary>
+<secondary>enabling TFTP on version 6.2</secondary></indexterm>Ensure that
+you have the tftp-server RPM package installed. By default, this installs
+the TFTP server in a disabled state. These steps will enable it:</para>
+</step>
+<step><para>Make sure that the following line is uncommented in the control
+file <filename>/etc/inetd.conf</filename> <screen>tftp dgram udp wait root /usr/sbin/tcpd /usr/sbin/in.tftpd
+</screen></para>
+<para></para>
+</step>
+<step><para>If it was necessary to change the line in Step 2, then the inetd
+server must be restarted, which can be done via the command: <programlisting>
+# service inet reload</programlisting></para>
+</step>
+</procedure>
+</sect3>
+<sect3>
+<title>Enable TFTP on Red Hat Linux 7 (or newer)</title>
+<procedure>
+<step><para><indexterm><primary>TFTP</primary><secondary>enabling on Red Hat
+Linux 7</secondary></indexterm><indexterm><primary>Red Hat Linux</primary>
+<secondary>enabling TFTP on version 7</secondary></indexterm>Ensure that the
+xinetd RPM is installed.</para>
+</step>
+<step><para>Ensure that the tftp-server RPM is installed.</para>
+</step>
+<step><para>Enable TFTP by means of the following: <programlisting>/sbin/chkconfig tftp on
+</programlisting>Reload the xinetd configuration using the command:<programlisting>
+ /sbin/service xinetd reload </programlisting>Create the directory /tftpboot
+using the command <programlisting>mkdir /tftpboot</programlisting></para>
+</step>
+<step><para>If you are using Red Hat 8 or newer, you may need to configure
+the built-in firewall to allow through TFTP. Either edit
+<filename>/etc/sysconfig/iptables</filename> or run
+<command>redhat-config-securitylevel</command> on the command line or from
+the menu as System Settings->Security Settings to lower the security level.
+You should only do this with the permission of your systems administrator and
+if you are already behind a separate firewall.</para>
+</step>
+</procedure>
+<note><title>NOTE</title>
+<para>Under Red Hat 7 you must address files by absolute pathnames, for example: <filename>
+/tftpboot/boot.img</filename> not <filename>/boot.img</filename>, as you may have done with
+other implementations.
+On systems newer than Red Hat 7 (7.1 and beyond), filenames are once again relative to the
+<filename>/tftpboot</filename> directory.
+</para>
+</note>
+</sect3>
+<sect3>
+<title>Enable BOOTP/DHCP server on Red Hat Linux</title>
+<para><indexterm><primary>DHCP</primary><secondary>enabling on Red Hat Linux
+</secondary></indexterm><indexterm><primary>BOOTP</primary><secondary>
+enabling on Red Hat Linux</secondary></indexterm>First, ensure that you have
+the proper package, <computeroutput>dhcp</computeroutput> (not <computeroutput>
+dhcpd</computeroutput>) installed. The DHCP server provides Dynamic Host Configuration,
+that is, IP address and other data to hosts on a network. It does this in
+different ways. Next, there can be a fixed relationship between a certain
+node and the data, based on that node&rsquo;s unique Ethernet Station Address
+(ESA, sometimes called a MAC address). The other possibility is simply to
+assign addresses that are free. The sample DHCP configuration file shown does
+both. Refer to the DHCP documentation for more details.</para>
+<example><title>Sample DHCP configuration file</title>
+<programlisting>--------------- /etc/dhcpd.conf -----------------------------
+default-lease-time 600;
+max-lease-time 7200;
+option subnet-mask 255.255.255.0;
+option broadcast-address 192.168.1.255;
+option domain-name-servers 198.41.0.4, 128.9.0.107;
+option domain-name &ldquo;bogus.com&rdquo;;
+allow bootp;
+shared-network BOGUS {
+subnet 192.168.1.0 netmask 255.255.255.0 {
+ option routers 192.168.1.101;
+ range 192.168.1.1 192.168.1.254;
+}
+ }
+host mbx {
+ hardware ethernet 08:00:3E:28:79:B8;
+ fixed-address 192.168.1.20;
+ filename &ldquo;/tftpboot/192.168.1.21/zImage&rdquo;;
+ default-lease-time -1;
+ server-name &ldquo;srvr.bugus.com&rdquo;;
+ server-identifier 192.168.1.101;
+ option host-name &ldquo;mbx&rdquo;;
+} </programlisting></example>
+<para>Once the DHCP package has been installed and the configuration file
+set up, type:<screen>
+# <userinput>service dhcpd start</userinput></screen></para>
+</sect3>
+<sect3>
+<title>Enable DNS server on Red Hat Linux</title>
+<para><indexterm><primary>DNS</primary><secondary>enabling on Red Hat
+Linux</secondary></indexterm>First, ensure that you have the proper
+RPM package, <computeroutput>caching-nameserver</computeroutput>
+installed. Then change the configuration
+(in <filename>/etc/named.conf</filename>) so that the
+<computeroutput>forwarders</computeroutput> point to the primary
+nameservers for your machine, normally using the nameservers listed in
+<filename>/etc/resolv.conf</filename>.</para>
+
+<example><title>
+Sample <filename>/etc/named.conf</filename> for Red Hat Linux 7.x
+</title>
+
+<programlisting>--------------- /etc/named.conf -----------------------------
+// generated by named-bootconf.pl
+
+options {
+ directory "/var/named";
+ /*
+ * If there is a firewall between you and nameservers you want
+ * to talk to, you might need to uncomment the query-source
+ * directive below. Previous versions of BIND always asked
+ * questions using port 53, but BIND 8.1 uses an unprivileged
+ * port by default.
+ */
+ // query-source address * port 53;
+
+
+ forward first;
+ forwarders {
+ 212.242.40.3;
+ 212.242.40.51;
+ };
+};
+
+//
+// a caching only nameserver config
+//
+// Uncomment the following for Red Hat Linux 7.2 or above:
+// controls {
+// inet 127.0.0.1 allow { localhost; } keys { rndckey; };
+// };
+// include "/etc/rndc.key";
+zone "." IN {
+ type hint;
+ file "named.ca";
+};
+
+zone "localhost" IN {
+ type master;
+ file "localhost.zone";
+ allow-update { none; };
+};
+
+zone "0.0.127.in-addr.arpa" IN {
+ type master;
+ file "named.local";
+ allow-update { none; };
+};
+
+</programlisting></example>
+
+<para>Make sure the server is started with the command:
+<screen># <userinput>service named start</userinput></screen> and is
+started on next reboot with the command
+<screen># <userinput>chkconfig named on</userinput></screen>
+Finally, you may wish to change
+<filename>/etc/resolv.conf</filename> to use
+<computeroutput>127.0.0.1</computeroutput> as the nameserver for your
+local machine.</para>
+</sect3>
+<sect3>
+<title>RedBoot network gateway</title>
+<para><indexterm><primary>RedBoot network gateway</primary></indexterm><indexterm>
+<primary>network gateway</primary></indexterm>RedBoot cannot communicate with
+machines on different subnets because it does not support routing. It always
+assumes that it can get to an address directly, therefore it always tries
+to ARP and then send packets directly to that unit. This means that whatever
+it talks to must be on the same subnet. If you need to talk to a host on a
+different subnet (even if it's on the same &lsquo;wire&rsquo;), you need to
+go through an ARP proxy, providing that there is a Linux box connected to
+the network which is able to route to the TFTP server. For example: <filename>
+/proc/sys/net/ipv4/conf/<replaceable>&lt;interface></replaceable>/proxy_arp </filename>where <replaceable>
+&lt;interface></replaceable>should be replaced with whichever network interface
+is directly connected to the board.</para>
+</sect3></sect2>
+<sect2>
+<title>Verification</title>
+<para><indexterm><primary>verification (network)</primary></indexterm><indexterm>
+<primary>network verification</primary></indexterm>Once your network setup
+has been configured, perform simple verification tests as follows: <itemizedlist>
+<listitem><para>Reboot your system, to enable the setup, and then try to &lsquo;ping&rsquo;
+the target board from a host.</para>
+</listitem>
+<listitem><para>Once communication has been established, try to ping
+a host using the RedBoot ping command - both by IP address and hostname.</para>
+</listitem>
+<listitem><para>Try using the RedBoot load command to download a file
+from a host.</para>
+</listitem>
+</itemizedlist></para>
+</sect2></sect1></chapter>
+
+<!-- Commands -->
+<!-- &redboot-current-doc-redboot-cmds-sgml; -->
+
+<!-- Rebuilding -->
+<!-- &redboot-current-doc-redboot-rebuilding-sgml; -->
+
+<!-- Installing and testing -->
+<!-- &redboot-current-doc-redboot-installing-sgml; -->
+
+<!-- Epilogue -->
+<!-- &redboot-current-doc-redboot-epilogue-sgml; -->
diff --git a/ecos/packages/redboot/current/doc/redboot_cmds.sgml b/ecos/packages/redboot/current/doc/redboot_cmds.sgml
new file mode 100644
index 0000000..bed6053
--- /dev/null
+++ b/ecos/packages/redboot/current/doc/redboot_cmds.sgml
@@ -0,0 +1,4090 @@
+<!-- {{{ Banner -->
+
+<!-- =============================================================== -->
+<!-- -->
+<!-- redboot_cmds.sgml -->
+<!-- -->
+<!-- Documentation for RedBoot Commands -->
+<!-- -->
+<!-- =============================================================== -->
+<!-- ####ECOSDOCCOPYRIGHTBEGIN#### -->
+<!-- =============================================================== -->
+<!-- Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. -->
+<!-- This material may be distributed only subject to the terms -->
+<!-- and conditions set forth in the Open Publication License, v1.0 -->
+<!-- or later (the latest version is presently available at -->
+<!-- http://www.opencontent.org/openpub/) -->
+<!-- Distribution of the work or derivative of the work in any -->
+<!-- standard (paper) book form is prohibited unless prior -->
+<!-- permission obtained from the copyright holder -->
+<!-- =============================================================== -->
+<!-- ####ECOSDOCCOPYRIGHTEND#### -->
+<!-- =============================================================== -->
+<!-- #####DESCRIPTIONBEGIN#### -->
+<!-- -->
+<!-- ####DESCRIPTIONEND#### -->
+<!-- =============================================================== -->
+
+<!-- }}} -->
+
+<chapter id="RedBoot-Commands-and-Examples">
+<title>RedBoot Commands and Examples</title>
+<sect1>
+<title>Introduction</title>
+<para><indexterm><primary>RedBoot</primary><secondary>commands and examples
+</secondary></indexterm><indexterm><primary>commands and examples</primary>
+</indexterm>RedBoot provides three basic classes of commands: <itemizedlist>
+<listitem><para>Program loading and execution</para>
+</listitem>
+<listitem><para>Flash image and configuration management</para>
+</listitem>
+<listitem><para>Miscellaneous commands</para>
+</listitem>
+</itemizedlist>Given the extensible and configurable nature of eCos and RedBoot,
+there may be extended or enhanced sets of commands available.</para>
+<para>The basic format for commands is: <programlisting>RedBoot> COMMAND [-S]... [-s val]... operand
+</programlisting>
+</para>
+<para>
+Commands may require additional information beyond the basic
+command name. In most cases this additional information is optional, with
+suitable default values provided if they are not present.
+
+ <informaltable frame="all">
+ <tgroup cols="3" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <thead>
+ <row>
+ <entry>Format</entry>
+ <entry>Description</entry>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>-S</entry>
+ <entry>A boolean switch; the behavior of the command will differ, depending
+on the presence of the switch. In this example, the <userinput>-f</userinput> switch
+indicates that a complete initialization of the FIS data should be performed.
+There may be many such switches available for any given command and any or all of
+them may be present, in any order.</entry>
+ <entry>
+ <computeroutput> RedBoot> <userinput>fis init -f</userinput></computeroutput>
+ </entry>
+ </row>
+ <row>
+ <entry>-s<replaceable> val</replaceable></entry>
+ <entry>A qualified value; the letter "s" introduces the value, qualifying it's meaning. In the
+example, <userinput>-b 0x100000</userinput> specifies where the memory dump should begin.
+There may be many such switches available for any given command and any or all of
+them may be present, in any order.
+</entry>
+ <entry>
+ <computeroutput> RedBoot> <userinput>dump -b 0x100000 -l 0x20</userinput></computeroutput>
+ </entry>
+ </row>
+ <row>
+ <entry><replaceable> operand</replaceable></entry>
+ <entry>A simple value; some commands require a single parameter for which an additional
+<userinput>-X</userinput> switch would be redundant. In the example, <userinput>JFFS2</userinput>
+is the name of a flash image. The image name is always required, thus is no need to qualify it with
+a switch.
+Note that any un-qualified operand must always appear at the end of the command.</entry>
+ <entry>
+ <computeroutput> RedBoot> <userinput>fis delete JFFS2</userinput></computeroutput>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+</para>
+<para>The list of available commands, and their syntax, can be obtained by
+typing <command>help</command> at the command line:
+<screen>
+RedBoot> <userinput>help</userinput>
+Manage aliases kept in FLASH memory
+ alias name [value]
+Set/Query the system console baud rate
+ baudrate [-b &lt;rate>]
+Manage machine caches
+ cache [ON | OFF]
+Display/switch console channel
+ channel [-1|&lt;channel number>]
+Display disk partitions
+ disks
+Display (hex dump) a range of memory
+ dump -b &lt;location> [-l &lt;length>] [-s]
+Manage flash images
+ fis {cmds}
+Manage configuration kept in FLASH memory
+ fconfig [-i] [-l] [-n] [-f] [-d] | [-d] nickname [value]
+Execute code at a location
+ go [-w &lt;timeout>] [-c] [-n] [entry]
+Help about help?
+ help [&lt;topic>]
+Set/change IP addresses
+ ip_address [-l &lt;local_ip_address>[/&lt;mask_length>]] [-h &lt;server_address>]
+Load a file
+ load [-r] [-v] [-d] [-c &lt;channel>] [-h &lt;host>] [-m {TFTP | HTTP | {x|y}MODEM | disk}]
+ [-b &lt;base_address>] &lt;file_name>
+Network connectivity test
+ ping [-v] [-n &lt;count>] [-t &lt;timeout>] [-i &lt;IP_addr]
+ -h &lt;host>
+Reset the system
+ reset
+Display RedBoot version information
+ version
+Display (hex dump) a range of memory
+ x -b &lt;location> [-l &lt;length>] [-s]
+</screen>
+</para>
+<para>
+Commands can be abbreviated to their shortest
+unique string. Thus in the list above, <command>d,du,dum</command>
+and dump are all valid for the <command>dump</command> command. The <command>fconfig</command>
+command can be abbreviated <command>fc</command>, but
+<command>f</command> would be ambiguous with <command>fis</command>.
+</para>
+<para>There is one additional, special command. When RedBoot detects '$' or '+'
+(unless escaped via '\') in a command, it switches to GDB protocol mode. At this
+point, the eCos GDB stubs take over, allowing connections from a GDB host.
+The only way to get back to RedBoot from GDB mode is to restart the platform.
+</para>
+<note><title>NOTE</title>
+<para>
+Multiple commands may be entered on a single line, separated by the semi-colon &ldquo;;&rdquo; character.
+</para>
+</note>
+<para>The standard RedBoot command set is structured around the bootstrap
+environment. These commands are designed to be simple to use and remember,
+while still providing sufficient power and flexibility to be useful. No attempt
+has been made to render RedBoot as the end-all product. As such, things such
+as the debug environment are left to other modules, such as GDB stubs, which
+are typically included in RedBoot. </para>
+<para>The command set may be also be extended on a platform basis. </para>
+</sect1>
+
+<sect1 id="common-commands">
+<title>Common Commands</title>
+<para>
+ <indexterm><primary>commands</primary><secondary>common</secondary>
+ </indexterm>
+</para>
+
+<!-- ******** alias *************************************************** -->
+ <refentry id="alias-command">
+ <refnamediv>
+ <refname>alias</refname>
+ <refpurpose>Manipulate command line aliases</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>alias</command>
+ <arg choice="req"><replaceable> name</replaceable></arg>
+ <arg><replaceable> value</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><replaceable>name</replaceable></entry>
+ <entry>Name</entry>
+ <entry>The name for this alias.</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ <row>
+ <entry><replaceable>value</replaceable></entry>
+ <entry>String</entry>
+ <entry>Replacement value for the alias.</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para>The <command>alias</command> command is used to maintain simple command
+line aliases. These aliases are shorthand for longer expressions.
+When the pattern %{name} appears in a command line, including in a script,
+the corresponding value will be substituted. Aliases may be nested.
+ </para>
+ <para>
+If no value is provided, then the current value of the alias is displayed.
+ </para>
+ <para>
+If the system supports non-volatile configuration data via the
+<command>fconfig</command> command (see <xref linkend="Persistent-State-Flash">),
+then the value will be saved and used when the system is reset.
+ </para>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Set an alias.
+<screen>
+RedBoot> <userinput>alias joe "This is Joe"</userinput>
+Update RedBoot non-volatile configuration - continue (y/n)? n
+</screen>
+</para>
+<para>
+Display an alias.
+<screen>
+RedBoot> <userinput>alias joe</userinput>
+'joe' = 'This is Joe'
+</screen>
+</para>
+<para>
+Use an alias. Note: the <command>"="</command> command simply echoes the command to to console.
+<screen>
+RedBoot> <userinput>= %{joe}</userinput>
+This is Joe
+</screen>
+</para>
+<para>
+Aliases can be nested.
+<screen>
+RedBoot> <userinput>alias frank "Who are you? %{joe}"</userinput>
+Update RedBoot non-volatile configuration - continue (y/n)? n
+RedBoot> <userinput>= %{frank}</userinput>
+Who are you? This is Joe
+</screen>
+</para>
+<para>
+Notice how the value of %{frank} changes when %{joe} is changed since
+the value of %{joe} is not evaluated until %{frank} is evaluated.
+<screen>
+RedBoot> <userinput>alias joe "This is now Josephine"</userinput>
+Update RedBoot non-volatile configuration - continue (y/n)? n
+RedBoot> <userinput>= %{frank}</userinput>
+Who are you? This is now Josephine
+</screen>
+ </para>
+ </refsect1>
+ </refentry>
+
+<!-- ******** baudrate *************************************************** -->
+ <refentry id="baudrate-command">
+ <refnamediv>
+ <refname>baudrate</refname>
+ <refpurpose>Set the baud rate for the system serial console</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>baudrate</command>
+ <arg>-b<replaceable> rate</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>-b <replaceable>rate</replaceable></entry>
+ <entry>Number</entry>
+ <entry>The baud rate to use for the serial console.</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para>The <command>baudrate</command> command sets the baud rate for the system serial console.
+ </para>
+ <para>
+If no value is provided, then the current value of the console baud rate is displayed.
+ </para>
+ <para>
+If the system supports non-volatile configuration data via the
+<command>fconfig</command> command (see <xref linkend="Persistent-State-Flash">),
+then the value will be saved and used when the system is reset.
+ </para>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Show the current baud rate.
+<screen>
+RedBoot> <userinput>baudrate</userinput>
+Baud rate = 38400
+</screen>
+</para>
+<para>
+Change the console baud rate. In order to make this operation safer,
+there will be a slight pause after the
+first message to give you time to change to the new baud rate.
+If it doesn't work, or a less than affirmative answer is given to the
+"continue" prompt, then the baud rate will revert to the current value.
+Only after the baud rate has been firmly established will <emphasis>RedBoot</emphasis>
+give you an opportunity to save the value in persistent storage.
+<screen>
+RedBoot> <userinput>baudrate -b 57600</userinput>
+Baud rate will be changed to 57600 - update your settings
+<emphasis>Device baud rate changed at this point</emphasis>
+Baud rate changed to 57600 - continue (y/n)? y
+Update RedBoot non-volatile configuration - continue (y/n)? n
+</screen>
+ </para>
+ </refsect1>
+ </refentry>
+
+<!-- ******** cache *************************************************** -->
+ <refentry id="cache-command">
+ <refnamediv>
+ <refname>cache</refname>
+ <refpurpose>Control hardware caches</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>cache</command>
+ <group>
+ <arg>on</arg>
+ <arg>off</arg>
+ </group>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>on</entry>
+ <entry></entry>
+ <entry>Turn the caches on</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ <row>
+ <entry>off</entry>
+ <entry></entry>
+ <entry>Turn the caches off</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para>The <command>cache</command> command is used to manipulate the caches on the processor. </para>
+ <para>With no options, this command specifies the state of the system caches.</para>
+ <para>When an option is given, the caches are turned off or on appropriately.</para>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Show the current cache state.
+<screen>
+RedBoot> <userinput>cache</userinput>
+Data cache: On, Instruction cache: On
+</screen>
+</para>
+<para>
+Disable the caches.
+<screen>
+RedBoot> <userinput>cache off</userinput>
+RedBoot> <userinput>cache</userinput>
+Data cache: Off, Instruction cache: Off
+</screen>
+</para>
+<para>
+Enable the caches.
+<screen>
+RedBoot> <userinput>cache on</userinput>
+RedBoot> <userinput>cache</userinput>
+Data cache: On, Instruction cache: On
+</screen>
+ </para>
+ </refsect1>
+ </refentry>
+
+<!-- ******** channel *************************************************** -->
+ <refentry id="channel-command">
+ <refnamediv>
+ <refname>channel</refname>
+ <refpurpose>Select the system console channel</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>channel</command>
+ <group>
+ <arg>-1</arg>
+ <arg><replaceable>channel_number</replaceable></arg>
+ </group>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>-1</entry>
+ <entry></entry>
+ <entry>Reset the console channel</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ <row>
+ <entry>channel_number</entry>
+ <entry>Number</entry>
+ <entry>Select a channel</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para>
+With no arguments, the <command>channel</command> command displays the current console channel number.
+</para><para>
+When passed an argument of 0 upward, this command switches the console
+channel to that channel number. The mapping between channel numbers and
+physical channels is platform specific but will typically be something like
+channel 0 is the first serial port, channel 1 is the second, etc.
+</para><para>
+When passed an argument of -1, this command reverts RedBoot to responding
+to whatever channel receives input first, as happens when RedBoot initially
+starts execution.
+</para>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Show the current channel.
+<screen>
+RedBoot> <userinput>channel</userinput>
+Current console channel id: 0
+</screen>
+</para>
+<para>
+Change to an invalid channel.
+<screen>
+RedBoot> <userinput>channel 99</userinput>
+**Error: bad channel number '99'
+</screen>
+</para>
+<para>
+Revert to the default channel setting (any console mode).
+<screen>
+RedBoot> <userinput>channel -1</userinput>
+</screen>
+ </para>
+ </refsect1>
+ </refentry>
+
+<!-- ******** cksum *************************************************** -->
+ <refentry id="cksum-command">
+ <refnamediv>
+ <refname>cksum</refname>
+ <refpurpose>Compute POSIX checksums</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>cksum</command>
+ <arg choice="req">-b <replaceable>location</replaceable></arg>
+ <arg choice="req">-l <replaceable>length</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>-b <replaceable>location</replaceable></entry>
+ <entry>Memory address</entry>
+ <entry>Location in memory for stat of data.</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ <row>
+ <entry>-l <replaceable>length</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Length of data</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para>Computes the POSIX checksum on a range of memory (either RAM or FLASH).
+The values printed (decimal cksum, decimal length, hexadecimal cksum,
+ hexadecimal length) can be compared with the output from the Linux program 'cksum'.
+</para>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Checksum a buffer.
+<screen>
+RedBoot> <userinput>cksum -b 0x100000 -l 0x100</userinput>
+POSIX cksum = 3286483632 256 (0xc3e3c2b0 0x00000100)
+</screen>
+ </para>
+ <para>
+Checksum an area of memory after loading a file. Note that the base
+address and length parameters are provided by the preceding
+load command.
+<screen>
+RedBoot> <userinput>load -r -b %{FREEMEMLO} redboot.bin</userinput>
+Raw file loaded 0x06012800-0x0602f0a8
+RedBoot> <userinput>cksum</userinput>
+Computing cksum for area 0x06012800-0x0602f0a8
+POSIX cksum = 2092197813 116904 (0x7cb467b5 0x0001c8a8)
+</screen>
+ </para>
+ </refsect1>
+ </refentry>
+
+<!-- ******** disks *************************************************** -->
+ <refentry id="disks-command">
+ <refnamediv>
+ <refname>disks</refname>
+ <refpurpose>List available disk partitions.</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>disks</command>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+<para>None.</para>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para>The <command>disks</command> command is used to list disk partitions recognized by RedBoot.</para>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Show what disk partitions are available.
+<screen>
+RedBoot> <userinput>disks</userinput>
+hda1 Linux Swap
+hda2 Linux
+00100000: 00 3E 00 06 00 06 00 06 00 00 00 00 00 00 00 00 |.>..............|
+00100010: 00 00 00 78 00 70 00 60 00 60 00 60 00 60 00 60 |...x.p.`.`.`.`.`|
+</screen>
+ </para>
+ </refsect1>
+ </refentry>
+
+<!-- ******** dump *************************************************** -->
+ <refentry id="dump-command">
+ <refnamediv>
+ <refname>dump</refname>
+ <refpurpose>Display memory.</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>dump</command>
+ <arg choice="req">-b <replaceable>location</replaceable></arg>
+ <arg>-l <replaceable>length</replaceable></arg>
+ <arg>-s</arg>
+ <group>
+ <arg>-1</arg>
+ <arg>-2</arg>
+ <arg>-4</arg>
+ </group>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>-b <replaceable>location</replaceable></entry>
+ <entry>Memory address</entry>
+ <entry>Location in memory for start of data.</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ <row>
+ <entry>-l <replaceable>length</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Length of data</entry>
+ <entry>32</entry>
+ </row>
+ <row>
+ <entry>-s</entry>
+ <entry>Boolean</entry>
+ <entry>Format data using Motorola S-records.</entry>
+ <entry></entry>
+ </row>
+ <row>
+ <entry>-1</entry>
+ <entry></entry>
+ <entry>Access one byte (8 bits) at a time.
+Only the least significant 8 bits of the pattern will be used.</entry>
+ <entry>-1</entry>
+ </row>
+ <row>
+ <entry>-2</entry>
+ <entry></entry>
+ <entry>Access two bytes (16 bits) at a time.
+Only the least significant 16 bits of the pattern will be used.</entry>
+ <entry>-1</entry>
+ </row>
+ <row>
+ <entry>-4</entry>
+ <entry></entry>
+ <entry>Access one word (32 bits) at a time.</entry>
+ <entry>-1</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para>Display a range of memory on the system console.</para>
+ <para>The <command>x</command> is a synonym for <command>dump</command>.</para>
+ <para>Note that this command could
+be detrimental if used on memory mapped hardware registers. </para>
+ <para>The memory is displayed at most sixteen bytes per line, first as the
+raw hex value, followed by an ASCII interpretation of the data. </para>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Display a buffer, one byte at a time.
+<screen>
+RedBoot> <userinput>mfill -b 0x100000 -l 0x20 -p 0xDEADFACE</userinput>
+RedBoot> <userinput>x -b 0x100000</userinput>
+00100000: CE FA AD DE CE FA AD DE CE FA AD DE CE FA AD DE |................|
+00100010: CE FA AD DE CE FA AD DE CE FA AD DE CE FA AD DE |................|
+</screen>
+</para>
+<para>
+Display a buffer, one short (16 bit) word at a time. Note in this case that
+the ASCII interpretation is suppressed.
+<screen>
+RedBoot> <userinput>dump -b 0x100000 -2</userinput>
+00100000: FACE DEAD FACE DEAD FACE DEAD FACE DEAD
+00100010: FACE DEAD FACE DEAD FACE DEAD FACE DEAD
+</screen>
+</para>
+<para>
+Display a buffer, one word (32 bit) word at a time. Note in this case that
+the ASCII interpretation is suppressed.
+<screen>
+RedBoot> <userinput>dump -b 0x100000 -4</userinput>
+00100000: DEADFACE DEADFACE DEADFACE DEADFACE
+00100010: DEADFACE DEADFACE DEADFACE DEADFACE
+</screen>
+</para>
+<para>
+Display the same buffer, using Motorola S-record format.
+<screen>
+RedBoot> <userinput>dump -b 0x100000 -s</userinput>
+S31500100000CEFAADDECEFAADDECEFAADDECEFAADDE8E
+S31500100010CEFAADDECEFAADDECEFAADDECEFAADDE7E
+</screen>
+</para>
+<para>
+Display a buffer, with visible ASCII strings.
+<screen>
+RedBoot> <userinput>d -b 0xfe00b000 -l 0x80</userinput>
+0xFE00B000: 20 25 70 0A 00 00 00 00 41 74 74 65 6D 70 74 20 | %p.....Attempt |
+0xFE00B010: 74 6F 20 6C 6F 61 64 20 53 2D 72 65 63 6F 72 64 |to load S-record|
+0xFE00B020: 20 64 61 74 61 20 74 6F 20 61 64 64 72 65 73 73 | data to address|
+0xFE00B030: 3A 20 25 70 20 5B 6E 6F 74 20 69 6E 20 52 41 4D |: %p [not in RAM|
+0xFE00B040: 5D 0A 00 00 2A 2A 2A 20 57 61 72 6E 69 6E 67 21 |]...*** Warning!|
+0xFE00B050: 20 43 68 65 63 6B 73 75 6D 20 66 61 69 6C 75 72 | Checksum failur|
+0xFE00B060: 65 20 2D 20 41 64 64 72 3A 20 25 6C 78 2C 20 25 |e - Addr: %lx, %|
+0xFE00B070: 30 32 6C 58 20 3C 3E 20 25 30 32 6C 58 0A 00 00 |02lX &lt;> %02lX...|
+0xFE00B080: 45 6E 74 72 79 20 70 6F 69 6E 74 3A 20 25 70 2C |Entry point: %p,|
+</screen>
+ </para>
+ </refsect1>
+ </refentry>
+
+<!-- ******** help *************************************************** -->
+ <refentry id="help-command">
+ <refnamediv>
+ <refname>help</refname>
+ <refpurpose>Display help on available commands</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>help</command>
+ <arg><replaceable> topic</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><replaceable>topic</replaceable></entry>
+ <entry>String</entry>
+ <entry>Which command to provide help for.</entry>
+ <entry>All commands</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para>
+The <command>help</command> command displays information about the available
+RedBoot commands. If a <emphasis>topic</emphasis> is given, then the display
+is restricted to information about that specific command.
+ </para>
+ <para>
+If the command has sub-commands, e.g. <command>fis</command>, then the topic
+specific display will print additional information about the available sub-commands.
+special (ICMP) packets to a specific host. These packets should be automatically
+returned by that host. The command will indicate how many of these round-trips
+were successfully completed.
+ </para>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Show generic help. Note that the contents of this display will depend on the various configuration
+options for RedBoot when it was built.
+<screen>
+RedBoot> <userinput>help</userinput>
+Manage aliases kept in FLASH memory
+ alias name [value]
+Manage machine caches
+ cache [ON | OFF]
+Display/switch console channel
+ channel [-1|&lt;channel number&gt;]
+Compute a 32bit checksum [POSIX algorithm] for a range of memory
+ cksum -b &lt;location&gt; -l &lt;length&gt;
+Display (hex dump) a range of memory
+ dump -b &lt;location&gt; [-l &lt;length&gt;] [-s] [-1|-2|-4]
+Manage FLASH images
+ fis {cmds}
+Manage configuration kept in FLASH memory
+ fconfig [-i] [-l] [-n] [-f] [-d] | [-d] nickname [value]
+Execute code at a location
+ go [-w &lt;timeout&gt;] [entry]
+Uncompress GZIP compressed data
+ gunzip -s &lt;location&gt; -d &lt;location&gt;
+Help about help?
+ help [&lt;topic&gt;]
+Read I/O location
+ iopeek [-b &lt;location&gt;] [-1|2|4]
+Write I/O location
+ iopoke [-b &lt;location&gt;] [-1|2|4] -v &lt;value&gt;
+Set/change IP addresses
+ ip_address [-l &lt;local_ip_address&gt;[/&lt;mask_length&gt;]] [-h &lt;server_address&gt;]
+Load a file
+ load [-r] [-v] [-d] [-h &lt;host&gt;] [-m {TFTP | HTTP | {x|y}MODEM -c &lt;channel_number&gt;}]
+ [-f &lt;flash_address&gt;] [-b &lt;base_address&gt;] &lt;file_name&gt;
+Compare two blocks of memory
+ mcmp -s &lt;location&gt; -d &lt;location&gt; -l &lt;length&gt; [-1|-2|-4]
+Fill a block of memory with a pattern
+ mfill -b &lt;location&gt; -l &lt;length&gt; -p &lt;pattern&gt;
+ [-1|-2|-4]
+Network connectivity test
+ ping [-v] [-n &lt;count&gt;] [-l &lt;length&gt;] [-t &lt;timeout&gt;] [-r &lt;rate&gt;]
+ [-i &lt;IP_addr&gt;] -h &lt;IP_addr&gt;
+Reset the system
+ reset
+Display RedBoot version information
+ version
+Display (hex dump) a range of memory
+ x -b &lt;location&gt; [-l &lt;length&gt;] [-s] [-1|-2|-4]
+</screen>
+ </para>
+ <para>
+Help about a command with sub-commands.
+<screen>
+RedBoot> <userinput>help fis</userinput>
+Manage FLASH images
+ fis {cmds}
+Create an image
+ fis create -b &lt;mem_base&gt; -l &lt;image_length&gt; [-s &lt;data_length&gt;]
+ [-f &lt;flash_addr&gt;] [-e &lt;entry_point&gt;] [-r &lt;ram_addr&gt;] [-n] &lt;name&gt;
+Display an image from FLASH Image System [FIS]
+ fis delete name
+Erase FLASH contents
+ fis erase -f &lt;flash_addr&gt; -l &lt;length&gt;
+Display free [available] locations within FLASH Image System [FIS]
+ fis free
+Initialize FLASH Image System [FIS]
+ fis init [-f]
+Display contents of FLASH Image System [FIS]
+ fis list [-c] [-d]
+Load image from FLASH Image System [FIS] into RAM
+ fis load [-d] [-b &lt;memory_load_address&gt;] [-c] name
+Write raw data directly to FLASH
+ fis write -f &lt;flash_addr&gt; -b &lt;mem_base&gt; -l &lt;image_length&gt;
+</screen>
+ </para>
+ </refsect1>
+ </refentry>
+
+<!-- ******** iopeek *************************************************** -->
+ <refentry id="iopeek-command">
+ <refnamediv>
+ <refname>iopeek</refname>
+ <refpurpose>Read I/O location</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>iopeek</command>
+ <arg>-b <replaceable> location</replaceable></arg>
+ <group>
+ <arg>-1</arg>
+ <arg>-2</arg>
+ <arg>-4</arg>
+ </group>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>-b <replaceable>location</replaceable></entry>
+ <entry>I/O address</entry>
+ <entry>I/O Location.</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ <row>
+ <entry>-1</entry>
+ <entry></entry>
+ <entry>Access a one byte (8 bit) I/O location.</entry>
+ <entry>-1</entry>
+ </row>
+ <row>
+ <entry>-2</entry>
+ <entry></entry>
+ <entry>Access a two byte (16 bit) I/O location.</entry>
+ <entry>-1</entry>
+ </row>
+ <row>
+ <entry>-4</entry>
+ <entry></entry>
+ <entry>Access a one word (32 bit) I/O location.</entry>
+ <entry>-1</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para>Reads a value from the I/O address space.</para>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Examine 8 bit value at I/O location 0x3F8.
+<screen>
+RedBoot> <userinput>iopeek -b 0x3f8</userinput>
+0x03f8 = 0x30
+</screen>
+</para>
+ <para>
+Examine 32 bit value at I/O location 0x3f8.
+<screen>
+RedBoot> <userinput>iopeek -b 0x3f8 -4</userinput>
+0x03f8 = 0x03c10065
+</screen>
+</para>
+ </refsect1>
+ </refentry>
+
+<!-- ******** iopoke *************************************************** -->
+ <refentry id="iopoke-command">
+ <refnamediv>
+ <refname>iopoke</refname>
+ <refpurpose>Write I/O location</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>iopoke</command>
+ <arg>-b <replaceable> location</replaceable></arg>
+ <group>
+ <arg>-1</arg>
+ <arg>-2</arg>
+ <arg>-4</arg>
+ </group>
+ <arg>-v <replaceable> value</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>-b <replaceable>location</replaceable></entry>
+ <entry>I/O address</entry>
+ <entry>I/O Location.</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ <row>
+ <entry>-1</entry>
+ <entry></entry>
+ <entry>Access a one byte (8 bit) I/O location.
+Only the 8 least significant bits of value will be used</entry>
+ <entry>-1</entry>
+ </row>
+ <row>
+ <entry>-2</entry>
+ <entry></entry>
+ <entry>Access a two byte (16 bit) I/O location.
+Only the 16 least significant bits of value will be used</entry>
+ <entry>-1</entry>
+ </row>
+ <row>
+ <entry>-4</entry>
+ <entry></entry>
+ <entry>Access a one word (32 bit) I/O location.</entry>
+ <entry>-1</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para>Writes a value to the I/O address space.</para>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Write 0x0123 to 16 bit I/O location 0x200.
+<screen>
+RedBoot> <userinput>iopoke -b 0x200 -v 0x123 -2</userinput>
+</screen>
+</para>
+ </refsect1>
+ </refentry>
+
+<!-- ******** gunzip *************************************************** -->
+ <refentry id="gunzip-command">
+ <refnamediv>
+ <refname>gunzip</refname>
+ <refpurpose>Uncompress GZIP compressed data</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>gunzip</command>
+ <arg choice="req">-s <replaceable>source</replaceable></arg>
+ <arg choice="req">-d <replaceable>destination</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>-s <replaceable>location1</replaceable></entry>
+ <entry>Memory address</entry>
+ <entry>Location of GZIP compressed data to uncompress.</entry>
+ <entry>Value set by last <command>load</command> or <command>fis load</command> command.</entry>
+ </row>
+ <row>
+ <entry>-d <replaceable>location2</replaceable></entry>
+ <entry>Memory address</entry>
+ <entry>Destination to write uncompressed data to.</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para>Uncompress GZIP compressed data.</para>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Uncompress data at location 0x100000 to 0x200000.
+<screen>
+RedBoot> <userinput>gunzip -s 0x100000 -d 0x200000</userinput>
+Decompressed 38804 bytes
+</screen>
+</para>
+ </refsect1>
+ </refentry>
+
+<!-- ******** ip_address *************************************************** -->
+ <refentry id="ip-address-command">
+ <refnamediv>
+ <refname>ip_address</refname>
+ <refpurpose>Set IP addresses</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>ip_address</command>
+ <arg>-b</arg>
+ <arg>-l <replaceable> local_IP_address</replaceable>
+ <arg choice=opt>/<replaceable>netmask_length</replaceable></arg> </arg>
+ <arg>-h <replaceable> server_IP_address</replaceable></arg>
+ <arg>-d <replaceable>
+DNS_server_IP_address</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>-b</entry>
+ <entry>Boolean</entry>
+ <entry>Obtain an IP address using BOOTP or DHCP.</entry>
+ <entry>don't use BOOTP/DHCP</entry>
+ </row>
+ <row>
+ <entry>-l <replaceable>
+local_IP_address</replaceable><option>[<replaceable>/netmask_length</replaceable>]</option></entry>
+ <entry>Numeric IP or DNS name</entry>
+ <entry>The IP address RedBoot should use, optionally
+with the network mask length.</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ <row>
+ <entry>-h <replaceable>
+server_IP_address</replaceable></entry>
+ <entry>Numeric IP or DNS name</entry>
+ <entry>The IP address of the default server. Use of this
+address is implied by other commands, such as
+<command>load</command>.</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ <row>
+ <entry>-d <replaceable>
+DNS_server_IP_address</replaceable></entry>
+ <entry>Numeric IP or DNS name</entry>
+ <entry>The IP address of the DNS server.</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para>The <command>ip_address</command> command is used to show and/or change the basic IP
+addresses used by RedBoot. IP addresses may be given as numeric
+values, e.g. 192.168.1.67, or as symbolic names such as www.redhat.com
+if DNS support is enabled.
+ </para>
+ <para>
+The <option>-b</option> option is used to cause the target to perform a bootp or dhcp negotiation to get an IP address.
+ </para>
+ <para>
+The <option>-l</option> option is used to set the IP address used by
+the target device. The network mask length can also be specified
+ </para>
+ <para>
+The <option>-h</option> option is used to set the default server
+address, such as is used by the <command>load</command> command.
+ </para>
+ <para>
+The <option>-d</option> option is used to set the default DNS server
+address which is used for resolving symbolic network addresses. Note
+that an address of 0.0.0.0 will disable DNS lookups.
+ </para>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Display the current network settings.
+<screen>
+RedBoot> <userinput>ip_address</userinput>
+IP: 192.168.1.31, Default server: 192.168.1.101, DNS server IP: 0.0.0.0, DNS domain name:
+</screen>
+</para>
+<para>
+Change the DNS server address.
+<screen>
+RedBoot> <userinput>ip_address -d 192.168.1.101</userinput>
+IP: 192.168.1.31, Default server: 192.168.1.101, DNS server IP: 192.168.1.101, DNS domain name:
+</screen>
+</para>
+<para>
+Change the DNS domain name.
+<screen>
+RedBoot> <userinput>ip_address -D example.com</userinput>
+IP: 192.168.1.31, Default server: 192.168.1.101, DNS server IP: 192.168.1.101, DNS domain name: example.com
+</screen>
+</para>
+<para>
+Change the default server address.
+<screen>
+RedBoot> <userinput>ip_address -h 192.168.1.104</userinput>
+IP: 192.168.1.31, Default server: 192.168.1.104, DNS server IP: 192.168.1.101, DNS domain name:
+</screen>
+</para>
+<para>
+Set the IP address to something new, with a 255.255.255.0 netmask
+<screen>
+RedBoot> <userinput>ip_address -l 192.168.1.32/24</userinput>
+IP: 192.168.1.32, Default server: 192.168.1.104, DNS server IP: 192.168.1.101, DNS domain name:
+</screen>
+ </para>
+ </refsect1>
+ </refentry>
+
+<!-- ******** load *************************************************** -->
+ <refentry id="download-command">
+ <refnamediv>
+ <refname>load</refname>
+ <refpurpose>Download programs or data to the RedBoot platform</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>load</command>
+ <arg>-v </arg>
+ <arg>-d </arg>
+ <arg>-r </arg>
+ <arg>-m
+ <group>
+ <arg choice="req"><group>
+ <arg>xmodem</arg>
+ <arg>ymodem</arg>
+ <arg>tftp</arg>
+ <arg>disk</arg>
+ <arg>file</arg></group>
+ </arg>
+ </group>
+ </arg>
+ <arg>-h <replaceable> server_IP_address</replaceable></arg>
+ <arg>-f <replaceable> location</replaceable></arg>
+ <arg>-b <replaceable> location</replaceable></arg>
+ <arg>-c <replaceable> channel</replaceable></arg>
+ <arg><replaceable>file_name</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>-v</entry>
+ <entry>Boolean</entry>
+ <entry>Display a small spinner (indicator)
+while the download is in progress. This is just for feedback, especially
+during long loads. Note that the option has no effect when using a
+serial download method since it would interfere with the protocol.</entry>
+ <entry><emphasis>quiet</emphasis></entry>
+ </row>
+ <row>
+ <entry>-d</entry>
+ <entry>Boolean</entry>
+ <entry>Decompress data stream (gzip data)</entry>
+ <entry><emphasis>non-compressed data</emphasis></entry>
+ </row>
+ <row>
+ <entry>-r</entry>
+ <entry>Boolean</entry>
+ <entry>Raw (or binary) data. -b or -f must be used</entry>
+ <entry><emphasis>formatted (S-records, ELF image, etc)</emphasis></entry>
+ </row>
+ <row>
+ <entry>-m tftp</entry>
+ <entry></entry>
+ <entry>Transfer data via the network using <acronym>TFTP</acronym> protocol.</entry>
+ <entry><acronym>TFTP</acronym></entry>
+ </row>
+ <row>
+ <entry>-m http</entry>
+ <entry></entry>
+ <entry>Transfer data via the network using <acronym>HTTP</acronym> protocol.</entry>
+ <entry><acronym>TFTP</acronym></entry>
+ </row>
+ <row>
+ <entry>-m xmodem</entry>
+ <entry></entry>
+ <entry>Transfer data using <emphasis>X-modem</emphasis> protocol.</entry>
+ <entry><acronym>TFTP</acronym></entry>
+ </row>
+ <row>
+ <entry>-m ymodem</entry>
+ <entry></entry>
+ <entry>Transfer data using <emphasis>Y-modem</emphasis> protocol.</entry>
+ <entry><acronym>TFTP</acronym></entry>
+ </row>
+ <row>
+ <entry>-m disk</entry>
+ <entry></entry>
+ <entry>Transfer data from a local disk.</entry>
+ <entry><acronym>TFTP</acronym></entry>
+ </row>
+ <row>
+ <entry>-m file</entry>
+ <entry></entry>
+ <entry>Transfer data from a local filesystem such as
+ JFFS2 or FAT.</entry>
+ <entry><acronym>TFTP</acronym></entry>
+ </row>
+ <row>
+ <entry>-h <replaceable>server_IP_address</replaceable></entry>
+ <entry>Numeric IP or DNS name</entry>
+ <entry>The IP address of the <acronym>TFTP</acronym> or <acronym>HTTP</acronym> server.</entry>
+ <entry>Value set by <command>ip_address</command></entry>
+ </row>
+ <row>
+ <entry>-b <replaceable>location</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Address in memory to load the data. Formatted data streams will have
+an implied load address which this option may override.</entry>
+ <entry><emphasis>Depends on data format</emphasis></entry>
+ </row>
+ <row>
+ <entry>-f <replaceable>location</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Address in flash to load the data. Formatted data streams will have
+an implied load address which this option may override.</entry>
+ <entry><emphasis>Depends on data format</emphasis></entry>
+ </row>
+ <row>
+ <entry>-c <replaceable>channel</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Specify which I/O channel to
+use for download. This option is only supported when using either
+xmodem or ymodem protocol.</entry>
+ <entry><emphasis>Depends on data format</emphasis></entry>
+ </row>
+ <row>
+ <entry><replaceable>file_name</replaceable></entry>
+ <entry>String</entry>
+ <entry>The name of the file on the <acronym>TFTP</acronym> or <acronym>HTTP</acronym>
+server or the local disk. Details of how this is specified for <acronym>TFTP</acronym> are
+host-specific. For local disk files, the name must be in <emphasis>disk</emphasis>:
+<emphasis>filename</emphasis> format. The disk portion must match one of the disk
+names listed by the <command>disks</command> command.</entry>
+ <entry><emphasis>None</emphasis></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para>
+The <command>load</command> command is used to download
+data into the target system. Data can be loaded via a network connection,
+using either the <acronym>TFTP</acronym> or <acronym>HTTP</acronym> protocols, or the console serial connection using the
+X/Y modem protocol. Files may also be loaded directly from local filesystems
+on disk. Files to be downloaded may either be executable images in
+ELF executable program format,
+Motorola S-record (SREC)
+format or raw data.
+ </para>
+ <note>
+ <title>Note</title>
+ <para>
+When downloading an ELF image, RedBoot will forcibly terminate the transfer
+once all the relevant (loadable) ELF sections have been received. This
+behaviour reduces download time when using the X/Y modem protocol
+over a slow serial connection. However, the terminal emulator may report
+that the transfer is incomplete and has been cancelled. Such messages
+are normal and may be ignored.
+ </para>
+ </note>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Download a Motorola S-record (or ELF) image, using <acronym>TFTP</acronym>, specifying the
+base memory address.
+<screen>
+RedBoot> <userinput>load redboot.ROM -b 0x8c400000</userinput>
+Address offset = 0x0c400000
+Entry point: 0x80000000, address range: 0x80000000-0x8000fe80
+</screen>
+ </para>
+ <para>
+Download a Motorola S-record (or ELF) image, using <acronym>HTTP</acronym>, specifying the
+host [server] address.
+<screen>
+RedBoot> <userinput>load /redboot.ROM -m HTTP -h 192.168.1.104</userinput>
+Address offset = 0x0c400000
+Entry point: 0x80000000, address range: 0x80000000-0x8000fe80
+</screen>
+ </para>
+ <para>
+Load an ELF file from /dev/hda1 which should be an EXT2 partition:
+<screen>
+RedBoot> <userinput>load -mode disk hda1:hello.elf</userinput>
+Entry point: 0x00020000, address range: 0x00020000-0x0002fd70
+</screen>
+ </para>
+ <para>
+Load an ELF file from /jffs2/applications which should be a directory
+in a JFFS2 filesystem:
+<screen>
+RedBoot> <userinput>load -mode file /jffs2/applications/hello.elf</userinput>
+Entry point: 0x00020000, address range: 0x00020000-0x0002fd70
+</screen>
+ </para>
+ </refsect1>
+ </refentry>
+
+<!-- ******** mcmp *************************************************** -->
+ <refentry id="mcmp-command">
+ <refnamediv>
+ <refname>mcmp</refname>
+ <refpurpose>Compare two segments of memory</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>mcmp</command>
+ <arg choice="req">-s <replaceable>location1</replaceable></arg>
+ <arg choice="req">-d <replaceable>location1</replaceable></arg>
+ <arg choice="req">-l <replaceable>length</replaceable></arg>
+ <group>
+ <arg>-1</arg>
+ <arg>-2</arg>
+ <arg>-4</arg>
+ </group>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>-s <replaceable>location1</replaceable></entry>
+ <entry>Memory address</entry>
+ <entry>Location for start of data.</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ <row>
+ <entry>-d <replaceable>location2</replaceable></entry>
+ <entry>Memory address</entry>
+ <entry>Location for start of data.</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ <row>
+ <entry>-l <replaceable>length</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Length of data</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ <row>
+ <entry>-1</entry>
+ <entry></entry>
+ <entry>Access one byte (8 bits) at a time.
+Only the least significant 8 bits of the pattern will be used.</entry>
+ <entry>-4</entry>
+ </row>
+ <row>
+ <entry>-2</entry>
+ <entry></entry>
+ <entry>Access two bytes (16 bits) at a time.
+Only the least significant 16 bits of the pattern will be used.</entry>
+ <entry>-4</entry>
+ </row>
+ <row>
+ <entry>-4</entry>
+ <entry></entry>
+ <entry>Access one word (32 bits) at a time.</entry>
+ <entry>-4</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para>Compares the contents of two ranges of memory (RAM, ROM, FLASH, etc).</para>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Compare two buffers which match (result is <emphasis>quiet</emphasis>).
+<screen>
+RedBoot> <userinput>mfill -b 0x100000 -l 0x20 -p 0xDEADFACE</userinput>
+RedBoot> <userinput>mfill -b 0x200000 -l 0x20 -p 0xDEADFACE</userinput>
+RedBoot> <userinput>mcmp -s 0x100000 -d 0x200000 -l 0x20</userinput>
+</screen>
+</para>
+<para>
+Compare two buffers which don't match.
+Only the first non-matching element is displayed.
+<screen>
+RedBoot> <userinput>mcmp -s 0x100000 -d 0x200000 -l 0x30 -2</userinput>
+Buffers don't match - 0x00100020=0x6000, 0x00200020=0x0000
+</screen>
+ </para>
+ </refsect1>
+ </refentry>
+
+<!-- ******** mcopy *************************************************** -->
+ <refentry id="mcopy-command">
+ <refnamediv>
+ <refname>mcopy</refname>
+ <refpurpose>Copy memory</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>mcopy</command>
+ <arg choice="req">-s <replaceable>source</replaceable></arg>
+ <arg choice="req">-d <replaceable>destination</replaceable></arg>
+ <arg choice="req">-l <replaceable>length</replaceable></arg>
+ <group>
+ <arg>-1</arg>
+ <arg>-2</arg>
+ <arg>-4</arg>
+ </group>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>-s <replaceable>location1</replaceable></entry>
+ <entry>Memory address</entry>
+ <entry>Location of data to copy.</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ <row>
+ <entry>-d <replaceable>location2</replaceable></entry>
+ <entry>Memory address</entry>
+ <entry>Destination for copied data.</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ <row>
+ <entry>-l <replaceable>length</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Length of data</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ <row>
+ <entry>-1</entry>
+ <entry></entry>
+ <entry>Copy one byte (8 bits) at a time.</entry>
+ <entry>-4</entry>
+ </row>
+ <row>
+ <entry>-2</entry>
+ <entry></entry>
+ <entry>Copy two bytes (16 bits) at a time.</entry>
+ <entry>-4</entry>
+ </row>
+ <row>
+ <entry>-4</entry>
+ <entry></entry>
+ <entry>Copy one word (32 bits) at a time.</entry>
+ <entry>-4</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para>Copies memory (RAM, ROM, FLASH, etc) from one area to another.</para>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Copy 16 bits at a time.
+<screen>
+RedBoot> <userinput>mfill -b 0x100000 -l 0x20 -2 -p 0xDEAD</userinput>
+RedBoot> <userinput>mfill -b 0x200000 -l 0x20 -2 -p 0x0</userinput>
+RedBoot> <userinput>dump -b 0x200000 -l 0x20 -2</userinput>
+00200000: 0000 0000 0000 0000 0000 0000 0000 0000
+00200010: 0000 0000 0000 0000 0000 0000 0000 0000
+RedBoot> <userinput>mcopy -s 0x100000 -d 0x200000 -2 -l 0x20</userinput>
+RedBoot> <userinput>dump -b 0x200000 -l 0x20 -2</userinput>
+00200000: DEAD DEAD DEAD DEAD DEAD DEAD DEAD DEAD
+00200010: DEAD DEAD DEAD DEAD DEAD DEAD DEAD DEAD
+</screen>
+</para>
+ </refsect1>
+ </refentry>
+
+<!-- ******** mfill *************************************************** -->
+ <refentry id="mfill-command">
+ <refnamediv>
+ <refname>mfill</refname>
+ <refpurpose>Fill RAM with a specified pattern</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>mfill</command>
+ <arg choice="req">-b <replaceable>location</replaceable></arg>
+ <arg choice="req">-l <replaceable>length</replaceable></arg>
+ <arg choice="req">-p <replaceable>value</replaceable></arg>
+ <group>
+ <arg>-1</arg>
+ <arg>-2</arg>
+ <arg>-4</arg>
+ </group>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>-b <replaceable>location</replaceable></entry>
+ <entry>Memory address</entry>
+ <entry>Location in memory for start of data.</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ <row>
+ <entry>-l <replaceable>length</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Length of data</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ <row>
+ <entry>-p <replaceable>pattern</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Data value to fill with</entry>
+ <entry>0</entry>
+ </row>
+ <row>
+ <entry>-1</entry>
+ <entry></entry>
+ <entry>Access one byte (8 bits) at a time.
+Only the least significant 8 bits of the pattern will be used.</entry>
+ <entry>-4</entry>
+ </row>
+ <row>
+ <entry>-2</entry>
+ <entry></entry>
+ <entry>Access two bytes (16 bits) at a time.
+Only the least significant 16 bits of the pattern will be used.</entry>
+ <entry>-4</entry>
+ </row>
+ <row>
+ <entry>-4</entry>
+ <entry></entry>
+ <entry>Access one word (32 bits) at a time.</entry>
+ <entry>-4</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para>Fills a range of memory with the given pattern.</para>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Fill a buffer with zeros.
+<screen>
+RedBoot> <userinput>x -b 0x100000 -l 0x20</userinput>
+00100000: 00 3E 00 06 00 06 00 06 00 00 00 00 00 00 00 00 |.>..............|
+00100010: 00 00 00 78 00 70 00 60 00 60 00 60 00 60 00 60 |...x.p.`.`.`.`.`|
+RedBoot> <userinput>mfill -b 0x100000 -l 0x20</userinput>
+RedBoot> <userinput>x -b 0x100000 -l 0x20</userinput>
+00100000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
+00100010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
+</screen>
+</para>
+<para>
+Fill a buffer with a pattern.
+<screen>
+RedBoot> <userinput>mfill -b 0x100000 -l 0x20 -p 0xDEADFACE</userinput>
+RedBoot> <userinput>x -b 0x100000 -l 0x20</userinput>
+00100000: CE FA AD DE CE FA AD DE CE FA AD DE CE FA AD DE |................|
+00100010: CE FA AD DE CE FA AD DE CE FA AD DE CE FA AD DE |................|
+</screen>
+ </para>
+ </refsect1>
+ </refentry>
+
+<!-- ******** ping *************************************************** -->
+ <refentry id="ping-command">
+ <refnamediv>
+ <refname>ping</refname>
+ <refpurpose>Verify network connectivity</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>ping</command>
+ <arg>-v </arg>
+ <arg>-i <replaceable> local_IP_address</replaceable></arg>
+ <arg>-l <replaceable> length</replaceable></arg>
+ <arg>-n <replaceable> count</replaceable></arg>
+ <arg>-t <replaceable> timeout</replaceable></arg>
+ <arg>-r <replaceable> rate</replaceable></arg>
+ <arg choice="req">-h <replaceable> server_IP_address</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>-v</entry>
+ <entry>Boolean</entry>
+ <entry>Be verbose, displaying information about each packet sent.</entry>
+ <entry><emphasis>quiet</emphasis></entry>
+ </row>
+ <row>
+ <entry>-n <replaceable>local_IP_address</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Controls the number of packets to be sent.</entry>
+ <entry>10</entry>
+ </row>
+ <row>
+ <entry>-i <replaceable>local_IP_address</replaceable></entry>
+ <entry>Numeric IP or DNS name</entry>
+ <entry>The IP address RedBoot should use.</entry>
+ <entry>Value set by <command>ip_address</command></entry>
+ </row>
+ <row>
+ <entry>-h <replaceable>server_IP_address</replaceable></entry>
+ <entry>Numeric IP or DNS name</entry>
+ <entry>The IP address of the host to contact.</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ <row>
+ <entry>-l <replaceable>length</replaceable></entry>
+ <entry>Number</entry>
+ <entry>The length of the ICMP data payload.</entry>
+ <entry>64</entry>
+ </row>
+ <row>
+ <entry>-r <replaceable>length</replaceable></entry>
+ <entry>Number</entry>
+ <entry>How fast to deliver packets, i.e. time between successive sends.
+A value of 0 sends packets as quickly as possible.</entry>
+ <entry>1000ms (1 second)</entry>
+ </row>
+ <row>
+ <entry>-t <replaceable>length</replaceable></entry>
+ <entry>Number</entry>
+ <entry>How long to wait for the round-trip to complete, specified in milliseconds.</entry>
+ <entry>1000ms (1 second)</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para>
+The <command>ping</command> command checks the connectivity of the local network by sending
+special (ICMP) packets to a specific host. These packets should be automatically
+returned by that host. The command will indicate how many of these round-trips
+were successfully completed.
+ </para>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Test connectivity to host 192.168.1.101.
+<screen>
+RedBoot> <userinput>ping -h 192.168.1.101</userinput>
+Network PING - from 192.168.1.31 to 192.168.1.101
+PING - received 10 of 10 expected
+</screen>
+</para>
+<para>
+Test connectivity to host 192.168.1.101, with verbose reporting.
+<screen>
+RedBoot> <userinput>ping -h 192.168.1.101 -v -n 4</userinput>
+Network PING - from 192.168.1.31 to 192.168.1.101
+ seq: 1, time: 1 (ticks)
+ seq: 2, time: 1 (ticks)
+ seq: 3, time: 1 (ticks)
+ seq: 4, time: 1 (ticks)
+PING - received 10 of 10 expected
+</screen>
+</para>
+<para>
+<screen>
+Test connectivity to a non-existent host (192.168.1.109).
+RedBoot> <userinput>ping -h 192.168.1.109 -v -n 4</userinput>
+PING: Cannot reach server '192.168.1.109' (192.168.1.109)
+</screen>
+ </para>
+ </refsect1>
+ </refentry>
+
+<!-- ******** reset *************************************************** -->
+ <refentry id="reset-command">
+ <refnamediv>
+ <refname>reset</refname>
+ <refpurpose>Reset the device</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>reset</command>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+<para><emphasis>None</emphasis></para>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para>
+The <command>reset</command> command causes the target platform to be reset.
+Where possible (hardware support permitting), this will be
+equivalent to a power-on reset condition.
+ </para>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Reset the platform.
+<screen>
+RedBoot> <userinput>reset</userinput>
+... Resetting.+... Waiting for network card: .
+Socket Communications, Inc: Low Power Ethernet CF Revision C 5V/3.3V 08/27/98
+Ethernet eth0: MAC address 00:c0:1b:00:ba:28
+IP: 192.168.1.29, Default server: 192.168.1.101
+
+RedBoot(tm) bootstrap and debug environment [ROM]
+Non-certified release, version UNKNOWN - built 10:41:41, May 14 2002
+
+Platform: Compaq iPAQ Pocket PC (StrongARM 1110)
+Copyright (C) 2000, 2001, 2002, Free Software Foundation, Inc.
+
+RAM: 0x00000000-0x01fc0000, 0x00014748-0x01f71000 available
+FLASH: 0x50000000 - 0x51000000, 64 blocks of 0x00040000 bytes each.
+RedBoot>
+</screen>
+ </para>
+ </refsect1>
+ </refentry>
+
+
+<!-- ******** version *************************************************** -->
+ <refentry id="version-command">
+ <refnamediv>
+ <refname>version</refname>
+ <refpurpose>Display RedBoot version information</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>version</command>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <para><emphasis>None</emphasis></para>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para>The <command>version</command> command simply displays version information about RedBoot.
+ </para>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Display RedBoot's version.
+<screen>
+RedBoot> <userinput>version</userinput>
+RedBoot(tm) debug environment - built 09:12:03, Feb 12 2001
+Platform: XYZ (PowerPC 860)
+Copyright (C) 2000, 2001, Free Software Foundation, Inc.
+RAM: 0x00000000-0x00400000
+</screen>
+ </para>
+ </refsect1>
+ </refentry>
+
+</sect1>
+
+<sect1 id="Flash-Image-System">
+<title>Flash Image System (FIS)</title>
+<para><indexterm><primary>commands</primary><secondary>flash image system
+</secondary></indexterm><indexterm><primary>flash image system commands</primary>
+</indexterm><indexterm><primary>commands</primary><secondary>fis</secondary>
+</indexterm><indexterm><primary>fis commands</primary></indexterm>If the platform
+has flash memory, RedBoot can use this for image storage. Executable images,
+as well as data, can be stored in flash in a simple file store. The <command>
+fis</command> command (fis is short for Flash Image System) is used to
+manipulate and maintain flash images.
+</para>
+
+<!-- ******** fis init ************************************************ -->
+
+ <refentry id="fis-init-command">
+ <refnamediv>
+ <refname>fis init</refname>
+ <refpurpose>Initialize Flash Image System (FIS)</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>fis init</command>
+ <arg><replaceable>-f</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>-f</entry>
+ <entry></entry>
+ <entry>All blocks of flash memory (except for the boot
+ blocks) will be erased as part of the initialization
+ procedure.</entry>
+ <entry></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+
+ <para>This command is used to initialize the Flash Image System
+ (FIS). It should normally only be executed once, when RedBoot
+ is first installed on the hardware. If the reserved images or
+ their sizes in the FIS change, due to a different configuration
+ of RedBoot being used, it may be necessary to issue the command
+ again though.
+
+ <note><para>Subsequent executions will cause loss of
+ previously stored information in the FIS.</para></note>
+ </para>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Initialize the FIS directory.
+<screen>
+RedBoot> <userinput>fis init</userinput>
+About to initialize [format] flash image system - continue (y/n)? <userinput>y</userinput>
+*** Initialize FLASH Image System
+ Warning: device contents not erased, some blocks may not be usable
+... Erase from 0x00070000-0x00080000: .
+... Program from 0x0606f000-0x0607f000 at 0x00070000: .
+</screen>
+</para>
+
+ <para>
+Initialize the FIS directory and all of flash memory, except for first
+blocks of the flash where the boot monitor resides.
+<screen>
+RedBoot> <userinput>fis init -f</userinput>
+About to initialize [format] flash image system - continue (y/n)? <userinput>y</userinput>
+*** Initialize FLASH Image System
+... Erase from 0x00020000-0x00070000: .....
+... Erase from 0x00080000-0x00080000:
+... Erase from 0x00070000-0x00080000: .
+... Program from 0x0606f000-0x0607f000 at 0x00070000: .
+</screen>
+</para>
+</refsect1>
+</refentry>
+
+<!-- ******** fis list ************************************************ -->
+ <refentry id="fis-list-command">
+ <refnamediv>
+ <refname>fis list</refname>
+ <refpurpose>List Flash Image System directory</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>fis list</command>
+ <arg><replaceable>-c</replaceable></arg>
+ <arg><replaceable>-d</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>-c</entry>
+ <entry></entry>
+ <entry>Show image checksum instead of memory address
+ (column <computeroutput>Mem addr</computeroutput> is
+ replaced by
+ <computeroutput>Checksum</computeroutput>).</entry>
+ <entry></entry>
+ </row>
+ <row>
+ <entry>-d</entry>
+ <entry></entry>
+ <entry>Show image data length instead of amount of flash
+ occupied by image (column
+ <computeroutput>Length</computeroutput> is replaced by
+ <computeroutput>Datalen</computeroutput>).</entry>
+ <entry></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+<para>This command lists the images currently available in the FIS. Certain
+images used by RedBoot have fixed names and have reserved slots in the
+FIS (these can be seen after using the <command>fis init</command>
+command). Other images can be manipulated by the user.</para>
+<note><para>The images are listed in the order they appear in the FIS
+directory, not by name or creation time.</para></note>
+ </refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+ <para>
+List the FIS directory.
+<screen>
+RedBoot> <userinput>fis list</userinput>
+Name FLASH addr Mem addr Length Entry point
+RedBoot 0x00000000 0x00000000 0x00020000 0x00000000
+RedBoot config 0x0007F000 0x0007F000 0x00001000 0x00000000
+FIS directory 0x00070000 0x00070000 0x0000F000 0x00000000
+</screen>
+</para>
+
+ <para>
+List the FIS directory, with image checksums substituted for
+memory addresses.
+<screen>
+RedBoot> <userinput>fis list -c</userinput>
+Name FLASH addr Checksum Length Entry point
+RedBoot 0x00000000 0x00000000 0x00020000 0x00000000
+RedBoot config 0x0007F000 0x00000000 0x00001000 0x00000000
+FIS directory 0x00070000 0x00000000 0x0000F000 0x00000000
+</screen>
+</para>
+
+ <para>
+List the FIS directory with image data lengths substituted for flash
+block reservation lengths.
+<screen>
+RedBoot> <userinput>fis list -d</userinput>
+Name FLASH addr Mem addr Datalen Entry point
+RedBoot 0x00000000 0x00000000 0x00000000 0x00000000
+RedBoot config 0x0007F000 0x0007F000 0x00000000 0x00000000
+FIS directory 0x00070000 0x00070000 0x00000000 0x00000000
+</screen>
+</para>
+</refsect1>
+</refentry>
+
+<!-- ******** fis free ************************************************ -->
+
+ <refentry id="fis-free-command">
+ <refnamediv>
+ <refname>fis free</refname>
+ <refpurpose>Free flash image</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>fis free</command>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Description</title>
+
+
+<para>This command shows which areas of the flash memory are currently
+not in use. When a block contains non-erased contents it is considered
+in use. Since it is possible to force an image to be loaded at a
+particular flash location, this command can be used to check whether
+that location is in use by any other image.</para>
+
+<note><para>There is currently no cross-checking between actual flash
+contents and the FIS directory, which mans that there could be a
+segment of flash which is not erased that does not correspond to a
+named image, or vice-versa.</para></note>
+ </refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Show free flash areas.
+<screen>
+RedBoot> <userinput>fis free</userinput>
+ 0xA0040000 .. 0xA07C0000
+ 0xA0840000 .. 0xA0FC0000
+</screen></para>
+</refsect1>
+</refentry>
+
+<!-- ******** fis create ************************************************ -->
+
+ <refentry id="fis-create-command">
+ <refnamediv>
+ <refname>fis create</refname>
+ <refpurpose>Create flash image</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>fis create</command>
+ <arg choice="req">-b <replaceable> data address</replaceable></arg>
+ <arg choice="req">-l <replaceable> length</replaceable></arg>
+ <arg>-f <replaceable> flash address</replaceable></arg>
+ <arg>-e <replaceable> entry</replaceable></arg>
+ <arg>-r <replaceable> relocation address</replaceable></arg>
+ <arg>-s <replaceable> data length</replaceable></arg>
+ <arg>-n </arg>
+ <arg><replaceable>name</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>-b</entry>
+ <entry>Number</entry>
+ <entry>Address of data to be written to the flash.</entry>
+ <entry>Address of last loaded file. If not set in a load
+ operation, it must be specified.</entry>
+ </row>
+ <row>
+ <entry>-l</entry>
+ <entry>Number</entry>
+ <entry>Length of flash area to occupy. If specified, and
+ the named image already exists, the length must match
+ the value in the FIS directory.</entry>
+ <entry>Length of area reserved in FIS directory if the
+ image already exists, or the length of the last loaded
+ file. If neither are set, it must be specified.</entry>
+ </row>
+ <row>
+ <entry>-f</entry>
+ <entry>Number</entry>
+ <entry>Address of flash area to occopy.</entry>
+ <entry>The address of an area reserved in the FIS
+ directory for extant images. Otherwise the first free block
+ which is large enough will be used.</entry>
+ </row>
+ <row>
+ <entry>-e</entry>
+ <entry>Number</entry>
+ <entry>Entry address for an executable image, used by
+ the <command>fis load</command> command.</entry>
+ <entry>The entry address of last loaded file.</entry>
+ </row>
+ <row>
+ <entry>-r</entry>
+ <entry>Number</entry>
+ <entry>Address where the image should be relocated to by
+ the <command>fis load</command> command. This is only
+ relevant for images that will be loaded with the
+ <command>fis load</command> command.</entry>
+ <entry>The load address of the last loaded file.</entry>
+ </row>
+ <row>
+ <entry>-s</entry>
+ <entry>Number</entry>
+ <entry>Actual length of data written to image. This is
+ used to control the range over which the checksum is
+ made.</entry>
+ <entry>It defaults to the length of the last loaded
+ file.</entry>
+ </row>
+ <row>
+ <entry>-n</entry>
+ <entry></entry>
+ <entry>When set, no image data will be written to the
+ flash. Only the FIS directory will be updated.</entry>
+ <entry></entry>
+ </row>
+ <row>
+ <entry><replaceable>name</replaceable></entry>
+ <entry>String</entry>
+ <entry>Name of flash image.</entry>
+ <entry></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+<para>This command creates an image in the FIS directory. The data for the
+image must exist in RAM memory before the copy. Typically, you would use the
+RedBoot <command>load</command> command to load file into
+RAM and then the <command>fis create</command> command to write
+it to a flash image.</para>
+</refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+ <para>Trying to create an extant image, will require the action
+ to be verified.
+<screen>
+RedBoot> <userinput>fis create RedBoot -f 0xa0000000 -b 0x8c400000 -l 0x20000</userinput>
+An image named &lsquo;RedBoot&rsquo; exists - continue (y/n)? <userinput>n</userinput>
+</screen>
+</para>
+
+<para>Create a new test image, let the command find a suitable place.
+<screen>
+RedBoot> <userinput>fis create junk -b 0x8c400000 -l 0x20000</userinput>
+... Erase from 0xa0040000-0xa0060000: .
+... Program from 0x8c400000-0x8c420000 at 0xa0040000: .
+... Erase from 0xa0fe0000-0xa1000000: .
+... Program from 0x8c7d0000-0x8c7f0000 at 0xa0fe0000: .
+</screen>
+</para>
+
+<para>Update the RedBoot[RAM] image.
+<screen>
+RedBoot> <userinput>load redboot_RAM.img</userinput>
+Entry point: 0x060213c0, address range: 0x06020000-0x06036cc0
+RedBoot> <userinput>fis create RedBoot[RAM]</userinput>
+No memory address set.
+An image named 'RedBoot[RAM]' exists - continue (y/n)? <userinput>y</userinput>
+* CAUTION * about to program 'RedBoot[RAM]'
+ at 0x00020000..0x00036cbf from 0x06020000 - continue (y/n)? <userinput>y</userinput>
+... Erase from 0x00020000-0x00040000: ..
+... Program from 0x06020000-0x06036cc0 at 0x00020000: ..
+... Erase from 0x00070000-0x00080000: .
+... Program from 0x0606f000-0x0607f000 at 0x00070000: .
+</screen>
+</para>
+</refsect1>
+</refentry>
+
+<!-- ******** fis load ************************************************ -->
+
+ <refentry id="fis-load-command">
+ <refnamediv>
+ <refname>fis load</refname>
+ <refpurpose>Load flash image</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>fis load</command>
+ <arg>-b <replaceable> load address</replaceable></arg>
+ <arg>-c </arg>
+ <arg>-d </arg>
+ <arg><replaceable>name</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>-b</entry>
+ <entry>Number</entry>
+ <entry>Address the image should be loaded to. Executable
+ images normally load at the location to which the file
+ was linked. This option allows the image to be loaded to
+ a specific memory location, possibly overriding any
+ assumed location.</entry>
+ <entry>If not specified, the address associated with the
+ image in the FIS directory will be used.</entry>
+ </row>
+ <row>
+ <entry>-c</entry>
+ <entry></entry>
+ <entry>Compute and print the checksum of the image data
+ after it has been loaded into memory.</entry>
+ </row>
+ <row>
+ <entry>-d</entry>
+ <entry></entry>
+ <entry>Decompress gzipped image while copying it from
+ flash to RAM.</entry>
+ </row>
+ <row>
+ <entry><replaceable>name</replaceable></entry>
+ <entry>String</entry>
+ <entry>The name of the file, as shown in the FIS
+ directory.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+<para>This command is used to transfer an image from flash memory to RAM.
+</para>
+<para>Once the image has been loaded, it may be executed using the
+<command>go</command> command.</para>
+</refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+<para>Load and run RedBoot[RAM] image.
+<screen>
+RedBoot> <userinput>fis load RedBoot[RAM]</userinput>
+RedBoot> <userinput>go</userinput>
+</screen>
+</para>
+</refsect1>
+</refentry>
+
+<!-- ******** fis delete ************************************************ -->
+
+ <refentry id="fis-delete-command">
+ <refnamediv>
+ <refname>fis delete</refname>
+ <refpurpose>Delete flash image</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>fis delete</command>
+ <arg choice="req"><replaceable>name</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><replaceable>name</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Name of image that should be deleted.</entry>
+ <entry></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+<para>This command removes an image from the FIS. The flash memory will be
+erased as part of the execution of this command, as well as removal of the
+name from the FIS directory.</para>
+
+<note><para>Certain images are reserved by RedBoot and cannot be deleted.
+RedBoot will issue a warning if this is attempted.</para></note>
+</refsect1>
+ <refsect1>
+ <title>Examples</title>
+<para>
+<screen>
+RedBoot> <userinput>fis list</userinput>
+Name flash addr Mem addr Length Entry point
+RedBoot 0xA0000000 0xA0000000 0x020000 0x80000000
+RedBoot config 0xA0FC0000 0xA0FC0000 0x020000 0x00000000
+FIS directory 0xA0FE0000 0xA0FE0000 0x020000 0x00000000
+junk 0xA0040000 0x8C400000 0x020000 0x80000000
+RedBoot> <userinput>fis delete junk</userinput>
+Delete image &lsquo;junk&rsquo; - continue (y/n)? <userinput>y</userinput>
+... Erase from 0xa0040000-0xa0060000: .
+... Erase from 0xa0fe0000-0xa1000000: .
+... Program from 0x8c7d0000-0x8c7f0000 at 0xa0fe0000: .
+</screen>
+</para>
+</refsect1>
+</refentry>
+
+<!-- ******** fis lock ************************************************ -->
+
+ <refentry id="fis-lock-command">
+ <refnamediv>
+ <refname>fis lock</refname>
+ <refpurpose>Lock flash area</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>fis lock</command>
+ <arg choice="req">-f <replaceable>flash_address</replaceable></arg>
+ <arg choice="req">-l <replaceable>length</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><replaceable>flash_address</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Address of area to be locked.</entry>
+ <entry></entry>
+ </row>
+ <row>
+ <entry><replaceable>length</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Length of area to be locked.</entry>
+ <entry></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+<para>This command is used to write-protect (lock) a portion of flash memory,
+to prevent accidental overwriting of images. In order to make any modifications
+to the flash, a matching <command>fis unlock</command> command must be
+issued. This command is optional and will only be provided on hardware
+which can support write-protection of the flash space.</para>
+<note>
+<para>Depending on the system, attempting to write to write-protected flash
+may generate errors or warnings, or be benignly quiet. </para>
+</note>
+</refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+<para>Lock an area of the flash
+<screen>
+RedBoot> <userinput>fis lock -f 0xa0040000 -l 0x20000</userinput>
+... Lock from 0xa0040000-0xa0060000: .
+</screen>
+</para>
+</refsect1>
+</refentry>
+
+<!-- ******** fis unlock ************************************************ -->
+
+ <refentry id="fis-unlock-command">
+ <refnamediv>
+ <refname>fis unlock</refname>
+ <refpurpose>Unlock flash area</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>fis unlock</command>
+ <arg choice="req">-f <replaceable>flash_address</replaceable></arg>
+ <arg choice="req">-l <replaceable>length</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><replaceable>flash_address</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Address of area to be unlocked.</entry>
+ <entry></entry>
+ </row>
+ <row>
+ <entry><replaceable>length</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Length of area to be unlocked.</entry>
+ <entry></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+<para>This command is used to unlock a portion of flash memory forcibly, allowing
+it to be updated. It must be issued for regions which have been locked before
+the FIS can reuse those portions of flash.</para>
+<note>
+<para>Some flash devices power up in locked state and always need to
+be manually unlocked before they can be written to.</para></note>
+</refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+<para>Unlock an area of the flash
+<screen>
+RedBoot> <userinput>fis unlock -f 0xa0040000 -l 0x20000</userinput>
+... Unlock from 0xa0040000-0xa0060000: .
+</screen>
+</para>
+</refsect1>
+</refentry>
+
+<!-- ******** fis erase ************************************************ -->
+
+ <refentry id="fis-erase-command">
+ <refnamediv>
+ <refname>fis erase</refname>
+ <refpurpose>Erase flash area</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>fis erase</command>
+ <arg choice="req">-f <replaceable>flash_address</replaceable></arg>
+ <arg choice="req">-l <replaceable>length</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><replaceable>flash_address</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Address of area to be erased.</entry>
+ <entry></entry>
+ </row>
+ <row>
+ <entry><replaceable>length</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Length of area to be erased.</entry>
+ <entry></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+<para>This command is used to erase a portion of flash memory forcibly. There
+is no cross-checking to ensure that the area being erased does not correspond
+to an existing image.</para>
+</refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+<para>Erase an area of the flash
+<screen>
+RedBoot> <userinput>fis erase -f 0xa0040000 -l 0x20000</userinput>
+... Erase from 0xa0040000-0xa0060000: .
+</screen>
+</para>
+</refsect1>
+</refentry>
+
+<!-- ******** fis write ************************************************ -->
+
+ <refentry id="fis-write-command">
+ <refnamediv>
+ <refname>fis write</refname>
+ <refpurpose>Write flash area</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>fis write</command>
+ <arg choice="req">-b <replaceable>mem_address</replaceable></arg>
+ <arg choice="req">-l <replaceable>length</replaceable></arg>
+ <arg choice="req">-f <replaceable>flash_address</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><replaceable>mem_address</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Address of data to be written to flash.</entry>
+ <entry></entry>
+ </row>
+ <row>
+ <entry><replaceable>length</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Length of data to be writtem.</entry>
+ <entry></entry>
+ </row>
+ <row>
+ <entry><replaceable>flash_address</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Address of flash to write to.</entry>
+ <entry></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+<para>This command is used to write data from memory to flash. There
+is no cross-checking to ensure that the area being written to does not
+correspond to an existing image.</para>
+</refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+<para>Write an area of data to the flash
+<screen>
+RedBoot> <userinput>fis write -b 0x0606f000 -l 0x1000 -f 0x00020000</userinput>
+* CAUTION * about to program FLASH
+ at 0x00020000..0x0002ffff from 0x0606f000 - continue (y/n)? <userinput>y</userinput>
+... Erase from 0x00020000-0x00030000: .
+... Program from 0x0606f000-0x0607f000 at 0x00020000: .
+</screen>
+</para>
+</refsect1>
+</refentry>
+</sect1>
+
+<sect1 id="filesystem-commands">
+<title>Filesystem Interface</title>
+
+<para>
+<indexterm><primary>commands</primary><secondary>filesystem access
+</secondary></indexterm><indexterm><primary>filesystem commands</primary>
+</indexterm><indexterm><primary>commands</primary><secondary>fs</secondary>
+</indexterm><indexterm><primary>fs commands</primary></indexterm>
+
+If the platform has access to secondary storage, then RedBoot may be
+able to access a filesystem stored on this device. RedBoot can access
+FAT filesystems stored on IDE disks or CompactFlash devices and can
+use JFFS2 filesystems stored in FLASH memory. The
+<command>fs</command> command is used to manipulate files on
+filesystems. Applications may be loaded into memory using the
+<emphasis>file</emphasis> mode of the <command>load</command> command.
+</para>
+
+<!-- ******** fs info ************************************************ -->
+
+<refentry id="fs-info-command">
+ <refnamediv>
+ <refname>fs info</refname>
+ <refpurpose>Print filesystem information</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>fs info</command>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <para>
+ The command takes no arguments.
+ </para>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+<para>This command prints information about the filesystems that are
+available. Three lists are produced. The first is a list of the
+filsystem implementations available in RedBoot; names from this list
+may be used in the <parameter>-t</parameter> option to the <command>fs
+mount</command> command. The second list describes the block devices
+that are available for mounting a filesystem; names from this list may
+be used in the <parameter>-d</parameter> option to the <command>fs
+mount</command> command. The last list describes the filesystems that
+are already mounted.
+</para>
+</refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+ <para>
+<screen>
+RedBoot> <userinput>fs info</userinput>
+Filesystems available:
+ramfs
+jffs2
+
+Devices available:
+/dev/flash1
+
+Mounted filesystems:
+ Device Filesystem Mounted on
+ &lt;undefined&gt; ramfs /
+ /dev/flash1 jffs2 /flash
+RedBoot></screen>
+ </para>
+ </refsect1>
+</refentry>
+
+<!-- ******** fs mount ************************************************ -->
+
+<refentry id="fs-mount-command">
+ <refnamediv>
+ <refname>fs mount</refname>
+ <refpurpose>Mount a filesystem</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>fs mount</command>
+ <arg choice="opt">-d <replaceable>device</replaceable></arg>
+ <arg choice="req">-t <replaceable>fstype</replaceable></arg>
+ <arg choice="req">mountpoint</arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><replaceable>device</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Device containing filsystem to mount.</entry>
+ <entry>undefined</entry>
+ </row>
+ <row>
+ <entry><replaceable>fstype</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Filesystem type.</entry>
+ <entry></entry>
+ </row>
+ <row>
+ <entry><replaceable>mountpoint</replaceable></entry>
+ <entry>String</entry>
+ <entry>Pathname for filesystem root.</entry>
+ <entry>/</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+<para>This command is used make a filesystem available for access with
+the filesystem access commands. Three things need to be defined to do
+this. First, the name of the device on which the filesystem is stored
+needs to be given to the <parameter>-d</parameter> option. Secondly,
+the type of filesystem it is needs to be given to the
+<parameter>-t</parameter> option. Finally, the pathname by which the
+new filesystem will be accessed needs to be supplied. Following a
+successful mount, the root of the filesystem will be accessible
+at the mountpoint.
+</para>
+</refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+<para>Mount a JFF2 partititon:
+<screen>
+RedBoot> <userinput>fs info</userinput>
+Filesystems available:
+ramfs
+jffs2
+
+Devices available:
+/dev/flash1
+
+Mounted filesystems:
+ Device Filesystem Mounted on
+ &lt;undefined&gt; ramfs /
+RedBoot> <userinput>fs mount -d /dev/flash1 -t jffs2 /flash</userinput>
+RedBoot> <userinput>fs info</userinput>
+Filesystems available:
+ramfs
+jffs2
+
+Devices available:
+/dev/flash1
+
+Mounted filesystems:
+ Device Filesystem Mounted on
+ &lt;undefined&gt; ramfs /
+ /dev/flash1 jffs2 /flash
+RedBoot>
+</screen>
+ </para>
+ </refsect1>
+</refentry>
+
+<!-- ******** fs umount ************************************************ -->
+
+<refentry id="fs-umount-command">
+ <refnamediv>
+ <refname>fs umount</refname>
+ <refpurpose>Unmount filesystem</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>fs umount</command>
+ <arg choice="req"><replaceable>mountpoint</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><replaceable>mountpoint</replaceable></entry>
+ <entry>String</entry>
+ <entry>Mountpoint of filesystem to unmount.</entry>
+ <entry></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+<para>This command removes a filesystem from being accessible using
+the filesystem commands. The single argument needs to be the
+mountpoint that was used when mounting the filesystem. This command
+will fail if the current directory is currently within the filesystem
+to be unmounted.
+</para>
+</refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+<para>Unmount a JFF2 partititon:
+<screen>
+RedBoot> <userinput>fs info</userinput>
+Filesystems available:
+ramfs
+jffs2
+
+Devices available:
+/dev/flash1
+
+Mounted filesystems:
+ Device Filesystem Mounted on
+ &lt;undefined&gt; ramfs /
+ /dev/flash1 jffs2 /flash
+RedBoot> <userinput>fs umount /flash</userinput>
+RedBoot> <userinput>fs info</userinput>
+Filesystems available:
+ramfs
+jffs2
+
+Devices available:
+/dev/flash1
+
+Mounted filesystems:
+ Device Filesystem Mounted on
+ &lt;undefined&gt; ramfs /
+RedBoot>
+</screen>
+ </para>
+ </refsect1>
+</refentry>
+
+<!-- ******** fs cd ************************************************ -->
+
+<refentry id="fs-cd-command">
+ <refnamediv>
+ <refname>fs cd</refname>
+ <refpurpose>Change filesystem directory</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>fs cd</command>
+ <arg choice="opt"><replaceable>directory</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><replaceable>directory</replaceable></entry>
+ <entry>String</entry>
+ <entry>Pathname to directory to change to.</entry>
+ <entry>Root directory</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+<para>This command changes the current filesystem
+directory. Subsequent filesystem commands will be executed in the new
+directory. If no argument is given, then the current directory is set
+back to the root of the filesystem name space.
+</para>
+</refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+ <para>Change current directory:
+<screen>
+RedBoot> <userinput>fs list</userinput>
+212416 d--------- 3 size 128 .
+212416 d--------- 3 size 128 ..
+211392 d--------- 2 size 96 tests
+210368 ---------- 1 size 4096 image
+RedBoot> <userinput>fs cd tests</userinput>
+RedBoot> <userinput>fs list</userinput>
+211392 d--------- 2 size 96 .
+212416 d--------- 3 size 128 ..
+205760 ---------- 1 size 16384 test1
+RedBoot>
+</screen>
+ </para>
+ </refsect1>
+</refentry>
+
+<!-- ******** fs mkdir ************************************************ -->
+
+<refentry id="fs-mkdir-command">
+ <refnamediv>
+ <refname>fs mkdir</refname>
+ <refpurpose>Create filesystem directory</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>fs mkdir</command>
+ <arg choice="req"><replaceable>directory</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><replaceable>directory</replaceable></entry>
+ <entry>String</entry>
+ <entry>Pathname to directory to delete.</entry>
+ <entry></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+<para>This command creates (makes) a directory in the filesystem.
+</para>
+</refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+ <para>Create directory:
+<screen>
+RedBoot> <userinput>fs list</userinput>
+212416 d--------- 2 size 128 .
+212416 d--------- 2 size 128 ..
+210368 ---------- 1 size 4096 image
+RedBoot> <userinput>fs mkdir tests</userinput>
+RedBoot> <userinput>fs list</userinput>
+212416 d--------- 3 size 128 .
+212416 d--------- 3 size 128 ..
+211392 d--------- 2 size 64 tests
+210368 ---------- 1 size 4096 image
+RedBoot>
+</screen>
+ </para>
+ </refsect1>
+</refentry>
+
+<!-- ******** fs deldir ************************************************ -->
+
+<refentry id="fs-deldir-command">
+ <refnamediv>
+ <refname>fs deldir</refname>
+ <refpurpose>Delete filesystem directory</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>fs deldir</command>
+ <arg choice="req"><replaceable>directory</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><replaceable>directory</replaceable></entry>
+ <entry>String</entry>
+ <entry>Pathname to directory to delete.</entry>
+ <entry></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+<para>This command deletes a directory from the filesystem. If the
+directory contains files or other directories then this command will
+fail.
+</para>
+</refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+ <para>Delete directory:
+<screen>
+RedBoot> <userinput>fs list</userinput>
+212416 d--------- 3 size 128 .
+212416 d--------- 3 size 128 ..
+211392 d--------- 2 size 96 tests
+210368 ---------- 1 size 4096 image
+RedBoot> <userinput>fs deldir tests</userinput>
+RedBoot> <userinput>fs list</userinput>
+212416 d--------- 2 size 128 .
+212416 d--------- 2 size 128 ..
+210368 ---------- 1 size 4096 image
+RedBoot>
+</screen>
+ </para>
+ </refsect1>
+</refentry>
+
+<!-- ******** fs del ************************************************ -->
+
+<refentry id="fs-del-command">
+ <refnamediv>
+ <refname>fs del</refname>
+ <refpurpose>Delete file</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>fs del</command>
+ <arg choice="req"><replaceable>file</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><replaceable>file</replaceable></entry>
+ <entry>String</entry>
+ <entry>Pathname of file to delete.</entry>
+ <entry></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+<para>This command deletes a file from the filesystem.
+</para>
+</refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+ <para>Change current directory:
+<screen>
+RedBoot> <userinput>fs list tests</userinput>
+211392 d--------- 2 size 96 .
+212416 d--------- 3 size 128 ..
+205760 ---------- 1 size 16384 test1
+RedBoot> <userinput>fs del tests/test1</userinput>
+RedBoot> <userinput>fs list tests</userinput>
+211392 d--------- 2 size 96 .
+212416 d--------- 3 size 128 ..
+RedBoot>
+</screen>
+ </para>
+ </refsect1>
+</refentry>
+
+<!-- ******** fs move ************************************************ -->
+
+<refentry id="fs-move-command">
+ <refnamediv>
+ <refname>fs move</refname>
+ <refpurpose>Move file</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>fs move</command>
+ <arg choice="req"><replaceable>source</replaceable></arg>
+ <arg choice="req"><replaceable>dest</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><replaceable>source</replaceable></entry>
+ <entry>String</entry>
+ <entry>Pathname of file to move.</entry>
+ <entry></entry>
+ </row>
+ <row>
+ <entry><replaceable>dest</replaceable></entry>
+ <entry>String</entry>
+ <entry>Pathname to new file location.</entry>
+ <entry></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+<para>This command moves a file within a filesystem. This command will
+fail if the destination file already exists, or is in a different
+filesystem.
+</para>
+</refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+ <para>Rename a file:
+<screen>
+RedBoot> <userinput>fs list tests</userinput>
+211392 d--------- 2 size 96 .
+212416 d--------- 3 size 128 ..
+205760 ---------- 1 size 12288 test1
+RedBoot> <userinput>fs move tests/test1 tests/test2</userinput>
+RedBoot> <userinput>fs list tests</userinput>
+211392 d--------- 2 size 128 .
+212416 d--------- 3 size 128 ..
+205760 ---------- 1 size 12288 test2
+RedBoot>
+</screen>
+ </para>
+ </refsect1>
+</refentry>
+
+<!-- ******** fs list ************************************************ -->
+
+<refentry id="fs-list-command">
+ <refnamediv>
+ <refname>fs list</refname>
+ <refpurpose>List filesystem directory</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>fs list</command>
+ <arg choice="opt"><replaceable>directory</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><replaceable>directory</replaceable></entry>
+ <entry>String</entry>
+ <entry>Pathname to directory to list.</entry>
+ <entry>Current directory</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+<para>This command prints a list of the contents of the named
+directory. Each line of the listing starts with the file's inode
+number, which is its address in the filesystem. Following is a set of
+UNIX-like access flags, the first character of this will be a
+&rdquo;d&ldquo; if this entry is a directory. The third item indicates
+the number of links to the file. Following this is the size of the
+file in bytes and the last item is its name.
+</para>
+</refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+ <para>List the current directory:
+<screen>
+RedBoot> <userinput>fs list</userinput>
+212416 d--------- 3 size 128 .
+212416 d--------- 3 size 128 ..
+211392 ---------- 1 size 4096 image
+206784 d--------- 2 size 96 tests
+RedBoot>
+</screen>
+ </para>
+<para>
+List a subdirectory:
+<screen>
+RedBoot> fs list tests
+206784 d--------- 2 size 96 .
+212416 d--------- 3 size 128 ..
+205760 ---------- 1 size 16384 test1
+RedBoot>
+</screen>
+</para>
+ </refsect1>
+</refentry>
+
+<!-- ******** fs write ************************************************ -->
+
+<refentry id="fs-write-command">
+ <refnamediv>
+ <refname>fs write</refname>
+ <refpurpose>Write to filesystem</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>fs write</command>
+ <arg choice="opt">-b <replaceable>mem_address</replaceable></arg>
+ <arg choice="opt">-l <replaceable>length</replaceable></arg>
+ <arg choice="req">name</arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><replaceable>mem_address</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Address of data to be written to flash.</entry>
+ <entry>Address of last loaded file. If not set by a load
+ operation it must be specified.</entry>
+ </row>
+ <row>
+ <entry><replaceable>length</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Length of data to be written.</entry>
+ <entry>Length of last loaded file.</entry>
+ </row>
+ <row>
+ <entry><replaceable>name</replaceable></entry>
+ <entry>String</entry>
+ <entry>Name of file to create.</entry>
+ <entry></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+<para>This command is used to write data from memory to a file. If the
+file does not exist it will be created. If it does exist, then it will
+be overwritten with the new contents.</para>
+</refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+<para>Write an area of data to a file
+<screen>
+RedBoot> <userinput>fs write -b 0x0606f000 -l 0x1000 image</userinput>
+RedBoot> <userinput>fs list</userinput>
+212416 d--------- 3 size 128 .
+212416 d--------- 3 size 128 ..
+211392 ---------- 1 size 4096 image
+206784 d--------- 2 size 96 tests
+RedBoot>
+</screen>
+ </para>
+ </refsect1>
+</refentry>
+
+
+
+</sect1>
+
+
+<sect1 id="Persistent-State-Flash">
+<title>Persistent State Flash-based Configuration and Control</title>
+<para><indexterm><primary>persistent state flash-based configuration and control
+</primary></indexterm><indexterm><primary>flash-based configuration and control
+</primary></indexterm><indexterm><primary>configuration and control</primary>
+<secondary>flash-based</secondary></indexterm></para>
+<para>RedBoot provides flash management support for storage in the flash memory
+of multiple executable images and of non-volatile information such as IP addresses
+and other network information.</para>
+<para>RedBoot on platforms that support flash based configuration information
+will report the following message the first time that RedBoot is booted on
+the target:</para>
+<screen>flash configuration checksum error or invalid key</screen>
+<para>This error can be ignored if no flash based configuration is desired,
+or can be silenced by running the <command>fconfig</command>
+command as described below. At this point you may also wish to run the <command>
+fis init</command> command. See other fis commands in <xref linkend="Flash-Image-System">.
+</para>
+<para>Certain control and configuration information used by RedBoot can be
+stored in flash. </para>
+<para>The details of what information is maintained in flash differ, based
+on the platform and the configuration. However, the basic operation used to
+maintain this information is the same. Using the <command>fconfig -l
+</command> command, the information may be displayed and/or changed.
+</para>
+<para>If the optional flag <computeroutput>-i</computeroutput> is specified,
+then the configuration database will be reset to its default
+state. This is also needed the first time RedBoot is installed on the
+target, or when updating to a newer RedBoot with different
+configuration keys.
+</para>
+<para>If the optional flag <computeroutput>-l</computeroutput> is specified,
+the configuration data is simply listed. Otherwise, each configuration parameter
+will be displayed and you are given a chance to change it. The entire value
+must be typed - typing just carriage return will leave a value unchanged.
+Boolean values may be entered using the first letter (<computeroutput>t</computeroutput>
+for true, <computeroutput>f</computeroutput> for false). At any time the editing
+process may be stopped simply by entering a period (.) on the line. Entering
+the caret (^) moves the editing back to the previous item. See &ldquo;RedBoot
+Editing Commands&rdquo;, <xref linkend="RedBoot-Editing-Commands">. </para>
+<para>If any changes are made in the configuration, then the updated data
+will be written back to flash after getting acknowledgment from the user.
+</para>
+<para>
+If the optional flag <computeroutput>-n</computeroutput> is specified
+(with or without <computeroutput>-l</computeroutput>) then &ldquo;nicknames&rdquo;
+of the entries are used. These are shorter and less descriptive than
+&ldquo;full&rdquo; names. The full name may also be displayed by adding the
+<computeroutput>-f</computeroutput> flag.</para>
+<para>The reason for telling you nicknames is that a quick way to set a single
+entry is provided, using the format
+<screen>
+ RedBoot> <userinput>fconfig <replaceable>nickname</replaceable> <replaceable>value
+</replaceable></userinput></screen>
+If no
+value is supplied, the command will list and prompt for only that entry.
+If a value is supplied, then the entry will be set to that value. You will
+be prompted whether to write the new information into flash if any change
+was made. For example
+<screen>
+ RedBoot> <userinput>fconfig -l -n</userinput>
+ boot_script: false
+ bootp: false
+ bootp_my_ip: 10.16.19.176
+ bootp_server_ip: 10.16.19.66
+ dns_ip: 10.16.19.1
+ gdb_port: 9000
+ net_debug: false
+ RedBoot> <userinput>fconfig bootp_my_ip 10.16.19.177</userinput>
+ bootp_my_ip: 10.16.19.176 Setting to 10.16.19.177
+ Update RedBoot non-volatile configuration - continue (y/n)? <userinput>y</userinput>
+ ... Unlock from 0x507c0000-0x507e0000: .
+ ... Erase from 0x507c0000-0x507e0000: .
+ ... Program from 0x0000a8d0-0x0000acd0 at 0x507c0000: .
+ ... Lock from 0x507c0000-0x507e0000: .
+ RedBoot>
+</screen>
+</para><para>
+Additionally, nicknames can be used like aliases via the format %{nickname}.
+This allows the values stored by <userinput>fconfig</userinput> to be used
+directly by scripts and commands.
+</para>
+<para>Depending on how your terminal program is connected and its
+capabilities, you might find that you are unable to use line-editing to
+delete the &lsquo;old&rsquo; value when using the default behaviour of
+<command>fconfig <replaceable>nickname</replaceable></command> or just
+plain <command>fconfig</command>, as shown in this example:
+<screen>
+RedBoot> <userinput>fco bootp</userinput>
+bootp: false&lowbar;
+</screen>
+The user deletes the word &ldquo;false;&rdquo and enters &ldquo;true&rdquo;
+so the display looks like this:
+<screen>
+RedBoot> <userinput>fco bootp</userinput>
+bootp: <userinput>true</userinput>
+Update RedBoot non-volatile configuration - continue (y/n)? y
+... Unlock from ...
+RedBoot> &lowbar;
+</screen>
+</para>
+<para>To edit when you cannot backspace, use the optional flag
+<computeroutput>-d</computeroutput> (for &ldquo;dumb terminal&rdquo;)
+to provide a simpler interface thus:
+<screen>
+RedBoot> <userinput>fco -d bootp</userinput>
+bootp: false ? &lowbar;
+</screen>
+and you enter the value in the obvious manner thus:
+<screen>
+RedBoot> <userinput>fco -d bootp</userinput>
+bootp: false ? <userinput>true</userinput>
+Update RedBoot non-volatile configuration - continue (y/n)? y
+... Unlock from ...
+RedBoot> &lowbar;
+</screen>
+</para>
+<para>One item which is always present in the configuration data is the ability
+to execute a script at boot time. A sequence of RedBoot commands can be entered
+which will be executed when the system starts up. Optionally, a time-out period
+can be provided which allows the user to abort the startup script and proceed
+with normal command processing from the console. </para>
+<para><screen>
+RedBoot> <userinput>fconfig -l</userinput>
+Run script at boot: false
+Use BOOTP for network configuration: false
+Local IP address: 192.168.1.29
+Default server IP address: 192.168.1.101
+DNS server IP address: 192.168.1.1
+DNS domain name: example.com
+GDB connection port: 9000
+Network debug at boot time: false
+</screen></para>
+<para>The following example sets a boot script and then shows it running.
+ </para>
+<para>
+<screen>
+RedBoot> <userinput>fconfig</userinput>
+Run script at boot: false <userinput>t</userinput>
+ Boot script:
+Enter script, terminate with empty line
+>> <userinput>fi li</userinput>
+ Boot script timeout: 0 <userinput>10</userinput>
+Use BOOTP for network configuration: false .
+Update RedBoot non-volatile configuration - continue (y/n)? <userinput>y</userinput>
+... Erase from 0xa0fc0000-0xa0fe0000: .
+... Program from 0x8c021f60-0x8c022360 at 0xa0fc0000: .
+RedBoot>
+RedBoot(tm) debug environment - built 08:22:24, Aug 23 2000
+Copyright (C) 2000, Free Software Foundation, Inc.
+
+
+RAM: 0x8c000000-0x8c800000
+flash: 0xa0000000 - 0xa1000000, 128 blocks of 0x00020000 bytes ea.
+Socket Communications, Inc: Low Power Ethernet CF Revision C \
+5V/3.3V 08/27/98 IP: 192.168.1.29, Default server: 192.168.1.101 \
+== Executing boot script in 10 seconds - enter ^C to abort
+RedBoot> <userinput>fi li</userinput>
+Name flash addr Mem addr Length Entry point
+RedBoot 0xA0000000 0xA0000000 0x020000 0x80000000
+RedBoot config 0xA0FC0000 0xA0FC0000 0x020000 0x00000000
+FIS directory 0xA0FE0000 0xA0FE0000 0x020000 0x00000000
+RedBoot>
+</screen>
+</para>
+<note><title>NOTE</title>
+<para>The bold characters above indicate where something was entered on the
+console. As you can see, the <command>fi li</command> command
+at the end came from the script,
+not the console. Once the script is executed, command processing reverts to
+the console. </para>
+</note>
+<para>
+<note><title>NOTE</title>
+<para>
+RedBoot supports the notion of a boot script timeout, i.e. a period of
+time that RedBoot waits before executing the boot time script. This period
+is primarily to allow the possibility of canceling the script. Since
+a timeout value of zero (0) seconds would never allow the script to
+be aborted or canceled, this value is not allowed. If the timeout
+value is zero, then RedBoot will abort the script execution immediately.
+</para>
+</note>
+On many targets, RedBoot may be configured to run from ROM or it may be
+configured to run from RAM. Other configurations are also possible. All
+RedBoot configurations will execute the boot script, but in certain cases
+it may be desirable to limit the execution of certain script commands to
+one RedBoot configuration or the other. This can be accomplished by
+prepending <computeroutput>{&lt;startup type>}</computeroutput> to the
+commands which should be executed only by the RedBoot configured for the
+specified startup type. The following boot script illustrates this concept
+by having the ROM based RedBoot load and run the RAM based RedBoot. The RAM
+based RedBoot will then list flash images.</para>
+<para><screen>
+RedBoot> <userinput>fco</userinput>
+Run script at boot: false <userinput>t</userinput>
+Boot script:
+Enter script, terminate with empty line
+>> <userinput>{ROM}fis load RedBoot[RAM]</userinput>
+>> <userinput>{ROM}go</userinput>
+>> <userinput>{RAM}fis li</userinput>
+>>
+Boot script timeout (1000ms resolution): <userinput>2</userinput>
+Use BOOTP for network configuration: <userinput>false</userinput>
+ ...
+Update RedBoot non-volatile configuration - continue (y/n)? <userinput>y</userinput>
+... Unlock from 0x007c0000-0x007e0000: .
+... Erase from 0x007c0000-0x007e0000: .
+... Program from 0xa0015030-0xa0016030 at 0x007df000: .
+... Lock from 0x007c0000-0x007e0000: .
+RedBoot> <userinput>reset</userinput>
+... Resetting.
++Ethernet eth0: MAC address 00:80:4d:46:01:05
+IP: 192.168.1.153, Default server: 192.168.1.10
+
+RedBoot(tm) bootstrap and debug environment [ROM]
+Red Hat certified release, version R1.xx - built 17:37:36, Aug 14 2001
+
+Platform: IQ80310 (XScale)
+Copyright (C) 2000, 2001, Free Software Foundation, Inc.
+
+RAM: 0xa0000000-0xa2000000, 0xa001b088-0xa1fdf000 available
+FLASH: 0x00000000 - 0x00800000, 64 blocks of 0x00020000 bytes each.
+== Executing boot script in 2.000 seconds - enter ^C to abort
+RedBoot> <userinput>fis load RedBoot[RAM]</userinput>
+RedBoot> <userinput>go</userinput>
++Ethernet eth0: MAC address 00:80:4d:46:01:05
+IP: 192.168.1.153, Default server: 192.168.1.10
+
+RedBoot(tm) bootstrap and debug environment [RAM]
+Red Hat certified release, version R1.xx - built 13:03:47, Aug 14 2001
+
+Platform: IQ80310 (XScale)
+Copyright (C) 2000, 2001, Free Software Foundation, Inc.
+
+RAM: 0xa0000000-0xa2000000, 0xa0057fe8-0xa1fdf000 available
+FLASH: 0x00000000 - 0x00800000, 64 blocks of 0x00020000 bytes each.
+== Executing boot script in 2.000 seconds - enter ^C to abort
+RedBoot> <userinput>fis li</userinput>
+Name FLASH addr Mem addr Length Entry point
+RedBoot 0x00000000 0x00000000 0x00040000 0x00002000
+RedBoot config 0x007DF000 0x007DF000 0x00001000 0x00000000
+FIS directory 0x007E0000 0x007E0000 0x00020000 0x00000000
+RedBoot>
+</screen></para>
+</sect1>
+<sect1 id="executing-programs">
+<title>Executing Programs from RedBoot</title>
+<para><indexterm><primary>executing programs</primary></indexterm><indexterm>
+<primary>RedBoot</primary><secondary>executing programs</secondary></indexterm>Once
+an image has been loaded into memory, either via the <command>load
+</command> command or the <command>fis load</command>
+command, execution may be transfered to that image.</para>
+<para> <note><title>NOTE</title>
+<para>The image is assumed to be a stand-alone entity, as RedBoot gives the
+entire platform over to it. Typical examples would be an eCos application
+or a Linux kernel.</para>
+</note></para>
+
+
+<!-- ******** go *************************************************** -->
+ <refentry id="go-command">
+ <refnamediv>
+ <refname>go</refname>
+ <refpurpose>Execute a program</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>go</command>
+ <arg>-w <replaceable> timeout</replaceable></arg>
+ <arg>-c</arg>
+ <arg>-n</arg>
+ <arg><replaceable> start_address</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>-w <replaceable>timeout</replaceable></entry>
+ <entry>Number</entry>
+ <entry>How long to wait before starting execution.</entry>
+ <entry>0</entry>
+ </row>
+ <row>
+ <entry>-c</entry>
+ <entry>Boolean</entry>
+ <entry>Go with caches enabled.</entry>
+ <entry>caches off</entry>
+ </row>
+ <row>
+ <entry>-n</entry>
+ <entry>Boolean</entry>
+ <entry>Go with network interface stopped.</entry>
+ <entry>network enabled</entry>
+ </row>
+ <row>
+ <entry><replaceable>start_address</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Address in memory to begin execution.</entry>
+ <entry>Value set by last <command>load</command> or <command>fis load</command> command.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para>
+The <command>go</command> command causes RedBoot to give control of the target platform to
+another program. This program must execute stand alone, e.g. an eCos
+application or a Linux kernel.
+ </para>
+ <para>
+If the -w option is used, RedBoot will print a message and then
+wait for a period of time before starting the execution. This is
+most useful in a script, giving the user a chance to abort executing
+a program and move on in the script.
+ </para>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Execute a program - <emphasis>no explicit output from RedBoot</emphasis>.
+<screen>
+RedBoot> <userinput>go 0x40040</userinput>
+</screen>
+ </para>
+ <para>
+Execute a program with a timeout.
+<screen>
+RedBoot> <userinput>go -w 10</userinput>
+About to start execution at 0x00000000 - abort with ^C within 10 seconds
+^C
+RedBoot>
+</screen>
+Note that the starting address was implied (0x00000000 in this example).
+The user is prompted that execution will commence in 10 seconds. At
+anytime within that 10 seconds the user may type <guibutton>Ctrl+C</guibutton>
+on the console and RedBoot will abort execution and return for the next
+command, either from a script or the console.
+ </para>
+ </refsect1>
+ </refentry>
+
+<!-- ******** exec *************************************************** -->
+ <refentry id="exec-command">
+ <refnamediv>
+ <refname>exec</refname>
+ <refpurpose>Execute a Linux kernel</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>exec</command>
+ <arg>-w <replaceable> timeout</replaceable></arg>
+ <arg>-r <replaceable> ramdisk_address</replaceable></arg>
+ <arg>-s <replaceable> ramdisk_length</replaceable></arg>
+ <arg>-b <replaceable> load_address</replaceable>
+ <arg choice="req">-l <replaceable> load_length</replaceable></arg>
+ </arg>
+ <arg>-c <replaceable> kernel_command_line</replaceable></arg>
+ <arg><replaceable> entry_point</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <colspec colname="c1">
+ <colspec colname="c2">
+ <colspec colname="c3">
+ <colspec colname="c4">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>-w <replaceable>timeout</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Time to wait before starting execution.</entry>
+ <entry>0</entry>
+ </row>
+ <row>
+ <entry>-r <replaceable>ramdisk_address</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Address in memory of "initrd"-style ramdisk - passed to Linux kernel.</entry>
+ <entry><emphasis>None</emphasis></entry>
+ </row>
+ <row>
+ <entry>-s <replaceable>ramdisk_length</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Length of ramdisk image - passed to Linux kernel.</entry>
+ <entry><emphasis>None</emphasis></entry>
+ </row>
+ <row>
+ <entry>-b <replaceable>load_address</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Address in memory of the Linux kernel image.</entry>
+ <entry>Value set by <command>load</command> or <command>fis load</command></entry>
+ </row>
+ <row>
+ <entry>-l <replaceable>load_length</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Length of Linux kernel image.</entry>
+ <entry><emphasis>none</emphasis></entry>
+ </row>
+ <row>
+ <entry>-c <replaceable>kernel_command_line</replaceable></entry>
+ <entry>String</entry>
+ <entry>Command line to pass to the Linux kernel.</entry>
+ <entry><emphasis>None</emphasis></entry>
+ </row>
+ <row>
+ <entry>-x</entry>
+ <entry></entry>
+ <entry>Boot kernel with endianess opposite of RedBoot endianess.</entry>
+ <entry>Boot kernel with same endianess as RedBoot</entry>
+ </row>
+ <row>
+ <entry><replaceable>entry_address</replaceable></entry>
+ <entry>Number</entry>
+ <entry>Starting address for Linux kernel execution</entry>
+ <entry>Implied by architecture</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para>
+The <command>exec</command> command is used to execute a non-eCos application, typically a
+Linux kernel. Additional information may be passed to the kernel at startup
+time. This command is quite special (and unique from the <command>go</command> command) in
+that the program being executed may expect certain environmental setups, for
+example that the MMU is turned off, etc. </para>
+<para>The Linux kernel expects to have been loaded to a particular memory
+location which is architecture dependent(0xC0008000 in the case of the SA1110).
+Since this memory is used
+by RedBoot internally, it is not possible to load the kernel to that location
+directly. Thus the requirement for the "-b" option which tells the command
+where the kernel has been loaded. When the <command>exec</command> command runs, the image will
+be relocated to the appropriate location before being started. The "-r" and
+"-s" options are used to pass information to the kernel about where a statically
+loaded ramdisk (initrd) is located.</para>
+<para>The "-c" option can be used to pass textual "command line" information
+to the kernel. If the command line data contains any punctuation (spaces,
+etc), then it must be quoted using the double-quote character '"'. If the
+quote character is required, it should be written as '\"'.
+ </para>
+<para>The "-x" option is optionally available on some bi-endian platforms. It is used to boot
+a kernel built with an endianess opposite of RedBoot.</para>
+ </refsect1>
+ <refsect1>
+ <title>Examples</title>
+ <para>
+Execute a Linux kernel, passing a command line, which needs relocation.
+The result from RedBoot is normally quiet, with the target platform being
+passed over to Linux immediately.
+<screen>
+RedBoot> <userinput>exec -b 0x100000 -l 0x80000 -c "noinitrd root=/dev/mtdblock3 console=ttySA0"</userinput>
+</screen>
+ </para>
+ <para>
+Execute a Linux kernel, default entry address and no relocation required, with a timeout.
+The <emphasis> emphasized lines</emphasis> are output from the loaded kernel.
+<screen>
+RedBoot> exec <userinput>-c "console=ttyS0,38400 ip=dhcp nfsroot=/export/elfs-sh" -w 5</userinput>
+Now booting linux kernel:
+Base address 0x8c001000 Entry 0x8c210000
+Cmdline : console=ttyS0,38400 ip=dhcp nfsroot=/export/elfs-sh
+About to start execution at 0x8x210000 - abort with ^C within 5 seconds
+<emphasis>
+Linux version 2.4.10-pre6 (...) (gcc version 3.1-stdsh-010931) #3 Thu Sep 27 11:04:23 BST 2001
+</emphasis>
+</screen>
+ </para>
+ </refsect1>
+ </refentry>
+
+</sect1>
+</chapter>
diff --git a/ecos/packages/redboot/current/doc/redboot_epilogue.sgml b/ecos/packages/redboot/current/doc/redboot_epilogue.sgml
new file mode 100644
index 0000000..b53bc63
--- /dev/null
+++ b/ecos/packages/redboot/current/doc/redboot_epilogue.sgml
@@ -0,0 +1,3 @@
+
+<!-- <index id="index"></index> -->
+<!-- </part> -->
diff --git a/ecos/packages/redboot/current/doc/redboot_installing.sgml b/ecos/packages/redboot/current/doc/redboot_installing.sgml
new file mode 100644
index 0000000..3c20dd4
--- /dev/null
+++ b/ecos/packages/redboot/current/doc/redboot_installing.sgml
@@ -0,0 +1,6832 @@
+<!-- {{{ Banner -->
+
+<!-- =============================================================== -->
+<!-- -->
+<!-- redboot_installing.sgml -->
+<!-- -->
+<!-- RedBoot Documentation -->
+<!-- -->
+<!-- =============================================================== -->
+<!-- ####ECOSDOCCOPYRIGHTBEGIN#### -->
+<!-- =============================================================== -->
+<!-- Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. -->
+<!-- This material may be distributed only subject to the terms -->
+<!-- and conditions set forth in the Open Publication License, v1.0 -->
+<!-- or later (the latest version is presently available at -->
+<!-- http://www.opencontent.org/openpub/) -->
+<!-- Distribution of the work or derivative of the work in any -->
+<!-- standard (paper) book form is prohibited unless prior -->
+<!-- permission obtained from the copyright holder -->
+<!-- =============================================================== -->
+<!-- ####ECOSDOCCOPYRIGHTEND#### -->
+<!-- =============================================================== -->
+<!-- #####DESCRIPTIONBEGIN#### -->
+<!-- -->
+<!-- ####DESCRIPTIONEND#### -->
+<!-- =============================================================== -->
+
+<!-- }}} -->
+
+<!-- FIXME:
+ Need to make index terms consistent
+-->
+
+
+<chapter id="Installation-and-Testing">
+<title>Installation and Testing</title>
+<indexterm><primary>installing and testing RedBoot</primary></indexterm><indexterm>
+<primary>RedBoot</primary><secondary>installing and testing</secondary></indexterm>
+
+<!-- *************************** AM3x ********************** -->
+
+<?Pub _newpage>
+<sect1 id="asb2305">
+<title>AM3x/MN103E010 Matsushita MN103E010 (AM33/2.0) ASB2305 Board</title>
+<sect2>
+<title>Overview</title>
+<para>
+<indexterm>
+<primary>Matsushita MN103E010 (AM33/2.0) ASB2305 Board</primary>
+<secondary>installing and testing</secondary>
+</indexterm>
+<indexterm>
+<primary>installing and testing</primary>
+<secondary>Matsushita MN103E010 (AM33/2.0) ASB2305 Board</secondary>
+</indexterm>
+RedBoot supports the debug serial port and the built in ethernet port for communication and
+downloads. The default serial port settings are 115200,8,N,1 with RTS/CTS flow control. RedBoot can
+run from either flash, and can support flash management for either the boot PROM or the system
+flash regions.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>PROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the boot PROM and able to
+ access the system flash.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>FLASH</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the system flash and able to
+ access the boot PROM.</entry>
+ <entry>redboot_FLASH.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM and able to access the
+ boot PROM.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+</sect2>
+
+<sect2>
+<title>Initial Installation</title>
+<para>Unless a pre-programmed system flash module is available to be plugged into a new board,
+RedBoot must be installed with the aid of a JTAG interface unit. To achieve this, the RAM mode
+RedBoot must be loaded directly into RAM by JTAG and started, and then <emphasis>that</emphasis>
+must be used to store the ROM mode RedBoot into the boot PROM.</para>
+<para>These instructions assume that you have binary images of the RAM-based and boot PROM-based
+RedBoot images available.</para>
+<sect3>
+<title>Preparing to program the board</title>
+<para>If the board is to be programmed, whether via JTAG or RedBoot, some hardware settings need to
+be changed:</para>
+<itemizedlist>
+<listitem>
+<para>Jumper across ST18 on the board to allow write access to the boot PROM.</para>
+</listitem>
+<listitem>
+<para>Set DIP switch S1-3 to OFF to allow RedBoot to write to the system flash.</para>
+</listitem>
+<listitem>
+<para>Set the switch S5 (on the front of the board) to boot from whichever flash is
+<emphasis>not</emphasis> being programmed. Note that the RedBoot image cannot access the flash from
+which it is currently executing (it can only access the other flash).</para>
+</listitem>
+</itemizedlist>
+<para>
+The RedBoot binary image files should also be copied to the TFTP pickup area on the host providing
+TFTP services if that is how RedBoot should pick up the images it is going to program into the
+flash. Alternatively, the images can be passed by YMODEM over the serial link.
+</para>
+</sect3>
+<sect3>
+<title>Preparing to use the JTAG debugger</title>
+<para>The JTAG debugger will also need setting up:</para>
+<orderedlist>
+<listitem><para>Install the JTAG debugger software (WICE103E) on a PC running Windows (WinNT is
+probably the best choice for this) in &ldquo;C:/PanaX&rdquo;.</para>
+</listitem>
+<listitem><para>Install the Matsushita provided &ldquo;project&rdquo; into the
+&ldquo;C:/Panax/wice103e/prj&rdquo; directory.</para>
+</listitem>
+<listitem><para>Install the RedBoot image files into the &ldquo;C:/Panax/wice103e/prj&rdquo;
+directory under the names redboot.ram and redboot.prom.</para>
+</listitem>
+<listitem><para>Make sure the PC's BIOS has the parallel port set to full bidirectional
+mode.</para>
+</listitem>
+<listitem><para>Connect the JTAG debugger to the PC's parallel port.</para>
+</listitem>
+<listitem><para>Connect the JTAG debugger to the board.</para>
+</listitem>
+<listitem><para>Set the switch on the front of the board to boot from &ldquo;boot
+PROM&rdquo;.</para>
+</listitem>
+<listitem><para>Power up the JTAG debugger and then power up the board.</para>
+</listitem>
+<listitem><para>Connect the board's Debug Serial port to a computer by a null modem cable.</para>
+</listitem>
+<listitem><para>Start minicom or some other serial communication software and set for 115200 baud,
+1-N-8 with hardware (RTS/CTS) flow control.</para>
+</listitem>
+</orderedlist>
+</sect3>
+<sect3>
+<title>Loading the RAM-based RedBoot via JTAG</title>
+<para>To perform the first half of the operation, the following steps should be followed:</para>
+<orderedlist>
+<listitem><para>Start the JTAG debugger software.</para>
+</listitem>
+<listitem>
+<para>Run the following commands at the JTAG debugger's prompt to set up the MMU registers on the
+CPU.</para>
+<screen>
+<userinput>ed 0xc0002000, 0x12000580</userinput>
+
+<userinput>ed 0xd8c00100, 0x8000fe01</userinput>
+<userinput>ed 0xd8c00200, 0x21111000</userinput>
+<userinput>ed 0xd8c00204, 0x00100200</userinput>
+<userinput>ed 0xd8c00208, 0x00000004</userinput>
+
+<userinput>ed 0xd8c00110, 0x8400fe01</userinput>
+<userinput>ed 0xd8c00210, 0x21111000</userinput>
+<userinput>ed 0xd8c00214, 0x00100200</userinput>
+<userinput>ed 0xd8c00218, 0x00000004</userinput>
+
+<userinput>ed 0xd8c00120, 0x8600ff81</userinput>
+<userinput>ed 0xd8c00220, 0x21111000</userinput>
+<userinput>ed 0xd8c00224, 0x00100200</userinput>
+<userinput>ed 0xd8c00228, 0x00000004</userinput>
+
+<userinput>ed 0xd8c00130, 0x8680ff81</userinput>
+<userinput>ed 0xd8c00230, 0x21111000</userinput>
+<userinput>ed 0xd8c00234, 0x00100200</userinput>
+<userinput>ed 0xd8c00238, 0x00000004</userinput>
+
+<userinput>ed 0xd8c00140, 0x9800f801</userinput>
+<userinput>ed 0xd8c00240, 0x00140000</userinput>
+<userinput>ed 0xd8c00244, 0x11011100</userinput>
+<userinput>ed 0xd8c00248, 0x01000001</userinput>
+
+<userinput>ed 0xda000000, 0x55561645</userinput>
+<userinput>ed 0xda000004, 0x000003c0</userinput>
+<userinput>ed 0xda000008, 0x9000fe01</userinput>
+<userinput>ed 0xda00000c, 0x9200fe01</userinput>
+<userinput>ed 0xda000000, 0xa89b0654</userinput>
+</screen>
+</listitem>
+<listitem>
+<para>Run the following commands at the JTAG debugger's prompt to tell it what regions of the CPU's
+address space it can access:</para>
+<screen>
+<userinput>ex 0x80000000,0x81ffffff,/mexram</userinput>
+<userinput>ex 0x84000000,0x85ffffff,/mexram</userinput>
+<userinput>ex 0x86000000,0x867fffff,/mexram</userinput>
+<userinput>ex 0x86800000,0x87ffffff,/mexram</userinput>
+<userinput>ex 0x8c000000,0x8cffffff,/mexram</userinput>
+<userinput>ex 0x90000000,0x93ffffff,/mexram</userinput>
+</screen>
+</listitem>
+<listitem><para>Instruct the debugger to load the RAM RedBoot image into RAM:</para>
+<screen>
+<userinput>_pc=90000000</userinput>
+<userinput>u_pc</userinput>
+<userinput>rd redboot.ram,90000000</userinput>
+</screen>
+</listitem>
+<listitem><para>Load the boot PROM RedBoot into RAM:</para>
+<screen>
+<userinput>rd redboot.prom,91020000</userinput>
+</screen>
+</listitem>
+<listitem><para>Start RedBoot in RAM:</para>
+<screen>
+<userinput>g</userinput>
+</screen>
+<para>Note that RedBoot may take some time to start up, as it will attempt to query a BOOTP or DHCP
+server to try and automatically get an IP address for the board. Note, however, that it should send
+a plus over the serial port immediately, and the 7-segment LEDs should display &ldquo;rh
+8&rdquo;.</para>
+</listitem>
+</orderedlist>
+</sect3>
+<sect3>
+<title>Loading the boot PROM-based RedBoot via the RAM mode RedBoot</title>
+<para>Once the RAM mode RedBoot is up and running, it can be communicated with by way of the serial
+port. Commands can now be entered directly to RedBoot for flashing the boot PROM.</para>
+<orderedlist>
+<listitem><para>Instruct RedBoot to initialise the boot PROM:</para>
+<screen>
+RedBoot> <userinput>fi init</userinput>
+</screen>
+</listitem>
+<listitem><para>Write the previously loaded redboot.prom image into the boot PROM:</para>
+<screen>
+RedBoot> <userinput>fi write -f 0x80000000 -b 0x91020000 -l 0x00020000</userinput>
+</screen>
+</listitem>
+<listitem><para>Check that RedBoot has written the image:</para>
+<screen>
+RedBoot> <userinput>dump -b 0x91020000</userinput>
+RedBoot> <userinput>dump -b 0x80000000</userinput>
+</screen>
+<para>Barring the difference in address, the two dumps should be the same.</para>
+</listitem>
+<listitem><para>Close the JTAG software and power-cycle the board. The RedBoot banners should be
+displayed again over the serial port, followed by the RedBoot prompt. The boot PROM-based RedBoot
+will now be running.</para>
+</listitem>
+<listitem><para>Power off the board and unjumper ST18 to write-protect the contents of the boot
+PROM. Then power the board back up.</para>
+</listitem>
+<listitem><para>Run the following command to initialise the system flash:</para>
+<screen>
+RedBoot> <userinput>fi init</userinput>
+</screen>
+<para>Then program the system flash based RedBoot into the system flash:</para>
+<screen>
+RedBoot> <userinput>load -r -b %{FREEMEMLO} redboot_FLASH.bin</userinput>
+RedBoot> <userinput>fi write -f 0x84000000 -b %{FREEMEMLO} -l 0x00020000</userinput>
+</screen>
+<note>
+<title>NOTE</title>
+<para>RedBoot arranges the flashes on booting such that they always appear at the same addresses,
+no matter which one was booted from.</para>
+</note>
+</listitem>
+<listitem>
+<para>A similar sequence of commands can be used to program the boot PROM when RedBoot has been
+booted from an image stored in the system flash.
+</para>
+<screen>
+RedBoot> <userinput>load -r -b %{FREEMEMLO} /tftpboot/redboot_ROM.bin</userinput>
+RedBoot> <userinput>fi write -f 0x80000000 -b %{FREEMEMLO} -l 0x00020000</userinput>
+</screen>
+<para>See <xref linkend="Persistent-State-Flash"> for details on configuring the RedBoot in
+general, and also <xref linkend="Flash-Image-System"> for more details on programming the system
+flash.</para>
+</listitem>
+</orderedlist>
+</sect3>
+</sect2>
+<sect2>
+<title>Additional Commands</title>
+<para>The <command>exec</command> command which allows the loading and execution of
+Linux kernels, is supported for this architecture (see <xref linkend="executing-programs">). The
+<command>exec</command> parameters used for ASB2305 board are:</para>
+<variablelist>
+<varlistentry><term>
+-w <replaceable>&lt;time></replaceable></term>
+<listitem><para>Wait time in seconds before starting kernel</para></listitem></varlistentry>
+<varlistentry><term>
+-c <replaceable>"params"</replaceable></term>
+<listitem><para>Parameters passed to kernel</para></listitem></varlistentry>
+<varlistentry><term><replaceable>&lt;addr></replaceable></term>
+<listitem><para>Kernel entry point, defaulting to the entry point of the last image
+loaded</para></listitem></varlistentry>
+</variablelist>
+<para>The parameter string is stored in the on-chip memory at location 0x8C001000, and is prefixed
+by &ldquo;cmdline:&rdquo; if it was supplied.</para>
+</sect2>
+<sect2>
+<title>Memory Maps </title>
+<para>RedBoot sets up the following memory map on the ASB2305 board.</para>
+<note>
+<title>NOTE</title>
+<para>The regions mapped between 0x80000000-0x9FFFFFFF are cached by the CPU. However, all those
+regions can be accessed uncached by adding 0x20000000 to the address.</para>
+</note>
+<programlisting>
+Physical Address Range Description
+----------------------- -----------
+0x80000000 - 0x9FFFFFFF Cached Region
+0x80000000 - 0x81FFFFFF Boot PROM
+0x84000000 - 0x85FFFFFF System Flash
+0x86000000 - 0x86007FFF 64Kbit Sys Config EEPROM
+0x86F90000 - 0x86F90003 4x 7-segment LEDs
+0x86FA0000 - 0x86FA0003 Software DIP Switches
+0x86FB0000 - 0x86FB001F PC16550 Debug Serial Port
+0x8C000000 - 0x8FFFFFFF On-Chip Memory (repeated 16Kb SRAM)
+0x90000000 - 0x93FFFFFF SDRAM
+0x98000000 - 0x9BFFFFFF Paged PCI Memory Space (64Mb)
+0x9C000000 - 0x9DFFFFFF PCI Local SRAM (32Mb)
+0x9E000000 - 0x9E03FFFF PCI I/O Space
+0x9E040000 - 0x9E0400FF AM33-PCI Bridge Registers
+0x9FFFFFF4 - 0x9FFFFFF7 PCI Memory Page Register
+0x9FFFFFF8 - 0x9FFFFFFF PCI Config Registers
+0xA0000000 - 0xBFFFFFFF Uncached Mirror Region
+0xC0000000 - 0xDFFFFFFF CPU Control Registers
+</programlisting>
+<para>The ASB2305 HAL makes use of the on-chip memory in the following way:</para>
+<programlisting>
+0x8C000000 - 0x8C0000FF hal_vsr_table
+0x8C000100 - 0x8C0001FF hal_virtual_vector_table
+0x8C001000 - Linux command line (RedBoot exec command)
+ - 0x8C003FFF Emergency DoubleFault Exception Stack
+</programlisting>
+<para>Currently the CPU's interrupt table lies at the beginning of the RedBoot image, which must
+therefore be aligned to a 0xFF000000 mask.</para>
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=asb2305
+export ARCH_DIR=mn10300
+export PLATFORM_DIR=asb2305
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2>
+</sect1>
+
+<!-- *************************** ARM ******************* -->
+
+<?Pub _newpage>
+<sect1 id="e7t">
+<title>ARM/ARM7 ARM Evaluator7T</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>ARM Evaluator7T</primary><secondary>installing and
+testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>ARM Evaluator7T</secondary></indexterm>RedBoot supports
+both serial ports for communication and downloads. The default serial port
+settings are 38400,8,N,1.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from flash address 0x20000, with
+ ARM Boot Monitor in flash boot sector.</entry>
+ <entry>redboot_ROMA.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+</sect2>
+<sect2>
+<title>Initial Installation</title>
+<para>RedBoot is installed using the on-board boot environment. See the user
+manual for full details.</para>
+</sect2>
+<sect2>
+<title>Quick download instructions</title>
+<para>Here are quick start instructions for downloading the prebuilt Redboot
+image:</para>
+<itemizedlist>
+<listitem><para>Boot the board and press ENTER:</para>
+<screen>
+
+ ARM Evaluator7T Boot Monitor PreRelease 1.00
+ Press ENTER within 2 seconds to stop autoboot
+ Boot: </screen>
+</listitem>
+<listitem><para>Erase the part of the flash where RedBoot will get programmed:
+</para>
+<screen> Boot: <userinput>flasherase 01820000 10000</userinput></screen>
+</listitem>
+<listitem><para>Prepare to download the UU-encoded version of the RedBoot
+image:</para>
+<screen> Boot: <userinput>download 10000</userinput>
+ Ready to download. Use 'transmit' option on terminal emulator to download file.
+</screen>
+</listitem>
+<listitem><para>Either use ASCII transmit option in the terminal emulator,
+or on Linux, simply cat the file to the serial port:<screen> $ <userinput>
+cat redboot.UU > /dev/ttyS0</userinput></screen>When complete, you should
+see:<screen> Loaded file redboot.bin at address 000100000, size = 41960
+ Boot:</screen></para>
+</listitem>
+<listitem><para>Program the flash:<screen> Boot: <userinput>flashwrite 01820000 10000 10000
+</userinput></screen></para>
+</listitem>
+<listitem><para>And verify that the module is available:<screen> Boot: <userinput>
+rommodules</userinput>
+ Header Base Limit
+ 018057c8 01800000 018059e7 BootStrapLoader v1.0 Apr 27 2000 10:33:58
+ 01828f24 01820000 0182a3e8 RedBoot Apr 5 2001</screen></para>
+</listitem>
+<listitem><para>Reboot the board and you should see the RedBoot banner.</para>
+</listitem>
+</itemizedlist>
+</sect2>
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>None.</para>
+</sect2>
+<sect2>
+<title>Memory Maps </title>
+<para>RedBoot sets up the following memory map on the E7T board. <note><title>
+NOTE</title>
+<para>The virtual memory maps in this section use a C and B column to indicate
+whether or not the region is cached (C) or buffered (B).</para>
+</note> <programlisting>Physical Address Range C B Description
+----------------------- - - -----------
+0x00000000 - 0x0007ffff Y N SDRAM
+0x03ff0000 - 0x03ffffff N N Microcontroller registers
+0x01820000 - 0x0187ffff N N System flash (mirrored)</programlisting></para>
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=e7t
+export ARCH_DIR=arm
+export PLATFORM_DIR=e7t
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2>
+</sect1>
+
+<?Pub _newpage>
+<sect1 id="integrator">
+<title>ARM/ARM7+ARM9 ARM Integrator</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>ARM Integrator</primary><secondary>installing and
+testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>ARM Integrator</secondary></indexterm>RedBoot supports
+both serial ports for communication and downloads. The default serial port
+settings are 38400,8,N,1.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+ <row>
+ <entry>ROMRAM</entry>
+ <entry>[ROMRAM]</entry>
+ <entry>RedBoot running from RAM, but contained in the
+ board's flash boot sector.</entry>
+ <entry>redboot_ROMRAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+</sect2>
+
+<sect2>
+<title>Initial Installation</title>
+<para>RedBoot is installed using the on-board bootPROM environment. See the user
+manual for full details.</para>
+</sect2>
+<sect2>
+<title>Quick download instructions</title>
+<para>Here are quick start instructions for downloading the prebuilt Redboot
+image:</para>
+<itemizedlist>
+<listitem><para>Set DIP switch S1[1] to the ON position and reset or
+power the board up. You will see the bootPROM startup message on
+serial port A (J14):</para>
+<screen>
+Initialising...
+
+
+ARM bootPROM [Version 1.3] Rebuilt on Jun 26 2001 at 22:04:10
+Running on a Integrator Evaluation Board
+Board Revision V1.0, ARM966E-S Processor
+Memory Size is 16MBytes, Flash Size is 32MBytes
+Copyright (c) ARM Limited 1999 - 2001. All rights reserved.
+Board designed by ARM Limited
+Hardware support provided at http://www.arm.com/
+For help on the available commands type ? or h
+boot Monitor >
+</screen>
+</listitem>
+<listitem>
+<para>Issue the FLASH ROM load command:
+</para>
+<screen>
+boot Monitor > <userinput>L</userinput>
+Load Motorola S-Records into flash
+
+Deleting Image 0
+
+The S-Record loader only accepts input on the serial port.
+Type Ctrl/C to exit loader.
+</screen>
+</listitem>
+<listitem><para>Either use the ASCII transmit option in the terminal emulator,
+or on Linux, simply cat the file to the serial port:
+</para>
+<screen>
+$ <userinput>cat redboot.srec > /dev/ttyS0</userinput>
+</screen>
+<para>
+When complete, type Ctrl-C and you should see something similar to:
+</para>
+<screen>
+................................
+................................
+....................
+Downloaded 5,394 records in 81 seconds.
+
+Overwritten block/s
+ 0
+
+boot Monitor >
+</screen>
+</listitem>
+<listitem><para>Set DIP switch S1[1] to the OFF position and reboot
+the board and you should see the RedBoot banner.</para>
+</listitem>
+</itemizedlist>
+</sect2>
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>None.</para>
+</sect2>
+<sect2>
+<title>Memory Maps </title>
+<para>RedBoot sets up the following memory map on the Integrator board. <note><title>
+NOTE</title>
+<para>The virtual memory maps in this section use a C and B column to indicate
+whether or not the region is cached (C) or buffered (B).</para>
+</note>
+<programlisting>
+
+ARM7TDMI
+--------
+
+Physical Address Range C B Description
+----------------------- - - -----------
+0x00000000 - 0x0007ffff N N SSRAM
+0x00080000 - 0x0fffffff N N SDRAM (depends on part fitted)
+0x10000000 - 0x1fffffff N N System control and peripheral registers
+0x20000000 - 0x23ffffff N N Boot ROM (contains boot Monitor)
+0x24000000 - 0x27ffffff N N FLASH ROM (contains RedBoot)
+0x28000000 - 0x2bffffff N N SSRAM echo area
+0x40000000 - 0x5fffffff N N PCI Memory access windows
+0x60000000 - 0x60ffffff N N PCI IO access window
+0x61000000 - 0x61ffffff N N PCI config space window
+0x62000000 - 0x6200ffff N N PCI bridge register window
+0x80000000 - 0x8fffffff N N SDRAM echo area (used for PCI accesses)
+
+
+ARM966E
+-------
+
+Physical Address Range C B Description
+----------------------- - - -----------
+0x00000000 - 0x000fffff N N SSRAM
+0x00100000 - 0x0fffffff N N SDRAM (depends on part fitted)
+0x10000000 - 0x1fffffff N N System control and peripheral registers
+0x20000000 - 0x23ffffff N N Boot ROM (contains boot Monitor)
+0x24000000 - 0x27ffffff N N FLASH ROM (contains RedBoot)
+0x28000000 - 0x2bffffff N N SSRAM echo area
+0x40000000 - 0x5fffffff N N PCI Memory access windows
+0x60000000 - 0x60ffffff N N PCI IO access window
+0x61000000 - 0x61ffffff N N PCI config space window
+0x62000000 - 0x6200ffff N N PCI bridge register window
+0x80000000 - 0x8fffffff N N SDRAM echo area (used for PCI accesses)
+
+</programlisting>
+</para>
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=integrator
+export ARCH_DIR=arm
+export PLATFORM_DIR=integrator
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2>
+</sect1>
+
+<?Pub _newpage>
+<sect1 id="pid">
+<title>ARM/ARM7+ARM9 ARM PID Board and EPI Dev7+Dev9</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>ARM ARM7 PID, Dev7 and Dev9</primary><secondary>
+installing and testing</secondary></indexterm><indexterm><primary>installing
+and testing</primary><secondary>ARM ARM7 PID, Dev7 and Dev9</secondary></indexterm>RedBoot
+uses either of the serial ports. The default serial port settings are 38400,8,N,1.
+Management of onboard flash is also supported.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+</sect2>
+
+<sect2>
+<title>Initial Installation Method </title>
+<para>Device programmer is used to program socketed flash parts with ROM version
+of RedBoot. </para>
+<para>Alternatively, to install RedBoot on a target that already has eCos
+GDB stubs, download the RAM mode image of RedBoot and run it. Initialize the
+flash image directory: <command>fis init</command> Then
+download the ROM version of RedBoot and program it into flash: <screen>
+RedBoot> <userinput>load -b %{FREEMEMLO} -m ymodem</userinput>
+RedBoot> <userinput>fi cr RedBoot</userinput>
+</screen></para>
+</sect2>
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>None.</para>
+</sect2>
+<sect2>
+<title>Memory Maps </title>
+<para>RedBoot sets up the following memory map on the PID board. <programlisting>
+Physical Address Range Description
+----------------------- -----------
+0x00000000 - 0x0007ffff DRAM
+0x04000000 - 0x04080000 flash
+0x08000000 - 0x09ffffff ASB Expansion
+0x0a000000 - 0x0bffffff APB Reference Peripheral
+0x0c000000 - 0x0fffffff NISA Serial, Parallel and PC Card ports </programlisting></para>
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=pid
+export ARCH_DIR=arm
+export PLATFORM_DIR=pid
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2></sect1>
+
+<?Pub _newpage>
+<sect1 id="at91">
+<title>ARM/ARM7 Atmel AT91 Evaluation Boards (EBXX)</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Atmel AT91/EBXX</primary>
+<secondary>installing and testing</secondary></indexterm><indexterm><primary>
+installing and testing</primary><secondary>Atmel AT91/EBXX
+</secondary></indexterm>
+RedBoot support is available for the EB40, EB40A, EB42 and EB55
+boards. By default all these boards are shipped with only 256Kbytes of
+RAM. To minimize the amount of RAM used by RedBoot, only very basic
+flash management is provided, comprising of just the <command>fis
+erase</command> and <command>fis write</command> commands.
+</para>
+<para>
+RedBoot supports both serial ports. On all AT91 evaluation boards, serial
+port A requires a straight through cable to connect with a PC, whereas
+serial port B requires a null modem cable. If you fail to be able to
+connect to Angel in the instructions below when installing RedBoot, be
+sure to verify you are using the appropriate cable for the serial port.
+The default serial port settings for RedBoot are 38400,8,N,1.
+</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+ <row>
+ <entry>ROMRAM</entry>
+ <entry>[ROMRAM]</entry>
+ <entry>RedBoot running from RAM, but contained in the
+ board's flash boot sector.</entry>
+ <entry>redboot_ROMRAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+</sect2>
+
+<sect2>
+<title>Initial Installation Method </title>
+<para>
+RedBoot installation is essentially the same for all boards, however
+the details differ slightly. Please make sure you follow the
+directions from the correct section below. Any errors could result in
+an unusable board.
+</para>
+
+<sect3>
+<title>Installing RedBoot on the EB40</title>
+<para>
+This development board comes with ARM's debug tool, Angel, installed
+in flash. At this time, Angel will not be replaced. Rather, RedBoot
+will be placed in the alternate half of flash. Switch SW1 is used to
+select which monitor to boot. Once RedBoot is installed, selecting SW1
+to <literal>lower mem</literal> will choose Angel, whereas selecting
+SW1 to <literal>upper mem</literal> will choose RedBoot.
+</para>
+<para>
+Set SW1 to <literal>lower mem</literal> and connect serial port A to a
+host computer. Using GDB from the host and Angel on the board,
+download and run the RAM mode image of RedBoot to the board.
+<screen>
+<userinput>arm-elf-gdb redboot_RAM.elf</userinput>
+(gdb) <userinput>tar rdi s=/dev/ttyS0</userinput>
+Angel Debug Monitor (serial) 1.04 (Advanced RISC Machines SDT 2.5) for
+AT91EB40 (2.00)
+Angel Debug Monitor rebuilt on Apr 07 2000 at 12:40:31
+Serial Rate: 9600
+Connected to ARM RDI target.
+(gdb) <userinput>set $cpsr=0xd3</userinput>
+(gdb) <userinput>load</userinput>
+Loading section .rom_vectors, size 0x40 lma 0x2020000
+Loading section .text, size 0x7fd8 lma 0x2020040
+Loading section .rodata, size 0x15a0 lma 0x2028018
+Loading section .data, size 0x2e4 lma 0x20295b8
+Start address 0x2020040 , load size 39068
+Transfer rate: 6250 bits/sec, 500 bytes/write.
+(gdb) <userinput>cont</userinput>
+Continuing.
+</screen>
+Once RedBoot is started, the GDB session connected with Angel
+must be suspended (this can be done using Ctrl-Z) or terminated
+(with Ctrl-C or the Windows task manager). Follow this
+by connecting to the board using a terminal emulator such as
+hyperterminal or minicom at 38400-8N1. At this point, RedBoot will be running on the board in
+RAM.
+<screen>
+RedBoot> <userinput>version</userinput>
+
+RedBoot(tm) bootstrap and debug environment [RAM]
+Non-certified release, version UNKNOWN - built 14:09:27, Jul 20 2001
+
+Platform: Atmel AT91/EB40 (ARM7TDMI)
+Copyright (C) 2000, 2001, Free Software Foundation, Inc.
+
+RAM: 0x02000000-0x02080000, 0x020116d8-0x0207fd00 available
+FLASH: 0x01010000 - 0x01020000, 256 blocks of 0x00000100 bytes each.
+
+RedBoot>
+</screen>
+Now, download the ROM mode image.
+<screen>
+RedBoot> <userinput>load -m ymodem -b %{FREEMEMLO}</userinput>
+</screen>
+Use your terminal emulator to send the file redboot_ROM.srec via YModem.
+e.g. <literal>Transfer->Send File</literal> in Hyperterminal, or
+<literal>Ctrl-A S</literal> in minicom.
+Finally, program it to flash.
+<screen>
+RedBoot> <userinput>fi wr -f 0x01010000 -b %{FREEMEMLO} -l 0xe100</userinput>
+</screen>
+SW1 should now be set to <literal>upper mem</literal> to select booting
+with RedBoot rather than Angel. Finally, press the "reset" pushbutton and
+RedBoot should come up on the board.
+</para>
+</sect3>
+
+<sect3>
+<title>Installing RedBoot on the EB40A, EB42 or EB55</title>
+<para>
+These development boards come with ARM's debug tool, Angel, installed
+in flash. At this time, Angel will not be replaced. Rather, RedBoot
+will be placed in the alternate half of flash. Jumper JP1 is used to
+select which monitor to boot. Once RedBoot is installed, setting JP1
+to <literal>STD</literal> will choose Angel, whereas setting JP1 to
+<literal>USER</literal> will choose RedBoot.
+</para>
+<para>
+Set JP1 to <literal>STD</literal> and connect serial port A to a host
+computer. Using GDB from the host and Angel on the board, download
+the RAM mode image of RedBoot to the board, and start it using the
+'cont' command.
+<screen>
+<userinput>arm-elf-gdb redboot_RAM.elf</userinput>
+(gdb) <userinput>tar rdi s=/dev/ttyS0</userinput>
+Angel Debug Monitor (serial) 1.04 (Advanced RISC Machines SDT 2.5) for AT91EB55 (2.20)
+Angel Debug Monitor rebuilt on Feb 03 2002 at 16:10:20
+Serial Rate: 9600
+Connected to ARM RDI target.
+(gdb) <userinput>set $cpsr=0xd3</userinput>
+(gdb) <userinput>load</userinput>
+Loading section .rom_vectors, size 0x40 lma 0x2008000
+Loading section .text, size 0xb0b8 lma 0x2008040
+Loading section .rodata, size 0x1c27 lma 0x20130f8
+Loading section .data, size 0x5f0 lma 0x2014d20
+Start address 0x2008040, load size 54031
+Transfer rate: 6264 bits/sec, 500 bytes/write.
+(gdb) <userinput>cont</userinput>
+Continuing.
+</screen>
+Once RedBoot is started, the GDB session connected with Angel must be
+suspended (this can be done using Ctrl-Z) or terminated
+(with Ctrl-C or the Windows task manager). Follow this by connecting to
+the board using a terminal emulator such as hyperterminal or minicom
+at 38400-8N1. At this point, RedBoot will be running on the board in
+RAM.
+<screen>
+RedBoot> <userinput>version</userinput>
+
+RedBoot(tm) bootstrap and debug environment [RAM]
+Non-certified release, version UNKNOWN - built 16:58:52, May 7 2003
+
+Platform: Atmel AT91/EB55 (ARM7TDMI)
+Copyright (C) 2000, 2001, 2002, Free Software Foundation, Inc.
+
+RAM: 0x02000000-0x02040000, 0x020068a8-0x0203f000 available
+FLASH: 0x01010000 - 0x01200000, 31 blocks of 0x00010000 bytes each.
+
+RedBoot>
+</screen>
+Now, download the ROM mode image.
+<screen>
+RedBoot> <userinput>load -m ymodem -b %{FREEMEMLO}</userinput>
+</screen>
+Use your terminal emulator to send the file redboot_ROM.srec via YModem.
+e.g. <literal>Transfer->Send File</literal> in Hyperterminal, or
+<literal>Ctrl-A S</literal> in minicom.
+Finally, program it to flash.
+<screen>
+RedBoot> <userinput>fi wr -f 0x01100000 -b %{FREEMEMLO} -l 0x10000</userinput>
+</screen>
+Set JP1 to the <literal>USER</literal> setting, press the "reset"
+pushbutton and RedBoot should come up on the board.
+</para>
+</sect3>
+
+
+</sect2>
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>None.</para>
+</sect2>
+<sect2>
+<title>Memory Maps </title>
+<para>This processor has no MMU, so the only memory map is for
+physical addresses.
+</para>
+<para>
+The memory layout of the EB40 is as follows:
+<programlisting>
+Physical Address Range Description
+----------------------- ----------------------------------
+0x00000000 - 0x00000fff On-chip SRAM
+0x01000000 - 0x0101ffff Flash
+0x02000000 - 0x0207ffff RAM
+0xffe00000 - 0xffffffff I/O registers
+</programlisting>
+
+The flash based RedBoot image occupies virtual addresses 0x01010000 - 0x0101dfff.
+</para>
+
+<para>
+The memory layout of the EB40A is as follows:
+<programlisting>
+Physical Address Range Description
+----------------------- ----------------------------------
+0x00000000 - 0x0003ffff On-chip SRAM
+0x01000000 - 0x011fffff Flash
+0x02000000 - 0x02ffffff External SRAM (optional)
+0xffe00000 - 0xffffffff I/O registers
+</programlisting>
+
+The flash based RedBoot image occupies virtual addresses 0x01100000 - 0x0110ffff.
+</para>
+
+<para>
+The memory layout of the EB42 and EB55 is as follows:
+<programlisting>
+Physical Address Range Description
+----------------------- ----------------------------------
+0x00000000 - 0x00001fff On-chip SRAM
+0x01000000 - 0x011fffff Flash
+0x02000000 - 0x0203ffff RAM
+0xffe00000 - 0xffffffff I/O registers
+</programlisting>
+
+The flash based RedBoot image occupies virtual addresses 0x01100000 - 0x0110ffff.
+</para>
+
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export ARCH_DIR=arm
+
+export TARGET=eb40
+export PLATFORM_DIR=at91/eb40
+
+export TARGET=eb40a
+export PLATFORM_DIR=at91/eb40a
+
+export TARGET=eb42
+export PLATFORM_DIR=at91/eb42
+
+export TARGET=eb55
+export PLATFORM_DIR=at91/eb55
+</programlisting>
+
+Use just one of the <literal>TARGET</literal> and
+<literal>PLATFORM_DIR</literal> variable pairs only.
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+<para>When reprogramming RedBoot using RedBoot itself, you should
+load a RedBoot RAM image as normal, and load the new ROM image
+into RAM. However before programming the new image into Flash
+you <emphasis>must</emphasis> switch SW1 to lower mem (EB40)
+or set JP1 to STD (EB40A, EB42, EB55) before writing to Flash.
+</para>
+
+<warning><title>Warning!</title><para>Failure to set SW1 to
+<literal>lower mem</literal> (EB40) or JP1 to
+<literal>STD</literal> (EB40A, EB42, EB55) will cause the
+installation of RedBoot to overwrite Angel, thus making the board
+<emphasis>unbootable</emphasis>. Only hardware JTAG can restore the
+board once in this state.
+</para></warning>
+</sect2>
+</sect1>
+
+<?Pub _newpage>
+<sect1 id="at91jtst">
+<title>ARM/ARM7 Atmel JTST Evaluation Board (AT572D740-DK1)</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Atmel AT91/JTST</primary>
+<secondary>installing and testing</secondary></indexterm><indexterm><primary>
+installing and testing</primary><secondary>Atmel AT91/JTST
+</secondary></indexterm>
+RedBoot support is available for the JTST board.
+By default this board is shipped with 256Kbytes of
+external SRAM. To minimize the amount of RAM used by RedBoot, only very basic
+flash management is provided, comprising of just the <command>fis
+erase</command> and <command>fis write</command> commands.
+</para>
+<para>
+RedBoot supports two serial ports.
+The default serial port settings for RedBoot are 115200,8,N,1.
+</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+</sect2>
+<sect2>
+<title>Installing a RedBoot image on the JTST</title>
+<para>
+This development board comes with RedBoot installed on flash. To
+install a new version of RedBoot or another binary image in flash you
+must start a GDB session setting a remote target and load and run the
+<command>jtstflashd.elf</command> diopsis application. This is a
+daemon that listens on JTST serial port 1. On the PC side you must use
+the <command>jtstflash.exe</command> (both linux and windows PC are
+supported) to flash the image on JTST. The sources for win32 and
+linux/cygwin versions of this host tool can be found in the support
+directory of the jtst hal. The binaries can be found along with the
+binaries for redboot on the eCos website at
+<ulink url="http://ecos.sourceware.org/ecos/boards/redbootbins/at91jtst/index.html">
+http://ecos.sourceware.org/ecos/boards/redbootbins/at91jtst/</ulink>
+</para>
+<para>
+When the jtstflashd.elf is started, the user should open the jumper
+JP5 to write in the second half (512Kbytes) of the flash, in this way
+the original RedBoot image is preserved.
+</para>
+<sect3>
+<title>GDB console</title>
+<screen>
+<userinput>arm-elf-gdb jtstflash.elf</userinput>
+(gdb) <userinput>set remotebaud 115200</userinput>
+(gdb) <userinput>target remote /dev/ttyS0</userinput>
+Remote debugging using /dev/ttyS0
+0x00502a44 in ?? ()
+(gdb) <userinput>load</userinput>
+Loading section .internal_vectors, size 0x1c4 lma 0x160
+Loading section .rom_vectors, size 0x40 lma 0x606000
+Loading section .text, size 0x14198 lma 0x606040
+Loading section .rodata, size 0xb6c lma 0x61a1d8
+Loading section .data, size 0x498 lma 0x61ad44
+Start address 0x606040, load size 86944
+Transfer rate: 77283 bits/sec, 301 bytes/write.
+(gdb) <userinput>c</userinput>
+Continuing.
+* JTST FLASH PROGRAMMER
+* opening usart port 1
+...
+</screen>
+</sect3>
+<sect3>
+<title>PC console</title>
+<screen>
+<userinput>jtstflash mybinaryimage.bin</userinput>
+* binary len 79536 bytes flash add 0x500000..
+* flash id check ok
+* erasing space address 0x500000... please wait
+* flash erase check ok
+* start programming 79536 bytes.
+</screen>
+</sect3>
+</sect2>
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>None.</para>
+</sect2>
+<sect2>
+<title>Memory Maps </title>
+<para>This processor has no MMU, so the only memory map is for
+physical addresses.
+</para>
+<para>
+The memory layout of the JTST after bootstrap is as follows:
+<programlisting>
+Physical Address Range Description
+----------------------- ----------------------------------
+0x00000000 - 0x00007fff On-chip SRAM
+0x00500000 - 0x0057ffff Flash
+0x00600000 - 0x0063ffff External SRAM
+0x00410000 - 0x0042fffc On-chip Magic Data Memory Left
+0x00430000 - 0x0043fffc On-chip Magic Data Memory Right
+0x00430000 - 0x0044fffc On-chip Magic Program Memory
+0x00490000 - 0x00490ffc On-chip Arm/Magic Data Exchange Left
+0x004A0000 - 0x004A0ffc On-chip Arm/Magic Data Exchange Right
+0x00450000 - 0x0045003c Magic I/O registers
+0x00460000 - 0x0046000c Magic Control registers
+0xffe00000 - 0xffffffff I/O registers
+</programlisting>
+</para>
+</sect2>
+</sect1>
+
+<?Pub _newpage>
+<sect1 id="edb7xxx">
+<title>ARM/ARM7 Cirrus Logic EP7xxx (EDB7211, EDB7212, EDB7312) </title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Cirrus Logic EP7xxx (EDB7211, EDB7212, EDB7312)</primary>
+<secondary>installing and testing</secondary></indexterm><indexterm><primary>
+installing and testing</primary><secondary>Cirrus Logic EP7xxx (EDB7211, EDB7212, EDB7312)
+</secondary></indexterm>RedBoot supports both serial ports on the board and
+the ethernet port. The default serial port settings are 38400,8,N,1. RedBoot
+also supports flash management on the EDB7xxx for the NOR flash
+only.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+ <row>
+ <entry>ROMRAM</entry>
+ <entry>[ROMRAM]</entry>
+ <entry>RedBoot running from RAM, but contained in the
+ board's flash boot sector (EDB7312 only).</entry>
+ <entry>redboot_ROMRAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+</sect2>
+<sect2>
+<title>Initial Installation Method </title>
+<para>A Windows or Linux utility is used to program flash using serial port
+#1 via on-chip programming firmware. See board documentation for details on
+in situ flash programming. </para>
+</sect2>
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>None.</para>
+</sect2>
+<sect2>
+<title>Memory Maps </title>
+<para>The MMU page tables and LCD display buffer, if enabled, are located
+at the end of DRAM. <note><title>NOTE
+</title>
+<para>The virtual memory maps in this section use a C and B column to indicate
+whether or not the region is cached (C) or buffered (B).</para>
+</note><programlisting>
+Physical Address Range Description
+----------------------- ----------------------------------
+0x00000000 - 0x01ffffff NOR Flash (EDB7211, EDB7212)
+0x00000000 - 0x00ffffff NOR Flash (EDB7312)
+0x10000000 - 0x11ffffff NAND Flash
+0x20000000 - 0x2fffffff Expansion 2
+0x30000000 - 0x3fffffff Expansion 3
+0x40000000 - 0x4fffffff PCMCIA 0
+0x50000000 - 0x5fffffff PCMCIA 1
+0x60000000 - 0x600007ff On-chip SRAM
+0x80000000 - 0x8fffffff I/O registers
+0xc0000000 - 0xc1ffffff DRAM (EDB7211, EDB7212)
+0xc0000000 - 0xc0ffffff DRAM (EDB7312)
+
+Virtual Address Range C B Description
+----------------------- - - ----------------------------------
+0x00000000 - 0x01ffffff Y Y DRAM
+0x00000000 - 0x00fcffff Y Y DRAM (EDB7312)
+0x20000000 - 0x2fffffff N N Expansion 2
+0x30000000 - 0x3fffffff N N Expansion 3
+0x40000000 - 0x4fffffff N N PCMCIA 0
+0x50000000 - 0x5fffffff N N PCMCIA 1
+0x60000000 - 0x600007ff Y Y On-chip SRAM
+0x80000000 - 0x8fffffff N N I/O registers
+0xc0000000 - 0xc001ffff N Y LCD buffer (if configured)
+0xe0000000 - 0xe1ffffff Y Y NOR Flash (EDB7211, EDB7212)
+0xe0000000 - 0xe0ffffff Y Y NOR Flash (EDB7312)
+0xf0000000 - 0xf1ffffff Y Y NAND Flash
+
+The flash based RedBoot image occupies virtual addresses 0xe0000000 - 0xe003ffff.
+</programlisting></para>
+</sect2>
+<sect2>
+<title>Platform Resource Usage</title>
+<para>The EP7xxx timer #2 is used as a polled timer to provide timeout support
+for network and XModem file transfers.</para>
+</sect2><sect2>
+
+<title>Rebuilding RedBoot</title>
+
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=edb7211
+export TARGET=edb7212
+export TARGET=edb7312
+export ARCH_DIR=arm
+export PLATFORM_DIR=edb7xxx
+</programlisting>
+
+Use one of the TARGET settings only.
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2>
+</sect1>
+
+<?Pub _newpage>
+<sect1 id="aaed2000">
+<title>ARM/ARM9 Agilent AAED2000</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Agilent AAED2000 ARM9 (aaed)</primary>
+<secondary>installing and testing</secondary></indexterm><indexterm><primary>
+installing and testing</primary><secondary>Agilent AAED2000 ARM9 (aaed)
+</secondary></indexterm>RedBoot supports the serial and ethernet ports
+on the board. The default serial port settings are 38400,8,N,1.
+RedBoot also supports flash management on the AAED2000.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROMRAM</entry>
+ <entry>[ROMRAM]</entry>
+ <entry>RedBoot running from RAM, but contained in the
+ board's flash boot sector.</entry>
+ <entry>redboot_primary_ROMRAM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_primary_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+</sect2>
+
+<sect2>
+<title>Initial Installation Method </title>
+<para>It is possible to install RedBoot in one of two ways. Either as
+the primary bootmonitor on the board (installed to blocks 0-1 of the
+flash) or as the secondary bootmonitor on the board (installed to
+blocks 1-2 of the flash).</para>
+
+<para>Presently, only the former method is supported.</para>
+<!-- Nuke the above line if uncommenting this block
+<para>When installed as the secondary bootmonitor, the ARM bootmonitor
+remains in flash and auto-executes RedBoot (but only when RedBoot is
+smaller than 128KB - which means it cannot include the LCD driver).
+It is of crucial importance that no RedBoot configured to be
+primary bootmonitor is executed on a board where RedBoot is actually
+supposed to be the secondary bootmonitor since it may cause corruption
+of the flash. Installing RedBoot as the primary booter is
+adviced.</para>
+-->
+
+<sect3><title>RedBoot as Primary Bootmonitor</title>
+
+<para>RedBoot is installed in flash using the on-board ARM Boot
+Monitor.</para>
+<para>Boot the board while pressing SPACE. This should bring up the
+Boot Monitor:
+<screen>ARM bootPROM [Version 1.3] Rebuilt on Jul 16 2001 at 16:21:36
+Running on a P920 board Evaluation Board
+Board Revision V1.0, ARM920T processor Processor
+Memory Size is 32MBytes, Flash Size is 32MBytes
+Copyright (c) ARM Limited 1999 - 2001. All rights reserved.
+Board designed by ARM Limited
+Hardware support provided at http://www.arm.com/
+For help on the available commands type ? or h
+boot Monitor >
+</screen>
+
+Download the RAM mode image of RedBoot configured as a primary
+bootmonitor using the ARM bootmonitor's SREC-download command:
+
+<screen>boot Monitor &gt; <userinput>m</userinput>
+Load Motorola S-Record image into memory and execute it
+The S-Record loader only accepts input on the serial port.
+Record addresses must be between 0x00008000 and 0x01E0F510.
+Type Ctrl/C to exit loader.
+</screen>
+
+Use the terminal emulator's ASCII upload command, or (on Linux) simply
+cat the file to the serial port:
+
+<screen>$ <userinput>cat redboot_primary_RAM/redboot.srec &gt;/dev/ttyS1</userinput>
+</screen>
+
+You should see RedBoot start up:
+
+<screen>FLASH configuration checksum error or invalid key
+Ethernet eth0: MAC address 00:30:d3:03:04:99
+IP: 192.168.42.111, Default server: 192.168.42.3
+
+RedBoot(tm) bootstrap and debug environment [RAM]
+Non-certified release, version UNKNOWN - built 13:15:40, Nov 9 2001
+
+Platform: AAED2000 system (ARM9) [Primary]
+Copyright (C) 2000, 2001, Free Software Foundation, Inc.
+
+RAM: 0x00000000-0x01f80000, 0x0006f208-0x01f51000 available
+FLASH: 0x60000000 - 0x62000000, 256 blocks of 0x00020000 bytes each.
+RedBoot></screen>
+
+As can be seen from the output above, the network has been configured
+to give the board an IP address and information about the default
+server. If things are not set up on your network, you can still
+continue, but use the Y-modem download method when loading the RedBoot
+ROMRAM mode image.
+
+Now initialize RedBoot's FIS:
+
+<screen>RedBoot&gt; <userinput>fis init</userinput>
+About to initialize [format] FLASH image system - continue (y/n)? <userinput>y</userinput>
+*** Initialize FLASH Image System
+ Warning: device contents not erased, some blocks may not be usable
+... Erase from 0x61fe0000-0x62000000: .
+... Program from 0x01f5f000-0x01f5f300 at 0x61fe0000: .
+</screen>
+
+Download the ROMRAM mode image of RedBoot via ethernet:
+
+<screen>RedBoot&gt; <userinput>load -b %{FREEMEMLO} redboot_primary_ROMRAM/redboot.srec</userinput>
+</screen>
+
+or using serial Y-modem protocol:
+
+<screen>RedBoot&gt; <userinput>load -mode ymodem -b %{FREEMEMLO}</userinput>
+</screen>
+
+(Use the terminal emulator's Y-modem upload command to send the file
+<filename>redboot_primary_ROMRAM/redboot.srec</filename>.)
+
+When the image has been downloaded, program it into flash:
+
+<screen>Address offset = 0x00ff8000
+Entry point: 0x00008040, address range: 0x00008000-0x0002da80
+RedBoot&gt; <userinput>fi cr RedBoot</userinput>
+An image named 'RedBoot' exists - continue (y/n)? <userinput>y</userinput>
+* CAUTION * about to program 'RedBoot'
+ at 0x60000000..0x6003ffff from 0x00100000 - continue (y/n)? <userinput>y</userinput>
+... Erase from 0x60000000-0x60040000: ..
+... Program from 0x00100000-0x00140000 at 0x60000000: ..
+... Erase from 0x61fe0000-0x62000000: .
+... Program from 0x01f5f000-0x01f7f000 at 0x61fe0000: .
+</screen>
+
+Now reset the board. You should see the RedBoot banner.</para>
+
+</sect3>
+
+<!--
+<sect3><title>RedBoot as Secondary Bootmonitor</title>
+
+<para>RedBoot is installed in flash using the on-board ARM Boot
+Monitor.</para>
+<para>Boot the board while pressing SPACE. This should bring up the
+Boot Monitor:
+<screen>ARM bootPROM [Version 1.3] Rebuilt on Jul 16 2001 at 16:21:36
+Running on a P920 board Evaluation Board
+Board Revision V1.0, ARM920T processor Processor
+Memory Size is 32MBytes, Flash Size is 32MBytes
+Copyright (c) ARM Limited 1999 - 2001. All rights reserved.
+Board designed by ARM Limited
+Hardware support provided at http://www.arm.com/
+For help on the available commands type ? or h
+boot Monitor >
+</screen>
+
+Download the RAM mode image of RedBoot configured as a secondary
+bootmonitor using the ARM bootmonitor's SREC-download command:
+
+<screen>boot Monitor &gt; <userinput>m</userinput>
+Load Motorola S-Record image into memory and execute it
+The S-Record loader only accepts input on the serial port.
+Record addresses must be between 0x00008000 and 0x01E0F510.
+Type Ctrl/C to exit loader.
+</screen>
+
+Use the terminal emulator's ASCII upload command, or (on Linux) simply
+cat the file to the serial port:
+
+<screen>$ <userinput>cat redboot_secondary_RAM.srec &gt;/dev/ttyS1</userinput>
+</screen>
+
+You should see RedBoot start up:
+
+<screen>FLASH configuration checksum error or invalid key
+Ethernet eth0: MAC address 00:30:d3:03:04:99
+IP: 192.168.42.111, Default server: 192.168.42.3
+
+RedBoot(tm) bootstrap and debug environment [RAM]
+Non-certified release, version UNKNOWN - built 12:31:13, Nov 9 2001
+
+Platform: AAED2000 system (ARM9) [Secondary]
+Copyright (C) 2000, 2001, Free Software Foundation, Inc.
+
+RAM: 0x00000000-0x01f80000, 0x00063568-0x01f51000 available
+FLASH: 0x60000000 - 0x62000000, 256 blocks of 0x00020000 bytes each.
+</screen>
+
+As can be seen from the output above, the network has been configured
+to give the board an IP address and information about the default
+server. If things are not set up on your network, you can still
+continue, but use the Y-modem download method when loading the RedBoot
+ROMRAM mode image.
+
+Next step is to erase all of the flash, except where the ARM booter resides:
+
+<screen>RedBoot&gt; <userinput>fi erase -f 0x60020000 -l 0x01fe0000</userinput>
+... Erase from 0x60020000-0x62000000: ..........................................
+................................................................................
+................................................................................
+.....................................................
+</screen>
+
+Then initialize RedBoot's FIS:
+
+<screen>RedBoot&gt; <userinput>fi init</userinput>
+About to initialize [format] FLASH image system - continue (y/n)? <userinput>y</userinput>
+*** Initialize FLASH Image System
+ Warning: device contents not erased, some blocks may not be usable
+... Erase from 0x61fc0000-0x61fe0000: .
+... Program from 0x01fdf000-0x01fff000 at 0x61fc0000: .
+</screen>
+
+Download the ROMRAM mode RedBoot image via ethernet:
+
+<screen>RedBoot&gt; <userinput>load -raw -b %{FREEMEMLO} redboot_secondary_ROMRAM.arm.bin</userinput>
+</screen>
+
+or using serial Y-modem protocol:
+
+<screen>RedBoot&gt; <userinput>load -raw -mode ymodem -b %{FREEMEMLO}</userinput>
+</screen>
+
+(Use the terminal emulator's Y-modem upload command to send the file
+<filename>redboot_secondary_ROMRAM.arm.bin</filename>.)
+
+When the image has been downloaded, program it into flash:
+
+<screen>RedBoot&gt; <userinput>fi cr RedBoot</userinput>
+An image named 'RedBoot' exists - continue (y/n)? <userinput>y</userinput>
+* CAUTION * about to program 'RedBoot'
+ at 0x60020000..0x6005ffff from 0x00100000 - continue (y/n)? <userinput>y</userinput>
+... Erase from 0x60020000-0x60060000: ..
+... Program from 0x00100000-0x00140000 at 0x60020000: ..
+... Erase from 0x61fc0000-0x61fe0000: .
+... Program from 0x01f5f000-0x01f7f000 at 0x61fc0000: .
+</screen>
+
+Now reset the board. You might see the ARM Monitor complain:
+
+<screen>Failed to boot from flash.
+The ARM Boot Monitor SIB can not be found.
+Press any key to continue.
+</screen>
+
+This is due to due to the flash having been erased. Press a key, and
+execute the "validate flash contents" command:
+
+<screen>boot Monitor &gt; <userinput>v</userinput>
+
+There are 254 128KByte blocks of Application Flash:
+
+No images found!
+================
+
+System Information Blocks
+=========================
+Address Owner Size Idx Rev
+~~~~~~~ ~~~~~ ~~~~ ~~~ ~~~
+0x05FE0000 ARM Boot Monitor 312 0 0
+
+
+Blocks of unknown type
+======================
+Block Size Footer Type
+~~~~~ ~~~~ ~~~~~~~~~~~
+ 252 1 0x52420000
+boot Monitor &gt;
+</screen>
+
+This causes the last block of the flash to be initialized with the ARM
+Boot Monitor ID, necessary for the Monitor to work properly. When
+resetting the board now, it should automatically start RedBoot. If you
+ever need to get into the ARM Boot Monitor again, reset the board
+while pressing the SPACE key.
+
+</para></sect3>
+-->
+
+</sect2>
+
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>The <command>exec</command> command which allows the loading
+and execution of Linux kernels,
+is supported for this board (see <xref linkend="executing-programs">). The <command>
+exec</command> parameters used for the AAED2000 are:</para>
+<variablelist><varlistentry>
+<term>-b <replaceable>&lt;addr></replaceable></term>
+<listitem><para>Location Linux kernel was loaded to</para></listitem></varlistentry>
+<varlistentry><term>
+-l <replaceable>&lt;len></replaceable></term>
+<listitem><para>Length of kernel</para></listitem></varlistentry>
+<varlistentry><term>
+-c <replaceable>"params"</replaceable></term>
+<listitem><para>Parameters passed to kernel</para></listitem></varlistentry>
+<varlistentry><term>-r <replaceable>&lt;addr></replaceable></term>
+<listitem><para>'initrd' ramdisk location</para></listitem></varlistentry>
+<varlistentry><term>-s <replaceable>&lt;len></replaceable></term>
+<listitem><para>Length of initrd ramdisk</para></listitem></varlistentry>
+</variablelist>
+
+<para>The parameters for kernel image base and size are automatically
+set after a load operation. So one way of starting the kernel would
+be:
+
+<screen>RedBoot&gt; <userinput>load -r -b 0x100000 zImage</userinput>
+Raw file loaded 0x00100000-0x001a3d6c
+RedBoot&gt; exec -c "console=ttyAC0,38400"
+Using base address 0x00100000 and length 0x000a3d6c
+Uncompressing Linux.....
+</screen>
+
+An image could also be put in flash and started directly:
+
+<screen>RedBoot&gt; <userinput>exec -b 0x60040000 -l 0xc0000 -c "console=ttyAC0,38400"</userinput>
+Uncompressing Linux.....
+</screen>
+
+</para>
+
+</sect2>
+<sect2>
+<title>Memory Maps </title>
+<para>The MMU page tables are located at 0x4000. <note><title>NOTE
+</title>
+<para>The virtual memory maps in this section use a C and B column to indicate
+whether or not the region is cached (C) or buffered (B).</para>
+</note><programlisting>Physical Address Range Description
+----------------------- ----------------------------------
+0x00000000 - 0x01ffffff Flash
+0x10000000 - 0x100fffff Ethernet
+0x30000000 - 0x300fffff Board registers
+0x40000000 - 0x4fffffff PCMCIA Slot (0)
+0x50000000 - 0x5fffffff Compact Flash Slot (1)
+0x80000000 - 0x800037ff I/O registers
+0xb0060000 - 0xb00fffff On-chip SRAM
+0xf0000000 - 0xfd3fffff SDRAM
+
+Virtual Address Range C B Description
+----------------------- - - ----------------------------------
+0x00000000 - 0x01f7ffff Y Y SDRAM
+0x01f80000 - 0x01ffffff Y Y SDRAM (used for LCD frame buffer)
+0x10000000 - 0x100fffff N N Ethernet
+0x30000000 - 0x300fffff N N Board registers
+0x40000000 - 0x4fffffff N N PCMCIA Slot (0)
+0x50000000 - 0x5fffffff N N Compact Flash Slot (1)
+0x60000000 - 0x61ffffff N N Flash
+0x80000000 - 0x800037ff N N I/O registers
+0xf0000000 - 0xffffffff N N SDRAM (uncached)
+
+</programlisting></para>
+
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=aaed
+export ARCH_DIR=arm
+export PLATFORM_DIR=arm9/aaed2000
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2>
+</sect1>
+
+<?Pub _newpage>
+<sect1 id="excaliburarm9">
+<title>ARM/ARM9 Altera Excalibur</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Altera Excalibur ARM9 (excalibur_arm9)</primary>
+<secondary>installing and testing</secondary></indexterm><indexterm><primary>
+installing and testing</primary><secondary>Altera Excalibur ARM9 (excalibur_arm9)
+</secondary></indexterm>RedBoot supports the serial port labelled
+P2 on the board. The default serial port settings are 57600,8,N,1. RedBoot
+also supports flash management on the Excalibur.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROMRAM</entry>
+ <entry>[ROMRAM]</entry>
+ <entry>RedBoot running from RAM, but contained in the
+ board's flash boot sector.</entry>
+ <entry>redboot_ROMRAM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+ <row>
+ <entry>REDBOOT</entry>
+ <entry>[ROMRAM]</entry>
+ <entry>RedBoot running from top of RAM, but contained in
+ the board's flash boot sector.</entry>
+ <entry>redboot_REDBOOT.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+<note> <title>NOTE</title>
+<para>RedBoot is currently hardwired to use a 128MB SDRAM SIMM module.
+</para>
+</note>
+</sect2>
+
+<sect2>
+<title>Initial Installation Method </title>
+<para>A Windows utility
+(<application>exc_flash_programmer.exe</application>) is used to
+program flash using the ByteBlasterMV JTAG unit.
+See board documentation for details on
+in situ flash programming. </para>
+<para>For ethernet to work (under Linux) the following jumper
+settings should be used on a REV 2 board: <literallayout>
+SW2-9 : OFF
+U179 : 2-3
+JP14-18 : OPEN
+JP40-41 : 2-3
+JP51-55 : 2-3
+</literallayout>
+</para>
+</sect2>
+<sect2>
+<title>Flash management</title>
+
+<para>The ROMRAM and REDBOOT configurations supported on this platform
+differ only in the memory layout (ROMRAM configuration runs RedBoot from
+0x00008000 while REDBOOT configuration runs RedBoot from 0x07f80000). The
+REDBOOT configuration allows applications to be loaded and run from
+address 0x00008000.</para>
+</sect2>
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>The <command>exec</command> command which allows the loading
+and execution of Linux kernels,
+is supported for this board (see <xref linkend="executing-programs">). The <command>
+exec</command> parameters used for the Excalibur are:</para>
+<variablelist><varlistentry>
+<term>-b <replaceable>&lt;addr></replaceable></term>
+<listitem><para>Location Linux kernel was loaded to</para></listitem></varlistentry>
+<varlistentry><term>
+-l <replaceable>&lt;len></replaceable></term>
+<listitem><para>Length of kernel</para></listitem></varlistentry>
+<varlistentry><term>
+-c <replaceable>"params"</replaceable></term>
+<listitem><para>Parameters passed to kernel</para></listitem></varlistentry>
+<varlistentry><term>-r <replaceable>&lt;addr></replaceable></term>
+<listitem><para>'initrd' ramdisk location</para></listitem></varlistentry>
+<varlistentry><term>-s <replaceable>&lt;len></replaceable></term>
+<listitem><para>Length of initrd ramdisk</para></listitem></varlistentry>
+</variablelist>
+
+<para>The parameters for kernel image base and size are automatically
+set after a load operation. So one way of starting the kernel would
+be:
+
+<screen>RedBoot&gt; <userinput>load -r -b 0x100000 zImage</userinput>
+Raw file loaded 0x00100000-0x001a3d6c
+RedBoot&gt; <userinput>exec -c "console=ttyUA0,57600"</userinput>
+Using base address 0x00100000 and length 0x000a3d6c
+Uncompressing Linux.....
+</screen>
+
+An image could also be put in flash and started directly:
+
+<screen>RedBoot&gt; <userinput>exec -b 0x40400000 -l 0xc0000 -c "console=ttyUA0,57600"</userinput>
+Uncompressing Linux.....
+</screen>
+
+</para>
+</sect2>
+<sect2>
+<title>Memory Maps </title>
+<para>The MMU page tables are located at 0x4000. <note><title>NOTE
+</title>
+<para>The virtual memory maps in this section use a C and B column to indicate
+whether or not the region is cached (C) or buffered (B).</para>
+</note><programlisting>Physical Address Range Description
+----------------------- ----------------------------------
+0x00000000 - 0x07ffffff SDRAM
+0x08000000 - 0x0805ffff On-chip SRAM
+0x40000000 - 0x40ffffff Flash
+0x7fffc000 - 0x7fffffff I/O registers
+0x80000000 - 0x8001ffff PLD
+
+Virtual Address Range C B Description
+----------------------- - - ----------------------------------
+0x00000000 - 0x07ffffff Y Y SDRAM
+0x08000000 - 0x0805ffff Y Y On-chip SRAM
+0x40000000 - 0x403fffff N Y Flash
+0x7fffc000 - 0x7fffffff N N I/O registers
+0x80000000 - 0x8001ffff N N PLD
+</programlisting></para>
+
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=excalibur_arm9
+export ARCH_DIR=arm
+export PLATFORM_DIR=arm9/excalibur
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2>
+</sect1>
+
+<?Pub _newpage>
+<sect1 id="ebsa285">
+<title>ARM/StrongARM(SA110) Intel EBSA 285</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Intel StrongArm EBSA 285</primary><secondary>installing
+and testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>Intel StrongArm EBSA 285</secondary></indexterm>RedBoot
+uses the single EBSA-285 serial port. The default serial port settings are
+38400,8,N,1. If the EBSA-285 is used as a host on a PCI backplane, ethernet
+is supported using an Intel PRO/100+ ethernet adapter. Management of
+onboard flash is also supported.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+</sect2>
+<sect2>
+<title>Initial Installation Method </title>
+<para>A linux application is used to program the flash over the PCI bus. Sources
+and build instructions for this utility are located in the RedBoot sources
+in: <filename class="directory">packages/hal/arm/ebsa285/current/support/linux/safl_util</filename>
+</para>
+</sect2>
+<sect2>
+<title>Communication Channels </title>
+<para>Serial, Intel PRO 10/100+ 82559 PCI ethernet card.</para>
+</sect2>
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>None.</para>
+</sect2>
+<sect2>
+<title>Memory Maps </title>
+<para>Physical and virtual mapping are mapped one to one on the EBSA-285 using
+a first level page table located at address 0x4000. No second level tables
+are used. <note><title>NOTE </title>
+<para>The virtual memory maps in this section use a C and B column to indicate
+whether or not the region is cached (C) or buffered (B).</para>
+</note><programlisting>Address Range C B Description
+----------------------- - - ----------------------------------
+0x00000000 - 0x01ffffff Y Y SDRAM
+0x40000000 - 0x400fffff N N 21285 Registers
+0x41000000 - 0x413fffff Y N flash
+0x42000000 - 0x420fffff N N 21285 CSR Space
+0x50000000 - 0x50ffffff Y Y Cache Clean
+0x78000000 - 0x78ffffff N N Outbound Write Flush
+0x79000000 - 0x7c0fffff N N PCI IACK/Config/IO
+0x80000000 - 0xffffffff N Y PCI Memory </programlisting></para>
+</sect2>
+<sect2>
+<title>Platform Resource Usage </title>
+<para>Timer3 is used as a polled timer to provide timeout support for networking
+and XModem file transfers.</para>
+</sect2>
+<!--
+<sect2>
+<title>Building eCos Test Cases to run with old RedBoots</title>
+<para>If using older versions of RedBoot, the default configuration for
+EBSA-285 will send diagnostic output to the serial line only, not over an ethernet
+connection. To allow eCos programs to use RedBoot to channel diagnostic output to
+GDB whether connected by net or serial, enable the configuration option <programlisting>
+CYGSEM_HAL_VIRTUAL_VECTOR_DIAG
+"Do diagnostic IO via virtual vector table"</programlisting> located here
+in the common HAL configuration tree: <programlisting>"eCos HAL"
+ "ROM monitor support"
+ "Enable use of virtual vector calling interface"
+ "Do diagnostic IO via virtual vector table"</programlisting>Other
+than that, no special configuration is required to use RedBoot. </para>
+<para>If you have been using built-in stubs to acquire support for thread-aware
+debugging, you can still do that, but you must only use the serial device
+for GDB connection and you must not enable the option mentioned above. However,
+it is no longer necessary to do that to get thread-awareness; RedBoot is thread
+aware.</para>
+</sect2>
+-->
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=ebsa285
+export ARCH_DIR=arm
+export PLATFORM_DIR=ebsa285
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2>
+</sect1>
+
+<?Pub _newpage>
+<sect1 id="brutus">
+<title>ARM/StrongARM(SA1100) Intel Brutus</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Intel-SA1100 (Brutus)</primary><secondary>installing
+and testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>Intel SA1100 (Brutus)</secondary></indexterm>RedBoot
+supports both board serial ports on the Brutus board. The default serial port
+settings are 38400,8,N,1. flash management is not currently supported. </para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+</sect2>
+<sect2>
+<title>Initial Installation Method </title>
+<para>Device programmer is used to program socketed flash parts.</para>
+</sect2>
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>None.</para>
+</sect2>
+<sect2>
+<title>Memory Maps </title>
+<para>The first level page table is located at physical address 0xc0004000.
+No second level tables are used.
+
+<note><title>NOTE</title>
+<para>The virtual memory maps in this section use a C and B column to indicate
+whether or not the region is cached (C) or buffered (B).</para>
+
+</note><programlisting>Physical Address Range Description
+----------------------- ----------------------------------
+0x00000000 - 0x000fffff Boot ROM
+0x08000000 - 0x083fffff Application flash
+0x10000000 - 0x100fffff SRAM
+0x18000000 - 0x180fffff Chip Select 3
+0x20000000 - 0x3fffffff PCMCIA
+0x80000000 - 0xbfffffff SA-1100 Internal Registers
+0xc0000000 - 0xc7ffffff DRAM Bank 0
+0xc8000000 - 0xcfffffff DRAM Bank 1
+0xd0000000 - 0xd7ffffff DRAM Bank 2
+0xd8000000 - 0xdfffffff DRAM Bank 3
+0xe0000000 - 0xe7ffffff Cache Clean
+
+
+Virtual Address Range C B Description
+----------------------- - - ----------------------------------
+0x00000000 - 0x003fffff Y Y DRAM Bank 0
+0x00400000 - 0x007fffff Y Y DRAM Bank 1
+0x00800000 - 0x00bfffff Y Y DRAM Bank 2
+0x00c00000 - 0x00ffffff Y Y DRAM Bank 3
+0x08000000 - 0x083fffff Y Y Application flash
+0x10000000 - 0x100fffff Y N SRAM
+0x20000000 - 0x3fffffff N N PCMCIA
+0x40000000 - 0x400fffff Y Y Boot ROM
+0x80000000 - 0xbfffffff N N SA-1100 Internal Registers
+0xe0000000 - 0xe7ffffff Y Y Cache Clean</programlisting></para>
+</sect2>
+<sect2>
+<title>Platform Resource Usage </title>
+<para>
+The SA11x0 OS timer is used as a polled timer to provide timeout
+support for XModem file transfers.</para>
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=brutus
+export ARCH_DIR=arm
+export PLATFORM_DIR=sa11x0/brutus
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2>
+</sect1>
+
+<?Pub _newpage>
+<sect1 id="sa1100mm">
+<title>ARM/StrongARM(SA1100) Intel SA1100 Multimedia Board </title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Intel SA1100 Multimedia Board</primary><secondary>
+installing and testing</secondary></indexterm><indexterm><primary>installing
+and testing</primary><secondary>Intel SA1100 Multimedia Board</secondary>
+</indexterm>RedBoot supports both board serial ports. The default serial port
+settings are 38400,8,N,1. flash management is also supported.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+</sect2>
+
+<sect2>
+<title>Initial Installation Method </title>
+<para>A device programmer is used to program socketed flash parts.</para>
+</sect2>
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>None.</para>
+</sect2>
+<sect2>
+<title>Memory Maps </title>
+<para>The first level page table is located at physical address 0xc0004000.
+No second level tables are used.<note><title>NOTE</title>
+<para>The virtual memory maps in this section use a C and B column to indicate
+whether or not the region is cached (C) or buffered (B).</para>
+</note><programlisting>Physical Address Range Description
+----------------------- ----------------------------------
+0x00000000 - 0x000fffff Boot flash
+0x08000000 - 0x083fffff Application flash
+0x10000000 - 0x107fffff SA-1101 Board Registers
+0x18000000 - 0x180fffff Ct8020 DSP
+0x18400000 - 0x184fffff XBusReg
+0x18800000 - 0x188fffff SysRegA
+0x18c00000 - 0x18cfffff SysRegB
+0x19000000 - 0x193fffff Spare CPLD A
+0x19400000 - 0x197fffff Spare CPLD B
+0x20000000 - 0x3fffffff PCMCIA
+0x80000000 - 0xbfffffff SA1100 Internal Registers
+0xc0000000 - 0xc07fffff DRAM Bank 0
+0xe0000000 - 0xe7ffffff Cache Clean
+Virtual Address Range C B Description
+
+
+----------------------- - - ----------------------------------
+0x00000000 - 0x007fffff Y Y DRAM Bank 0
+0x08000000 - 0x083fffff Y Y Application flash
+0x10000000 - 0x100fffff N N SA-1101 Registers
+0x18000000 - 0x180fffff N N Ct8020 DSP
+0x18400000 - 0x184fffff N N XBusReg
+0x18800000 - 0x188fffff N N SysRegA
+0x18c00000 - 0x18cfffff N N SysRegB
+0x19000000 - 0x193fffff N N Spare CPLD A
+0x19400000 - 0x197fffff N N Spare CPLD B
+0x20000000 - 0x3fffffff N N PCMCIA
+0x50000000 - 0x500fffff Y Y Boot flash
+0x80000000 - 0xbfffffff N N SA1100 Internal Registers
+0xc0000000 - 0xc07fffff N Y DRAM Bank 0
+0xe0000000 - 0xe7ffffff Y Y Cache Clean</programlisting></para>
+</sect2>
+<sect2>
+<title>Platform Resource Usage </title>
+<para> The SA11x0 OS timer is used as a polled timer to provide timeout support
+for XModem file transfers.</para>
+</sect2><sect2>
+
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=sa1100mm
+export ARCH_DIR=arm
+export PLATFORM_DIR=sa11x0/sa1100mm
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2>
+</sect1>
+
+
+
+<?Pub _newpage>
+<sect1 id="assabet">
+<title>ARM/StrongARM(SA1110) Intel SA1110 (Assabet) </title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Intel SA1110 (Assabet)</primary><secondary>installing
+and testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>Intel SA1110 (Assabet)</secondary></indexterm>RedBoot
+supports the board serial port and the compact flash ethernet port. The default
+serial port settings are 38400,8,N,1. RedBoot also supports flash management
+on the Assabet. </para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+</sect2>
+<sect2>
+<title>Initial Installation Method</title>
+<para>A Windows or Linux utility is used to program flash over parallel port
+driven JTAG interface. See board documentation for details on in situ flash
+programming. </para>
+<para>The flash parts are also socketed and may be programmed in a suitable
+device programmer.</para>
+</sect2>
+<sect2>
+<title>Special RedBoot Commands</title>
+<para>None.</para>
+</sect2>
+<sect2>
+<title>Memory Maps</title>
+<para>The first level page table is located at physical address 0xc0004000.
+No second level tables are used.<note><title>NOTE</title>
+<para>The virtual memory maps in this section use a C and B column to indicate
+whether or not the region is cached (C) or buffered (B).</para>
+</note><programlisting>Physical Address Range Description
+----------------------- ----------------------------------
+0x00000000 - 0x07ffffff flash
+0x08000000 - 0x0fffffff SA-1111 Board flash
+0x10000000 - 0x17ffffff Board Registers
+0x18000000 - 0x1fffffff Ethernet
+0x20000000 - 0x2fffffff SA-1111 Board PCMCIA
+0x30000000 - 0x3fffffff Compact Flash
+0x40000000 - 0x47ffffff SA-1111 Board
+0x48000000 - 0x4bffffff GFX
+0x80000000 - 0xbfffffff SA-1110 Internal Registers
+0xc0000000 - 0xc7ffffff DRAM Bank 0
+0xc8000000 - 0xcfffffff DRAM Bank 1
+0xd0000000 - 0xd7ffffff DRAM Bank 2
+0xd8000000 - 0xdfffffff DRAM Bank 3
+0xe0000000 - 0xe7ffffff Cache Clean
+
+
+Virtual Address Range C B Description
+----------------------- - - ----------------------------------
+0x00000000 - 0x01ffffff Y Y DRAM Bank 0
+0x08000000 - 0x0fffffff Y Y SA-1111 Board flash
+0x10000000 - 0x17ffffff N N Board Registers
+0x18000000 - 0x1fffffff N N Ethernet
+0x20000000 - 0x2fffffff N N SA-1111 Board PCMCIA
+0x30000000 - 0x3fffffff N N Compact Flash
+0x40000000 - 0x47ffffff N N SA-1111 Board
+0x48000000 - 0x4bffffff N N GFX
+0x50000000 - 0x57ffffff Y Y flash
+0x80000000 - 0xbfffffff N N SA-1110 Internal Registers
+0xc0000000 - 0xc1ffffff N Y DRAM Bank 0
+0xe0000000 - 0xe7ffffff Y Y Cache Clean
+</programlisting></para>
+</sect2>
+<sect2>
+<title>Platform Resource Usage </title>
+<para>The SA11x0 OS timer is used as a polled timer to provide timeout support
+for network and XModem file transfers.</para>
+</sect2><sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=assabet
+export ARCH_DIR=arm
+export PLATFORM_DIR=sa11x0/assabet
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2>
+</sect1>
+
+<?Pub _newpage>
+<sect1 id="nano">
+<title>ARM/StrongARM(SA11X0) Bright Star Engineering commEngine and nanoEngine</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>commEngine</primary><secondary>installing and testing
+</secondary></indexterm><indexterm><primary>nanoEngine</primary><secondary>
+installing and testing</secondary></indexterm><indexterm><primary>installing
+and testing</primary><secondary>commEngine</secondary></indexterm><indexterm>
+<primary>installing and testing</primary><secondary>nanoEngine</secondary>
+</indexterm>RedBoot supports a serial port and the built in ethernet port
+for communication and downloads. The default serial port settings are 38400,8,N,1.
+RedBoot runs from and supports flash management for the system flash
+region.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>POST</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the first free flash block
+ at 0x40000.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+</sect2>
+<sect2>
+<title>Initial Installation</title>
+<para>Unlike other targets, the nanoEngine comes equipped with boot firmware
+which you cannot modify. See chapter 5, "nanoEngine Firmware" of the <citetitle>
+nanoEngine Hardware Reference Manual</citetitle> (we refer to "July 17, 2000
+Rev 0.6") from Bright Star Engineering. </para>
+<para>Because of this, eCos, and therefore Redboot, only supports a
+special configuration of the ROM mode, starting at offset 0x40000 in
+the flash.</para>
+<para>Briefly, the POST-configuration RedBoot image lives in flash following the
+BSE firmware. The BSE firmware is configured, using its standard <command>
+bootcmd</command> command, to run RedBoot at startup.
+</para>
+</sect2>
+<sect2>
+<title>Download Instructions</title>
+<para>You can perform the initial load of the POST-configuration RedBoot image into
+flash using the BSE firmware's <command>load</command> command.
+This will load a binary file, using TFTP, and program it into flash in one
+operation. Because no memory management is used in the BSE firmware, flash
+is mapped from address zero upwards, so the address for the RedBoot POST image
+is 0x40000. You must use the binary version of RedBoot for this,
+<filename>redboot-post.bin</filename>.</para>
+
+<para>This assumes you have set up the other BSE firmware config
+parameters such that it can communicate over your network to your TFTP
+server.
+<screen>><userinput>load redboot-post.bin 40000</userinput>
+loading ... erasing blk at 00040000
+erasing blk at 00050000
+94168 bytes loaded cksum 00008579
+done
+>
+> <userinput>set bootcmd "go 40000"</userinput>
+> <userinput>get</userinput>
+myip = 10.16.19.198
+netmask = 255.255.255.0
+eth = 0
+gateway = 10.16.19.66
+serverip = 10.16.19.66
+bootcmd = go 40000
+></screen>
+
+<note><title>NOTE</title>
+<para>the BSE firmware runs its serial IO at 9600 Baud; RedBoot runs instead
+at 38400 Baud. You must select the right baud rate in your terminal program
+to be able to set up the BSE firmware.</para>
+</note>
+
+After a reset, the BSE firmware will print
+
+<screen>Boot: BSE 2000 Sep 12 2000 14:00:30
+autoboot: "go 40000" [hit ESC to abort]</screen>
+
+and then RedBoot starts, switching to 38400 Baud.</para>
+
+<para>Once you have installed a bootable RedBoot in the system in this
+manner, we advise re-installing using the generic method described in
+<xref linkend="updating-redboot"> in order that the Flash Image System
+contains an appropriate description of the flash entries.</para>
+</sect2>
+<sect2>
+<title>Cohabiting with POST in Flash</title>
+<para>The configuration file named <filename>redboot_POST.ecm</filename>
+configures RedBoot to build for execution at address 0x50040000 (or, during
+bootup, 0x00040000). This is to allow power-on self-test (POST) code or immutable
+firmware to live in the lower addresses of the flash and to run before RedBoot
+gets control. The assumption is that RedBoot will be entered at its base address
+in physical memory, that is 0x00040000.</para>
+
+<para>Alternatively, for testing, you can call it in an already running system
+by using <userinput>go 0x50040040</userinput> at another RedBoot prompt, or
+a branch to that address. The address is where the reset vector
+points. It is reported by RedBoot's <command>load</command> command
+and listed
+by the <command>fis list</command> command, amongst other
+places.</para>
+
+<para>Using the POST configuration enables a normal config option which causes
+linking and initialization against memory layout files called "...post..."
+rather than "...rom..." or "...ram..." in the <filename class="directory">include/pkgconf
+</filename> directory. Specifically:<literallayout><filename>include/pkgconf/mlt_arm_sa11x0_nano_post.h</filename>
+<filename>include/pkgconf/mlt_arm_sa11x0_nano_post.ldi</filename>
+<filename>include/pkgconf/mlt_arm_sa11x0_nano_post.mlt</filename></literallayout>
+
+It is these you should edit if you wish to move the execution address
+from 0x50040000 in the POST configuration. Startup mode naturally
+remains ROM in this configuration.</para>
+
+<para>Because the nanoEngine contains immutable boot firmware at the start
+of flash, RedBoot for this target is configured to reserve that area in the
+Flash Image System, and to create by default an entry for the POST
+mode RedBoot.
+<screen>
+RedBoot> <userinput>fis list</userinput>
+Name FLASH addr Mem addr Length Entry point
+(reserved) 0x50000000 0x50000000 0x00040000 0x00000000
+RedBoot[post] 0x50040000 0x00100000 0x00020000 0x50040040
+RedBoot config 0x503E0000 0x503E0000 0x00010000 0x00000000
+FIS directory 0x503F0000 0x503F0000 0x00010000 0x00000000
+RedBoot>
+</screen>
+The entry "(reserved)" ensures that the FIS cannot attempt
+to overwrite the BSE firmware, thus ensuring that the board remains bootable
+and recoverable even after installing a broken RedBoot image.</para>
+</sect2>
+<sect2>
+<title>Special RedBoot Commands</title>
+<para>The nanoEngine/commEngine has one or two Intel i82559 Ethernet controllers
+installed, but these have no associated serial EEPROM in which to record their
+Ethernet Station Address (ESA, or MAC address). The BSE firmware records an
+ESA for the device it uses, but this information is not available to RedBoot;
+we cannot share it.</para>
+<para>To keep the ESAs for the two ethernet interfaces, two new items of RedBoot
+configuration data are introduced. You can list them with the RedBoot command <command>
+fconfig -l</command> thus:
+<screen>
+RedBoot> <userinput>fconfig -l</userinput>
+Run script at boot: false
+Use BOOTP for network configuration: false
+Local IP address: 10.16.19.91
+Default server IP address: 10.16.19.66
+Network hardware address [MAC] for eth0: 0x00:0xB5:0xE0:0xB5:0xE0:0x99
+Network hardware address [MAC] for eth1: 0x00:0xB5:0xE0:0xB5:0xE0:0x9A
+GDB connection port: 9000
+Network debug at boot time: false
+RedBoot></screen>
+
+You should set them before running RedBoot or eCos applications with
+the board connected to a network. The <command>fconfig </command>
+command can be used as for any configuration data item; the entire ESA
+is entered in one line.</para>
+</sect2>
+<sect2>
+<title>Memory Maps</title>
+<para>The first level page table is located at physical address 0xc0004000.
+ No second level tables are used. <note><title>NOTE</title>
+<para>The virtual memory maps in this section use a C and B column to indicate
+whether or not the region is cached (C) or buffered (B).</para>
+</note><programlisting>Physical Address Range Description
+----------------------- ----------------------------------
+0x00000000 - 0x003fffff 4Mb FLASH (nCS0)
+0x18000000 - 0x18ffffff Internal PCI bus - 2 x i82559 ethernet
+0x40000000 - 0x4fffffff External IO or PCI bus
+0x80000000 - 0xbfffffff SA-1110 Internal Registers
+0xc0000000 - 0xc7ffffff DRAM Bank 0 - 32Mb SDRAM
+0xc8000000 - 0xcfffffff DRAM Bank 1 - empty
+0xe0000000 - 0xe7ffffff Cache Clean
+
+Virtual Address Range C B Description
+----------------------- - - ----------------------------------
+0x00000000 - 0x001fffff Y Y DRAM - 8Mb to 32Mb
+0x18000000 - 0x180fffff N N Internal PCI bus - 2 x i82559 ethernet
+0x40000000 - 0x4fffffff N N External IO or PCI bus
+0x50000000 - 0x51ffffff Y Y Up to 32Mb FLASH (nCS0)
+0x80000000 - 0xbfffffff N N SA-1110 Internal Registers
+0xc0000000 - 0xc0ffffff N Y DRAM Bank 0: 8 or 16Mb
+0xc8000000 - 0xc8ffffff N Y DRAM Bank 1: 8 or 16Mb or absent
+0xe0000000 - 0xe7ffffff Y Y Cache Clean</programlisting>
+</para>
+
+<para>The ethernet devices use a "PCI window" to communicate with the CPU.
+This is 1Mb of SDRAM which is shared with the ethernet devices that are on
+the PCI bus. It is neither cached nor buffered, to ensure that CPU and PCI
+accesses see correct data in the correct order. By default it is configured
+to be megabyte number 30, at addresses 0x01e00000-0x01efffff. This can be
+modified, and indeed must be, if less than 32Mb of SDRAM is installed, via
+the memory layout tool, or by moving the section <computeroutput>__pci_window
+</computeroutput> referred to by symbols <computeroutput>CYGMEM_SECTION_pci_window*
+</computeroutput> in the linker script. </para>
+<para>Though the nanoEngine ships with 32Mb of SDRAM all attached to DRAM
+bank 0, the code can cope with any of these combinations also; "2 x " in this
+context means one device in each DRAM Bank. <literallayout>1 x 8Mb = 8Mb 2 x 8Mb = 16Mb
+1 x 16Mb = 16Mb 2 x 16Mb = 32Mb</literallayout>All are programmed the same
+in the memory controller. </para>
+<para>Startup code detects which is fitted and programs the memory map accordingly.
+If the device(s) is 8Mb, then there are gaps in the physical memory map, because
+a high order address bit is not connected. The gaps are the higher 2Mb out
+of every 4Mb.</para>
+
+<para> The SA11x0 OS timer is used as a polled timer to provide timeout
+support within RedBoot.</para>
+</sect2>
+<sect2>
+<title>Nano Platform Port</title>
+<para>The nano is in the set of SA11X0-based platforms. It uses the arm architectural
+HAL, the sa11x0 variant HAL, plus the nano platform hal. These are components
+ <literallayout>CYGPKG_HAL_ARM hal/arm/arch/
+CYGPKG_HAL_ARM_SA11X0 hal/arm/sa11x0/var
+CYGPKG_HAL_ARM_SA11X0_NANO hal/arm/sa11x0/nano</literallayout> respectively.
+ </para>
+<para>The target name is "nano" which includes all these, plus the ethernet
+driver packages, flash driver, and so on.</para>
+</sect2>
+<sect2>
+<title>Ethernet Driver</title>
+<para>The ethernet driver is in two parts: </para>
+<para>A generic ether driver for Intel i8255x series devices, specifically
+the i82559, is <computeroutput>devs/eth/intel/i82559</computeroutput>. Its
+package name is <computeroutput>CYGPKG_DEVS_ETH_INTEL_I82559</computeroutput>.
+ </para>
+<para>The platform-specific ether driver is <computeroutput>devs/eth/arm/nano
+</computeroutput>. Its package is <computeroutput>CYGPKG_DEVS_ETH_ARM_NANO
+</computeroutput>. This tells the generic driver the address in IO memory
+of the chip, for example, and other configuration details. This driver picks
+up the ESA from RedBoot's configuration data - unless configured to use a
+static ESA in the usual manner. </para>
+</sect2><sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=nano
+export ARCH_DIR=arm
+export PLATFORM_DIR=sa11x0/nano
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+</sect2>
+</sect1>
+
+<?Pub _newpage>
+<sect1 id="ipaq">
+<title>ARM/StrongARM(SA11X0) Compaq iPAQ PocketPC</title>
+<indexterm><primary>Compaq iPAQ PocketPC</primary><secondary>installing and
+testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>Compaq iPAQ PocketPC</secondary></indexterm>
+<sect2>
+<title>Overview</title>
+<para>RedBoot supports the serial port via cradle or cable, and Compact Flash
+ethernet cards if fitted for communication and downloads. The LCD touchscreen
+may also be used for the console, although by default RedBoot will switch
+exclusively to one channel once input arrives. </para>
+<para>The default serial port settings are 38400,8,N,1. RedBoot runs from
+and supports flash management for the system flash region. </para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+ <row>
+ <entry>WinCE</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM, started from
+ <application>OSloader</application>.</entry>
+ <entry>redboot_WinCE.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+
+
+</sect2>
+<sect2>
+<title>Initial Installation</title>
+<para>RedBoot ROM and WinCE mode images are needed by the installation process.
+</para>
+<sect3>
+<title>Installing RedBoot on the iPAQ using Windows/CE</title>
+<para>
+The Windows/CE environment originally shipped with the iPAQ contains a hidden
+mini-loader, sometimes referred to as the "Parrot" loader. This loader can
+be started by holding down the action button (the joypad) while resetting
+the unit or when powering on. At this point, a blue bird will appear on
+the LCD screen. Also at this point, a simple loader can be accessed over the
+serial port at 115200/8N1. Using this loader, the contents of the iPAQ flash
+memory can be saved to a Compact Flash memory card.
+<note><title>NOTE</title><para>We have only tested this operation with a 32Mbyte CF memory card.
+Given that the backup will take 16MBytes + 1KByte, something more than a 16MByte
+card will be required.</para></note>
+</para>
+<para>
+Use the "r2c" command to dump Flash contents to the CF memory card. Once this
+completes, RedBoot can be installed with no fear since the Parrot loader can
+be used to restore the Flash contents at a later time.
+</para>
+<para>
+If you expect to completely recover the state of the iPAQ Win/CE environment, then
+HotSync should be run to backup all "RAM" files as well before installing RedBoot.
+</para>
+<para>The next step in installing RedBoot on the iPAQ actually involves Windows/CE,
+which is the native environment on the unit. Using WinCE, you need to
+install an application which will run a RAM based version of RedBoot. Once
+this is installed and running, RedBoot can be used to update the flash with
+a native/ROM version of RedBoot. <itemizedlist>
+<listitem><para>Using ActiveSync, copy the file OSloader to your iPAQ. </para>
+</listitem>
+<listitem><para>Using ActiveSync, copy the file redboot_WinCE.bin to the iPAQ
+as bootldr in its root directory. Note: this is not the top level folder
+displayed by Windows (Mobile Device), but rather the 'My Pocket PC' folder
+within it.</para>
+</listitem>
+<listitem><para>Execute OSloader. If you didn't create a shortcut, then you
+will have to poke around for it using the WinCE file explorer.</para>
+</listitem>
+<listitem><para>Choose the <guimenuitem>Tools->BootLdr->Run after loading
+from file</guimenuitem> menu item. </para>
+</listitem>
+</itemizedlist>At this point, the RAM based version of RedBoot should be running.
+ You should be able to return to this point by just executing the last two
+steps of the previous process if necessary.</para>
+</sect3>
+<sect3>
+<title>Installing RedBoot on the iPAQ - using the Compaq boot loader</title>
+<para>This method of installation is no longer supported.
+If you have previously installed either the Compaq boot loader or older
+versions of RedBoot, restore the Win/CE environment and proceed as outlined
+above.
+</para>
+</sect3>
+<sect3 id="setting-up-and-testing-redboot">
+<title>Setting up and testing RedBoot</title>
+<para>When RedBoot first comes up, it will want to initialize its LCD touch
+screen parameters. It does this by displaying a keyboard graphic and asks
+you to press certain keys. Using the stylus, press and hold until the prompt
+is withdrawn. When you lift the stylus, RedBoot will continue with the next
+calibration. </para>
+<para>Once the LCD touchscreen has been calibrated, RedBoot will start. The
+calibration step can be skipped by pressing the <guibutton>return/abort</guibutton>
+button on the unit (right most button with a curved arrow icon). Additionally,
+the unit will assume default values if the screen is not touched within about
+15 seconds. </para>
+<para>Once RedBoot has started, you should get information similar to this
+on the LCD screen. It will also appear on the serial port at 38400,8,N,1.
+
+<screen>RedBoot(tm) bootstrap and debug environment [ROM]
+Non-certified release, version UNKNOWN - built 06:17:41, Mar 19 2001
+Platform: Compaq iPAQ Pocket PC (StrongARM 1110)
+
+Copyright (C) 2000, 2001, Free Software Foundation, Inc.
+
+RAM: 0x00000000-0x01fc0000, 0x0001f200-0x01f70000 available
+FLASH: 0x50000000 - 0x51000000, 64 blocks of 0x00040000 bytes
+each.</screen>
+
+Since the LCD touchscreen is only 30 characters wide, some of this
+data will be off the right hand side of the display. The joypad may be
+used to pan left and right in order to see the full lines. </para>
+<para>If you have a Compact Flash ethernet card, RedBoot should find
+it. You'll need to have BOOTP enabled for this unit (see your
+sysadmin for details). If it does, it will print a message like:
+
+<screen>... Waiting for network card: .Ready!
+Socket Communications Inc: CF+ LPE Revision E 08/04/99
+IP: 192.168.1.34, Default server: 192.168.1.101</screen></para>
+</sect3>
+
+<sect3 id="ipaq-install-rb-permanently">
+<title>Installing RedBoot permanently</title>
+<para>Once you are satisfied with the setup and that RedBoot is operating
+properly in your environment, you can set up your iPAQ unit to have RedBoot
+be the bootstrap application.
+
+<caution><title>CAUTION</title>
+<para>This step will destroy your Windows/CE environment.</para>
+<para>Before you take this step, it is strongly recommended you save your WinCE FLASH contents
+as outlined above using the "parrot" loader, or
+by using the Compaq OSloader:<itemizedlist>
+
+<listitem><para>Using OSloader on the iPAQ, select the <guimenuitem>Tools->Flash->Save
+to files...</guimenuitem>. menu item.</para>
+</listitem>
+
+<listitem><para>Four (4) files, 4MB each in size will be created.</para>
+</listitem>
+
+<listitem><para>After each file is created, copy the file to your computer,
+then delete the file from the iPAQ to make room in the WinCE ramdisk for the
+next file.</para></listitem>
+</itemizedlist></para>
+
+</caution>You will need to download the version of RedBoot designed as the
+ROM bootstrap. Then install it permanently using these commands:
+ <screen>
+RedBoot> <userinput>lo -r -b 0x100000 redboot_ROM.bin</userinput>
+RedBoot> <userinput>fi loc -f 0x50000000 -l 0x40000</userinput>
+RedBoot> <userinput>fis init</userinput>
+RedBoot> <userinput>fi unl -f 0x50040000 -l 0x40000</userinput>
+RedBoot> <userinput>fi cr RedBoot -b 0x100000</userinput>
+RedBoot> <userinput>fi loc -f 0x50040000 -l 0x40000</userinput>
+RedBoot> <userinput>reset</userinput>
+</screen>
+
+<warning><title>WARNING</title>
+<para>You must type these commands exactly! Failure to do so may render your
+iPAQ totally useless. Once you've done this, RedBoot should come up every
+time you reset.</para>
+</warning></para>
+</sect3>
+
+<sect3>
+<title>Restoring Windows/CE</title>
+<para>To restore Windows/CE from the backup taken in <xref linkend="ipaq-install-rb-permanently">,
+visit <ulink url="http://www.handhelds.org/projects/wincerestoration.html">http://www.handhelds.org/projects/wincerestoration.html</ulink>
+for directions.
+</para>
+</sect3></sect2>
+
+<sect2>
+<title>Additional commands</title>
+<para>The <command>exec</command> command which allows the loading
+and execution of Linux kernels,
+is supported for this board (see <xref linkend="executing-programs">). The <command>
+exec</command> parameters used for the iPAQ are:</para>
+<variablelist><varlistentry>
+<term>-b <replaceable>&lt;addr></replaceable></term>
+<listitem><para>Location Linux kernel was loaded to</para></listitem></varlistentry>
+<varlistentry><term>
+-l <replaceable>&lt;len></replaceable></term>
+<listitem><para>Length of kernel</para></listitem></varlistentry>
+<varlistentry><term>
+-c <replaceable>"params"</replaceable></term>
+<listitem><para>Parameters passed to kernel</para></listitem></varlistentry>
+<varlistentry><term>-r <replaceable>&lt;addr></replaceable></term>
+<listitem><para>'initrd' ramdisk location</para></listitem></varlistentry>
+<varlistentry><term>-s <replaceable>&lt;len></replaceable></term>
+<listitem><para>Length of initrd ramdisk</para></listitem></varlistentry>
+</variablelist>
+<para>Linux kernels may be run on the iPAQ using the sources from the anonymous
+CVS repository at the Handhelds project (<ulink url="http://www.handhelds.org/">
+http://www.handhelds.org/</ulink>) with
+the <filename>elinux.patch</filename> patch file applied. This file can be
+found in the
+<filename>misc/</filename> subdirectory of the iPAQ platform HAL in the
+RedBoot sources, normally
+<filename>hal/arm/sa11x0/ipaq/<replaceable>VERSION</replaceable>/misc/</filename>
+ </para>
+<para>
+On the iPAQ (and indeed all SA11x0 platforms), Linux expects to be loaded
+at address 0xC0008000 and the entry point is also at 0xC0008000.
+</para>
+
+</sect2>
+<sect2>
+<title>Memory Maps</title>
+<para>RedBoot sets up the following memory map on the iPAQ: The first level
+page table is located at physical address 0xC0004000. No second level tables
+are used. <note><title>NOTE</title>
+<para>The virtual memory maps in this section use a C and B column to indicate
+whether or not the region is cached (C) or buffered (B).</para>
+</note> <programlisting>Physical Address Range Description
+----------------------- ----------------------------------
+0x00000000 - 0x01ffffff 16Mb to 32Mb FLASH (nCS0) [organized as below]
+ 0x000000 - 0x0003ffff Parrot Loader
+ 0x040000 - 0x0007ffff RedBoot
+ 0xf80000 - 0x00fbffff Fconfig data
+ 0xfc0000 - 0x00ffffff FIS directory
+0x30000000 - 0x3fffffff Compact Flash
+0x48000000 - 0x4bffffff iPAQ internal registers
+0x80000000 - 0xbfffffff SA-1110 Internal Registers
+0xc0000000 - 0xc1ffffff DRAM Bank 0 - 32Mb SDRAM
+0xe0000000 - 0xe7ffffff Cache Clean
+
+
+Virtual Address Range C B Description
+----------------------- - - ----------------------------------
+0x00000000 - 0x01ffffff Y Y DRAM - 32Mb
+0x30000000 - 0x3fffffff N N Compact Flash
+0x48000000 - 0x4bffffff N N iPAQ internal registers
+0x50000000 - 0x51ffffff Y Y Up to 32Mb FLASH (nCS0)
+0x80000000 - 0xbfffffff N N SA-1110 Internal Registers
+0xc0000000 - 0xc1ffffff N Y DRAM Bank 0: 32Mb
+0xe0000000 - 0xe7ffffff Y Y Cache Clean </programlisting> </para>
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=ipaq
+export ARCH_DIR=arm
+export PLATFORM_DIR=sa11x0/ipaq
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2></sect1>
+
+<?Pub _newpage>
+<sect1 id="cerfcube">
+<title>ARM/StrongARM(SA11X0) Intrinsyc CerfCube</title>
+<indexterm><primary>Intrinsyc CerfCube</primary><secondary>installing and
+testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>Intrinsyc CerfCube</secondary></indexterm>
+<sect2>
+<title>Overview</title>
+<para>RedBoot supports the serial port and the builtin
+ethernet connection for communication and downloads.
+</para>
+<para>The default serial port settings are 38400,8,N,1. RedBoot runs from
+and supports flash management for the system flash region. </para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+
+</sect2>
+<sect2>
+<title>Initial Installation</title>
+<para>
+The original boot loader supplied with the CerfCube can be used to install
+RedBoot. Connect to the device using a serial port at 38400/8N1.
+Copy the binary RedBoot ROM mode image to an available TFTP server.
+Issue these commands to the Instrinsyc loader:
+<screen>
+<userinput>download tftp:<replaceable>x.x.x.x</replaceable> redboot_ROM.bin 0xc0000000</userinput>
+<userinput>flashloader 0x00000000 0xc0000000 0x20000</userinput>
+</screen>
+where <replaceable>x.x.x.x</replaceable> is the IP address of the TFTP
+server.
+<note>
+<title>NOTE</title>
+<para>
+Other installation methods may be available via the Intrinsyc loader.
+Contact Intrinsyc for details.
+</para>
+</note>
+</para>
+</sect2>
+<sect2>
+<title>Additional commands</title>
+<para>The <command>exec</command> command which allows the loading
+and execution of Linux kernels,
+is supported for this board (see <xref linkend="executing-programs">). The <command>
+exec</command> parameters used for the CerfCube are:</para>
+<variablelist><varlistentry>
+<term>-b <replaceable>&lt;addr></replaceable></term>
+<listitem><para>Location Linux kernel was loaded to</para></listitem></varlistentry>
+<varlistentry><term>
+-l <replaceable>&lt;len></replaceable></term>
+<listitem><para>Length of kernel</para></listitem></varlistentry>
+<varlistentry><term>
+-c <replaceable>"params"</replaceable></term>
+<listitem><para>Parameters passed to kernel</para></listitem></varlistentry>
+<varlistentry><term>-r <replaceable>&lt;addr></replaceable></term>
+<listitem><para>'initrd' ramdisk location</para></listitem></varlistentry>
+<varlistentry><term>-s <replaceable>&lt;len></replaceable></term>
+<listitem><para>Length of initrd ramdisk</para></listitem></varlistentry>
+</variablelist>
+
+</sect2>
+<sect2>
+<title>Memory Maps</title>
+<para>RedBoot sets up the following memory map on the CerfCube: The first level
+page table is located at physical address 0xC0004000. No second level tables
+are used. <note><title>NOTE</title>
+<para>The virtual memory maps in this section use a C and B column to indicate
+whether or not the region is cached (C) or buffered (B).</para>
+</note> <programlisting>Physical Address Range Description
+----------------------- ----------------------------------
+0x00000000 - 0x01ffffff 16Mb to 32Mb FLASH (nCS0) [organized as below]
+ 0x000000 - 0x0001ffff RedBoot
+ 0x020000 - 0x0003ffff RedBoot [RAM version]
+ 0xfc0000 - 0x00fdffff Fconfig data
+ 0xfe0000 - 0x00ffffff FIS directory
+0x0f000000 - 0x0fffffff Onboard ethernet
+0x10000000 - 0x17ffffff CerfCube internal registers
+0x20000000 - 0x3fffffff PCMCIA / Compact Flash
+0x80000000 - 0xbfffffff SA-1110 Internal Registers
+0xc0000000 - 0xc1ffffff DRAM Bank 0 - 32Mb SDRAM
+0xe0000000 - 0xe7ffffff Cache Clean
+
+
+Virtual Address Range C B Description
+----------------------- - - ----------------------------------
+0x00000000 - 0x01ffffff Y Y DRAM - 32Mb
+0x08000000 - 0x0fffffff N N Onboard ethernet controller
+0x10000000 - 0x17ffffff N N CerfCube internal registers
+0x20000000 - 0x3fffffff N N PCMCIA / Compact Flash
+0x50000000 - 0x51ffffff Y Y Up to 32Mb FLASH (nCS0)
+0x80000000 - 0xbfffffff N N SA-1110 Internal Registers
+0xc0000000 - 0xc1ffffff N Y DRAM Bank 0: 32Mb
+0xe0000000 - 0xe7ffffff Y Y Cache Clean </programlisting> </para>
+</sect2>
+
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=cerf
+export ARCH_DIR=arm
+export PLATFORM_DIR=sa11x0/cerf
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2></sect1>
+
+
+<sect1 id="iq80310">
+<title>ARM/XScale Cyclone IQ80310</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Cyclone IQ80310</primary><secondary>installing and
+testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>Cyclone IQ80310</secondary></indexterm>RedBoot supports
+both serial ports and the built-in ethernet port for communication and downloads.
+The default serial port settings are 115200,8,N,1. RedBoot also supports flash
+management for the onboard 8MB flash.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+ <row>
+ <entry>ROMA</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from flash address 0x40000, with
+ ARM bootloader in flash boot sector.</entry>
+ <entry>redboot_ROMA.ecm</entry>
+ </row>
+ <row>
+ <entry>RAMA</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with ARM bootloader in
+ flash boot sector.</entry>
+ <entry>redboot_RAMA.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+</sect2>
+<sect2>
+<title>Initial Installation Method</title>
+
+<para>The board manufacturer provides a DOS application which is
+capable of programming the flash over the PCI bus, and this is
+required for initial installations of RedBoot. Please see the board
+manual for information on using this utility. In general, the process
+involves programming one of the two flash based RedBoot images to
+flash. The ROM mode RedBoot (which runs from the flash boot sector)
+should be programmed to flash address 0x00000000. The ROMA RedBoot
+mode (which is started by the ARM bootloader) should be programmed to
+flash address 0x00004000.
+</para>
+
+<para> To install RedBoot to run from the flash boot sector, use the manufacturer's
+flash utility to install the ROM mode image at address zero.
+</para>
+<para>To install RedBoot to run from address 0x40000 with the ARM bootloader
+in the flash boot sector, use the manufacturer's flash utility to install
+the ROMA mode image at address 0x40000. </para>
+
+<para>After booting the initial installation of RedBoot, this warning may
+be printed: <screen>flash configuration checksum error or invalid key
+</screen>This is normal, and indicates that the flash must be configured
+for use by RedBoot. Even if the above message is not printed, it may be a
+good idea to reinitialize the flash anyway. Do this with the <command>
+fis</command> command: <screen>RedBoot> <userinput>fis init</userinput>
+About to initialize [format] flash image system - continue (y/n)? <userinput>y</userinput>
+*** Initialize flash Image System
+Warning: device contents not erased, some blocks may not be usable
+... Unlock from 0x007e0000-0x00800000: .
+... Erase from 0x007e0000-0x00800000: .
+... Program from 0xa1fd0000-0xa1fd0400 at 0x007e0000: .
+... Lock from 0x007e0000-0x00800000: .
+Followed by the fconfig command:
+ RedBoot> <userinput>fconfig</userinput>
+ Run script at boot: <userinput>false</userinput>
+ Use BOOTP for network configuration: <userinput>false</userinput>
+ Local IP address: <userinput>192.168.1.153</userinput>
+ Default server IP address: <userinput>192.168.1.10</userinput>
+ GDB connection port: <userinput>1000</userinput>
+ Network debug at boot time: <userinput>false</userinput>
+ Update RedBoot non-volatile configuration - continue (y/n)? <userinput>y</userinput>
+ ... Unlock from 0x007c0000-0x007e0000: .
+ ... Erase from 0x007c0000-0x007e0000: .
+ ... Program from 0xa0013018-0xa0013418 at 0x007c0000: .
+ ... Lock from 0x007c0000-0x007e0000: .</screen></para>
+
+<note><para>When later updating RedBoot in situ, it is important to
+use a matching ROM and RAM mode pair of images. So use either RAM/ROM
+or RAMA/ROMA images. Do not mix them.</para></note>
+
+</sect2>
+<sect2>
+<title>Error codes</title>
+<para>RedBoot uses the two digit LED display to indicate errors during board
+initialization. Possible error codes are: <literallayout>88 - Unknown Error
+55 - I2C Error
+FF - SDRAM Error
+01 - No Error</literallayout></para>
+</sect2>
+<sect2>
+<title>Using RedBoot with ARM Bootloader </title>
+<para>RedBoot can coexist with ARM tools in flash on the IQ80310 board. In
+this configuration, the ARM bootloader will occupy the flash boot sector while
+RedBoot is located at flash address 0x40000. The sixteen position rotary switch
+is used to tell the ARM bootloader to jump to the RedBoot image located at
+address 0x40000. RedBoot is selected by switch position 0 or 1. Other switch
+positions are used by the ARM firmware and RedBoot will not be started. </para>
+</sect2>
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>A special RedBoot command, <command>diag</command>, is used to
+access a set of hardware diagnostics provided by the board
+manufacturer. To access the diagnostic menu, enter diag at the RedBoot prompt:
+<screen>
+RedBoot> <userinput>diag</userinput>
+Entering Hardware Diagnostics - Disabling Data Cache!
+1 - Memory Tests
+2 - Repeating Memory Tests
+3 - 16C552 DUART Serial Port Tests
+4 - Rotary Switch S1 Test for positions 0-3
+5 - seven Segment LED Tests
+6 - Backplane Detection Test
+7 - Battery Status Test
+8 - External Timer Test
+9 - i82559 Ethernet Configuration
+10 - i82559 Ethernet Test
+11 - Secondary PCI Bus Test
+12 - Primary PCI Bus Test
+13 - i960Rx/303 PCI Interrupt Test
+14 - Internal Timer Test
+15 - GPIO Test
+0 - quit Enter the menu item number (0 to quit):
+</screen>
+Tests for various hardware subsystems are provided, and some
+tests require special hardware in order to execute normally. The Ethernet
+Configuration item may be used to set the board ethernet address.</para>
+</sect2>
+<sect2>
+<title>IQ80310 Hardware Tests</title>
+<para><screen>1 - Memory Tests
+2 - Repeating Memory Tests
+3 - 16C552 DUART Serial Port Tests
+4 - Rotary Switch S1 Test for positions 0-3
+5 - 7 Segment LED Tests
+6 - Backplane Detection Test
+7 - Battery Status Test
+8 - External Timer Test
+9 - i82559 Ethernet Configuration
+10 - i82559 Ethernet Test
+11 - i960Rx/303 PCI Interrupt Test
+12 - Internal Timer Test
+13 - Secondary PCI Bus Test
+14 - Primary PCI Bus Test
+15 - Battery Backup SDRAM Memory Test
+16 - GPIO Test
+17 - Repeat-On-Fail Memory Test
+18 - Coyonosa Cache Loop (No return)
+19 - Show Software and Hardware Revision
+0 - quit
+Enter the menu item number (0 to quit): </screen></para>
+<para>Tests for various hardware subsystems are provided, and some tests require
+special hardware in order to execute normally. The Ethernet Configuration
+item may be used to set the board ethernet address.</para>
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot </title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=iq80310
+export ARCH_DIR=arm
+export PLATFORM_DIR=iq80310
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2>
+
+<sect2>
+<title>Interrupts</title>
+<para>RedBoot uses an interrupt vector table which is located at address 0xA000A004.
+Entries in this table are pointers to functions with this protoype:: <programlisting>
+int irq_handler( unsigned vector, unsigned data )</programlisting>On an IQ80310
+board, the vector argument is one of 49 interrupts defined in <computeroutput>
+hal/arm/iq80310/current/include/hal_platform_ints.h:</computeroutput>: <programlisting>
+// *** 80200 CPU ***
+#define CYGNUM_HAL_INTERRUPT_reserved0 0
+#define CYGNUM_HAL_INTERRUPT_PMU_PMN0_OVFL 1 // See Ch.12 - Performance Mon.
+#define CYGNUM_HAL_INTERRUPT_PMU_PMN1_OVFL 2 // PMU counter 0/1 overflow
+#define CYGNUM_HAL_INTERRUPT_PMU_CCNT_OVFL 3 // PMU clock overflow
+#define CYGNUM_HAL_INTERRUPT_BCU_INTERRUPT 4 // See Ch.11 - Bus Control Unit
+#define CYGNUM_HAL_INTERRUPT_NIRQ 5 // external IRQ
+#define CYGNUM_HAL_INTERRUPT_NFIQ 6 // external FIQ
+
+
+// *** XINT6 interrupts ***
+#define CYGNUM_HAL_INTERRUPT_DMA_0 7
+#define CYGNUM_HAL_INTERRUPT_DMA_1 8
+#define CYGNUM_HAL_INTERRUPT_DMA_2 9
+#define CYGNUM_HAL_INTERRUPT_GTSC 10 // Global Time Stamp Counter
+#define CYGNUM_HAL_INTERRUPT_PEC 11 // Performance Event Counter
+#define CYGNUM_HAL_INTERRUPT_AAIP 12 // application accelerator unit
+
+
+// *** XINT7 interrupts ***
+// I2C interrupts
+#define CYGNUM_HAL_INTERRUPT_I2C_TX_EMPTY 13
+#define CYGNUM_HAL_INTERRUPT_I2C_RX_FULL 14
+#define CYGNUM_HAL_INTERRUPT_I2C_BUS_ERR 15
+#define CYGNUM_HAL_INTERRUPT_I2C_STOP 16
+#define CYGNUM_HAL_INTERRUPT_I2C_LOSS 17
+#define CYGNUM_HAL_INTERRUPT_I2C_ADDRESS 18
+
+
+// Messaging Unit interrupts
+#define CYGNUM_HAL_INTERRUPT_MESSAGE_0 19
+#define CYGNUM_HAL_INTERRUPT_MESSAGE_1 20
+#define CYGNUM_HAL_INTERRUPT_DOORBELL 21
+#define CYGNUM_HAL_INTERRUPT_NMI_DOORBELL 22
+#define CYGNUM_HAL_INTERRUPT_QUEUE_POST 23
+#define CYGNUM_HAL_INTERRUPT_OUTBOUND_QUEUE_FULL 24
+#define CYGNUM_HAL_INTERRUPT_INDEX_REGISTER 25
+// PCI Address Translation Unit
+#define CYGNUM_HAL_INTERRUPT_BIST 26
+
+
+// *** External board interrupts (XINT3) ***
+#define CYGNUM_HAL_INTERRUPT_TIMER 27 // external timer
+#define CYGNUM_HAL_INTERRUPT_ETHERNET 28 // onboard enet
+#define CYGNUM_HAL_INTERRUPT_SERIAL_A 29 // 16x50 uart A
+#define CYGNUM_HAL_INTERRUPT_SERIAL_B 30 // 16x50 uart B
+#define CYGNUM_HAL_INTERRUPT_PCI_S_INTD 31 // secondary PCI INTD
+// The hardware doesn't (yet?) provide masking or status for these
+// even though they can trigger cpu interrupts. ISRs will need to
+// poll the device to see if the device actually triggered the
+// interrupt.
+#define CYGNUM_HAL_INTERRUPT_PCI_S_INTC 32 // secondary PCI INTC
+#define CYGNUM_HAL_INTERRUPT_PCI_S_INTB 33 // secondary PCI INTB
+#define CYGNUM_HAL_INTERRUPT_PCI_S_INTA 34 // secondary PCI INTA
+
+
+// *** NMI Interrupts go to FIQ ***
+#define CYGNUM_HAL_INTERRUPT_MCU_ERR 35
+#define CYGNUM_HAL_INTERRUPT_PATU_ERR 36
+#define CYGNUM_HAL_INTERRUPT_SATU_ERR 37
+#define CYGNUM_HAL_INTERRUPT_PBDG_ERR 38
+#define CYGNUM_HAL_INTERRUPT_SBDG_ERR 39
+#define CYGNUM_HAL_INTERRUPT_DMA0_ERR 40
+#define CYGNUM_HAL_INTERRUPT_DMA1_ERR 41
+#define CYGNUM_HAL_INTERRUPT_DMA2_ERR 42
+#define CYGNUM_HAL_INTERRUPT_MU_ERR 43
+#define CYGNUM_HAL_INTERRUPT_reserved52 44
+#define CYGNUM_HAL_INTERRUPT_AAU_ERR 45
+#define CYGNUM_HAL_INTERRUPT_BIU_ERR 46
+
+
+// *** ATU FIQ sources ***
+#define CYGNUM_HAL_INTERRUPT_P_SERR 47
+#define CYGNUM_HAL_INTERRUPT_S_SERR 48</programlisting>The data passed
+to the ISR is pulled from a data table <computeroutput>(hal_interrupt_data)
+</computeroutput> which immediately follows the interrupt vector table. With
+49 interrupts, the data table starts at address 0xA000A0C8. </para>
+<para>An application may create a normal C function with the above prototype
+to be an ISR. Just poke its address into the table at the correct index and
+enable the interrupt at its source. The return value of the ISR is ignored
+by RedBoot.</para>
+</sect2>
+<sect2>
+<title>Memory Maps</title>
+<para>The first level page table is located at 0xa0004000. Two second level
+tables are also used. One second level table is located at 0xa0008000 and
+maps the first 1MB of flash. The other second level table is at 0xa0008400,
+and maps the first 1MB of SDRAM. <note><title>NOTE</title>
+<para>The virtual memory maps in this section use a C and B column to indicate
+whether or not the region is cached (C) or buffered (B).</para>
+</note></para>
+<para><programlisting>Physical Address Range Description
+----------------------- ----------------------------------
+0x00000000 - 0x00000fff flash Memory
+0x00001000 - 0x00001fff 80312 Internal Registers
+0x00002000 - 0x007fffff flash Memory
+0x00800000 - 0x7fffffff PCI ATU Outbound Direct Window
+0x80000000 - 0x83ffffff Primary PCI 32-bit Memory
+0x84000000 - 0x87ffffff Primary PCI 64-bit Memory
+0x88000000 - 0x8bffffff Secondary PCI 32-bit Memory
+0x8c000000 - 0x8fffffff Secondary PCI 64-bit Memory
+0x90000000 - 0x9000ffff Primary PCI IO Space
+0x90010000 - 0x9001ffff Secondary PCI IO Space
+0x90020000 - 0x9fffffff Unused
+0xa0000000 - 0xbfffffff SDRAM
+0xc0000000 - 0xefffffff Unused
+0xf0000000 - 0xffffffff 80200 Internal Registers
+
+
+Virtual Address Range C B Description
+----------------------- - - ----------------------------------
+0x00000000 - 0x00000fff Y Y SDRAM
+0x00001000 - 0x00001fff N N 80312 Internal Registers
+0x00002000 - 0x007fffff Y N flash Memory
+0x00800000 - 0x7fffffff N N PCI ATU Outbound Direct Window
+0x80000000 - 0x83ffffff N N Primary PCI 32-bit Memory
+0x84000000 - 0x87ffffff N N Primary PCI 64-bit Memory
+0x88000000 - 0x8bffffff N N Secondary PCI 32-bit Memory
+0x8c000000 - 0x8fffffff N N Secondary PCI 64-bit Memory
+0x90000000 - 0x9000ffff N N Primary PCI IO Space
+0x90010000 - 0x9001ffff N N Secondary PCI IO Space
+0xa0000000 - 0xbfffffff Y Y SDRAM
+0xc0000000 - 0xcfffffff Y Y Cache Flush Region
+0xd0000000 - 0xd0000fff Y N first 4k page of flash
+0xf0000000 - 0xffffffff N N 80200 Internal Registers </programlisting></para>
+</sect2>
+<sect2>
+<title>Platform Resource Usage</title>
+<para>The external timer is used as a polled timer to provide timeout support
+for networking and XModem file transfers.</para>
+</sect2></sect1>
+
+<?Pub _newpage>
+<sect1 id="iq80321">
+<title>ARM/XScale Intel IQ80321</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Intel IQ80321</primary><secondary>installing and
+testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>Intel IQ80321</secondary></indexterm>RedBoot supports
+the serial port and the built-in ethernet port for communication and downloads.
+The default serial port settings are 115200,8,N,1. RedBoot also supports flash
+management for the onboard 8MB flash.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+
+</sect2>
+<sect2>
+<title>Initial Installation Method</title>
+<para>The board manufacturer provides a DOS application which is capable of
+programming the flash over the PCI bus, and this is required for initial installations
+of RedBoot. Please see the board manual for information on using this utility.
+In general, the process involves programming the ROM mode RedBoot
+image to flash. RedBoot should be programmed to flash address
+0x00000000 using the DOS utility.
+</para>
+
+<para>After booting the initial installation of RedBoot, this warning may
+be printed: <screen>flash configuration checksum error or invalid key
+</screen>This is normal, and indicates that the flash must be configured
+for use by RedBoot. Even if the above message is not printed, it may be a
+good idea to reinitialize the flash anyway. Do this with the <command>
+fis</command> command: <screen>RedBoot> <userinput>fis init</userinput>
+About to initialize [format] FLASH image system - continue (y/n)? <userinput>y</userinput>
+*** Initialize FLASH Image System
+ Warning: device contents not erased, some blocks may not be usable
+ ... Unlock from 0xf07e0000-0xf0800000: .
+ ... Erase from 0xf07e0000-0xf0800000: .
+ ... Program from 0x01ddf000-0x01ddf400 at 0xf07e0000: .
+ ... Lock from 0xf07e0000-0xf0800000: .
+</screen></para></sect2>
+<sect2>
+<title>Switch Settings</title>
+<para>The 80321 board is highly configurable through a number of switches and jumpers.
+RedBoot makes some assumptions about board configuration and attention must be paid
+to these assumptions for reliable RedBoot operation:
+<itemizedlist>
+<listitem><para>The onboard ethernet and the secondary slot may be placed in a
+private space so that they are not seen by a PC BIOS. If the board is to be used
+in a PC with BIOS, then the ethernet should be placed in this private space so that
+RedBoot and the BIOS do not conflict.
+</para></listitem>
+<listitem><para>RedBoot assumes that the board is plugged into a PC with BIOS. This
+requires RedBoot to detect when the BIOS has configured the PCI-X secondary bus. If
+the board is placed in a backplane, RedBoot will never see the BIOS configure the
+secondary bus. To prevent this wait, set switch S7E1-3 to ON when using the board
+in a backplane.</para></listitem>
+<listitem><para>For the remaining switch settings, the following is a known good
+configuration:
+<informaltable frame=all>
+<tgroup cols=2>
+<tbody>
+<row><entry>S1D1</entry><entry>All OFF</entry></row>
+<row><entry>S7E1</entry><entry>7 is ON, all others OFF</entry></row>
+<row><entry>S8E1</entry><entry>2,3,5,6 are ON, all others OFF</entry></row>
+<row><entry>S8E2</entry><entry>2,3 are ON, all others OFF</entry></row>
+<row><entry>S9E1</entry><entry>3 is ON, all others OFF</entry></row>
+<row><entry>S4D1</entry><entry>1,3 are ON, all others OFF</entry></row>
+<row><entry>J9E1</entry><entry>2,3 jumpered</entry></row>
+<row><entry>J9F1</entry><entry>2,3 jumpered</entry></row>
+<row><entry>J3F1</entry><entry>Nothing jumpered</entry></row>
+<row><entry>J3G1</entry><entry>2,3 jumpered</entry></row>
+<row><entry>J1G2</entry><entry>2,3 jumpered</entry></row>
+</tbody></tgroup></informaltable></para></listitem>
+</itemizedlist>
+</para>
+</sect2>
+<sect2>
+<title>LED Codes</title>
+<para>RedBoot uses the two digit LED display to indicate status during board
+initialization. Possible codes are:</para>
+
+<literallayout width=72>
+LED Actions
+-------------------------------------------------------------
+ Power-On/Reset
+88
+ Set the CPSR
+ Enable coprocessor access
+ Drain write and fill buffer
+ Setup PBIU chip selects
+A1
+ Enable the Icache
+A2
+ Move FLASH chip select from 0x0 to 0xF0000000
+ Jump to new FLASH location
+A3
+ Setup and enable the MMU
+A4
+ I2C interface initialization
+90
+ Wait for I2C initialization to complete
+91
+ Send address (via I2C) to the DIMM
+92
+ Wait for transmit complete
+93
+ Read SDRAM PD data from DIMM
+94
+ Read remainder of EEPROM data.
+ An error will result in one of the following
+ error codes on the LEDs:
+ 77 BAD EEPROM checksum
+ 55 I2C protocol error
+ FF bank size error
+A5
+ Setup DDR memory interface
+A6
+ Enable branch target buffer
+ Drain the write & fill buffers
+ Flush Icache, Dcache and BTB
+ Flush instuction and data TLBs
+ Drain the write & fill buffers
+SL
+ ECC Scrub Loop
+SE
+A7
+ Clean, drain, flush the main Dcache
+A8
+ Clean, drain, flush the mini Dcache
+ Flush Dcache
+ Drain the write & fill buffers
+A9
+ Enable ECC
+AA
+ Save SDRAM size
+ Move MMU tables into RAM
+AB
+ Clean, drain, flush the main Dcache
+ Clean, drain, flush the mini Dcache
+ Drain the write & fill buffers
+AC
+ Set the TTB register to DRAM mmu_table
+AD
+ Set mode to IRQ mode
+A7
+ Move SWI & Undefined "vectors" to RAM (at 0x0)
+A6
+ Switch to supervisor mode
+A5
+ Move remaining "vectors" to RAM (at 0x0)
+A4
+ Copy DATA to RAM
+ Initialize interrupt exception environment
+ Initialize stack
+ Clear BSS section
+A3
+ Call platform specific hardware initialization
+A2
+ Run through static constructors
+A1
+ Start up the eCos kernel or RedBoot
+</literallayout>
+</sect2>
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>A special RedBoot command, <command>diag</command>, is used to
+access a set of hardware diagnostics. To access the diagnostic menu,
+enter <command>diag</command> at the RedBoot prompt:
+<screen>
+RedBoot> <userinput>diag</userinput>
+Entering Hardware Diagnostics - Disabling Data Cache!
+
+ IQ80321 Hardware Tests
+
+ 1 - Memory Tests
+ 2 - Repeating Memory Tests
+ 3 - Repeat-On-Fail Memory Tests
+ 4 - Rotary Switch S1 Test
+ 5 - 7 Segment LED Tests
+ 6 - i82544 Ethernet Configuration
+ 7 - Baterry Status Test
+ 8 - Battery Backup SDRAM Memory Test
+ 9 - Timer Test
+10 - PCI Bus test
+11 - CPU Cache Loop (No Return)
+ 0 - quit
+Enter the menu item number (0 to quit):
+</screen>
+Tests for various hardware subsystems are provided, and some tests require
+special hardware in order to execute normally. The Ethernet Configuration
+item may be used to set the board ethernet address.</para>
+<sect3>
+<title>Memory Tests</title>
+<para>This test is used to test installed DDR SDRAM memory. Five different
+tests are run over the given address ranges. If errors are encountered, the
+test is aborted and information about the failure is printed. When selected,
+the user will be prompted to enter the base address of the test range and its
+size. The numbers must be in hex with no leading &ldquo;0x&rdquo;
+</para>
+<screen>
+Enter the menu item number (0 to quit): <userinput>1</userinput>
+
+Base address of memory to test (in hex): <userinput>100000</userinput>
+
+Size of memory to test (in hex): <userinput>200000</userinput>
+
+Testing memory from 0x00100000 to 0x002fffff.
+
+Walking 1's test:
+0000000100000002000000040000000800000010000000200000004000000080
+0000010000000200000004000000080000001000000020000000400000008000
+0001000000020000000400000008000000100000002000000040000000800000
+0100000002000000040000000800000010000000200000004000000080000000
+passed
+32-bit address test: passed
+32-bit address bar test: passed
+8-bit address test: passed
+Byte address bar test: passed
+Memory test done.
+</screen>
+</sect3>
+<sect3>
+<title>Repeating Memory Tests</title>
+<para>The repeating memory tests are exactly the same as the above memory tests,
+except that the tests are automatically rerun after completion. The only way out
+of this test is to reset the board.
+</para>
+</sect3>
+<sect3>
+<title>Repeat-On-Fail Memory Tests</title>
+<para>This is similar to the repeating memory tests except that when an error
+is found, the failing test continuously retries on the failing address.
+</para>
+</sect3>
+<sect3>
+<title>Rotary Switch S1 Test</title>
+<para>This tests the operation of the sixteen position rotary switch. When run,
+this test will display the current position of the rotary switch on the LED
+display. Slowly dial through each position and confirm reading on LED.
+</para>
+</sect3>
+<sect3>
+<title>7 Segment LED Tests</title>
+<para>This tests the operation of the seven segment displays. When run, each
+LED cycles through 0 through F and a decimal point.
+</para>
+</sect3>
+<sect3>
+<title>i82544 Ethernet Configuration</title>
+<para>This test initializes the ethernet controller&rsquo;s serial EEPROM if
+the current contents are invalid. In any case, this test will also allow the
+user to enter a six byte ethernet MAC address into the serial EEPROM.
+</para>
+<screen>
+Enter the menu item number (0 to quit): <userinput>6</userinput>
+
+
+Current MAC address: 00:80:4d:46:00:02
+Enter desired MAC address: <userinput>00:80:4d:46:00:01</userinput>
+Writing to the Serial EEPROM... Done
+
+******** Reset The Board To Have Changes Take Effect ********
+</screen>
+</sect3>
+<sect3>
+<title>Battery Status Test</title>
+<para>This tests the current status of the battery. First, the test checks to
+see if the battery is installed and reports that finding. If the battery is
+installed, the test further determines whether the battery status is one or
+more of the following:
+<itemizedlist>
+<listitem><para>Battery is charging.</para></listitem>
+<listitem><para>Battery is fully discharged.</para></listitem>
+<listitem><para>Battery voltage measures within normal operating range.
+</para></listitem>
+</itemizedlist>
+</para>
+</sect3>
+<sect3>
+<title>Battery Backup SDRAM Memory Test</title>
+<para>This tests the battery backup of SDRAM memory. This test is a three
+step process:</para>
+<orderedlist>
+<listitem><para>Select Battery backup test from main diag menu, then write
+data to SDRAM.</para></listitem>
+<listitem><para>Turn off power for 60 seconds, then repower the board.
+</para></listitem>
+<listitem><para>Select Battery backup test from main diag menu, then check
+data that was written in step 1.
+</para></listitem>
+</orderedlist>
+</sect3>
+<sect3>
+<title>Timer Test</title>
+<para>This tests the internal timer by printing a number of dots at one
+second intervals.</para>
+</sect3>
+<sect3>
+<title>PCI Bus Test</title>
+<para>This tests the secondary PCI-X bus and socket. This test requires that
+an IQ80310 board be plugged into the secondary slot of the IOP80321 board.
+The test assumes at least 32MB of installed memory on the IQ80310. That memory
+is mapped into the IOP80321 address space and the memory tests are run on that
+memory.
+</para>
+</sect3>
+<sect3>
+<title>CPU Cache Loop</title>
+<para>This test puts the CPU into a tight loop run entirely from the ICache.
+This should prevent all external bus accesses.
+</para>
+</sect3>
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot </title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=iq80321
+export ARCH_DIR=arm
+export PLATFORM_DIR=xscale/iq80321
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+</sect2>
+
+<sect2>
+<title>Interrupts</title>
+<para>RedBoot uses an interrupt vector table which is located at address 0x8004.
+Entries in this table are pointers to functions with this protoype:: <programlisting>
+int irq_handler( unsigned vector, unsigned data )</programlisting>On an IQ80321
+board, the vector argument is one of 32 interrupts defined in <computeroutput>
+hal/arm/xscale/verde/current/include/hal_var_ints.h:</computeroutput>: <programlisting>
+// *** 80200 CPU ***
+#define CYGNUM_HAL_INTERRUPT_DMA0_EOT 0
+#define CYGNUM_HAL_INTERRUPT_DMA0_EOC 1
+#define CYGNUM_HAL_INTERRUPT_DMA1_EOT 2
+#define CYGNUM_HAL_INTERRUPT_DMA1_EOC 3
+#define CYGNUM_HAL_INTERRUPT_RSVD_4 4
+#define CYGNUM_HAL_INTERRUPT_RSVD_5 5
+#define CYGNUM_HAL_INTERRUPT_AA_EOT 6
+#define CYGNUM_HAL_INTERRUPT_AA_EOC 7
+#define CYGNUM_HAL_INTERRUPT_CORE_PMON 8
+#define CYGNUM_HAL_INTERRUPT_TIMER0 9
+#define CYGNUM_HAL_INTERRUPT_TIMER1 10
+#define CYGNUM_HAL_INTERRUPT_I2C_0 11
+#define CYGNUM_HAL_INTERRUPT_I2C_1 12
+#define CYGNUM_HAL_INTERRUPT_MESSAGING 13
+#define CYGNUM_HAL_INTERRUPT_ATU_BIST 14
+#define CYGNUM_HAL_INTERRUPT_PERFMON 15
+#define CYGNUM_HAL_INTERRUPT_CORE_PMU 16
+#define CYGNUM_HAL_INTERRUPT_BIU_ERR 17
+#define CYGNUM_HAL_INTERRUPT_ATU_ERR 18
+#define CYGNUM_HAL_INTERRUPT_MCU_ERR 19
+#define CYGNUM_HAL_INTERRUPT_DMA0_ERR 20
+#define CYGNUM_HAL_INTERRUPT_DMA1_ERR 22
+#define CYGNUM_HAL_INTERRUPT_AA_ERR 23
+#define CYGNUM_HAL_INTERRUPT_MSG_ERR 24
+#define CYGNUM_HAL_INTERRUPT_SSP 25
+#define CYGNUM_HAL_INTERRUPT_RSVD_26 26
+#define CYGNUM_HAL_INTERRUPT_XINT0 27
+#define CYGNUM_HAL_INTERRUPT_XINT1 28
+#define CYGNUM_HAL_INTERRUPT_XINT2 29
+#define CYGNUM_HAL_INTERRUPT_XINT3 30
+#define CYGNUM_HAL_INTERRUPT_HPI 31
+</programlisting>
+The data passed to the ISR is pulled from a data table <computeroutput>(hal_interrupt_data)
+</computeroutput> which immediately follows the interrupt vector table. With
+32 interrupts, the data table starts at address 0x8084. </para>
+<para>An application may create a normal C function with the above prototype
+to be an ISR. Just poke its address into the table at the correct index and
+enable the interrupt at its source. The return value of the ISR is ignored
+by RedBoot.</para>
+</sect2>
+<sect2>
+<title>Memory Maps</title>
+<para>The RAM based page table is located at RAM start + 0x4000. RedBoot may be configured
+for one of two memory maps. The difference between them is the location of RAM and the
+PCI outbound windows. The alternative memory map may be used when
+building RedBoot or eCos by using the <literal>RAM_ALTMAP</literal>
+and <literal>ROM_ALTMAP</literal> startup types in the configuration.
+<note><title>NOTE</title>
+<para>The virtual memory maps in this section use a C, B, and X column to indicate
+the caching policy for the region..</para>
+</note></para>
+<para><programlisting>
+X C B Description
+- - - ---------------------------------------------
+0 0 0 Uncached/Unbuffered
+0 0 1 Uncached/Buffered
+0 1 0 Cached/Buffered Write Through, Read Allocate
+0 1 1 Cached/Buffered Write Back, Read Allocate
+1 0 0 Invalid -- not used
+1 0 1 Uncached/Buffered No write buffer coalescing
+1 1 0 Mini DCache - Policy set by Aux Ctl Register
+1 1 1 Cached/Buffered Write Back, Read/Write Allocate
+
+Physical Address Range Description
+----------------------- ----------------------------------
+0x00000000 - 0x7fffffff ATU Outbound Direct Window
+0x80000000 - 0x900fffff ATU Outbound Translate Windows
+0xa0000000 - 0xbfffffff SDRAM
+0xf0000000 - 0xf0800000 FLASH (PBIU CS0)
+0xfe800000 - 0xfe800fff UART (PBIU CS1)
+0xfe840000 - 0xfe840fff Left 7-segment LED (PBIU CS3)
+0xfe850000 - 0xfe850fff Right 7-segment LED (PBIU CS2)
+0xfe8d0000 - 0xfe8d0fff Rotary Switch (PBIU CS4)
+0xfe8f0000 - 0xfe8f0fff Baterry Status (PBIU CS5)
+0xfff00000 - 0xffffffff Verde Memory mapped Registers
+
+
+Default Virtual Map X C B Description
+----------------------- - - - ----------------------------------
+0x00000000 - 0x1fffffff 1 1 1 SDRAM
+0x20000000 - 0x9fffffff 0 0 0 ATU Outbound Direct Window
+0xa0000000 - 0xb00fffff 0 0 0 ATU Outbound Translate Windows
+0xc0000000 - 0xdfffffff 0 0 0 Uncached alias for SDRAM
+0xe0000000 - 0xe00fffff 1 1 1 Cache flush region (no phys mem)
+0xf0000000 - 0xf0800000 0 1 0 FLASH (PBIU CS0)
+0xfe800000 - 0xfe800fff 0 0 0 UART (PBIU CS1)
+0xfe840000 - 0xfe840fff 0 0 0 Left 7-segment LED (PBIU CS3)
+0xfe850000 - 0xfe850fff 0 0 0 Right 7-segment LED (PBIU CS2)
+0xfe8d0000 - 0xfe8d0fff 0 0 0 Rotary Switch (PBIU CS4)
+0xfe8f0000 - 0xfe8f0fff 0 0 0 Baterry Status (PBIU CS5)
+0xfff00000 - 0xffffffff 0 0 0 Verde Memory mapped Registers
+
+Alternate Virtual Map X C B Description
+----------------------- - - - ----------------------------------
+0x00000000 - 0x000fffff 1 1 1 Alias for 1st MB of SDRAM
+0x00100000 - 0x7fffffff 0 0 0 ATU Outbound Direct Window
+0x80000000 - 0x900fffff 0 0 0 ATU Outbound Translate Windows
+0xa0000000 - 0xbfffffff 1 1 1 SDRAM
+0xc0000000 - 0xdfffffff 0 0 0 Uncached alias for SDRAM
+0xe0000000 - 0xe00fffff 1 1 1 Cache flush region (no phys mem)
+0xf0000000 - 0xf0800000 0 1 0 FLASH (PBIU CS0)
+0xfe800000 - 0xfe800fff 0 0 0 UART (PBIU CS1)
+0xfe840000 - 0xfe840fff 0 0 0 Left 7-segment LED (PBIU CS3)
+0xfe850000 - 0xfe850fff 0 0 0 Right 7-segment LED (PBIU CS2)
+0xfe8d0000 - 0xfe8d0fff 0 0 0 Rotary Switch (PBIU CS4)
+0xfe8f0000 - 0xfe8f0fff 0 0 0 Baterry Status (PBIU CS5)
+0xfff00000 - 0xffffffff 0 0 0 Verde Memory mapped Registers
+
+</programlisting></para>
+</sect2>
+<sect2>
+<title>Platform Resource Usage</title>
+<para>The Verde programmable timer0 is used for timeout support
+for networking and XModem file transfers.</para>
+</sect2></sect1>
+
+<?Pub _newpage>
+<sect1 id="IXDP425">
+<title>ARM/Intel XScale IXDP425 Network Processor Evaluation Board</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Intel IXDP425</primary><secondary>installing and
+testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>Intel IXDP</secondary></indexterm>RedBoot supports
+the builtin high-speed and console UARTs and a PCI based i82559 ethernet
+card for communication and downloads. The default serial port settings are
+115200,8,N,1. RedBoot also supports flash management for the 16MB boot flash
+on the mainboard.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from flash
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+</sect2>
+<sect2>
+<title>Initial Installation Method</title>
+<para>The IXDP425 flash is socketed, so initial installation may be done using
+an appropriate device programmer. JTAG based initial may also be used. In either
+case, the ROM mode RedBoot is programmed into the boot flash at address 0x00000000.
+</para>
+
+<para>After booting the initial installation of RedBoot, this warning may
+be printed: <screen>flash configuration checksum error or invalid key
+</screen>This is normal, and indicates that the flash should be configured
+for use by RedBoot. See <xref linkend="Persistent-State-Flash"> for more
+details.
+</para></sect2>
+<sect2>
+<title>LED Codes</title>
+<para>RedBoot uses the 4 digit LED display to indicate status during board
+initialization. Possible codes are:</para>
+
+<literallayout width=72>
+LED Actions
+-------------------------------------------------------------
+ Power-On/Reset
+ Set the CPSR
+ Enable coprocessor access
+ Drain write and fill buffer
+ Setup expansion bus chip selects
+1001
+ Enable Icache
+1002
+ Initialize SDRAM controller
+1003
+ Switch flash (CS0) from 0x00000000 to 0x50000000
+1004
+ Copy MMU table to RAM
+1005
+ Setup TTB and domain permissions
+1006
+ Enable MMU
+1007
+ Enable DCache
+1008
+ Enable branch target buffer
+1009
+ Drain write and fill buffer
+ Flush caches
+100A
+ Start up the eCos kernel or RedBoot
+0001
+
+</literallayout>
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot </title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=ixdp425
+export ARCH_DIR=arm
+export PLATFORM_DIR=xscale/ixdp425
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+</sect2>
+
+<sect2>
+<title>Interrupts</title>
+<para>RedBoot uses an interrupt vector table which is located at address 0x8004.
+Entries in this table are pointers to functions with this protoype:: <programlisting>
+int irq_handler( unsigned vector, unsigned data )</programlisting>On the IXDP425
+board, the vector argument is one of many interrupts defined in <computeroutput>
+hal/arm/xscale/ixp425/current/include/hal_var_ints.h:</computeroutput>: <programlisting>
+#define CYGNUM_HAL_INTERRUPT_NPEA 0
+#define CYGNUM_HAL_INTERRUPT_NPEB 1
+#define CYGNUM_HAL_INTERRUPT_NPEC 2
+#define CYGNUM_HAL_INTERRUPT_QM1 3
+#define CYGNUM_HAL_INTERRUPT_QM2 4
+#define CYGNUM_HAL_INTERRUPT_TIMER0 5
+#define CYGNUM_HAL_INTERRUPT_GPIO0 6
+#define CYGNUM_HAL_INTERRUPT_GPIO1 7
+#define CYGNUM_HAL_INTERRUPT_PCI_INT 8
+#define CYGNUM_HAL_INTERRUPT_PCI_DMA1 9
+#define CYGNUM_HAL_INTERRUPT_PCI_DMA2 10
+#define CYGNUM_HAL_INTERRUPT_TIMER1 11
+#define CYGNUM_HAL_INTERRUPT_USB 12
+#define CYGNUM_HAL_INTERRUPT_UART2 13
+#define CYGNUM_HAL_INTERRUPT_TIMESTAMP 14
+#define CYGNUM_HAL_INTERRUPT_UART1 15
+#define CYGNUM_HAL_INTERRUPT_WDOG 16
+#define CYGNUM_HAL_INTERRUPT_AHB_PMU 17
+#define CYGNUM_HAL_INTERRUPT_XSCALE_PMU 18
+#define CYGNUM_HAL_INTERRUPT_GPIO2 19
+#define CYGNUM_HAL_INTERRUPT_GPIO3 20
+#define CYGNUM_HAL_INTERRUPT_GPIO4 21
+#define CYGNUM_HAL_INTERRUPT_GPIO5 22
+#define CYGNUM_HAL_INTERRUPT_GPIO6 23
+#define CYGNUM_HAL_INTERRUPT_GPIO7 24
+#define CYGNUM_HAL_INTERRUPT_GPIO8 25
+#define CYGNUM_HAL_INTERRUPT_GPIO9 26
+#define CYGNUM_HAL_INTERRUPT_GPIO10 27
+#define CYGNUM_HAL_INTERRUPT_GPIO11 28
+#define CYGNUM_HAL_INTERRUPT_GPIO12 29
+#define CYGNUM_HAL_INTERRUPT_SW_INT1 30
+#define CYGNUM_HAL_INTERRUPT_SW_INT2 31
+</programlisting>
+The data passed to the ISR is pulled from a data table <computeroutput>(hal_interrupt_data)
+</computeroutput> which immediately follows the interrupt vector table. With
+32 interrupts, the data table starts at address 0x8084. </para>
+<para>An application may create a normal C function with the above prototype
+to be an ISR. Just poke its address into the table at the correct index and
+enable the interrupt at its source. The return value of the ISR is ignored
+by RedBoot.</para>
+</sect2>
+<sect2>
+<title>Memory Maps</title>
+<para>The RAM based page table is located at RAM start + 0x4000.
+<note><title>NOTE</title>
+<para>The virtual memory maps in this section use a C, B, and X column to indicate
+the caching policy for the region..</para>
+</note></para>
+<para><programlisting>
+X C B Description
+- - - ---------------------------------------------
+0 0 0 Uncached/Unbuffered
+0 0 1 Uncached/Buffered
+0 1 0 Cached/Buffered Write Through, Read Allocate
+0 1 1 Cached/Buffered Write Back, Read Allocate
+1 0 0 Invalid -- not used
+1 0 1 Uncached/Buffered No write buffer coalescing
+1 1 0 Mini DCache - Policy set by Aux Ctl Register
+1 1 1 Cached/Buffered Write Back, Read/Write Allocate
+
+Virtual Address Physical Address XCB Size (MB) Description
+--------------- ---------------- --- --------- -----------
+ 0x00000000 0x00000000 010 256 SDRAM (cached)
+ 0x10000000 0x10000000 010 256 SDRAM (alias)
+ 0x20000000 0x00000000 000 256 SDRAM (uncached)
+ 0x48000000 0x48000000 000 64 PCI Data
+ 0x50000000 0x50000000 010 16 Flash (CS0)
+ 0x51000000 0x51000000 000 112 CS1 - CS7
+ 0x60000000 0x60000000 000 64 Queue Manager
+ 0xC0000000 0xC0000000 000 1 PCI Controller
+ 0xC4000000 0xC4000000 000 1 Exp. Bus Config
+ 0xC8000000 0xC8000000 000 1 Misc IXP425 IO
+ 0xCC000000 0xCC000000 000 1 SDRAM Config
+
+</programlisting></para>
+</sect2>
+<sect2>
+<title>Platform Resource Usage</title>
+<para>The IXP425 programmable OStimer0 is used for timeout support
+for networking and XModem file transfers.</para>
+</sect2></sect1>
+
+<?Pub _newpage>
+<sect1 id="GRG">
+<title>ARM/Intel XScale Generic Residential Gateway</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Intel GRG</primary><secondary>installing and
+testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>Intel GRG</secondary></indexterm>RedBoot supports
+the console UART and a PCI based i82559 ethernet card for communication
+and downloads. The default serial port settings are 115200,8,N,1. RedBoot
+also supports flash management for the 16MB onboard flash.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from flash
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+</sect2>
+<sect2>
+<title>Initial Installation Method</title>
+<para>The GRG flash is socketed, so initial installation may be done using
+an appropriate device programmer. JTAG based initial may also be used. In either
+case, the ROM mode RedBoot is programmed into the boot flash at address 0x00000000.
+</para>
+
+<para>After booting the initial installation of RedBoot, this warning may
+be printed: <screen>flash configuration checksum error or invalid key
+</screen>This is normal, and indicates that the flash should be configured
+for use by RedBoot. See <xref linkend="Persistent-State-Flash"> for more
+details.
+</para></sect2>
+<sect2>
+<title>Rebuilding RedBoot </title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=grg
+export ARCH_DIR=arm
+export PLATFORM_DIR=xscale/grg
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+</sect2>
+
+<sect2>
+<title>Interrupts</title>
+<para>RedBoot uses an interrupt vector table which is located at address 0x8004.
+Entries in this table are pointers to functions with this protoype:: <programlisting>
+int irq_handler( unsigned vector, unsigned data )</programlisting>On the GRG
+board, the vector argument is one of many interrupts defined in <computeroutput>
+hal/arm/xscale/ixp425/current/include/hal_var_ints.h:</computeroutput>: <programlisting>
+#define CYGNUM_HAL_INTERRUPT_NPEA 0
+#define CYGNUM_HAL_INTERRUPT_NPEB 1
+#define CYGNUM_HAL_INTERRUPT_NPEC 2
+#define CYGNUM_HAL_INTERRUPT_QM1 3
+#define CYGNUM_HAL_INTERRUPT_QM2 4
+#define CYGNUM_HAL_INTERRUPT_TIMER0 5
+#define CYGNUM_HAL_INTERRUPT_GPIO0 6
+#define CYGNUM_HAL_INTERRUPT_GPIO1 7
+#define CYGNUM_HAL_INTERRUPT_PCI_INT 8
+#define CYGNUM_HAL_INTERRUPT_PCI_DMA1 9
+#define CYGNUM_HAL_INTERRUPT_PCI_DMA2 10
+#define CYGNUM_HAL_INTERRUPT_TIMER1 11
+#define CYGNUM_HAL_INTERRUPT_USB 12
+#define CYGNUM_HAL_INTERRUPT_UART2 13
+#define CYGNUM_HAL_INTERRUPT_TIMESTAMP 14
+#define CYGNUM_HAL_INTERRUPT_UART1 15
+#define CYGNUM_HAL_INTERRUPT_WDOG 16
+#define CYGNUM_HAL_INTERRUPT_AHB_PMU 17
+#define CYGNUM_HAL_INTERRUPT_XSCALE_PMU 18
+#define CYGNUM_HAL_INTERRUPT_GPIO2 19
+#define CYGNUM_HAL_INTERRUPT_GPIO3 20
+#define CYGNUM_HAL_INTERRUPT_GPIO4 21
+#define CYGNUM_HAL_INTERRUPT_GPIO5 22
+#define CYGNUM_HAL_INTERRUPT_GPIO6 23
+#define CYGNUM_HAL_INTERRUPT_GPIO7 24
+#define CYGNUM_HAL_INTERRUPT_GPIO8 25
+#define CYGNUM_HAL_INTERRUPT_GPIO9 26
+#define CYGNUM_HAL_INTERRUPT_GPIO10 27
+#define CYGNUM_HAL_INTERRUPT_GPIO11 28
+#define CYGNUM_HAL_INTERRUPT_GPIO12 29
+#define CYGNUM_HAL_INTERRUPT_SW_INT1 30
+#define CYGNUM_HAL_INTERRUPT_SW_INT2 31
+</programlisting>
+The data passed to the ISR is pulled from a data table <computeroutput>(hal_interrupt_data)
+</computeroutput> which immediately follows the interrupt vector table. With
+32 interrupts, the data table starts at address 0x8084. </para>
+<para>An application may create a normal C function with the above prototype
+to be an ISR. Just poke its address into the table at the correct index and
+enable the interrupt at its source. The return value of the ISR is ignored
+by RedBoot.</para>
+</sect2>
+<sect2>
+<title>Memory Maps</title>
+<para>The RAM based page table is located at RAM start + 0x4000.
+<note><title>NOTE</title>
+<para>The virtual memory maps in this section use a C, B, and X column to indicate
+the caching policy for the region..</para>
+</note></para>
+<para><programlisting>
+X C B Description
+- - - ---------------------------------------------
+0 0 0 Uncached/Unbuffered
+0 0 1 Uncached/Buffered
+0 1 0 Cached/Buffered Write Through, Read Allocate
+0 1 1 Cached/Buffered Write Back, Read Allocate
+1 0 0 Invalid -- not used
+1 0 1 Uncached/Buffered No write buffer coalescing
+1 1 0 Mini DCache - Policy set by Aux Ctl Register
+1 1 1 Cached/Buffered Write Back, Read/Write Allocate
+
+Virtual Address Physical Address XCB Size (MB) Description
+--------------- ---------------- --- --------- -----------
+ 0x00000000 0x00000000 010 32 SDRAM (cached)
+ 0x10000000 0x00000000 010 32 SDRAM (alias)
+ 0x20000000 0x00000000 000 32 SDRAM (uncached)
+ 0x48000000 0x48000000 000 64 PCI Data
+ 0x50000000 0x50000000 010 16 Flash (CS0)
+ 0x51000000 0x51000000 000 112 CS1 - CS7
+ 0x60000000 0x60000000 000 64 Queue Manager
+ 0xC0000000 0xC0000000 000 1 PCI Controller
+ 0xC4000000 0xC4000000 000 1 Exp. Bus Config
+ 0xC8000000 0xC8000000 000 1 Misc IXP425 IO
+ 0xCC000000 0xCC000000 000 1 SDRAM Config
+
+</programlisting></para>
+</sect2>
+<sect2>
+<title>Platform Resource Usage</title>
+<para>The IXP425 programmable OStimer0 is used for timeout support
+for networking and XModem file transfers.</para>
+</sect2></sect1>
+
+<?Pub _newpage>
+<sect1 id="PrPMC1100">
+<title>Motorola PrPMC1100 CPU card</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Motorola PrPMC1100</primary><secondary>installing and
+testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>Motorola PrPMC1100</secondary></indexterm>RedBoot supports
+the builtin high-speed and console UARTs
+.
+The console UART is the default and feeds the front panel COM1 connector. The
+high-speed UART signals are only available from the PN4 IO connector. Therefore,
+usability of this port depends on the carrier board used. The default serial
+port settings are 115200,8,N,1. RedBoot also supports flash management for
+the 16MB boot flash on the mainboard.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from flash
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+</sect2>
+<sect2>
+<title>Initial Installation Method</title>
+<para>The PrPMC1100 flash is socketed, so initial installation may be done using
+an appropriate device programmer. JTAG based flash programming may also be used.
+In either case, the ROM mode RedBoot is programmed into the boot flash at address
+0x00000000.
+</para>
+
+<para>After booting the initial installation of RedBoot, this warning may
+be printed: <screen>flash configuration checksum error or invalid key
+</screen>This is normal, and indicates that the flash should be configured
+for use by RedBoot. Even if this message is not seen, it is recommended that
+the <command>fconfig</command> be run to initialize the flash configuration
+area. See <xref linkend="Persistent-State-Flash"> for more details.
+</para></sect2>
+
+<sect2>
+<title>Rebuilding RedBoot </title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=prpmc1100
+export ARCH_DIR=arm
+export PLATFORM_DIR=xscale/prpmc1100
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+</sect2>
+
+<sect2>
+<title>Interrupts</title>
+<para>RedBoot uses an interrupt vector table which is located at address 0x8004.
+Entries in this table are pointers to functions with this protoype:: <programlisting>
+int irq_handler( unsigned vector, unsigned data )</programlisting>On the PrPMC1100
+board, the vector argument is one of many interrupts defined in <computeroutput>
+hal/arm/xscale/ixp425/current/include/hal_var_ints.h:</computeroutput>: <programlisting>
+#define CYGNUM_HAL_INTERRUPT_NPEA 0
+#define CYGNUM_HAL_INTERRUPT_NPEB 1
+#define CYGNUM_HAL_INTERRUPT_NPEC 2
+#define CYGNUM_HAL_INTERRUPT_QM1 3
+#define CYGNUM_HAL_INTERRUPT_QM2 4
+#define CYGNUM_HAL_INTERRUPT_TIMER0 5
+#define CYGNUM_HAL_INTERRUPT_GPIO0 6
+#define CYGNUM_HAL_INTERRUPT_GPIO1 7
+#define CYGNUM_HAL_INTERRUPT_PCI_INT 8
+#define CYGNUM_HAL_INTERRUPT_PCI_DMA1 9
+#define CYGNUM_HAL_INTERRUPT_PCI_DMA2 10
+#define CYGNUM_HAL_INTERRUPT_TIMER1 11
+#define CYGNUM_HAL_INTERRUPT_USB 12
+#define CYGNUM_HAL_INTERRUPT_UART2 13
+#define CYGNUM_HAL_INTERRUPT_TIMESTAMP 14
+#define CYGNUM_HAL_INTERRUPT_UART1 15
+#define CYGNUM_HAL_INTERRUPT_WDOG 16
+#define CYGNUM_HAL_INTERRUPT_AHB_PMU 17
+#define CYGNUM_HAL_INTERRUPT_XSCALE_PMU 18
+#define CYGNUM_HAL_INTERRUPT_GPIO2 19
+#define CYGNUM_HAL_INTERRUPT_GPIO3 20
+#define CYGNUM_HAL_INTERRUPT_GPIO4 21
+#define CYGNUM_HAL_INTERRUPT_GPIO5 22
+#define CYGNUM_HAL_INTERRUPT_GPIO6 23
+#define CYGNUM_HAL_INTERRUPT_GPIO7 24
+#define CYGNUM_HAL_INTERRUPT_GPIO8 25
+#define CYGNUM_HAL_INTERRUPT_GPIO9 26
+#define CYGNUM_HAL_INTERRUPT_GPIO10 27
+#define CYGNUM_HAL_INTERRUPT_GPIO11 28
+#define CYGNUM_HAL_INTERRUPT_GPIO12 29
+#define CYGNUM_HAL_INTERRUPT_SW_INT1 30
+#define CYGNUM_HAL_INTERRUPT_SW_INT2 31
+</programlisting>
+The data passed to the ISR is pulled from a data table <computeroutput>(hal_interrupt_data)
+</computeroutput> which immediately follows the interrupt vector table. With
+32 interrupts, the data table starts at address 0x8084. </para>
+<para>An application may create a normal C function with the above prototype
+to be an ISR. Just poke its address into the table at the correct index and
+enable the interrupt at its source. The return value of the ISR is ignored
+by RedBoot.</para>
+</sect2>
+<sect2>
+<title>Memory Maps</title>
+<para>The RAM based page table is located at RAM start + 0x4000.
+<note><title>NOTE</title>
+<para>The virtual memory maps in this section use a C, B, and X column to indicate
+the caching policy for the region..</para>
+</note></para>
+<para><programlisting>
+X C B Description
+- - - ---------------------------------------------
+0 0 0 Uncached/Unbuffered
+0 0 1 Uncached/Buffered
+0 1 0 Cached/Buffered Write Through, Read Allocate
+0 1 1 Cached/Buffered Write Back, Read Allocate
+1 0 0 Invalid -- not used
+1 0 1 Uncached/Buffered No write buffer coalescing
+1 1 0 Mini DCache - Policy set by Aux Ctl Register
+1 1 1 Cached/Buffered Write Back, Read/Write Allocate
+
+Virtual Address Physical Address XCB Size (MB) Description
+--------------- ---------------- --- --------- -----------
+ 0x00000000 0x00000000 010 256 SDRAM (cached)
+ 0x10000000 0x10000000 010 256 SDRAM (alias)
+ 0x20000000 0x00000000 000 256 SDRAM (uncached)
+ 0x48000000 0x48000000 000 64 PCI Data
+ 0x50000000 0x50000000 010 16 Flash (CS0)
+ 0x51000000 0x51000000 000 112 CS1 - CS7
+ 0x60000000 0x60000000 000 64 Queue Manager
+ 0xC0000000 0xC0000000 000 1 PCI Controller
+ 0xC4000000 0xC4000000 000 1 Exp. Bus Config
+ 0xC8000000 0xC8000000 000 1 Misc CPU IO
+ 0xCC000000 0xCC000000 000 1 SDRAM Config
+
+</programlisting></para>
+</sect2>
+<sect2>
+<title>Platform Resource Usage</title>
+<para>The CPU programmable OStimer0 is used for timeout support
+for networking and XModem file transfers.</para>
+</sect2></sect1>
+
+<!-- ********************** CalmRISC ********************** -->
+<?Pub _newpage>
+<sect1 id="CalmRISC16">
+<title>CalmRISC/CalmRISC16 Samsung CalmRISC16 Core Evaluation Board </title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Samsung CalmRISC16 Core EVB</primary><secondary>installing
+and testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>Samsung CalmRISC16 Core EVB</secondary></indexterm> The
+Samsung CalmRISC16 evaluation platform consists of two boards connected by a
+ribbon cable. One board contains the CPU core and memory. The other board is
+called the MDSChip board and provides the host interface. The calmRISC16 is a
+harvard architecture with separate 22-bit program and data addresses. The
+instruction set provides no instruction for writing to program memory. The
+MDSChip board firmware (called CalmBreaker) provides a pseudo register interface
+so that code running on the core has access to a serial channel and a mechanism
+to write to program memory. The serial channel is fixed at 57600-8-N-1 by the
+firmware. The CalmBreaker firmware also provides a serial protocol which
+allows a host to download a program and to start or stop the core board.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running via the MDSChip board.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+</sect2>
+<sect2>
+<title>Initial Installation Method </title>
+<para>The CalmRISC16 core is controlled through the MDSChip board. There is
+no non-volatile storage available for RedBoot, so RedBoot must be downloaded
+to the board on every power cycle. A small utility program is used to download
+S-record files to the eval board. Sources and build instructions for this
+utility are located in the RedBoot sources in:
+<filename class="directory">packages/hal/calmrisc16/ceb/current/support
+</filename></para>
+<para>To download the RedBoot image, first press the reset button on the MDSChip
+board. The green 'Run' LED on the core board should go off. Now, use the
+utility to download the RedBoot image with:
+<screen>$ <userinput>calmbreaker -p /dev/term/b --reset --srec-code -f redboot.elf</userinput>
+</screen>
+Note that the '-p /dev/term/b' specifies the serial port to use and will vary
+from system to system. The download will take about two minutes. After it
+finishes, start RedBoot with:
+<screen>$ <userinput>calmbreaker -p /dev/term/b --run</userinput></screen>
+The 'Run' LED on the core board should be on. Connecting to the MDSboard with
+a terminal and typing enter should result in RedBoot reprinting the command
+prompt.
+</para>
+</sect2>
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>None.</para>
+</sect2>
+<sect2>
+<title>Special Note on Serial Channel </title>
+<para>The MDSChip board uses a relatively slow microcontroller to provide
+the pseudo-register interface to the core board. This pseudo-register
+interface provides access to the serial channel and write access to program
+memory. Those interfaces are slow and the serial channel is easily overrun
+by a fast host. For this reason, GDB must be told to limit the size of code
+download packets to avoid serial overrun. This is done with the following
+GDB command:
+<screen>(gdb) <userinput>set download-write-size 25</userinput></screen>
+</para>
+</sect2>
+<sect2>
+
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=calm16_ceb
+export ARCH_DIR=calmrisc16
+export PLATFORM_DIR=ceb
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2>
+</sect1>
+
+<?Pub _newpage>
+<sect1 id="CalmRISC32">
+<title>CalmRISC/CalmRISC32 Samsung CalmRISC32 Core Evaluation Board </title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Samsung CalmRISC32 Core EVB</primary><secondary>installing
+and testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>Samsung CalmRISC32 Core EVB</secondary></indexterm> The
+Samsung CalmRISC32 evaluation platform consists of two boards connected by a
+ribbon cable. One board contains the CPU core and memory. The other board is
+called the MDSChip board and provides the host interface. The calmRISC32 is a
+harvard architecture with separate 32-bit program and data addresses. The
+instruction set provides no instruction for writing to program memory. The
+MDSChip board firmware (called CalmBreaker) provides a pseudo register interface
+so that code running on the core has access to a serial channel and a mechanism
+to write to program memory. The serial channel is fixed at 57600-8-N-1 by the
+firmware. The CalmBreaker firmware also provides a serial protocol which
+allows a host to download a program and to start or stop the core board.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running via the MDSChip board.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+</sect2>
+<sect2>
+<title>Initial Installation Method </title>
+<para>The calmRISC32 core is controlled through the MDSChip board. There is
+no non-volatile storage available for RedBoot, so RedBoot must be downloaded
+to the board on every power cycle. A small utility program is used to download
+S-record files to the eval board. Sources and build instructions for this
+utility are located in the RedBoot sources in:
+<filename class="directory">packages/hal/calmrisc32/ceb/current/support
+</filename></para>
+<para>To download the RedBoot image, first press the reset button on the MDSChip
+board. The green 'Run' LED on the core board should go off. Now, use the
+utility to download the RedBoot image with:
+<screen>$ <userinput>calmbreaker -p /dev/term/b --reset --srec-code -f redboot.elf</userinput>
+</screen>
+Note that the '-p /dev/term/b' specifies the serial port to use and will vary
+from system to syetm. The download will take about two minutes. After it
+finishes, start RedBoot with:
+<screen>$ <userinput>calmbreaker -p /dev/term/b --run</userinput></screen>
+The 'Run' LED on the core board should be on. Connecting to the MDSboard with
+a terminal and typing enter should result in RedBoot reprinting the command
+prompt.
+</para>
+</sect2>
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>None.</para>
+</sect2>
+<sect2>
+<title>Special Note on Serial Channel </title>
+<para>The MDSChip board uses a relatively slow microcontroller to provide
+the pseudo-register interface to the core board. This pseudo-register
+interface provides access to the serial channel and write access to program
+memory. Those interfaces are slow and the serial channel is easily overrun
+by a fast host. For this reason, GDB must be told to limit the size of code
+download packets to avoid serial overrun. This is done with the following
+GDB command:
+<screen>(gdb) <userinput>set download-write-size 25</userinput></screen>
+</para>
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=calm32_ceb
+export ARCH_DIR=calmrisc32
+export PLATFORM_DIR=ceb
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2>
+</sect1>
+
+<!-- ******************************** FRV ********************* -->
+
+<?Pub _newpage>
+<sect1 id="frv400">
+<title>FRV/FRV400 Fujitsu FR-V 400 (MB-93091)</title>
+<sect2>
+<title>Overview</title>
+
+<para><indexterm><primary>Fujitsu FR-V 400</primary>
+<secondary>installing and testing</secondary></indexterm><indexterm><primary>
+installing and testing
+</primary><secondary>Fujitsu FR-V 400</secondary></indexterm>
+RedBoot supports both serial ports, which are available via
+the stacked serial connectors on the mother board.
+The topmost port is the default and is considered to be port 0 by RedBoot.
+The bottommost port is serial port 1.
+The default serial port settings are 38400,8,N,1.
+</para>
+<para>
+FLASH management is also supported, but only for the FLASH device in IC7.
+This arrangement allows for IC8 to retain either the original Fujitsu board
+firmware, or some application specific contents.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROMRAM</entry>
+ <entry>[ROMRAM]</entry>
+ <entry>RedBoot running from RAM, but contained in the
+ board's flash boot sector.</entry>
+ <entry>redboot_ROMRAM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+</sect2>
+
+<sect2>
+<title>Initial Installation Method </title>
+
+<para>
+RedBoot can be installed by directly programming the FLASH device in IC7
+or by using the Fujitsu provided software to download and install a
+version into the FLASH device. Complete instructions are provided
+separately.
+</para>
+
+</sect2>
+
+<sect2>
+<title>Special RedBoot Commands</title>
+
+<para>None.</para>
+</sect2>
+
+<sect2>
+<title>Memory Maps</title>
+
+<para>The memory map of this platform is fixed by the hardware (cannot
+be changed by software). The only attributes which can be modified are
+control over cacheability, as noted below.
+<screen>
+Address Cache? Resource
+00000000-03EFFFFF Yes SDRAM (via plugin DIMM)
+03F00000-03FFFFFF No SDRAM (used for PCI window)
+10000000-1FFFFFFF No MB86943 PCI bridge
+20000000-201FFFFF No SRAM
+21000000-23FFFFFF No Motherboard resources
+24000000-25FFFFFF No PCI I/O space
+26000000-2FFFFFFF No PCI Memory space
+30000000-FDFFFFFF ?? Unused
+FE000000-FEFFFFFF No I/O devices
+FF000000-FF1FFFFF No IC7 - RedBoot FLASH
+FF200000-FF3FFFFF No IC8 - unused FLASH
+FF400000-FFFFFFFF No Misc other I/O
+</screen>
+</para>
+
+<note> <title>NOTE</title>
+<para>
+The only configuration currently suppored requires a 64MB SDRAM
+DIMM to be present on the CPU card. No other memory configuration
+is supported at this time.
+</para>
+</note>
+
+</sect2>
+
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=frv400
+export ARCH_DIR=frv
+export PLATFORM_DIR=frv400
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+</sect2>
+
+</sect1>
+
+<?Pub _newpage>
+<sect1 id="mb93091">
+<title>Fujitsu FR-V Design Kit (MB93091-CBxx)</title>
+<sect2>
+<title>Overview</title>
+
+<para><indexterm><primary>Fujitsu FR-V MB93091-CBxx Design
+Kit</primary> <secondary>installing and
+testing</secondary></indexterm><indexterm><primary> installing and
+testing </primary><secondary>Fujitsu FR-V MB93091-CBxx Design
+Kit</secondary></indexterm> RedBoot supports both serial ports, which
+are available via the stacked serial connectors on the mother board in
+the case of the FR400 CPU board, and via serial connectors present on
+the other supported CPU boards themselves. The topmost port is the
+default and is considered to be port 0 by RedBoot. The bottommost
+port is serial port 1. The default serial port settings are
+115200,8,N,1. The serial port supports baud rates up to 460800, which
+can be set using the <command>baud</command> command as described in
+<xref linkend="RedBoot-Commands-and-Examples">.
+
+</para>
+<para>
+FLASH management is also supported, but only for the FLASH device in IC7.
+This arrangement allows for IC8 to retain either the original Fujitsu board
+firmware, or some application specific contents.
+Two basic RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROMRAM</entry>
+ <entry>[ROMRAM]</entry>
+ <entry>RedBoot running from RAM, but contained in the
+ board's flash boot sector.</entry>
+ <entry>redboot_ROMRAM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+<para>Since the normal RedBoot configuration does not use the FLASH ROM
+except during startup, it is unnecessary to load a RAM-based RedBoot
+before reprogramming the FLASH.</para>
+</sect2>
+
+<sect2>
+<title>Initial Installation Method </title>
+
+<para>
+RedBoot can be installed by directly programming the FLASH device in IC7
+or by using the Fujitsu provided software to download and install a
+version into the FLASH device. Complete instructions are provided
+separately.
+</para>
+
+</sect2>
+
+<sect2>
+<title>Special RedBoot Commands</title>
+
+<para>The <command>exec</command> command as described in <xref linkend="RedBoot-Commands-and-Examples">
+is supported by RedBoot on this target, for executing Linux kernels. Only the command line and timeout options
+are relevant to this platform.</para>
+</sect2>
+
+<sect2>
+<title>Memory Maps</title>
+
+<para>The memory map of this platform is fixed by the hardware (cannot
+be changed by software). The only attributes which can be modified are
+control over cacheability, as noted below.
+<screen>
+Address Cache? Resource
+00000000-03EFFFFF Yes SDRAM (via plugin DIMM)
+03F00000-03FFFFFF No SDRAM (used for PCI window)
+10000000-1FFFFFFF No MB86943 PCI bridge
+20000000-201FFFFF No SRAM
+21000000-23FFFFFF No Motherboard resources
+24000000-25FFFFFF No PCI I/O space
+26000000-2FFFFFFF No PCI Memory space
+30000000-FDFFFFFF ?? Unused
+FE000000-FEFFFFFF No I/O devices
+FF000000-FF1FFFFF No IC7 - RedBoot FLASH
+FF200000-FF3FFFFF No IC8 - unused FLASH
+FF400000-FFFFFFFF No Misc other I/O
+</screen>
+</para>
+
+<note> <title>NOTE</title>
+<para>
+The only configuration currently suppored requires a 64MiB SDRAM
+DIMM to be present on the CPU card. No other memory configuration
+is supported at this time.
+</para>
+</note>
+
+</sect2>
+
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=mb93091
+export ARCH_DIR=frv
+export PLATFORM_DIR=mb93091
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+</sect2>
+
+<sect2>
+<title>Resource Usage</title>
+
+<para>
+The RedBoot image occupies flash addresses 0xFF000000 - 0xFF03FFFF. To
+execute it copies itself out of there to RAM at 0x03E00000. RedBoot
+reserves memory from 0x00000000 to 0x0001FFFF for its own use.
+User programs can use memory from 0x00020000 to 0x03DFFFFF.
+RAM based RedBoot configurations are
+designed to run from RAM at 0x00020000.
+</para>
+</sect2>
+
+</sect1>
+
+<?Pub _newpage>
+<sect1 id="mb93093">
+<title>Fujitsu FR-V Portable Demonstration Kit (MB93093-PD00)</title>
+<sect2>
+<title>Overview</title>
+
+<para><indexterm><primary>Fujitsu FR-V Portable Demonstration Kit</primary>
+<secondary>installing and testing</secondary></indexterm><indexterm><primary>
+installing and testing
+</primary><secondary>Fujitsu FR-V Portable Demonstration Kit</secondary></indexterm>
+RedBoot supports the serial port which is available via a special cable connected
+to the CON_UART connector on the board. The default serial port settings are 115200,8,N,1.
+The serial port supports baud rates up to 460800, which can be set using the <command>baud</command>
+command as described in <xref linkend="RedBoot-Commands-and-Examples">.
+</para>
+
+<para>
+FLASH management is also supported.
+Two basic RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROMRAM</entry>
+ <entry>[ROMRAM]</entry>
+ <entry>RedBoot running from RAM, but contained in the
+ board's flash boot sector.</entry>
+ <entry>redboot_ROMRAM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+<para>Since the normal RedBoot configuration does not use the FLASH ROM
+except during startup, it is unnecessary to load a RAM-based RedBoot
+before reprogramming the FLASH.</para>
+</sect2>
+
+<sect2>
+<title>Initial Installation Method </title>
+
+<para>
+The Portable Demonstration Kit should have been shipped with an existing
+version of RedBoot, which can be upgraded to the current version using
+the instructions below.
+</para>
+
+</sect2>
+
+<sect2>
+<title>Special RedBoot Commands</title>
+
+<para>The <command>exec</command> command as described in <xref linkend="RedBoot-Commands-and-Examples">
+is supported by RedBoot on this target, for executing Linux kernels. Only the command line and timeout options
+are relevant to this platform.</para>
+</sect2>
+
+<sect2>
+<title>Memory Maps</title>
+
+<para>The memory map of this platform is fixed by the hardware (cannot
+be changed by software). The only attributes which can be modified are
+control over cacheability, as noted below.
+<screen>
+Address Cache? Resource
+00000000-03EFFFFF Yes SDRAM (via plugin DIMM)
+03F00000-03FFFFFF No Unused (SDRAM)
+10000000-1FFFFFFF No AX88796 Ethernet
+20000000-2FFFFFFF No System FPGA
+30000000-3FFFFFFF No MB93493 companion chip (unused)
+40000000-FCFFFFFF ?? Unused
+FD000000-FDFFFFFF ?? FLASH (ROM3,ROM4) (unused)
+FE000000-FEFFFFFF No Miscellaneous on-chip I/O
+FF000000-FFFFFFFF No RedBoot FLASH (16MiB)
+</screen>
+</para>
+
+<note> <title>NOTE</title>
+<para>
+The only configuration currently suppored requires a 64MiB SDRAM
+DIMM to be present on the CPU card. No other memory configuration
+is supported at this time.
+</para>
+</note>
+
+</sect2>
+
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=mb93093
+export ARCH_DIR=frv
+export PLATFORM_DIR=mb93093
+</programlisting>
+</para>
+</sect2>
+
+<sect2>
+<title>Resource Usage</title>
+
+<para>
+The RedBoot image occupies flash addresses 0xFF000000 - 0xFF03FFFF. To
+execute it copies itself out of there to RAM at 0x03E00000. RedBoot
+reserves memory from 0x00000000 to 0x0001FFFF for its own use.
+User programs can use memory from 0x00020000 to 0x03DFFFFF.
+RAM based RedBoot configurations are
+designed to run from RAM at 0x00020000.
+</para>
+</sect2>
+
+</sect1>
+
+
+<!-- ********************************* IA32 *************************** -->
+<?Pub _newpage>
+<sect1 id="x86pc">
+<title>IA32/x86 x86-Based PC</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>x86 Based PC</primary><secondary>installing and
+testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>x86 Based PC</secondary></indexterm>RedBoot supports
+two serial ports and an Intel i82559 based ethernet card (for example an Intel
+EtherExpress Pro 10/100) for communication and downloads. The default serial
+port settings are 38400,8,N,1.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>Floppy</entry>
+ <entry>[Floppy]</entry>
+ <entry>RedBoot running from a boot floppy disk installed
+ in the A: drive of the PC.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+</sect2>
+<sect2>
+<title>Initial Installation</title>
+<para>RedBoot takes the form of a self-booting image that must be written
+onto a formatted floppy disk. The process will erase any file system or data
+that already exists on that disk, so proceed with caution.</para>
+<para>For Red Hat Linux users, this can be done by:</para>
+<screen>$ <userinput>dd conv=sync if=install/bin/redboot.bin of=/dev/fd0H1440
+</userinput></screen>
+<para>For NT Cygwin users, this can be done by first ensuring that the raw
+floppy device is mounted as <filename>/dev/fd0</filename>. To check if this
+is the case, type the command <command>mount</command> at the Cygwin bash
+prompt. If the floppy drive is already mounted, it will be listed as something
+similar to the following line:</para>
+<screen> \\.\a: /dev/fd0 user binmode</screen>
+<para>If this line is not listed, then mount the floppy drive using the command:
+</para>
+<screen>$ <userinput>mount -f -b //./a: /dev/fd0</userinput></screen>
+<para>To actually install the boot image on the floppy, use the command:</para>
+<screen>$ <userinput>dd conv=sync if=install/bin/redboot.bin of=/dev/fd0
+</userinput></screen>
+<para>Insert this floppy in the A: drive of the PC to be used as a target
+and ensure that the BIOS is configured to boot from A: by default. On reset,
+the PC will boot from the floppy and be ready to be debugged via either serial
+line, or via the ethernet interface if it is installed.</para>
+<note><title>NOTE</title>
+<para>Unreliable floppy media may cause the write to silently fail. This
+can be determined if the RedBoot image does not correctly
+boot. In such cases, the floppy should be (unconditionally) reformatted
+using the <command>fdformat</command> command on Linux, or
+<command>format a: /u</command> on DOS/Windows.</para>
+</note>
+</sect2>
+<sect2>
+<title>Flash management</title>
+<para>PC RedBoot does not support any FLASH commands.</para>
+</sect2>
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>None.</para>
+</sect2>
+<sect2>
+<title>Memory Maps </title>
+<para>All selectors are initialized to map the entire 32-bit address space
+in the familiar protected mode flat model. Page translation is not used.
+RAM up to 640K is mapped to 0x0 to 0xa0000. RAM above 640K is mapped
+from address 0x100000 upwards. Space is reserved between 0xa0000 and
+0x100000 for option ROMs and the BIOS.
+</para>
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=pc
+export ARCH_DIR=i386
+export PLATFORM_DIR=pc
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2>
+</sect1>
+
+<!-- *************** MIPS ******************* -->
+
+<?Pub _newpage>
+<sect1 id="atlas">
+<title>MIPS/MIPS32(CoreLV 4Kc)+MIPS64(CoreLV 5Kc) Atlas Board</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>MIPS Atlas Board with CoreLV 4KC and CoreLV 5KC
+</primary><secondary>installing and testing</secondary></indexterm><indexterm>
+<primary>installing and testing</primary><secondary>MIPS Atlas Board with
+CoreLV 4KC and CoreLV 5KC</secondary></indexterm>RedBoot supports the DgbSer
+serial port and the built in ethernet port for communication and downloads.
+The default serial port settings are 115200,8,N,1. RedBoot runs from and supports
+flash management for the system flash region.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+</sect2>
+<sect2>
+<title>Initial Installation</title>
+<para>RedBoot is installed using the code download facility built into the
+Atlas board. See the Atlas User manual for details, and also the Atlas download
+format in <xref linkend="Atlas-download-format">.</para>
+<sect3>
+<title>Quick download instructions</title>
+<para>Here are quick start instructions for downloading the prebuilt RedBoot
+image.</para>
+<orderedlist>
+<listitem><para>Locate the prebuilt files in the bin directory: <filename>
+deleteall.dl</filename> and <filename>redboot.dl</filename>.
+</para>
+</listitem>
+<listitem><para>Make sure switch S1-1 is OFF and switch S5-1 is ON. Reset
+the board and verify that the LED display reads <computeroutput>Flash DL</computeroutput>.
+</para>
+</listitem>
+<listitem><para>Make sure your parallel port is connected to the 1284 port
+Of the Atlas board. </para>
+</listitem>
+<listitem><para>Send the <filename>deleteall.dl</filename> file to the
+parallel port to erase previous images:
+<screen>$ <userinput>cat deleteall.dl >/dev/lp0</userinput></screen>
+When this is complete, the LED display should read
+<computeroutput>Deleted</computeroutput>.</para>
+</listitem>
+<listitem><para>Send the ROM mode RedBoot image to the board:
+<screen>$ <userinput>cat redboot.dl >/dev/lp0</userinput></screen>
+When this is complete, the LED display should show the last
+address programmed. This will be something like: <computeroutput>1fc17000
+</computeroutput>. </para>
+</listitem>
+<listitem><para>Change switch S5-1 to OFF and reset the board. The LED display
+should read <computeroutput>RedBoot</computeroutput>. </para>
+</listitem>
+<listitem><para>Run the RedBoot <command>fis init</command>
+and <command>fconfig</command> commands to initialize the flash.
+See <xref linkend="Atlas-Additional-fconfig-options">, <xref linkend="Flash-Image-System">
+and <xref linkend="Persistent-State-Flash"> for details. </para>
+</listitem>
+</orderedlist>
+</sect3>
+<sect3 id="Atlas-download-format">
+<title>Atlas download format</title>
+<para>In order to download RedBoot to the Atlas board, it must be converted
+to the Atlas download format. There are different ways of doing this depending
+on which version of the developer's kit is shipped with the board. </para>
+<para>The <citetitle>Atlas Developer's Kit</citetitle> CD contains an <application>
+srec2flash</application> utility. The source code for this utility is part
+of the <filename>yamon/yamon-src-01.01.tar.gz</filename> tarball
+on the Dev Kit CD. The path in the expanded tarball is <filename
+class="directory">yamon/bin/tools</filename>. To use
+<application>srec2flash</application> to convert the S-record file:
+<screen>$ <userinput>srec2flash -EL -S29 redboot.srec >redboot.dl</userinput></screen>
+The <citetitle>Atlas/Malta Developer's Kit</citetitle> CD
+contains an <application>srecconv.pl</application> utility which requires
+Perl. This utilty is part of the <filename>yamon/yamon-src-02.00.tar.gz</filename>
+tarball on the Dev Kit CD. The path in the expanded tarball
+is <filename class="directory">yamon/bin/tools</filename>. To use <application>
+srecconv</application> to convert the S-record file:
+<screen>$ <userinput>cp redboot_ROM.srec redboot_ROM.rec</userinput>
+$ <userinput>srecconv.pl -ES L -A 29 redboot_ROM</userinput></screen>
+The resulting file is named <filename>redboot_ROM.fl</filename>.</para>
+</sect3></sect2>
+<sect2>
+<title>Flash management</title>
+<sect3 id="Atlas-Additional-fconfig-options">
+<title>Additional config options</title>
+<para>The ethernet MAC address is stored in flash manually using the <command>
+fconfig</command> command. You can use the YAMON <command>setenv
+ethaddr</command> command to print out the board ethernet address.
+Typically, it is: <screen>00:0d:a0:00:<replaceable>xx:xx</replaceable></screen> where
+<replaceable>xx.xx</replaceable> is the hex representation of the
+board serial number.</para>
+</sect3>
+</sect2>
+<sect2>
+<title>Additional commands</title>
+<para>The <command>exec</command> command which allows the
+loading and execution of Linux kernels, is supported for this architecture
+ (see <xref linkend="executing-programs">). The
+<command>exec</command> parameters used for MIPS boards are:</para>
+<variablelist><varlistentry>
+<term>-b <replaceable>&lt;addr></replaceable></term>
+<listitem><para>Location to store command line and environment passed to kernel</para></listitem></varlistentry>
+<varlistentry><term>
+-w <replaceable>&lt;time></replaceable></term>
+<listitem><para>Wait time in seconds before starting kernel</para></listitem></varlistentry>
+<varlistentry><term>
+-c <replaceable>"params"</replaceable></term>
+<listitem><para>Parameters passed to kernel</para></listitem></varlistentry>
+<varlistentry><term><replaceable>&lt;addr></replaceable></term>
+<listitem><para>Kernel entry point, defaulting to the entry point of the last image
+loaded</para></listitem></varlistentry>
+</variablelist>
+<para>Linux kernels on MIPS platforms expect the entry point to be called with arguments
+in the registers equivalent to a C call with prototype:
+<programlisting>void Linux(int argc, char **argv, char **envp);</programlisting></para>
+<para>RedBoot will place the appropriate data at the offset specified by the
+<parameter>-b</parameter> parameter, or by default at address 0x80080000, and will set the
+arguments accordingly when calling into the kernel.</para>
+<para>
+The default entry point, if no image with explicit entry point has been loaded and
+none is specified, is 0x80000750.
+</para>
+</sect2>
+
+<sect2>
+<title>Interrupts</title>
+<para>RedBoot uses an interrupt vector table which is located at address 0x80000400.
+Entries in this table are pointers to functions with this protoype: <programlisting>
+int irq_handler( unsigned vector, unsigned data )</programlisting>On an atlas
+board, the vector argument is one of 25 interrupts defined in <computeroutput>
+hal/mips/atlas/<replaceable>VERSION</replaceable>/include/plf_intr.h</computeroutput>: <programlisting>
+#define CYGNUM_HAL_INTERRUPT_SER 0
+#define CYGNUM_HAL_INTERRUPT_TIM0 1
+#define CYGNUM_HAL_INTERRUPT_2 2
+#define CYGNUM_HAL_INTERRUPT_3 3
+#define CYGNUM_HAL_INTERRUPT_RTC 4
+#define CYGNUM_HAL_INTERRUPT_COREHI 5
+#define CYGNUM_HAL_INTERRUPT_CORELO 6
+#define CYGNUM_HAL_INTERRUPT_7 7
+#define CYGNUM_HAL_INTERRUPT_PCIA 8
+#define CYGNUM_HAL_INTERRUPT_PCIB 9
+#define CYGNUM_HAL_INTERRUPT_PCIC 10
+#define CYGNUM_HAL_INTERRUPT_PCID 11
+#define CYGNUM_HAL_INTERRUPT_ENUM 12
+#define CYGNUM_HAL_INTERRUPT_DEG 13
+#define CYGNUM_HAL_INTERRUPT_ATXFAIL 14
+#define CYGNUM_HAL_INTERRUPT_INTA 15
+#define CYGNUM_HAL_INTERRUPT_INTB 16
+#define CYGNUM_HAL_INTERRUPT_INTC 17
+#define CYGNUM_HAL_INTERRUPT_INTD 18
+#define CYGNUM_HAL_INTERRUPT_SERR 19
+#define CYGNUM_HAL_INTERRUPT_HW1 20
+#define CYGNUM_HAL_INTERRUPT_HW2 21
+#define CYGNUM_HAL_INTERRUPT_HW3 22
+#define CYGNUM_HAL_INTERRUPT_HW4 23
+#define CYGNUM_HAL_INTERRUPT_HW5 24</programlisting>The data
+passed to the ISR is pulled from a data table (<computeroutput>hal_interrupt_data
+</computeroutput>) which immediately follows the interrupt vector table. With
+25 interrupts, the data table starts at address 0x80000464 on atlas.</para>
+<para>An application may create a normal C function with the above prototype
+to be an ISR. Just poke its address into the table at the correct index and
+enable the interrupt at its source. The return value of the ISR is ignored
+by RedBoot. </para>
+</sect2>
+<sect2>
+<title>Memory Maps </title>
+<para>Memory Maps RedBoot sets up the following memory map on the Atlas board.
+<programlisting>Physical Address Range Description
+----------------------- -------------
+0x00000000 - 0x07ffffff SDRAM
+0x08000000 - 0x17ffffff PCI Memory Space
+0x18000000 - 0x1bdfffff PCI I/O Space
+0x1be00000 - 0x1bffffff System Controller
+0x1c000000 - 0x1dffffff System flash
+0x1e000000 - 0x1e3fffff Monitor flash
+0x1f000000 - 0x1fbfffff FPGA</programlisting></para>
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=atlas_mips32_4kc
+export TARGET=atlas_mips64_5kc
+export ARCH_DIR=mips
+export PLATFORM_DIR=atlas
+</programlisting>
+
+Use one of the TARGET settings only.
+
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2>
+</sect1>
+<?Pub _newpage>
+<sect1 id="malta">
+<title>MIPS/MIPS32(CoreLV 4Kc)+MIPS64(CoreLV 5Kc) Malta Board </title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>MIPS Malta Board with CoreLV 4KC and CoreLV 5KC
+</primary><secondary>installing and testing</secondary></indexterm><indexterm>
+<primary>installing and testing</primary><secondary>MIPS Malta Board with
+CoreLV 4KC and CoreLV 5KC</secondary></indexterm>RedBoot supports both front
+facing serial ports and the built in ethernet port for communication and downloads.
+The default serial port settings are 38400,8,N,1. RedBoot runs from and supports
+flash management for the system flash region.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+</sect2>
+<sect2>
+<title>Initial Installation</title>
+<para>RedBoot is installed using the code download facility built into the
+Malta board. See the Malta User manual for details, and also the Malta download
+format in <xref linkend="Malta-download-format">.</para>
+<sect3>
+<title>Quick download instructions</title>
+<para>Here are quick start instructions for downloading the prebuilt RedBoot
+image. </para>
+<orderedlist>
+<listitem><para>Locate the prebuilt files in the bin directory: <filename>
+deleteall.fl</filename> and <filename>redboot_ROM.fl</filename>. </para>
+</listitem>
+<listitem><para>Make sure switch S5-1 is ON. Reset the board and verify that
+the LED display reads <computeroutput>Flash DL</computeroutput>. </para>
+</listitem>
+<listitem><para>Make sure your parallel port is connected to the 1284 port
+Of the Atlas board. </para>
+</listitem>
+<listitem><para>Send the <filename>deleteall.fl</filename> file to the
+parallel port to erase previous images:
+<screen>$ <userinput>cat deleteall.fl >/dev/lp0</userinput></screen>
+When this is complete, the LED display should read
+<computeroutput>Deleted</computeroutput>.</para>
+</listitem>
+<listitem><para>Send the RedBoot image to the board:
+<screen>$ <userinput>cat redboot_ROM.fl >/dev/lp0</userinput></screen>
+When this is complete, the LED display should show the last address
+programmed. This will be something like:
+<computeroutput>1fc17000</computeroutput>. </para>
+</listitem>
+<listitem><para>Change switch S5-1 to OFF and reset the board. The LED display
+should read <computeroutput>RedBoot</computeroutput>. </para>
+</listitem>
+<listitem><para>Run the RedBoot <command>fis init</command> and <command>
+fconfig</command> commands to initialize the flash. See <xref linkend="Flash-Image-System">
+and <xref linkend="Persistent-State-Flash"> for details. </para>
+</listitem>
+</orderedlist>
+</sect3>
+<sect3 id="malta-download-format">
+<title>Malta download format</title>
+<para>In order to download RedBoot to the Malta board, it must be converted
+to the Malta download format.</para>
+<para>The <citetitle>Atlas/Malta Developer's Kit</citetitle> CD contains an <application>
+srecconv.pl</application> utility which requires Perl. This utility is part
+of the <filename>yamon/yamon-src-02.00.tar.gz</filename> tarball
+on the Dev Kit CD. The path in the expanded tarball is <filename
+class="directory">yamon/bin/tools</filename>. To use
+<application>srecconv</application> to convert the S-record file:
+<screen>$ <userinput>cp redboot_ROM.srec redboot_ROM.rec</userinput>
+$ <userinput>srecconv.pl -ES L -A 29 redboot_ROM</userinput></screen>
+The resulting file is named <filename>redboot_ROM.fl</filename>.</para>
+</sect3></sect2>
+
+<sect2>
+<title>Additional commands</title>
+<para>The <command>exec</command> command which allows the
+loading and execution of Linux kernels, is supported for this architecture
+ (see <xref linkend="executing-programs">). The
+<command>exec</command> parameters used for MIPS boards are:</para>
+<variablelist><varlistentry>
+<term>-b <replaceable>&lt;addr></replaceable></term>
+<listitem><para>Location to store command line and environment passed to kernel</para></listitem></varlistentry>
+<varlistentry><term>
+-w <replaceable>&lt;time></replaceable></term>
+<listitem><para>Wait time in seconds before starting kernel</para></listitem></varlistentry>
+<varlistentry><term>
+-c <replaceable>"params"</replaceable></term>
+<listitem><para>Parameters passed to kernel</para></listitem></varlistentry>
+<varlistentry><term><replaceable>&lt;addr></replaceable></term>
+<listitem><para>Kernel entry point, defaulting to the entry point of the last image
+loaded</para></listitem></varlistentry>
+</variablelist>
+<para>Linux kernels on MIPS platforms expect the entry point to be called with arguments
+in the registers equivalent to a C call with prototype:
+<programlisting>void Linux(int argc, char **argv, char **envp);</programlisting></para>
+<para>RedBoot will place the appropriate data at the offset specified by the
+<parameter>-b</parameter> parameter, or by default at address 0x80080000, and will set the
+arguments accordingly when calling into the kernel.</para>
+<para>
+The default entry point, if no image with explicit entry point has been loaded and
+none is specified, is 0x80000750.
+</para>
+</sect2>
+
+<sect2>
+<title>Interrupts</title>
+<para>RedBoot uses an interrupt vector table which is located at address 0x80000200.
+Entries in this table are pointers to functions with this protoype: <programlisting>
+int irq_handler( unsigned vector, unsigned data )</programlisting>On the malta
+board, the vector argument is one of 22 interrupts defined in <computeroutput>
+hal/mips/malta/<replaceable>VERSION</replaceable>/include/plf_intr.h</computeroutput>: <programlisting>
+
+#define CYGNUM_HAL_INTERRUPT_SOUTH_BRIDGE_INTR 0
+#define CYGNUM_HAL_INTERRUPT_SOUTH_BRIDGE_SMI 1
+#define CYGNUM_HAL_INTERRUPT_CBUS_UART 2
+#define CYGNUM_HAL_INTERRUPT_COREHI 3
+#define CYGNUM_HAL_INTERRUPT_CORELO 4
+#define CYGNUM_HAL_INTERRUPT_COMPARE 5
+#define CYGNUM_HAL_INTERRUPT_TIMER 6
+#define CYGNUM_HAL_INTERRUPT_KEYBOARD 7
+#define CYGNUM_HAL_INTERRUPT_CASCADE 8
+#define CYGNUM_HAL_INTERRUPT_TTY1 9
+#define CYGNUM_HAL_INTERRUPT_TTY0 10
+#define CYGNUM_HAL_INTERRUPT_11 11
+#define CYGNUM_HAL_INTERRUPT_FLOPPY 12
+#define CYGNUM_HAL_INTERRUPT_PARALLEL 13
+#define CYGNUM_HAL_INTERRUPT_REAL_TIME_CLOCK 14
+#define CYGNUM_HAL_INTERRUPT_I2C 15
+#define CYGNUM_HAL_INTERRUPT_PCI_AB 16
+#define CYGNUM_HAL_INTERRUPT_PCI_CD 17
+#define CYGNUM_HAL_INTERRUPT_MOUSE 18
+#define CYGNUM_HAL_INTERRUPT_19 19
+#define CYGNUM_HAL_INTERRUPT_IDE_PRIMARY 20
+#define CYGNUM_HAL_INTERRUPT_IDE_SECONDARY 21</programlisting>The data
+passed to the ISR is pulled from a data table (<computeroutput>hal_interrupt_data
+</computeroutput>) which immediately follows the interrupt vector table. With
+22 interrupts, the data table starts at address 0x80000258.</para>
+<para>An application may create a normal C function with the above prototype
+to be an ISR. Just poke its address into the table at the correct index and
+enable the interrupt at its source. The return value of the ISR is ignored
+by RedBoot. </para>
+</sect2>
+<sect2>
+<title>Memory Maps </title>
+<para>Memory Maps RedBoot sets up the following memory map on the Malta board.<note>
+<title>NOTE</title>
+<para>The virtual memory maps in this section use a C and B column to indicate
+whether or not the region is cached (C) or buffered (B).</para>
+</note><programlisting>Physical Address Range C B Description
+----------------------- - - -----------
+0x80000000 - 0x81ffffff Y Y SDRAM
+0x9e000000 - 0x9e3fffff Y N System flash (cached)
+0x9fc00000 - 0x9fffffff Y N System flash (mirrored)
+0xa8000000 - 0xb7ffffff N N PCI Memory Space
+0xb4000000 - 0xb40fffff N N Galileo System Controller
+0xb8000000 - 0xb80fffff N N Southbridge / ISA
+0xb8100000 - 0xbbdfffff N N PCI I/O Space
+0xbe000000 - 0xbe3fffff N N System flash (noncached)
+0xbf000000 - 0xbfffffff N N Board logic FPGA</programlisting></para>
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=malta_mips32_4kc
+export ARCH_DIR=mips
+export PLATFORM_DIR=malta
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2></sect1>
+<?Pub _newpage>
+<sect1 id="ocelot">
+<title>MIPS/RM7000 PMC-Sierra Ocelot</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>PMC-Sierra MIPS RM7000 Ocelot</primary><secondary>installing
+and testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>PMC-Sierra MIPS RM7000 Ocelot</secondary></indexterm>RedBoot
+uses the front facing serial port. The default serial port settings are 38400,8,N,1.
+RedBoot also supports ethernet. Management of onboard flash is also supported.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+</sect2>
+
+<sect2>
+<title>Additional commands</title>
+<para>The <command>exec</command> command which allows the
+loading and execution of Linux kernels, is supported for this architecture
+ (see <xref linkend="executing-programs">). The
+<command>exec</command> parameters used for MIPS boards are:</para>
+<variablelist><varlistentry>
+<term>-b <replaceable>&lt;addr></replaceable></term>
+<listitem><para>Location to store command line and environment passed to kernel</para></listitem></varlistentry>
+<varlistentry><term>
+-w <replaceable>&lt;time></replaceable></term>
+<listitem><para>Wait time in seconds before starting kernel</para></listitem></varlistentry>
+<varlistentry><term>
+-c <replaceable>"params"</replaceable></term>
+<listitem><para>Parameters passed to kernel</para></listitem></varlistentry>
+<varlistentry><term><replaceable>&lt;addr></replaceable></term>
+<listitem><para>Kernel entry point, defaulting to the entry point of the last image
+loaded</para></listitem></varlistentry>
+</variablelist>
+<para>Linux kernels on MIPS platforms expect the entry point to be called with arguments
+in the registers equivalent to a C call with prototype:
+<programlisting>void Linux(int argc, char **argv, char **envp);</programlisting></para>
+<para>RedBoot will place the appropriate data at the offset specified by the
+<parameter>-b</parameter> parameter, or by default at address 0x80080000, and will set the
+arguments accordingly when calling into the kernel.</para>
+<para>
+The default entry point, if no image with explicit entry point has been loaded and
+none is specified, is 0x80000750.
+</para>
+</sect2>
+
+<sect2>
+<title>Memory Maps </title>
+<para>RedBoot sets up the following memory map on the Ocelot board. </para>
+<para>Note that these addresses are accessed through kseg0/1 and thus translate
+to the actual address range 0x80000000-0xbfffffff, depending on the need for
+caching/non-caching access to the bus.<note><title>NOTE</title>
+<para>The virtual memory maps in this section use a C and B column to indicate
+whether or not the region is cached (C) or buffered (B).</para>
+</note><programlisting>Physical Address Range Description
+----------------------- -----------
+0x00000000 - 0x0fffffff SDRAM
+0x10000000 - 0x10ffffff PCI I/O space
+0x12000000 - 0x13ffffff PCI Memory space
+0x14000000 - 0x1400ffff Galileo system controller
+0x1c000000 - 0x1c0000ff PLD (board logic)
+0x1fc00000 - 0x1fc7ffff flash</programlisting></para>
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=ocelot
+export ARCH_DIR=mips
+export PLATFORM_DIR=rm7000/ocelot
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2></sect1>
+
+
+<?Pub _newpage>
+<sect1 id="vrc4375">
+<title>MIPS/VR4375 NEC DDB-VRC4375</title>
+<sect2>
+<title>Overview</title>
+
+<para><indexterm><primary>NEC DDB-VRC4375</primary>
+<secondary>installing and testing</secondary></indexterm><indexterm><primary>
+installing and testing</primary><secondary>NEC DDB-VRC4375
+</secondary></indexterm>RedBoot supports only serial port 1, which is connected to the upper
+of the stacked serial connectors on the board. The default serial
+port settings are 38400,8,N,1. FLASH management is also supported.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROMRAM</entry>
+ <entry>[ROMRAM]</entry>
+ <entry>RedBoot running from RAM, but contained in the
+ board's flash boot sector.</entry>
+ <entry>redboot_ROMRAM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+</sect2>
+
+<sect2>
+<title>Initial Installation Method </title>
+
+<para>A device programmer should be used to program a socketed FLASH part
+(AMD 29F040). The board as delivered is configured for a 512K
+EPROM. To install a FLASH ROM, Jumpers J30, J31 and J36 need to be
+changed as described in the board's User Manual.</para>
+</sect2>
+
+<sect2>
+<title>Special RedBoot Commands</title>
+
+<para>None.</para>
+</sect2>
+
+<sect2>
+<title>Memory Maps</title>
+
+<para>RedBoot sets up the memory map primarily as described in the board's
+User Manual. There are some minor differences, noted in the following
+table:
+<screen>
+Physical Virtual Resource
+Addresses Addresses
+00000000-01FFFFFF 80000000-81FFFFFF Base SDRAM (cached)
+00000000-01FFFFFF A0000000-A1FFFFFF Base SDRAM (uncached)
+0C000000-0C0BFFFF AC000000-AC0B0000 PCI IO space
+0F000000-0F0001FF AF000000-AF0001FF VRC4375 Registers
+1C000000-1C0FFFFF BC000000-BC0FFFFF VRC4372 Registers
+1C100000-1DFFFFFF BC100000-BDFFFFFF PCI Memory space
+1FC00000-1FC7FFFF BFC00000-BFC7FFFF FLASH ROM
+80000000-8000000D C0000000-C000000D RTC
+8000000E-80007FFF C000000E-C0007FFF NVRAM
+81000000-81FFFFFF C1000000-C1FFFFFF Z85C30 DUART
+82000000-82FFFFFF C2000000-C2FFFFFF Z8536 Timer
+83000000-83FFFFFF C3000000-C3FFFFFF 8255 Parallel port
+87000000-87FFFFFF C7000000-C7FFFFFF Seven segment display</screen>
+</para>
+
+<note> <title>NOTE</title>
+<para>
+By default the VRC4375 SIMM control registers are not programmed
+since the values used must depend on the SIMMs installed. If SIMMs
+are to be used, correct values must be placed in these registers
+before accessing the SIMM address range.
+</para>
+</note>
+
+<note> <title>NOTE</title>
+<para>
+The allocation of address ranges to devices in the PCI IO and
+memory spaces is handled by the eCos PCI support library. They do
+not correspond to those described in the board User Manual.
+</para>
+</note>
+
+<note> <title>NOTE</title>
+<para>
+The MMU has been set up to relocate the VRC4372 supported devices
+mapped at physical addresses 0x8xxxxxxx to virtual addresses
+0xCxxxxxxx.
+</para>
+</note>
+
+</sect2>
+
+<sect2>
+<title>Ethernet Driver</title>
+
+<para>
+The ethernet driver is in two parts:
+</para>
+
+<para>
+A generic ether driver for the Intel i21143 device is located in
+<filename class="directory">devs/eth/intel/i21143</filename>. Its package name is <computeroutput>CYGPKG_DEVS_ETH_INTEL_I21143</computeroutput>.
+</para>
+
+<para>
+The platform-specific ether driver is <filename
+class="directory">devs/eth/mips/vrc4375</filename>. Its package is
+<computeroutput>CYGPKG_DEVS_ETH_MIPS_VRC4375</computeroutput>. This
+tells the generic driver the address in IO memory of the chip, for
+example, and other configuration details. The ESA (MAC address) is by
+default collected from on-board serial EEPROM, unless configured
+statically within this package.
+</para>
+</sect2>
+
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=vrc4373
+export ARCH_DIR=mips
+export PLATFORM_DIR=vrc4373
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2>
+</sect1>
+
+<!-- ************************** PowerPC ********************** -->
+
+<?Pub _newpage>
+<sect1 id="viper">
+<title>PowerPC/MPC860T Analogue & Micro PowerPC 860T</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Analogue & Micro PowerPC 860T</primary><secondary>installing
+and testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>Analogue & Micro PowerPC 860T</secondary></indexterm>RedBoot uses
+the SMC1 serial port. The default serial port settings are 38400,8,N,1.
+Ethernet is also supported using the RJ-45 connector. Management of
+onboard flash is also supported.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROMRAM</entry>
+ <entry>[ROMRAM]</entry>
+ <entry>RedBoot running from RAM, but contained in the
+ board's flash boot sector.</entry>
+ <entry>redboot_ROMRAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+</sect2>
+<sect2>
+<title>Initial Installation Method </title>
+<para>RedBoot must be installed at the A & M factory.
+</para>
+</sect2>
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>None.</para>
+</sect2>
+<sect2>
+<title>Memory Maps </title>
+<para>Memory Maps RedBoot sets up the following memory map on the MBX board.<programlisting>
+Physical Address Range Description
+----------------------- -----------
+0x00000000 - 0x007fffff DRAM
+0xfe000000 - 0xfe0fffff flash (AMD29LV8008B)
+0xff000000 - 0xff0fffff MPC registers</programlisting></para>
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=viper
+export ARCH_DIR=powerpc
+export PLATFORM_DIR=viper
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2>
+</sect1>
+
+<?Pub _newpage>
+<sect1 id="mbx">
+<title>PowerPC/MPC8XX Motorola MBX</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Motorola PowerPC MBX</primary><secondary>installing
+and testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>Motorola PowerPC MBX</secondary></indexterm>RedBoot uses
+the SMC1/COM1 serial port. The default serial port settings are 38400,8,N,1.
+Ethernet is also supported using the 10-base T connector. </para>
+<para>Management of onboard flash is also supported.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+</sect2>
+<sect2>
+<title>Initial Installation Method </title>
+<para>Device programmer is used to program the XU1 socketed flash part (AM29F040B)
+with the ROM mode image of RedBoot. Use the on-board EPPC-Bug monitor to update
+RedBoot. </para>
+<para>This assumes that you have EPPC-Bug in the on-board flash. This can
+be determined by setting up the board according to the following instructions
+and powering up the board. </para>
+<para>The EPPC-Bug prompt should appear on the SMC1 connector at 9600 baud,
+8N1. </para>
+<orderedlist>
+<listitem><para>Set jumper 3 to 2-3 [allow XU1 flash to be programmed] </para>
+</listitem>
+<listitem><para>Set jumper 4 to 2-3 [boot EPPC-Bug] </para>
+</listitem>
+</orderedlist>
+<para>If it is available, program the flash by following these steps: </para>
+<orderedlist>
+<listitem><para>Prepare EPPC-Bug for download: <screen>EPPC-Bug><userinput>lo 0</userinput>
+</screen>At this point the monitor is ready for input. It will not
+return the prompt until the file has been downloaded. </para>
+</listitem>
+<listitem><para>Use the terminal emulator's ASCII download feature (or a simple
+clipboard copy/paste operation) to download the
+<filename>redboot.ppcbug</filename> file.</para>
+<para>Note that on Linux, <application>Minicom</application>'s ASCII
+download feature seems to be broken. A workaround is to load the file
+into <application>emacs</application> (or another editor) and copy the
+full contents to the clipboard. Then press the mouse paste-button (usually
+the middle one) over the <application>Minicom</application> window. </para>
+</listitem>
+<listitem><para>Program the flash with the downloaded data: <screen>
+EPPC-Bug><userinput>pflash 40000 60000 fc000000</userinput></screen></para>
+</listitem>
+<listitem><para>Switch off the power, and change jumper 4 to 1-2. Turn on
+the power again. The board should now boot using the newly programmed RedBoot.
+</para>
+</listitem>
+</orderedlist>
+</sect2>
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>None.</para>
+</sect2>
+<sect2>
+<title>Memory Maps </title>
+<para>Memory Maps RedBoot sets up the following memory map on the MBX board.<programlisting>
+Physical Address Range Description
+----------------------- -----------
+0x00000000 - 0x003fffff DRAM
+0xfa100000 - 0xfa100003 LEDs
+0xfe000000 - 0xfe07ffff flash (AMD29F040B)
+0xff000000 - 0xff0fffff MPC registers</programlisting></para>
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=mbx
+export ARCH_DIR=powerpc
+export PLATFORM_DIR=mbx
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2>
+</sect1>
+
+
+
+
+<!-- ********************** SuperH ************************ -->
+
+
+
+<?Pub _newpage>
+<sect1 id="edk7708">
+<title>SuperH/SH3(SH7708) Hitachi EDK7708</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Hitachi SH EDK7708</primary><secondary>installing
+and testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>Hitachi SH EDK7708</secondary></indexterm>RedBoot uses
+the serial port. The default serial port settings are 38400,8,N,1.</para>
+<para>Management of onboard flash is also supported.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+</sect2>
+<sect2>
+<title>Initial Installation Method </title>
+<para>Program the ROM RedBoot image into flash using an eprom programmer.</para>
+
+</sect2>
+
+<sect2>
+<title>Memory Maps </title>
+<para>RedBoot sets up the following memory map on the EDK7708 board.<programlisting>
+Physical Address Range Description
+----------------------- -----------
+0x80000000 - 0x8001ffff Flash (AT29LV1024)
+0x88000000 - 0x881fffff DRAM
+0xa4000000 - 0xa40000ff LED ON
+0xb8000000 - 0xb80000ff LED ON
+</programlisting></para>
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=edk7708
+export ARCH_DIR=sh
+export PLATFORM_DIR=edk7708
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+
+</sect2>
+</sect1>
+
+<?Pub _newpage>
+<sect1 id="se7709">
+<title>SuperH/SH3(SH7709) Hitachi Solution Engine 7709</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Hitachi SH SE7709</primary><secondary>installing
+and testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>Hitachi SH SE7709</secondary></indexterm>This
+description covers the MS7709SE01 variant. See <xref linkend="se77x9">
+for instructions for the MS7729SE01 and MS7709SSE0101 variants.</para>
+
+<para>RedBoot uses
+the COM1 and COM2 serial ports. The default serial port settings are 38400,8,N,1.
+Ethernet is also supported using the 10-base T connector. </para>
+<para>Management of onboard flash is also supported.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+</sect2>
+<sect2>
+<title>Initial Installation Method </title>
+<para>The Solution Engine ships with the Hitachi boot monitor in EPROM
+which allows for initial programming of RedBoot:</para>
+
+<orderedlist>
+<listitem><para>Set switch SW4-1 to ON [boot from EPROM]</para>
+</listitem>
+<listitem><para>Connect a serial cable to CN1 (SCI) and power up the board.</para>
+</listitem>
+<listitem><para>After the boot monitor banner, invoke the flash
+download/program command:<screen>Ready &gt;<userinput>fl</userinput></screen></para>
+</listitem>
+<listitem><para>The monitor should now ask for input:
+<screen>Flash ROM data copy to RAM
+Please Send A S-format Record</screen>At this point copy the
+RedBoot ROM SREC file to the serial port:<screen>
+$ <userinput>cat redboot_SE7709RP_ROM.eprom.srec &gt /dev/ttyS0</userinput></screen>
+Eventually you
+should see something like<screen>Start Addrs = A1000000
+End Addrs = A1xxxxxx
+Transfer complete</screen> from the monitor.
+</para></listitem>
+<listitem><para>Set switch SW4-1 to OFF [boot from flash] and reboot the board. You
+should now see the RedBoot banner.</para>
+</listitem>
+</orderedlist>
+</sect2>
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>The <command>exec</command> command which allows the loading
+and execution of Linux kernels
+is supported for this board (see <xref linkend="executing-programs">). The <command>
+exec</command> parameters used for the SE77x9 are:</para>
+<variablelist>
+<varlistentry>
+<term>-b <replaceable>&lt;addr></replaceable></term>
+<listitem><para>Parameter block address. This is normally the first
+page of the kernel image and defaults to 0x8c101000</para></listitem></varlistentry>
+
+<varlistentry><term>-i <replaceable>&lt;addr></replaceable></term>
+<listitem><para>Start address of initrd
+image</para></listitem></varlistentry>
+
+<varlistentry><term>-j <replaceable>&lt;size></replaceable></term>
+<listitem><para>Size of initrd image</para></listitem></varlistentry>
+
+<varlistentry><term>-c <replaceable>"args"</replaceable></term>
+<listitem><para>Kernel arguments string</para></listitem></varlistentry>
+
+<varlistentry><term>
+-m <replaceable>&lt;flags></replaceable></term>
+<listitem><para>Mount rdonly flags. If set to a non-zero value the
+root partition will be mounted read-only.</para></listitem></varlistentry>
+
+<varlistentry><term>
+-f <replaceable>&lt;flags></replaceable></term>
+<listitem><para>RAM disk flags. Should normally be 0x4000</para></listitem></varlistentry>
+
+<varlistentry><term>-r <replaceable>&lt;device number></replaceable></term>
+<listitem><para>Root device specification. /dev/ram is 0x0101</para></listitem></varlistentry>
+
+<varlistentry><term>-l <replaceable>&lt;type></replaceable></term>
+<listitem><para>Loader type</para></listitem></varlistentry>
+
+</variablelist>
+
+<para>Finally the kernel entry address can be specified as an optional
+argument. The default is 0x8c102000</para>
+
+<para>
+For the the SE77x9, Linux by default expects to be loaded at
+0x8c001000 which conflicts with the data space used by RedBoot.
+To work around this, either change the CONFIG_MEMORY_START kernel
+option to a higher address, or use the compressed kernel image and load
+it at a higher address. For example, setting CONFIG_MEMORY_START to
+0x8c100000, the kernel expects to be loaded at address 0x8c101000 with
+the entry point at 0x8c102000.
+</para>
+
+</sect2>
+<sect2>
+<title>Memory Maps </title>
+<para>RedBoot sets up the following memory map on the SE77x9 board.<programlisting>
+Physical Address Range Description
+----------------------- -----------
+0x80000000 - 0x803fffff Flash (MBM29LV160)
+0x81000000 - 0x813fffff EPROM (M27C800)
+0x8c000000 - 0x8dffffff DRAM
+0xb0000000 - 0xb03fffff Ethernet (DP83902A)
+0xb0800000 - 0xb08fffff 16C552A
+0xb1000000 - 0xb100ffff Switches
+0xb1800000 - 0xb18fffff LEDs
+0xb8000000 - 0xbbffffff PCMCIA (MaruBun)
+</programlisting></para>
+</sect2>
+<sect2>
+<title>Ethernet Driver</title>
+<para>The ethernet driver uses a hardwired ESA which can, at present,
+only be changed in CDL.</para>
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=se77x9
+export ARCH_DIR=sh
+export PLATFORM_DIR=se77x9
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+</sect2>
+</sect1>
+
+<?Pub _newpage>
+<sect1 id="hs7729pci">
+<title>SuperH/SH3(SH7729) Hitachi HS7729PCI</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Hitachi SH HS7729PCI</primary><secondary>installing
+and testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>Hitachi SH HS7729PCI</secondary></indexterm>RedBoot uses
+the COM1 and COM2 serial ports (and the debug port on the
+motherboard).
+The default serial port settings are 38400,8,N,1.
+Ethernet is also supported using a D-Link DFE-530TX PCI plugin
+card. Management of onboard flash is also supported. </para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+
+</sect2>
+<sect2>
+<title>Initial Installation Method </title>
+<para>A ROM mode RedBoot image must be programmed
+into the two EPROMs. Two files with a split version of the ROM mode
+image is
+provided: it is also possible to recreate these from the
+<filename>redboot.bin</filename>
+file, but requires the <application>split_word.c</application> program in
+<filename
+class="directory">hal/sh/hs7729pci/<replaceable>VERSION</replaceable>/misc</filename>
+to be built and executed with the <filename>redboot.bin</filename>
+filename as sole argument.</para>
+
+<para>After doing this it is advised that another ROM mode image of
+RedBoot is programmed into the on-board flash, and that copy be used
+for booting the board. This allows for software programmed updates of
+RedBoot instead of having to reprogram the EPROMs.</para>
+
+<orderedlist>
+<listitem><para>Program the EPROMs with RedBoot. The .lo image should
+go in socket M1 and the .hi image in socket M2.
+</para>
+</listitem>
+<listitem><para>Set switch SW1-6 to ON [boot from EPROM]</para>
+</listitem>
+<listitem><para>Follow the instructions under Flash management for
+updating the flash copy of RedBoot, but force the flash destination
+address with
+<screen><userinput>-f 0x80400000</userinput></screen> due to setting of
+the SW1-6 switch.</para>
+</listitem>
+<listitem><para>Set switch SW1-6 to OFF [boot from flash] and reboot the board. You
+should now see the RedBoot banner. At this time you may want to issue
+the command <command>fis init</command> to initialize
+the flash table with the correct addresses.</para>
+</listitem>
+</orderedlist>
+
+
+</sect2>
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>The <command>exec</command> command which allows the loading
+and execution of Linux kernels
+is supported for this board (see <xref linkend="executing-programs">). The <command>
+exec</command> parameters used for the HS7729PCI are:</para>
+<variablelist>
+<varlistentry>
+<term>-b <replaceable>&lt;addr></replaceable></term>
+<listitem><para>Parameter block address. This is normally the first
+page of the kernel image and defaults to 0x8c101000</para></listitem></varlistentry>
+
+<varlistentry><term>-i <replaceable>&lt;addr></replaceable></term>
+<listitem><para>Start address of initrd
+image</para></listitem></varlistentry>
+
+<varlistentry><term>-j <replaceable>&lt;size></replaceable></term>
+<listitem><para>Size of initrd image</para></listitem></varlistentry>
+
+<varlistentry><term>-c <replaceable>"args"</replaceable></term>
+<listitem><para>Kernel arguments string</para></listitem></varlistentry>
+
+<varlistentry><term>
+-m <replaceable>&lt;flags></replaceable></term>
+<listitem><para>Mount rdonly flags. If set to a non-zero value the
+root partition will be mounted read-only.</para></listitem></varlistentry>
+
+<varlistentry><term>
+-f <replaceable>&lt;flags></replaceable></term>
+<listitem><para>RAM disk flags. Should normally be 0x4000</para></listitem></varlistentry>
+
+<varlistentry><term>-r <replaceable>&lt;device number></replaceable></term>
+<listitem><para>Root device specification. /dev/ram is 0x0101</para></listitem></varlistentry>
+
+<varlistentry><term>-l <replaceable>&lt;type></replaceable></term>
+<listitem><para>Loader type</para></listitem></varlistentry>
+
+</variablelist>
+
+<para>Finally the kernel entry address can be specified as an optional
+argument. The default is 0x8c102000</para>
+
+<para>
+On the HS7729PCI, Linux expects to be loaded at address 0x8c101000 with
+the entry point at 0x8c102000. This is configurable in the kernel
+using the CONFIG_MEMORY_START option.
+</para>
+
+</sect2>
+<sect2>
+<title>Memory Maps </title>
+<para>RedBoot sets up the following memory map on the HS7729PCI board.<programlisting>
+Physical Address Range Description
+----------------------- -----------
+0x80000000 - 0x803fffff Flash (MBM29LV160)
+0x80400000 - 0x807fffff EPROM (M27C800)
+0x82000000 - 0x82ffffff SRAM
+0x89000000 - 0x89ffffff SRAM
+0x8c000000 - 0x8fffffff SDRAM
+0xa8000000 - 0xa800ffff SuperIO (FDC37C935A)
+0xa8400000 - 0xa87fffff USB function (ML60851C)
+0xa8800000 - 0xa8bfffff USB host (SL11HT)
+0xa8c00000 - 0xa8c3ffff Switches
+0xa8c40000 - 0xa8c7ffff LEDs
+0xa8c80000 - 0xa8cfffff Interrupt controller
+0xb0000000 - 0xb3ffffff PCI (SD0001)
+0xb8000000 - 0xbbffffff PCMCIA (MaruBun)
+</programlisting></para>
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=hs7729pci
+export ARCH_DIR=sh
+export PLATFORM_DIR=hs7729pci
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+</sect2>
+</sect1>
+
+<?Pub _newpage>
+<sect1 id="se77x9">
+<title>SuperH/SH3(SH77X9) Hitachi Solution Engine 77X9</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Hitachi SH SE77X9</primary><secondary>installing
+and testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>Hitachi SH SE77X9</secondary></indexterm>This
+description covers the MS7729SE01 and MS7709SSE0101 variants. See <xref linkend="se7709">
+for instructions for the MS7709SE01 variant.</para>
+
+<para>RedBoot uses
+the COM1 and COM2 serial ports. The default serial port settings are 38400,8,N,1.
+Ethernet is also supported using the 10-base T connector. Management
+of onboard flash is also supported.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+</sect2>
+<sect2>
+<title>Initial Installation Method </title>
+<para>The Solution Engine ships with the Hitachi boot monitor in EPROM
+which allows for initial programming of RedBoot:</para>
+
+<orderedlist>
+<listitem><para>Set switches SW4-3 and SW4-4 to ON [boot from EPROM]</para>
+</listitem>
+<listitem><para>Connect a serial cable to COM2 and power up the board.</para>
+</listitem>
+<listitem><para>After the boot monitor banner, invoke the flash
+download/program command:<screen>Ready &gt;<userinput>fl</userinput></screen></para>
+</listitem>
+<listitem><para>The monitor should now ask for input:
+<screen>Flash ROM data copy to RAM
+Please Send A S-format Record</screen>At this point copy the
+RedBoot ROM SREC file to the serial port:<screen>
+$ <userinput>cat redboot_ROM.eprom.srec &gt /dev/ttyS0</userinput></screen>
+Eventually you
+should see something like<screen>Start Addrs = A1000000
+End Addrs = A1xxxxxx
+Transfer complete</screen> from the monitor.
+</para></listitem>
+<listitem><para>Set switch SW4-3 to OFF [boot from flash] and reboot the board. You
+should now see the RedBoot banner.</para>
+</listitem>
+</orderedlist>
+</sect2>
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>The <command>exec</command> command which allows the loading
+and execution of Linux kernels
+is supported for this board (see <xref linkend="executing-programs">). The <command>
+exec</command> parameters used for the SE77x9 are:</para>
+<variablelist>
+<varlistentry>
+<term>-b <replaceable>&lt;addr></replaceable></term>
+<listitem><para>Parameter block address. This is normally the first
+page of the kernel image and defaults to 0x8c101000</para></listitem></varlistentry>
+
+<varlistentry><term>-i <replaceable>&lt;addr></replaceable></term>
+<listitem><para>Start address of initrd
+image</para></listitem></varlistentry>
+
+<varlistentry><term>-j <replaceable>&lt;size></replaceable></term>
+<listitem><para>Size of initrd image</para></listitem></varlistentry>
+
+<varlistentry><term>-c <replaceable>"args"</replaceable></term>
+<listitem><para>Kernel arguments string</para></listitem></varlistentry>
+
+<varlistentry><term>
+-m <replaceable>&lt;flags></replaceable></term>
+<listitem><para>Mount rdonly flags. If set to a non-zero value the
+root partition will be mounted read-only.</para></listitem></varlistentry>
+
+<varlistentry><term>
+-f <replaceable>&lt;flags></replaceable></term>
+<listitem><para>RAM disk flags. Should normally be 0x4000</para></listitem></varlistentry>
+
+<varlistentry><term>-r <replaceable>&lt;device number></replaceable></term>
+<listitem><para>Root device specification. /dev/ram is 0x0101</para></listitem></varlistentry>
+
+<varlistentry><term>-l <replaceable>&lt;type></replaceable></term>
+<listitem><para>Loader type</para></listitem></varlistentry>
+
+</variablelist>
+
+<para>Finally the kernel entry address can be specified as an optional
+argument. The default is 0x8c102000</para>
+
+<para>
+On the SE77x9, Linux expects to be loaded at address 0x8c101000 with
+the entry point at 0x8c102000. This is configurable in the kernel
+using the CONFIG_MEMORY_START option.
+</para>
+
+</sect2>
+<sect2>
+<title>Memory Maps </title>
+<para>RedBoot sets up the following memory map on the SE77x9 board.<programlisting>
+Physical Address Range Description
+----------------------- -----------
+0x80000000 - 0x803fffff Flash (MBM29LV160)
+0x81000000 - 0x813fffff EPROM (M27C800)
+0x8c000000 - 0x8dffffff SDRAM
+0xb0000000 - 0xb03fffff Ethernet (DP83902A)
+0xb0400000 - 0xb07fffff SuperIO (FDC37C935A)
+0xb0800000 - 0xb0bfffff Switches
+0xb0c00000 - 0xbfffffff LEDs
+0xb1800000 - 0xb1bfffff PCMCIA (MaruBun)
+</programlisting></para>
+</sect2>
+<sect2>
+<title>Ethernet Driver</title>
+<para>The ethernet driver uses a hardwired ESA which can, at present,
+only be changed in CDL.</para>
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=se77x9
+export ARCH_DIR=sh
+export PLATFORM_DIR=se77x9
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+</sect2>
+</sect1>
+
+<?Pub _newpage>
+<sect1 id="se7751">
+<title>SuperH/SH4(SH7751) Hitachi Solution Engine 7751</title>
+<sect2>
+<title>Overview</title>
+<para><indexterm><primary>Hitachi SH SE7751</primary><secondary>installing
+and testing</secondary></indexterm><indexterm><primary>installing and testing
+</primary><secondary>Hitachi SH SE7751</secondary></indexterm>RedBoot uses
+the COM1 serial port. The default serial port settings are 38400,8,N,1.
+Ethernet is also supported using the 10-base T connector. Management
+of onboard flash is also supported.</para>
+
+<para>The following RedBoot configurations are supported:
+
+ <informaltable frame="all">
+ <tgroup cols="4" colsep="1" rowsep="1" align="left">
+ <thead>
+ <row>
+ <entry>Configuration</entry>
+ <entry>Mode</entry>
+ <entry>Description</entry>
+ <entry>File</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>ROM</entry>
+ <entry>[ROM]</entry>
+ <entry>RedBoot running from the board's flash boot
+ sector.</entry>
+ <entry>redboot_ROM.ecm</entry>
+ </row>
+ <row>
+ <entry>RAM</entry>
+ <entry>[RAM]</entry>
+ <entry>RedBoot running from RAM with RedBoot in the
+ flash boot sector.</entry>
+ <entry>redboot_RAM.ecm</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+
+</sect2>
+<sect2>
+<title>Initial Installation Method </title>
+<para>The Solution Engine ships with the Hitachi boot monitor in EPROM
+which allows for initial programming of RedBoot:</para>
+
+<orderedlist>
+<listitem><para>Set switches SW5-3 and SW5-4 to ON [boot from EPROM]</para>
+</listitem>
+<listitem><para>Connect a serial cable to COM1 and power up the board.</para>
+</listitem>
+<listitem><para>After the boot monitor banner, invoke the flash
+download/program command:<screen>Ready &gt;<userinput>fl</userinput></screen></para>
+</listitem>
+<listitem><para>The monitor should now ask for input:
+<screen>Flash ROM data copy to RAM
+Please Send A S-format Record</screen>At this point copy the
+RedBoot ROM SREC file to the serial port:<screen>
+$ <userinput>cat redboot_ROM.eprom.srec &gt /dev/ttyS0</userinput></screen>
+Eventually you
+should see something like<screen>Start Addrs = A1000000
+End Addrs = A1xxxxxx
+Transfer complete</screen> from the monitor.
+</para></listitem>
+<listitem><para>Set switch SW5-3 to OFF [boot from flash] and reboot the board. You
+should now see the RedBoot banner.</para>
+</listitem>
+</orderedlist>
+</sect2>
+<sect2>
+<title>Special RedBoot Commands </title>
+<para>The <command>exec</command> command which allows the loading
+and execution of Linux kernels
+is supported for this board (see <xref linkend="executing-programs">). The <command>
+exec</command> parameters used for the SE7751 are:</para>
+<variablelist>
+<varlistentry>
+<term>-b <replaceable>&lt;addr></replaceable></term>
+<listitem><para>Parameter block address. This is normally the first
+page of the kernel image and defaults to 0x8c101000</para></listitem></varlistentry>
+
+<varlistentry><term>-i <replaceable>&lt;addr></replaceable></term>
+<listitem><para>Start address of initrd
+image</para></listitem></varlistentry>
+
+<varlistentry><term>-j <replaceable>&lt;size></replaceable></term>
+<listitem><para>Size of initrd image</para></listitem></varlistentry>
+
+<varlistentry><term>-c <replaceable>"args"</replaceable></term>
+<listitem><para>Kernel arguments string</para></listitem></varlistentry>
+
+<varlistentry><term>
+-m <replaceable>&lt;flags></replaceable></term>
+<listitem><para>Mount rdonly flags. If set to a non-zero value the
+root partition will be mounted read-only.</para></listitem></varlistentry>
+
+<varlistentry><term>
+-f <replaceable>&lt;flags></replaceable></term>
+<listitem><para>RAM disk flags. Should normally be 0x4000</para></listitem></varlistentry>
+
+<varlistentry><term>-r <replaceable>&lt;device number></replaceable></term>
+<listitem><para>Root device specification. /dev/ram is 0x0101</para></listitem></varlistentry>
+
+<varlistentry><term>-l <replaceable>&lt;type></replaceable></term>
+<listitem><para>Loader type</para></listitem></varlistentry>
+
+</variablelist>
+
+<para>Finally the kernel entry address can be specified as an optional
+argument. The default is 0x8c102000</para>
+
+<para>
+On the SE7751, Linux expects to be loaded at address 0x8c101000 with
+the entry point at 0x8c102000. This is configurable in the kernel
+using the CONFIG_MEMORY_START option.
+</para>
+
+</sect2>
+<sect2>
+<title>Memory Maps </title>
+<para>RedBoot sets up the following memory map on the SE7751 board.<programlisting>
+Physical Address Range Description
+----------------------- -----------
+0x80000000 - 0x803fffff Flash (MBM29LV160)
+0x81000000 - 0x813fffff EPROM (M27C800)
+0x8c000000 - 0x8fffffff SDRAM
+0xb8000000 - 0xb8ffffff PCMCIA (MaruBun)
+0xb9000000 - 0xb9ffffff Switches
+0xba000000 - 0xbaffffff LEDs
+0xbd000000 - 0xbdffffff PCI MEM space
+0xbe200000 - 0xbe23ffff PCI Ctrl space
+0xbe240000 - 0xbe27ffff PCI IO space
+</programlisting></para>
+</sect2>
+<sect2>
+<title>Ethernet Driver</title>
+<para>The ethernet driver uses a hardwired ESA which can, at present,
+only be changed in CDL.</para>
+</sect2>
+<sect2>
+<title>Rebuilding RedBoot</title>
+
+<para>These shell variables provide the platform-specific information
+needed for building RedBoot according to the procedure described in
+<xref linkend="Rebuilding-Redboot">:
+<programlisting>
+export TARGET=se7751
+export ARCH_DIR=sh
+export PLATFORM_DIR=se7751
+</programlisting>
+</para>
+
+<para>The names of configuration files are listed above with the
+description of the associated modes.</para>
+</sect2>
+</sect1>
+
+</chapter>
diff --git a/ecos/packages/redboot/current/doc/redboot_main.sgml b/ecos/packages/redboot/current/doc/redboot_main.sgml
new file mode 100644
index 0000000..cd2a5ea
--- /dev/null
+++ b/ecos/packages/redboot/current/doc/redboot_main.sgml
@@ -0,0 +1,117 @@
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V3.1//EN" [
+
+<!-- Begin Document Specific Declarations -->
+<!ENTITY ui "&micro;ITRON">
+<!ENTITY versiondir CDATA "v2_0">
+<!ENTITY version CDATA "2.0">
+<!ENTITY lt SDATA "[lt ]">
+<!ENTITY redboot-sgml SYSTEM "redboot.sgml">
+<!ENTITY redboot-cmds-sgml SYSTEM "redboot_cmds.sgml">
+<!ENTITY redboot-rebuilding-sgml SYSTEM "redboot_rebuilding.sgml">
+<!ENTITY redboot-installing-sgml SYSTEM "redboot_installing.sgml">
+<!-- End Document Specific Declarations -->
+]>
+
+<BOOK ID="REDBOOT-GUIDE">
+ <bookinfo>
+ <TITLE>RedBoot User's Guide</TITLE>
+
+ <copyright>
+ <year>1998</year>
+ <year>1999</year>
+ <year>2000</year>
+ <year>2001</year>
+ <year>2002</year>
+ <year>2003</year>
+ <year>2004</year>
+ <year>2005</year>
+ <year>2006</year>
+ <year>2007</year>
+ <year>2009</year>
+ <holder>Free Software Foundation, Inc.</holder>
+ </copyright>
+
+ <legalnotice>
+ <title>Documentation licensing terms</title>
+<para>This material may be distributed only subject to the terms
+and conditions set forth in the Open Publication License, v1.0
+or later (the latest version is presently available at
+<ulink url="http://www.opencontent.org/openpub/">http://www.opencontent.org/openpub/</ulink>).
+</para>
+<para>
+Distribution of substantively modified versions of this
+document is prohibited without the explicit permission of the
+copyright holder.</para>
+<para>
+Distribution of the work or derivative of the work in any
+standard (paper) book form is prohibited unless prior
+permission is obtained from the copyright holder.
+</para>
+ </legalnotice>
+ <legalnotice>
+ <title>Trademarks</title>
+<para>Altera&reg; and Excalibur&trade; are trademarks of Altera Corporation.</para>
+<para>AMD&reg; is a registered trademark of Advanced Micro Devices, Inc.</para>
+<para>ARM&reg;, StrongARM&reg;, Thumb&reg;, ARM7&trade;, ARM9&trade; is a registered trademark of Advanced RISC Machines, Ltd.</para>
+<para>Cirrus Logic&reg; and Maverick&trade; are registered trademarks of Cirrus Logic, Inc.</para>
+<para>Cogent&trade; is a trademark of Cogent Computer Systems, Inc.</para>
+<para>Compaq&reg; is a registered trademark of the Compaq Computer Corporation.</para>
+<para>Fujitsu&reg; is a registered trademark of Fujitsu Limited.</para>
+<para>IBM&reg;, and PowerPC&trade; are trademarks of International Business Machines Corporation.</para>
+<para>IDT&reg; is a registered trademark of Integrated Device Technology Inc.</para>
+<para>Intel&reg;, i386&trade;, Pentium&reg;, StrataFlash&reg; and XScale&trade; are trademarks of Intel Corporation.</para>
+<para>Intrinsyc&reg; and Cerf&trade; are trademarks of Intrinsyc Software, Inc.</para>
+<para>Linux&reg; is a registered trademark of Linus Torvalds. </para>
+<para>Matsushita&trade; and Panasonic&reg; are trademarks of the Matsushita Electric Industrial Corporation.</para>
+<para>Microsoft&reg;, Windows&reg;, Windows NT&reg; and Windows XP&reg; are registered trademarks of Microsoft Corporation, Inc. </para>
+<para>MIPS&reg;, MIPS32&trade; MIPS64&trade;, 4K&trade, 5K&trade; Atlas&trade; and Malta&trade; are trademarks of MIPS Technologies, Inc.</para>
+<para>Motorola&reg;, ColdFire&reg; is a trademark of Motorola, Inc.</para>
+<para>NEC&reg; V800&trade;, V850&trade;, V850/SA1&trade;, V850/SB1&trade;, VR4300&trade;, and VRC4375&trade; are trademarks of NEC Corporation.</para>
+<para>PMC-Sierra&reg; RM7000&trade; and Ocelot&trade; are trademarks of PMC-Sierra Incorporated. </para>
+<para>Red Hat, eCos&trade;, RedBoot&trade;, GNUPro&reg;, and Insight&trade; are trademarks of Red Hat, Inc. </para>
+<para>Samsung&reg; and CalmRISC&trade; are trademarks or registered trademarks of Samsung, Inc. </para>
+<para>Sharp&reg; is a registered trademark of Sharp Electronics Corp.</para>
+<para>SPARC&reg; is a registered trademark of SPARC International, Inc., and is used under license by Sun Microsystems, Inc. </para>
+<para>Sun Microsystems&reg; and Solaris&reg; are registered trademarks of Sun Microsystems, Inc. </para>
+<para>SuperH&trade; and Renesas&trade; are trademarks owned by Renesas Technology Corp.</para>
+<para>Texas Instruments&reg;, OMAP&trade; and Innovator&trade; are trademarks of Texas Instruments Incorporated.</para>
+<para>Toshiba&reg; is a registered trademark of the Toshiba Corporation.</para>
+<para>UNIX&reg; is a registered trademark of The Open Group. </para>
+<para>All other brand and product names, trademarks, and copyrights are the
+property of their respective owners. </para>
+ </legalnotice>
+ <legalnotice>
+<title>Warranty</title>
+<para>eCos and RedBoot are open source software, covered by a
+modified version of the <ulink url="http://www.gnu.org/copyleft/gpl.html">GNU
+General Public Licence</ulink>,
+and you are welcome to change it and/or distribute copies of it under certain
+conditions. See <ulink
+url="http://ecos.sourceware.org/license-overview.html">http://ecos.sourceware.org/license-overview.html
+</ulink> for more information about the license.</para>
+<para>eCos and RedBoot software have NO WARRANTY. </para>
+<para>Because this software is licensed free of charge, there are no warranties
+for it, to the extent permitted by applicable law. Except when otherwise stated
+in writing, the copyright holders and/or other parties provide the software
+&ldquo;as is&rdquo; without warranty of any kind, either expressed or implied,
+including, but not limited to, the implied warranties of merchantability and
+fitness for a particular purpose. The entire risk as to the quality and performance
+of the software is with you. Should the software prove defective, you assume
+the cost of all necessary servicing, repair or correction.</para>
+<para> In no event, unless required by applicable law or agreed to in writing,
+will any copyright holder, or any other party who may modify and/or redistribute
+the program as permitted above, be liable to you for damages, including any
+general, special, incidental or consequential damages arising out of the use
+or inability to use the program (including but not limited to loss of data
+or data being rendered inaccurate or losses sustained by you or third parties
+or a failure of the program to operate with any other programs), even if such
+holder or other party has been advised of the possibility of such damages.
+</para>
+ </legalnotice>
+ </bookinfo>
+<toc id="redboot-toc"></toc>
+&redboot-sgml;
+&redboot-cmds-sgml;
+&redboot-rebuilding-sgml;
+&redboot-installing-sgml;
+</book>
diff --git a/ecos/packages/redboot/current/doc/redboot_rebuilding.sgml b/ecos/packages/redboot/current/doc/redboot_rebuilding.sgml
new file mode 100644
index 0000000..ece728f
--- /dev/null
+++ b/ecos/packages/redboot/current/doc/redboot_rebuilding.sgml
@@ -0,0 +1,372 @@
+<!-- {{{ Banner -->
+
+<!-- =============================================================== -->
+<!-- -->
+<!-- redboot_rebuilding.sgml -->
+<!-- -->
+<!-- RedBoot Documentation -->
+<!-- -->
+<!-- =============================================================== -->
+<!-- ####ECOSDOCCOPYRIGHTBEGIN#### -->
+<!-- =============================================================== -->
+<!-- Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. -->
+<!-- This material may be distributed only subject to the terms -->
+<!-- and conditions set forth in the Open Publication License, v1.0 -->
+<!-- or later (the latest version is presently available at -->
+<!-- http://www.opencontent.org/openpub/) -->
+<!-- Distribution of the work or derivative of the work in any -->
+<!-- standard (paper) book form is prohibited unless prior -->
+<!-- permission obtained from the copyright holder -->
+<!-- =============================================================== -->
+<!-- ####ECOSDOCCOPYRIGHTEND#### -->
+<!-- =============================================================== -->
+<!-- #####DESCRIPTIONBEGIN#### -->
+<!-- -->
+<!-- ####DESCRIPTIONEND#### -->
+<!-- =============================================================== -->
+
+<!-- }}} -->
+
+<chapter id="Rebuilding-Redboot">
+<title>Rebuilding RedBoot</title>
+<sect1>
+<title>Introduction</title>
+<para><indexterm><primary>rebuilding RedBoot</primary></indexterm><indexterm>
+<primary>RedBoot</primary><secondary>rebuilding</secondary></indexterm>
+RedBoot is built as an application on top of eCos. The makefile rules
+for building RedBoot are part of the eCos CDL package, so it's
+possible to build eCos from the <application>Configuration
+Tool</application>, as well as from the command line using
+<application>ecosconfig</application>.</para>
+
+<para>Building RedBoot requires only a few steps: selecting the
+platform and the RedBoot template, importing a platform specific
+configuration file, and finally starting the build.</para>
+
+<para>The platform specific configuration file makes sure the settings
+are correct for building RedBoot on the given platform. Each platform
+should provide at least two of these configuration files:
+<filename>redboot_RAM.ecm</filename> for a RAM mode RedBoot
+configuration and <filename>redboot_ROM.ecm</filename> or
+<filename>redboot_ROMRAM.ecm</filename> for a ROM or ROMRAM mode
+RedBoot configuration. There may be additional
+configuration files according to the requirements of the particular
+platform.</para>
+
+<para>The RedBoot build process results in a number of files in the
+install <filename class="directory">bin</filename> directory. The ELF
+file <filename>redboot.elf</filename> is the pricipal
+result. Depending on the platform CDL, there will also be generated
+versions of RedBoot in other file formats, such as
+<filename>redboot.bin</filename> (binary format, good when doing an
+update of a primary RedBoot image, see <xref
+linkend="update-primary-image">), <filename>redboot.srec</filename>
+(Motorola S-record format, good when downloading a RAM mode image for
+execution), and <filename>redboot.img</filename> (stripped ELF format,
+good when downloading a RAM mode image for execution, smaller than the
+.srec file). Some platforms may provide additional file formats and
+also relocate some of these files to a
+particular address making them more suitable for downloading using a
+different boot monitor or flash programming tools.</para>
+
+<para>The platform specific information in <xref
+linkend="Installation-and-Testing"> should be consulted, as there may
+be other special instructions required to build RedBoot for particular
+platforms.</para>
+
+<sect2>
+<title>Rebuilding RedBoot using <application>ecosconfig</application></title>
+
+<para>To rebuild RedBoot using the
+<application>ecosconfig</application> tool, create a temporary
+directory for building RedBoot, name it according to the desired
+configuration of RedBoot, here RAM:
+<screen>
+$ <userinput>mkdir /tmp/redboot_RAM</userinput>
+$ <userinput>cd /tmp/redboot_RAM</userinput>
+</screen>
+</para>
+
+<para>Create the build tree according to the chosen platform, here
+using the Hitachi Solution Engine 7751 board as
+an example:
+<note><para>It is assumed that the environment variable
+ECOS_REPOSITORY points to the eCos/RedBoot source tree.</para></note>
+<screen>
+$ <userinput>ecosconfig new se7751 redboot</userinput>
+U CYGPKG_HAL_SH_7750, new inferred value 0
+U CYGPKG_HAL_SH_7751, new inferred value 1
+U CYGHWR_HAL_SH_IRQ_USE_IRQLVL, new inferred value 1
+U CYGSEM_HAL_USE_ROM_MONITOR, new inferred value 0
+U CYGDBG_HAL_COMMON_CONTEXT_SAVE_MINIMUM, new inferred value 0
+U CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS, new inferred value 1
+U CYGFUN_LIBC_STRING_BSD_FUNCS, new inferred value 0
+U CYGPKG_NS_DNS_BUILD, new inferred value 0
+</screen>
+Replace the platform name ("se7751") with the appropriate name for the
+chosen platform.
+</para>
+
+<para>Then import the appropriate platform RedBoot configuration file,
+here for RAM configuration:
+<screen>
+$ <userinput>ecosconfig import <filename>${ECOS_REPOSITORY}/hal/sh/se7751/<replaceable>VERSION</replaceable>/misc/redboot_RAM.ecm</filename></userinput>
+$ <userinput>ecosconfig tree</userinput>
+</screen>
+Replace architecture ("sh"), platform ("se7751") and version
+("<replaceable>VERSION</replaceable>") with those appropriate for the
+chosen platform and the version number of its HAL package. Also
+replace the configuration name ("redboot_RAM.ecm") with that of the
+appropriate configuration file.
+</para>
+
+<para>RedBoot can now be built:
+<screen>
+$ <userinput>make</userinput>
+</screen>
+</para>
+
+<para>The resulting RedBoot files will be in the associated
+install directory, in this example, <filename
+class="directory">./install/bin</filename>.</para>
+
+<para>In <xref linkend="Installation-and-Testing"> each platform's
+details are described in the form of shell variables. Using those,
+the steps to build RedBoot are:
+<programlisting>
+export REDBOOT_CFG=redboot_ROM
+export VERSION=<replaceable>VERSION</replaceable>
+mkdir /tmp/${REDBOOT_CFG}
+cd /tmp/${REDBOOT_CFG}
+ecosconfig new ${TARGET} redboot
+ecosconfig import ${ECOS_REPOSITORY}/hal/${ARCH_DIR}/${PLATFORM_DIR}/${VERSION}/misc/${REDBOOT_CFG}.ecm
+ecosconfig tree
+make
+</programlisting>
+To build for another configuration, simply change the
+<replaceable>REDBOOT_CFG</replaceable> definition accordingly. Also
+make sure the <replaceable>VERSION</replaceable> variable matches the
+version of the platform package.
+</para>
+</sect2>
+
+
+<sect2>
+<title>Rebuilding RedBoot from the <application>Configuration Tool</application></title>
+
+<para>To rebuild RedBoot from the <application>Configuration
+Tool</application>, open the template window (<guimenuitem>Build->Templates</guimenuitem>) and
+select the appropriate Hardware target and in Packages select
+"redboot". Then press OK. Depending on the platform, a number of
+conflicts may need to be resolved before the build can be started;
+select "Continue".</para>
+
+<para>Import the desired RedBoot configuration file from the platform HAL
+(<guimenuitem>File->Import...</guimenuitem>). Depending on the platform, a number of
+conflicts may need to be resolved before the build can be started;
+select "Continue". For example, if the platform selected is Hitachi
+SE7751 board and the RAM configuration RedBoot should be built, import
+the file
+<filename>hal/sh/se7751/<replaceable>VERSION</replaceable>/misc/redboot_RAM.ecm</filename>.</para>
+
+<para>Save the configuration somewhere suitable with enough disk space
+for building RedBoot (<guimenuitem>File->Save...</guimenuitem>). Choose the name according to
+the RedBoot configuration, for example
+<filename>redboot_RAM.ecc</filename>.</para>
+
+<para>Then start the build (<guimenuitem>Build->Library</guimenuitem>) and wait for it to
+complete. The resulting RedBoot files will be in the associated
+install directory, for the example this would be <filename
+class="directory">redboot_RAM_install/bin</filename>.</para>
+
+<para>As noted above, each platform's details are described in <xref
+linkend="Installation-and-Testing">. Use the information provided in
+the shell variables to find the configuration file - the path to it is
+<filename>${ECOS_REPOSITORY}/hal/${ARCH_DIR}/${PLATFORM_DIR}/${VERSION}/misc/${REDBOOT_CFG}.ecm</filename>,
+where <replaceable>ECOS_REPOSITORY</replaceable> points to the
+eCos/RedBoot sources, <replaceable>VERSION</replaceable> is the
+version of the package (usually "current") and
+<replaceable>REDBOOT_CFG</replaceable> is the desired configuration,
+e.g. redboot_RAM.
+</para>
+</sect2></sect1></chapter>
+
+<chapter id="Updating-Redboot">
+<title>Updating RedBoot</title>
+<sect1>
+<title>Introduction</title>
+<para><indexterm><primary>updating
+RedBoot</primary></indexterm><indexterm>
+<primary>RedBoot</primary><secondary>updating</secondary></indexterm>RedBoot
+normally resides in an EPROM or, more common these days, a flash
+on the board. In the former case, updating RedBoot necessitates
+physically removing the part and
+reprogramming a new RedBoot image into it using prommer hardware. In
+the latter case, it is often possible to update RedBoot in situ using
+Redboot's flash management commands.</para>
+
+<para>The process of updating RedBoot in situ is documented in this
+section. For this process, it is assumed that the target is connected
+to a host system and that there is a serial connection giving access
+to the RedBoot CLI. For platforms with a ROMRAM mode RedBoot, skip to
+<xref linkend="update-primary-image">.</para>
+
+<note><para>The addresses and sizes included in the below are examples
+only, and will differ from those you will see. This is normal and
+should not cause concern.</para></note>
+
+<sect2 id="different-version-from-RAM">
+<title>Load and start a RedBoot RAM instance</title>
+<para>There are a number of choices here. The basic case is where a RAM
+mode image has been stored in the FIS (flash Image System). To load and
+execute this image, use the commands: <screen>
+RedBoot> <userinput>fis load RedBoot[RAM]</userinput>
+RedBoot> <userinput>go</userinput></screen>
+If this image is not available, or does not work,
+then an alternate RAM mode image must be loaded:
+<screen>
+RedBoot> <userinput>load redboot_RAM.img</userinput>
+Entry point: 0x060213c0, address range: 0x06020000-0x060369c8
+RedBoot> <userinput>go</userinput>
+</screen>
+
+<note><para>This command loads the RedBoot image using the TFTP
+protocol via a network connection. Other methods of loading are
+available, refer to the <command><link
+linkend="download-command">load</link</command> command for more
+details. </para></note>
+
+<note><para>If you expect to be doing this more than once, it is a
+good idea to program the RAM mode image into the flash. You do this
+using the <command>fis create</command> command after having
+downloaded the RAM mode image, but before you start it.</para>
+<para>Some platforms support locking (write protecting) certain regions of
+the flash, while others do not. If your platform does not support
+locking, simply ignore the <command>fis unlock</command> and
+<command>fis lock</command> steps (the commands will not be
+recognized by RedBoot).</para>
+<para>
+<screen>
+RedBoot> <userinput>fis unlock RedBoot[RAM]</userinput>
+ ... Unlock from 0x00000000-0x00020000: ..
+RedBoot> <userinput>fis create RedBoot[RAM]</userinput>
+An image named 'RedBoot[RAM]' exists - continue (y/n)? <userinput>y</userinput>
+* CAUTION * about to program 'RedBoot[RAM]'
+ at 0x00020000..0x000369c7 from 0x06020000 - continue (y/n)?<userinput>y</userinput>
+... Erase from 0x00020000-0x00040000: ..
+... Program from 0x06020000-0x060369c8 at 0x00020000: ..
+... Erase from 0x00070000-0x00080000: .
+... Program from 0x0606f000-0x0607f000 at 0x00070000: .
+RedBoot> <userinput>fis lock RedBoot[RAM]</userinput>
+ ... Lock from 0x00000000-0x00020000: ..
+</screen>
+</para></note>
+</para>
+</sect2>
+
+<sect2 id="update-primary-image">
+<title>Update the primary RedBoot flash image</title> <para>An
+instance of RedBoot should now be running on the target from RAM. This
+can be verified by looking for the mode identifier in the banner. It
+should be either [RAM] or [ROMRAM].</para>
+
+<para>If this is the first time RedBoot is running on the board or if
+the flash contents has been damaged, initialize the FIS directory:
+<screen>RedBoot> <userinput>fis init -f</userinput>
+About to initialize [format] FLASH image system - continue (y/n)? <userinput>y</userinput>
+*** Initialize FLASH Image System
+... Erase from 0x00020000-0x00070000: .....
+... Erase from 0x00080000-0x00080000:
+... Erase from 0x00070000-0x00080000: .
+... Program from 0x0606f000-0x0607f000 at 0x00070000: .
+</screen>
+</para>
+
+<para>It is important to understand that the presence of a correctly
+initialized FIS directory allows RedBoot to automatically determine
+the flash parameters. Additionally, executing the steps below as
+stated without loading other data or using other flash commands (than
+possibly <command>fis list</command>) allows RedBoot to automatically
+determine the image location and size parameters. This greatly reduces
+the risk of potential critical mistakes due to typographical errors. It is
+still always possible to explicitly specify parameters, and indeed
+override these, but it is not advised.</para>
+
+<note><para>If the new RedBoot image has grown beyond the slot in
+flash reserved for it, it is necessary to change the RedBoot
+configuration option CYGBLD_REDBOOT_MIN_IMAGE_SIZE so the FIS is
+created with adequate space reserved for RedBoot images. In this case,
+it is necessary to re-initialize the FIS directory as described above,
+using a RAM mode RedBoot compiled with the updated
+configuration.</para></note>
+
+<para>Using the <command>load</command> command, download the
+new flash based image from the host, relocating the image to RAM::
+<screen>RedBoot> <userinput>load -r -b %{FREEMEMLO} redboot_ROM.bin</userinput>
+Raw file loaded 0x06046800-0x06062fe8, assumed entry at 0x06046800
+</screen>
+
+<note><para>This command loads the RedBoot image using the TFTP
+protocol via a network connection. Other methods of loading are
+available, refer to the <xref linkend="download-command"> command for
+more details. </para></note>
+
+<note><para>Note that the binary version of the image is being
+downloaded. This is to ensure that the memory after the image is
+loaded should match the contents of the file on the host. Loading SREC
+or ELF versions of the image does not guarantee this since these
+formats may contain holes, leaving bytes in these holes in an unknown
+state after the load, and thus causing a likely cksum difference. It
+is possible to use these, but then the step verifying the cksum below
+may fail.</para></note>
+</para>
+
+<para>Once the image is loaded into RAM, it should be checksummed,
+thus verifying that the image on the target is indeed the image
+intended to be loaded, and that no corruption of the image has
+happened. This is done using the <xref linkend="cksum-command">
+command:
+<screen>RedBoot> <userinput>cksum</userinput>
+Computing cksum for area 0x06046800-0x06062fe8
+POSIX cksum = 2535322412 116712 (0x971df32c 0x0001c7e8)
+</screen>
+Compare the numbers with those for the binary version of the image on
+the host. If they do not match, try downloading the image again.</para>
+
+
+<para>Assuming the cksum matches, the next step is programming the
+image into flash using the FIS commands.</para>
+
+<para>Some platforms support locking (write protecting) certain
+regions of the flash, while others do not. If your platform does not
+support locking, simply ignore the <command>fis unlock</command> and
+<command>fis lock</command> steps (the commands will not be recognized
+by RedBoot).</para>
+
+<screen>RedBoot> <userinput>fis unlock RedBoot</userinput>
+ ... Unlock from 0x00000000-0x00020000: ..
+RedBoot> <userinput>fis create RedBoot</userinput>
+An image named 'RedBoot' exists - continue (y/n)? <userinput>y</userinput>
+* CAUTION * about to program 'RedBoot'
+ at 0x00000000..0x0001c7e7 from 0x06046800 - continue (y/n)? <userinput>y</userinput>
+... Erase from 0x00000000-0x00020000: ..
+... Program from 0x06046800-0x06062fe8 at 0x00000000: ..
+... Erase from 0x00070000-0x00080000: .
+... Program from 0x0606f000-0x0607f000 at 0x00070000: .
+RedBoot> <userinput>fis lock RedBoot</userinput>
+ ... Lock from 0x00000000-0x00020000: ..
+</screen>
+
+</sect2>
+<sect2>
+<title>Reboot; run the new RedBoot image</title>
+<para>Once the image has been successfully written into the flash, simply
+reset the target and the new version of RedBoot should be running. </para>
+<para>When installing RedBoot for the first time, or after updating to
+a newer RedBoot with different configuration keys, it is necessary to
+update the configuration directory in the flash using the
+<command>fconfig</command> command. See <xref
+linkend="Persistent-State-Flash">.
+</para>
+
+</sect2></sect1></chapter>
diff --git a/ecos/packages/redboot/current/include/elf.h b/ecos/packages/redboot/current/include/elf.h
new file mode 100644
index 0000000..40e9309
--- /dev/null
+++ b/ecos/packages/redboot/current/include/elf.h
@@ -0,0 +1,703 @@
+#ifndef CYGONCE_REDBOOT_ELF_H
+#define CYGONCE_REDBOOT_ELF_H
+
+//==========================================================================
+//
+// elf.h
+//
+// ELF file format definitions
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): nickg
+// Contributors: nickg
+// Date: 2000-11-15
+// Purpose: Define ELF file format
+// Description: The types defined here describe the ELF file format.
+//
+// Usage: #include <cyg/loader/elf.h>
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+//
+// Quite a lot of this file was taken from the BSD exec_elf.h header file.
+// Hence we should show you this...
+//
+/* $OpenBSD: exec_elf.h,v 1.20 1999/09/19 16:16:49 kstailey Exp $ */
+/*
+ * Copyright (c) 1995, 1996 Erik Theisen. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+//==========================================================================
+
+#include <cyg/infra/cyg_type.h>
+
+// -------------------------------------------------------------------------
+// Basic types:
+
+typedef cyg_uint32 Elf32_Addr;
+typedef cyg_uint32 Elf32_Off;
+typedef cyg_uint16 Elf32_Half;
+typedef cyg_uint32 Elf32_Word;
+typedef cyg_int32 Elf32_Sword;
+
+typedef cyg_uint64 Elf64_Addr;
+typedef cyg_uint64 Elf64_Off;
+typedef cyg_uint16 Elf64_Half;
+typedef cyg_uint32 Elf64_Word;
+typedef cyg_int32 Elf64_Sword;
+typedef cyg_uint64 Elf64_Xword;
+typedef cyg_int64 Elf64_Sxword;
+
+// -------------------------------------------------------------------------
+// ELF header
+
+#define EI_NIDENT 16
+
+typedef struct {
+ unsigned char e_ident[EI_NIDENT];
+ Elf32_Half e_type;
+ Elf32_Half e_machine;
+ Elf32_Word e_version;
+ Elf32_Addr e_entry;
+ Elf32_Off e_phoff;
+ Elf32_Off e_shoff;
+ Elf32_Word e_flags;
+ Elf32_Half e_ehsize;
+ Elf32_Half e_phentsize;
+ Elf32_Half e_phnum;
+ Elf32_Half e_shentsize;
+ Elf32_Half e_shnum;
+ Elf32_Half e_shtrndx;
+} Elf32_Ehdr;
+
+typedef struct {
+ unsigned char e_ident[EI_NIDENT];
+ Elf64_Half e_type;
+ Elf64_Half e_machine;
+ Elf64_Word e_version;
+ Elf64_Addr e_entry;
+ Elf64_Off e_phoff;
+ Elf64_Off e_shoff;
+ Elf64_Word e_flags;
+ Elf64_Half e_ehsize;
+ Elf64_Half e_phentsize;
+ Elf64_Half e_phnum;
+ Elf64_Half e_shentsize;
+ Elf64_Half e_shnum;
+ Elf64_Half e_shtrndx;
+} Elf64_Ehdr;
+
+// -------------------------------------------------------------------------
+/* e_ident[] identification indexes */
+
+#define EI_MAG0 0 /* file ID */
+#define EI_MAG1 1 /* file ID */
+#define EI_MAG2 2 /* file ID */
+#define EI_MAG3 3 /* file ID */
+#define EI_CLASS 4 /* file class */
+#define EI_DATA 5 /* data encoding */
+#define EI_VERSION 6 /* ELF header version */
+#define EI_OSABI 7 /* Operating system/ABI identification */
+#define EI_ABIVERSION 8 /* ABI version */
+#define EI_PAD 9 /* start of pad bytes */
+
+// -------------------------------------------------------------------------
+/* e_ident[] magic number */
+
+#define ELFMAG0 0x7f /* e_ident[EI_MAG0] */
+#define ELFMAG1 'E' /* e_ident[EI_MAG1] */
+#define ELFMAG2 'L' /* e_ident[EI_MAG2] */
+#define ELFMAG3 'F' /* e_ident[EI_MAG3] */
+#define ELFMAG "\177ELF" /* magic */
+#define SELFMAG 4 /* size of magic */
+
+// -------------------------------------------------------------------------
+/* e_ident[] file class */
+
+#define ELFCLASSNONE 0 /* invalid */
+#define ELFCLASS32 1 /* 32-bit objs */
+#define ELFCLASS64 2 /* 64-bit objs */
+#define ELFCLASSNUM 3 /* number of classes */
+
+// -------------------------------------------------------------------------
+/* e_ident[] data encoding */
+
+#define ELFDATANONE 0 /* invalid */
+#define ELFDATA2LSB 1 /* Little-Endian */
+#define ELFDATA2MSB 2 /* Big-Endian */
+#define ELFDATANUM 3 /* number of data encode defines */
+
+// -------------------------------------------------------------------------
+/* e_ident */
+
+#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
+ (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
+ (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
+ (ehdr).e_ident[EI_MAG3] == ELFMAG3)
+
+// -------------------------------------------------------------------------
+/* e_type */
+
+#define ET_NONE 0 /* No file type */
+#define ET_REL 1 /* relocatable file */
+#define ET_EXEC 2 /* executable file */
+#define ET_DYN 3 /* shared object file */
+#define ET_CORE 4 /* core file */
+#define ET_NUM 5 /* number of types */
+#define ET_LOOS 0xfe00 /* Operating system-specific */
+#define ET_HIOS 0xfeff /* Operating system-specific */
+#define ET_LOPROC 0xff00 /* reserved range for processor */
+#define ET_HIPROC 0xffff /* specific e_type */
+
+// -------------------------------------------------------------------------
+/* e_machine */
+// The following values taken from 22 June 2000 SysV ABI spec, updated with
+// extra values from binutils elf/common.h.
+
+#define EM_NONE 0 // No machine
+#define EM_M32 1 // AT&T WE 32100
+#define EM_SPARC 2 // SPARC
+#define EM_386 3 // Intel 80386
+#define EM_68K 4 // Motorola 68000
+#define EM_88K 5 // Motorola 88000
+#define EM_860 7 // Intel 80860
+#define EM_MIPS 8 // MIPS I Architecture
+#define EM_S370 9 // IBM System/370 Processor
+#define EM_MIPS_RS3_LE 10 // MIPS RS3000 Little-endian
+#define EM_PARISC 15 // Hewlett-Packard PA-RISC
+#define EM_VPP500 17 // Fujitsu VPP500
+#define EM_SPARC32PLUS 18 // Enhanced instruction set SPARC
+#define EM_960 19 // Intel 80960
+#define EM_PPC 20 // PowerPC
+#define EM_PPC64 21 // 64-bit PowerPC
+#define EM_V800 36 // NEC V800
+#define EM_FR20 37 // Fujitsu FR20
+#define EM_RH32 38 // TRW RH-32
+#define EM_RCE 39 // Motorola RCE
+#define EM_ARM 40 // Advanced RISC Machines ARM
+#define EM_ALPHA 41 // Digital Alpha
+#define EM_SH 42 // Hitachi SH
+#define EM_SPARCV9 43 // SPARC Version 9
+#define EM_TRICORE 44 // Siemens Tricore embedded processor
+#define EM_ARC 45 // Argonaut RISC Core, Argonaut Technologies Inc.
+#define EM_H8_300 46 // Hitachi H8/300
+#define EM_H8_300H 47 // Hitachi H8/300H
+#define EM_H8S 48 // Hitachi H8S
+#define EM_H8_500 49 // Hitachi H8/500
+#define EM_IA_64 50 // Intel IA-64 processor architecture
+#define EM_MIPS_X 51 // Stanford MIPS-X
+#define EM_COLDFIRE 52 // Motorola ColdFire
+#define EM_68HC12 53 // Motorola M68HC12
+#define EM_MMA 54 // Fujitsu MMA Multimedia Accelerator
+#define EM_PCP 55 // Siemens PCP
+#define EM_NCPU 56 // Sony nCPU embedded RISC processor
+#define EM_NDR1 57 // Denso NDR1 microprocessor
+#define EM_STARCORE 58 // Motorola Star*Core processor
+#define EM_ME16 59 // Toyota ME16 processor
+#define EM_ST100 60 // STMicroelectronics ST100 processor
+#define EM_TINYJ 61 // Advanced Logic Corp. TinyJ embedded processor family
+#define EM_FX66 66 // Siemens FX66 microcontroller
+#define EM_ST9PLUS 67 // STMicroelectronics ST9+ 8/16 bit microcontroller
+#define EM_ST7 68 // STMicroelectronics ST7 8-bit microcontroller
+#define EM_68HC16 69 // Motorola MC68HC16 Microcontroller
+#define EM_68HC11 70 // Motorola MC68HC11 Microcontroller
+#define EM_68HC08 71 // Motorola MC68HC08 Microcontroller
+#define EM_68HC05 72 // Motorola MC68HC05 Microcontroller
+#define EM_SVX 73 // Silicon Graphics SVx
+#define EM_ST19 74 // STMicroelectronics ST19 8-bit microcontroller
+#define EM_VAX 75 // Digital VAX
+#define EM_CRIS 76 // Axis Communications 32-bit embedded processor
+#define EM_JAVELIN 77 // Infineon Technologies 32-bit embedded processor
+#define EM_FIREPATH 78 // Element 14 64-bit DSP Processor
+#define EM_ZSP 79 // LSI Logic 16-bit DSP Processor
+#define EM_MMIX 80 // Donald Knuth's educational 64-bit processor
+#define EM_HUANY 81 // Harvard University machine-independent object files
+#define EM_PRISM 82 // SiTera Prism
+
+/* Cygnus PowerPC ELF backend. Written in the absence of an ABI. */
+#define EM_CYGNUS_POWERPC 0x9025
+
+/* Old version of Sparc v9, from before the ABI; this should be
+ removed shortly. */
+#define EM_OLD_SPARCV9 11
+
+/* Old version of PowerPC, this should be removed shortly. */
+#define EM_PPC_OLD 17
+
+/* Cygnus ARC ELF backend. Written in the absence of an ABI. */
+#define EM_CYGNUS_ARC 0x9040
+
+/* Cygnus M32R ELF backend. Written in the absence of an ABI. */
+#define EM_CYGNUS_M32R 0x9041
+
+/* Alpha backend magic number. Written in the absence of an ABI. */
+//#define EM_ALPHA 0x9026
+
+/* D10V backend magic number. Written in the absence of an ABI. */
+#define EM_CYGNUS_D10V 0x7650
+
+/* D30V backend magic number. Written in the absence of an ABI. */
+#define EM_CYGNUS_D30V 0x7676
+
+/* V850 backend magic number. Written in the absense of an ABI. */
+#define EM_CYGNUS_V850 0x9080
+
+/* mn10200 and mn10300 backend magic numbers.
+ Written in the absense of an ABI. */
+#define EM_CYGNUS_MN10200 0xdead
+#define EM_CYGNUS_MN10300 0xbeef
+
+/* FR30 magic number - no EABI available. */
+#define EM_CYGNUS_FR30 0x3330
+
+/* AVR magic number
+ Written in the absense of an ABI. */
+#define EM_AVR 0x1057
+
+// -------------------------------------------------------------------------
+/* Version */
+
+#define EV_NONE 0 /* Invalid */
+#define EV_CURRENT 1 /* Current */
+#define EV_NUM 2 /* number of versions */
+
+// -------------------------------------------------------------------------
+/* Section Header */
+
+typedef struct {
+ Elf32_Word sh_name; /* name - index into section header
+ string table section */
+ Elf32_Word sh_type; /* type */
+ Elf32_Word sh_flags; /* flags */
+ Elf32_Addr sh_addr; /* address */
+ Elf32_Off sh_offset; /* file offset */
+ Elf32_Word sh_size; /* section size */
+ Elf32_Word sh_link; /* section header table index link */
+ Elf32_Word sh_info; /* extra information */
+ Elf32_Word sh_addralign; /* address alignment */
+ Elf32_Word sh_entsize; /* section entry size */
+} Elf32_Shdr;
+
+typedef struct {
+ Elf64_Word sh_name; /* section name */
+ Elf64_Word sh_type; /* section type */
+ Elf64_Xword sh_flags; /* section flags */
+ Elf64_Addr sh_addr; /* virtual address */
+ Elf64_Off sh_offset; /* file offset */
+ Elf64_Xword sh_size; /* section size */
+ Elf64_Word sh_link; /* link to another */
+ Elf64_Word sh_info; /* misc info */
+ Elf64_Xword sh_addralign; /* memory alignment */
+ Elf64_Xword sh_entsize; /* table entry size */
+} Elf64_Shdr;
+
+// -------------------------------------------------------------------------
+/* Special Section Indexes */
+
+#define SHN_UNDEF 0 /* undefined */
+#define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */
+#define SHN_LOPROC 0xff00 /* reserved range for processor */
+#define SHN_HIPROC 0xff1f /* specific section indexes */
+#define SHN_LOOS 0xff20 /* reserved range for operating */
+#define SHN_HIOS 0xff3f /* system specific section indexes */
+#define SHN_ABS 0xfff1 /* absolute value */
+#define SHN_COMMON 0xfff2 /* common symbol */
+#define SHN_XINDEX 0xffff /* escape value for oversize index */
+#define SHN_HIRESERVE 0xffff /* upper bounds of reserved indexes */
+
+// -------------------------------------------------------------------------
+/* sh_type */
+
+#define SHT_NULL 0 /* inactive */
+#define SHT_PROGBITS 1 /* program defined information */
+#define SHT_SYMTAB 2 /* symbol table section */
+#define SHT_STRTAB 3 /* string table section */
+#define SHT_RELA 4 /* relocation section with addends*/
+#define SHT_HASH 5 /* symbol hash table section */
+#define SHT_DYNAMIC 6 /* dynamic section */
+#define SHT_NOTE 7 /* note section */
+#define SHT_NOBITS 8 /* no space section */
+#define SHT_REL 9 /* relation section without addends */
+#define SHT_SHLIB 10 /* reserved - purpose unknown */
+#define SHT_DYNSYM 11 /* dynamic symbol table section */
+#define SHT_INIT_ARRAY 14 /* init procedure array */
+#define SHT_FINI_ARRAY 15 /* fini procedure array */
+#define SHT_PREINIT_ARRAY 16 /* preinit procedure array */
+#define SHT_GROUP 17 /* section group */
+#define SHT_SYMTAB_SHNDX 18 /* oversize index table */
+#define SHT_NUM 19 /* number of section types */
+#define SHT_LOOS 0x60000000 /* reserved range for O/S */
+#define SHT_HIOS 0x6fffffff /* specific section header types */
+#define SHT_LOPROC 0x70000000 /* reserved range for processor */
+#define SHT_HIPROC 0x7fffffff /* specific section header types */
+#define SHT_LOUSER 0x80000000 /* reserved range for application */
+#define SHT_HIUSER 0xffffffff /* specific indexes */
+
+// -------------------------------------------------------------------------
+/* Section names */
+
+#define ELF_BSS ".bss" /* uninitialized data */
+#define ELF_DATA ".data" /* initialized data */
+#define ELF_DEBUG ".debug" /* debug */
+#define ELF_DYNAMIC ".dynamic" /* dynamic linking information */
+#define ELF_DYNSTR ".dynstr" /* dynamic string table */
+#define ELF_DYNSYM ".dynsym" /* dynamic symbol table */
+#define ELF_FINI ".fini" /* termination code */
+#define ELF_GOT ".got" /* global offset table */
+#define ELF_HASH ".hash" /* symbol hash table */
+#define ELF_INIT ".init" /* initialization code */
+#define ELF_REL_DATA ".rel.data" /* relocation data */
+#define ELF_REL_FINI ".rel.fini" /* relocation termination code */
+#define ELF_REL_INIT ".rel.init" /* relocation initialization code */
+#define ELF_REL_DYN ".rel.dyn" /* relocaltion dynamic link info */
+#define ELF_REL_RODATA ".rel.rodata" /* relocation read-only data */
+#define ELF_REL_TEXT ".rel.text" /* relocation code */
+#define ELF_RODATA ".rodata" /* read-only data */
+#define ELF_SHSTRTAB ".shstrtab" /* section header string table */
+#define ELF_STRTAB ".strtab" /* string table */
+#define ELF_SYMTAB ".symtab" /* symbol table */
+#define ELF_TEXT ".text" /* code */
+
+// -------------------------------------------------------------------------
+/* Section Attribute Flags - sh_flags */
+
+#define SHF_WRITE 0x001 /* Writable */
+#define SHF_ALLOC 0x002 /* occupies memory */
+#define SHF_EXECINSTR 0x004 /* executable */
+#define SHF_MERGE 0x010 /* merge data */
+#define SHF_STRINGS 0x020 /* contains strings */
+#define SHF_INFO_LINK 0x040 /* link in sh_info field */
+#define SHF_LINK_ORDER 0x080 /* preserve link order */
+#define SHF_OS_NONCONFORMING 0x100 /* special OS-specific */
+ /* processing needed */
+#define SHF_GROUP 0x200 /* member of group */
+#define SHF_MASKOS 0x0ff00000 /* reserved bits for OS */
+ /* specific section attributes */
+#define SHF_MASKPROC 0xf0000000 /* reserved bits for processor */
+ /* specific section attributes */
+
+// -------------------------------------------------------------------------
+/* Symbol Table Entry */
+
+typedef struct {
+ Elf32_Word st_name; /* name - index into string table */
+ Elf32_Addr st_value; /* symbol value */
+ Elf32_Word st_size; /* symbol size */
+ unsigned char st_info; /* type and binding */
+ unsigned char st_other; /* visibility */
+ Elf32_Half st_shndx; /* section header index */
+} Elf32_Sym;
+
+typedef struct {
+ Elf64_Word st_name; /* Symbol name index in str table */
+ unsigned char st_info; /* type / binding attrs */
+ unsigned char st_other; /* visibility */
+ Elf64_Half st_shndx; /* section index of symbol */
+ Elf64_Addr st_value; /* value of symbol */
+ Elf64_Xword st_size; /* size of symbol */
+} Elf64_Sym;
+
+// -------------------------------------------------------------------------
+/* Symbol table index */
+
+#define STN_UNDEF 0 /* undefined */
+
+/* Extract symbol info - st_info */
+#define ELF32_ST_BIND(x) ((x) >> 4)
+#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf)
+#define ELF32_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf))
+
+#define ELF64_ST_BIND(x) ((x) >> 4)
+#define ELF64_ST_TYPE(x) (((unsigned int) x) & 0xf)
+#define ELF64_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf))
+
+#define ELF32_ST_VISIBILITY(o) ((o)&0x3)
+#define ELF64_ST_VISIBILITY(o) ((o)&0x3)
+
+// -------------------------------------------------------------------------
+/* Symbol Binding - ELF32_ST_BIND - st_info */
+
+#define STB_LOCAL 0 /* Local symbol */
+#define STB_GLOBAL 1 /* Global symbol */
+#define STB_WEAK 2 /* like global - lower precedence */
+#define STB_NUM 3 /* number of symbol bindings */
+#define STB_LOOS 10 /* reserved range for OS */
+#define STB_HIOS 12 /* specific symbol bindings */
+#define STB_LOPROC 13 /* reserved range for processor */
+#define STB_HIPROC 15 /* specific symbol bindings */
+
+// -------------------------------------------------------------------------
+/* Symbol type - ELF32_ST_TYPE - st_info */
+
+#define STT_NOTYPE 0 /* not specified */
+#define STT_OBJECT 1 /* data object */
+#define STT_FUNC 2 /* function */
+#define STT_SECTION 3 /* section */
+#define STT_FILE 4 /* file */
+#define STT_COMMON 5 /* common block */
+#define STT_NUM 6 /* number of symbol types */
+#define STT_LOOS 10 /* reserved range for OS */
+#define STT_HIOS 12 /* specific symbol types */
+#define STT_LOPROC 13 /* reserved range for processor */
+#define STT_HIPROC 15 /* specific symbol types */
+
+// -------------------------------------------------------------------------
+// symbol visibility in st_other
+
+#define STV_DEFAULT 0 /* default to binding type */
+#define STV_INTERNAL 1 /* processor specific */
+#define STV_HIDDEN 2 /* invisible */
+#define STV_PROTECTED 3 /* non-premptable */
+
+// -------------------------------------------------------------------------
+// 32 bit relocation records
+
+/* Relocation entry with implicit addend */
+typedef struct
+{
+ Elf32_Addr r_offset; /* offset of relocation */
+ Elf32_Word r_info; /* symbol table index and type */
+} Elf32_Rel;
+
+/* Relocation entry with explicit addend */
+typedef struct
+{
+ Elf32_Addr r_offset; /* offset of relocation */
+ Elf32_Word r_info; /* symbol table index and type */
+ Elf32_Sword r_addend;
+} Elf32_Rela;
+
+/* Extract relocation info - r_info */
+#define ELF32_R_SYM(i) ((i) >> 8)
+#define ELF32_R_TYPE(i) ((unsigned char) (i))
+#define ELF32_R_INFO(s,t) (((s) << 8) + (unsigned char)(t))
+
+// -------------------------------------------------------------------------
+// 64 bit equivalents of above structures and macros.
+
+typedef struct {
+ Elf64_Addr r_offset; /* where to do it */
+ Elf64_Xword r_info; /* index & type of relocation */
+} Elf64_Rel;
+
+typedef struct {
+ Elf64_Addr r_offset; /* where to do it */
+ Elf64_Xword r_info; /* index & type of relocation */
+ Elf64_Sxword r_addend; /* adjustment value */
+} Elf64_RelA;
+
+#define ELF64_R_SYM(info) ((info) >> 32)
+#define ELF64_R_TYPE(info) ((info) & 0xFFFFFFFF)
+#define ELF64_R_INFO(s,t) (((s) << 32) + (u_int32_t)(t))
+
+// -------------------------------------------------------------------------
+/* Program Header */
+
+typedef struct {
+ Elf32_Word p_type; /* segment type */
+ Elf32_Off p_offset; /* segment offset */
+ Elf32_Addr p_vaddr; /* virtual address of segment */
+ Elf32_Addr p_paddr; /* physical address - ignored? */
+ Elf32_Word p_filesz; /* number of bytes in file for seg. */
+ Elf32_Word p_memsz; /* number of bytes in mem. for seg. */
+ Elf32_Word p_flags; /* flags */
+ Elf32_Word p_align; /* memory alignment */
+} Elf32_Phdr;
+
+typedef struct {
+ Elf64_Word p_type; /* entry type */
+ Elf64_Word p_flags; /* flags */
+ Elf64_Off p_offset; /* offset */
+ Elf64_Addr p_vaddr; /* virtual address */
+ Elf64_Addr p_paddr; /* physical address */
+ Elf64_Xword p_filesz; /* file size */
+ Elf64_Xword p_memsz; /* memory size */
+ Elf64_Xword p_align; /* memory & file alignment */
+} Elf64_Phdr;
+
+// -------------------------------------------------------------------------
+/* Segment types - p_type */
+
+#define PT_NULL 0 /* unused */
+#define PT_LOAD 1 /* loadable segment */
+#define PT_DYNAMIC 2 /* dynamic linking section */
+#define PT_INTERP 3 /* the RTLD */
+#define PT_NOTE 4 /* auxiliary information */
+#define PT_SHLIB 5 /* reserved - purpose undefined */
+#define PT_PHDR 6 /* program header */
+#define PT_NUM 7 /* Number of segment types */
+#define PT_LOOS 0x60000000 /* reserved range for OS */
+#define PT_HIOS 0x6fffffff /* specific segment types */
+#define PT_LOPROC 0x70000000 /* reserved range for processor */
+#define PT_HIPROC 0x7fffffff /* specific segment types */
+
+// -------------------------------------------------------------------------
+/* Segment flags - p_flags */
+
+#define PF_X 0x1 /* Executable */
+#define PF_W 0x2 /* Writable */
+#define PF_R 0x4 /* Readable */
+#define PF_MASKOS 0x0ff00000 /* reserved bits for OS */
+ /* specific segment flags */
+#define PF_MASKPROC 0xf0000000 /* reserved bits for processor */
+ /* specific segment flags */
+
+// -------------------------------------------------------------------------
+/* Dynamic structure */
+
+typedef struct {
+ Elf32_Sword d_tag; /* controls meaning of d_val */
+ union {
+ Elf32_Word d_val; /* Multiple meanings - see d_tag */
+ Elf32_Addr d_ptr; /* program virtual address */
+ } d_un;
+} Elf32_Dyn;
+
+extern Elf32_Dyn _DYNAMIC[]; /* XXX not 64-bit clean */
+
+typedef struct {
+ Elf64_Sxword d_tag; /* controls meaning of d_val */
+ union {
+ Elf64_Xword d_val;
+ Elf64_Addr d_ptr;
+ } d_un;
+} Elf64_Dyn;
+
+// -------------------------------------------------------------------------
+/* Dynamic Array Tags - d_tag */
+
+#define DT_NULL 0 /* marks end of _DYNAMIC array */
+#define DT_NEEDED 1 /* string table offset of needed lib */
+#define DT_PLTRELSZ 2 /* size of relocation entries in PLT */
+#define DT_PLTGOT 3 /* address PLT/GOT */
+#define DT_HASH 4 /* address of symbol hash table */
+#define DT_STRTAB 5 /* address of string table */
+#define DT_SYMTAB 6 /* address of symbol table */
+#define DT_RELA 7 /* address of relocation table */
+#define DT_RELASZ 8 /* size of relocation table */
+#define DT_RELAENT 9 /* size of relocation entry */
+#define DT_STRSZ 10 /* size of string table */
+#define DT_SYMENT 11 /* size of symbol table entry */
+#define DT_INIT 12 /* address of initialization func. */
+#define DT_FINI 13 /* address of termination function */
+#define DT_SONAME 14 /* string table offset of shared obj */
+#define DT_RPATH 15 /* string table offset of library
+ search path */
+#define DT_SYMBOLIC 16 /* start sym search in shared obj. */
+#define DT_REL 17 /* address of rel. tbl. w addends */
+#define DT_RELSZ 18 /* size of DT_REL relocation table */
+#define DT_RELENT 19 /* size of DT_REL relocation entry */
+#define DT_PLTREL 20 /* PLT referenced relocation entry */
+#define DT_DEBUG 21 /* bugger */
+#define DT_TEXTREL 22 /* Allow rel. mod. to unwritable seg */
+#define DT_JMPREL 23 /* add. of PLT's relocation entries */
+#define DT_BIND_NOW 24 /* Bind now regardless of env setting */
+#define DT_INIT_ARRAY 25 /* init array address */
+#define DT_FINI_ARRAY 26 /* fini array address */
+#define DT_INIT_ARRAYSZ 27 /* init array size */
+#define DT_FINI_ARRAYSZ 28 /* fini array size */
+#define DT_RUNPATH 29 /* library search path */
+#define DT_FLAGS 30 /* flags */
+#define DT_ENCODING 32 /* encoding rules start here */
+#define DT_PREINIT_ARRAY 32 /* preinit array address */
+#define DT_PREINIT_ARRAYSZ 33 /* preinit array size */
+#define DT_NUM 26 /* Number used. */
+#define DT_LOOS 0x60000000 /* reserved range for OS */
+#define DT_HIOS 0x6fffffff /* specific dynamic array tags */
+#define DT_LOPROC 0x70000000 /* reserved range for processor */
+#define DT_HIPROC 0x7fffffff /* specific dynamic array tags */
+
+// -------------------------------------------------------------------------
+// Values for DT_FLAGS entry
+
+#define DF_ORIGIN 0x1 /* Uses $ORIGIN substitution string */
+#define DF_SYMBOLIC 0x2 /* search for symbols here first */
+#define DF_TEXTREL 0x4 /* text may be relocatable */
+#define DF_BIND_NOW 0x8 /* bind references now, dammit */
+
+// -------------------------------------------------------------------------
+/* Note Definitions */
+
+typedef struct {
+ Elf32_Word namesz;
+ Elf32_Word descsz;
+ Elf32_Word type;
+} Elf32_Note;
+
+typedef struct {
+ Elf64_Word namesz;
+ Elf64_Word descsz;
+ Elf64_Word type;
+} Elf64_Note;
+
+// -------------------------------------------------------------------------
+// Hash table structure
+// The same structure is used by both 32 and 64 bit formats
+
+typedef struct {
+ Elf32_Word nbucket; /* number of buckets */
+ Elf32_Word nchain; /* number of chains */
+
+ /* The buckets follow this structure in memory and the chains
+ follow those. */
+} Elf_Hash;
+
+// -------------------------------------------------------------------------
+#endif // ifndef CYGONCE_REDBOOT_ELF_H
+// EOF elf.h
diff --git a/ecos/packages/redboot/current/include/fis.h b/ecos/packages/redboot/current/include/fis.h
new file mode 100644
index 0000000..81cafd8
--- /dev/null
+++ b/ecos/packages/redboot/current/include/fis.h
@@ -0,0 +1,107 @@
+#ifndef _FIS_H_
+#define _FIS_H_
+//==========================================================================
+//
+// fis.h
+//
+// RedBoot - FLASH image directory layout
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas, tkoeller
+// Date: 2000-07-28
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <pkgconf/redboot.h>
+#ifdef CYGOPT_REDBOOT_FIS
+#include <cyg/infra/cyg_type.h>
+
+//the version can be tested via the VV calls to check for compatibility
+#define CYG_REDBOOT_FIS_VERSION (1)
+
+// the following defines will be used if RedBoot is configured
+// with support for redundant FIS tables, which enable failsafe updating
+#ifdef CYGOPT_REDBOOT_REDUNDANT_FIS
+
+#define CYG_REDBOOT_RFIS_VALID_MAGIC_LENGTH 10
+#define CYG_REDBOOT_RFIS_VALID_MAGIC ".FisValid" // exactly 10 bytes
+
+#define CYG_REDBOOT_RFIS_VALID (0xa5) // this FIS table is valid, the only "good" value
+#define CYG_REDBOOT_RFIS_IN_PROGRESS (0xfd) // this FIS table is being modified
+#define CYG_REDBOOT_RFIS_EMPTY (0xff) // this FIS table is empty
+
+struct fis_valid_info
+{
+ char magic_name[CYG_REDBOOT_RFIS_VALID_MAGIC_LENGTH];
+ unsigned char valid_flag[2]; // one of the flags defined above
+ unsigned long version_count; // with each successfull update the version count will increase by 1
+};
+
+#endif // CYGOPT_REDBOOT_REDUNDANT_FIS
+
+#define FIS_IMAGE_DESC_SIZE_UNPADDED \
+ (16 + 4 * sizeof(unsigned long) + 3 * sizeof(CYG_ADDRESS))
+
+struct fis_image_desc {
+ union
+ {
+ char name[16]; // Null terminated name
+ #ifdef CYGOPT_REDBOOT_REDUNDANT_FIS
+ struct fis_valid_info valid_info;
+ #endif
+ } u;
+ CYG_ADDRESS flash_base; // Address within FLASH of image
+ CYG_ADDRESS mem_base; // Address in memory where it executes
+ unsigned long size; // Length of image
+ CYG_ADDRESS entry_point; // Execution entry point
+ unsigned long data_length; // Length of actual data
+ unsigned char _pad[CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_SIZE-FIS_IMAGE_DESC_SIZE_UNPADDED];
+ unsigned long desc_cksum; // Checksum over image descriptor
+ unsigned long file_cksum; // Checksum over image data
+};
+
+struct fis_image_desc *fis_lookup(char *name, int *num);
+
+#endif // CYGOPT_REDBOOT_FIS
+#endif // _FIS_H_
diff --git a/ecos/packages/redboot/current/include/flash_config.h b/ecos/packages/redboot/current/include/flash_config.h
new file mode 100644
index 0000000..d214a4b
--- /dev/null
+++ b/ecos/packages/redboot/current/include/flash_config.h
@@ -0,0 +1,109 @@
+//==========================================================================
+//
+// flash_config.h
+//
+// Flash configuration data tables for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2008 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-08-21
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#ifndef _FLASH_CONFIG_H_
+#define _FLASH_CONFIG_H_
+
+#define MAX_SCRIPT_LENGTH CYGNUM_REDBOOT_FLASH_SCRIPT_SIZE
+#define MAX_STRING_LENGTH CYGNUM_REDBOOT_FLASH_STRING_SIZE
+#define MAX_CONFIG_DATA CYGNUM_REDBOOT_FLASH_CONFIG_SIZE
+
+#define CONFIG_EMPTY 0
+#define CONFIG_BOOL 1
+#define CONFIG_INT 2
+#define CONFIG_STRING 3
+#define CONFIG_SCRIPT 4
+#ifdef CYGPKG_REDBOOT_NETWORKING
+#define CONFIG_IP 5
+#define CONFIG_ESA 6
+#define CONFIG_NETPORT 7
+#endif
+
+struct config_option {
+ char *key;
+ char *title;
+ char *enable;
+ bool enable_sense;
+ int type;
+ unsigned long dflt;
+} CYG_HAL_TABLE_TYPE;
+
+#define ALWAYS_ENABLED (char *)0
+
+#define RedBoot_config_option(_t_,_n_,_e_,_ie_,_type_,_dflt_) \
+struct config_option _config_option_##_n_ \
+CYG_HAL_TABLE_QUALIFIED_ENTRY(RedBoot_config_options,_n_) = \
+ {#_n_,_t_,_e_,_ie_,_type_,(unsigned long)_dflt_};
+
+// Cause the in-memory configuration data to be written to flash
+void flash_write_config(bool prompt);
+// Fetch a data item from flash storage, returns 'false' if not found
+bool flash_get_config(char *key, void *val, int type);
+// Update a data item from flash storage, returns 'false' if not found
+bool flash_set_config(char *key, void *val, int type);
+// Enumerate keys from configuration
+bool flash_next_key(char *key, int keylen, int *type, int *offset);
+// Add a new data item to configuration data base. Returns 'false'
+// if no space is available.
+bool flash_add_config(struct config_option *opt, bool update);
+
+// Internal structure used to hold config data
+struct _config {
+ unsigned long len;
+ unsigned long key1;
+ char config_data[MAX_CONFIG_DATA-(4*4)];
+ unsigned long key2;
+ unsigned long cksum;
+};
+
+#endif // _FLASH_CONFIG_H_
diff --git a/ecos/packages/redboot/current/include/fs/disk.h b/ecos/packages/redboot/current/include/fs/disk.h
new file mode 100644
index 0000000..c0d41f6
--- /dev/null
+++ b/ecos/packages/redboot/current/include/fs/disk.h
@@ -0,0 +1,172 @@
+//==========================================================================
+//
+// disk.h
+//
+// Stand-alone disk support for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): msalter
+// Contributors: msalter
+// Date: 2001-07-02
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#ifndef CYGONCE_REDBOOT_DISK_H
+#define CYGONCE_REDBOOT_DISK_H
+
+#define SECTOR_SIZE 512
+
+// Convenience macros to access disk/filesystem info which may
+// be stored in a fixed endian format.
+
+#define __SWAB16(x) \
+ ((((x) & 0xFF) << 8) | (((x) >> 8) & 0xFF))
+
+#define __SWAB32(x) \
+ ((((x) & 0xff) << 24) | \
+ (((x) & 0xff00) << 8) | \
+ (((x) >> 8) & 0xff00) | \
+ (((x) >> 24) & 0xff))
+
+#if (CYG_BYTEORDER == CYG_MSBFIRST)
+#define SWAB_LE16(x) __SWAB16(x)
+#define SWAB_LE32(x) __SWAB32(x)
+#define SWAB_BE16(x) (x)
+#define SWAB_BE32(x) (x)
+#else
+#define SWAB_LE16(x) (x)
+#define SWAB_LE32(x) (x)
+#define SWAB_BE16(x) __SWAB16(x)
+#define SWAB_BE32(x) __SWAB32(x)
+#endif
+
+struct partition;
+
+// filesystem interface
+typedef struct fs_funs {
+ // Load a file into memory.
+ void * (*open)(struct partition *p, const char *path);
+ int (*read)(void *fp, char *buf, cyg_uint32 nbytes);
+} fs_funs_t;
+
+struct disk;
+
+typedef struct partition {
+ struct disk *disk;
+ fs_funs_t *funs;
+ cyg_uint32 start_sector; // first sector in partition
+ cyg_uint32 nr_sectors; // number of sectors in partition
+ cyg_uint8 systype; // FAT12, FAT16, Linux, etc.
+ cyg_uint8 bootflag; // not really used...
+} partition_t;
+
+// System types
+#define SYSTYPE_FAT12 0x01
+#define SYSTYPE_FAT16_32M 0x04
+#define SYSTYPE_EXTENDED 0x05
+#define SYSTYPE_FAT16 0x06
+#define SYSTYPE_LINUX_SWAP 0x82
+#define SYSTYPE_LINUX 0x83
+
+typedef struct disk_funs {
+ int (*read)(struct disk *d,
+ cyg_uint32 start_sector,
+ cyg_uint32 *buf,
+ cyg_uint8 nr_sectors);
+} disk_funs_t;
+
+
+typedef struct disk {
+ disk_funs_t *funs; // Disk driver functions
+ void *private; // Whatever is needed by disk functions
+ cyg_uint32 nr_sectors; // Total disk size in sectors
+ short kind; // IDE_HD, IDE_CDROM, SCSI_HD, etc
+ short index; // index within specific kind
+ partition_t partitions[CYGNUM_REDBOOT_MAX_PARTITIONS];
+} disk_t;
+
+#define DISK_READ(d,s,p,n) ((d)->funs->read)((d),(s),(p),(n))
+#define PARTITION_READ(part,s,p,n) \
+ DISK_READ((part)->disk, (s) + (part)->start_sector, (p), (n))
+
+// Kinds of disks
+#define DISK_IDE_HD 1
+#define DISK_IDE_CDROM 2
+#define DISK_FLOPPY 3
+
+// DOS partition table as laid out in the MBR
+//
+struct mbr_partition {
+ cyg_uint8 boot_ind; // 0x80 == active
+ cyg_uint8 head;
+ cyg_uint8 sector;
+ cyg_uint8 cyl;
+ cyg_uint8 sys_ind; // partition type
+ cyg_uint8 end_head;
+ cyg_uint8 end_sector;
+ cyg_uint8 end_cyl;
+ cyg_uint8 start_sect[4]; // starting sector counting from 0
+ cyg_uint8 nr_sects[4]; // number of sectors in partition
+};
+
+#define MBR_PTABLE_OFFSET 0x1be
+#define MBR_MAGIC_OFFSET 0x1fe
+#define MBR_MAGIC 0xaa55
+
+// Add a disk to the disk table.
+// Return zero if no more room in table.
+//
+externC int disk_register(disk_t *disk);
+
+
+#define diskerr_badname -1
+#define diskerr_partition -2
+#define diskerr_open -3
+#define diskerr_read -4
+
+externC int disk_stream_open(connection_info_t *info, int *err);
+externC void disk_stream_close(int *err);
+externC int disk_stream_read(char *buf, int size, int *err);
+externC char *disk_error(int err);
+
+#endif // CYGONCE_REDBOOT_DISK_H
diff --git a/ecos/packages/redboot/current/include/fs/e2fs.h b/ecos/packages/redboot/current/include/fs/e2fs.h
new file mode 100644
index 0000000..eff0a0d
--- /dev/null
+++ b/ecos/packages/redboot/current/include/fs/e2fs.h
@@ -0,0 +1,198 @@
+//==========================================================================
+//
+// e2fs.h
+//
+// Second extended filesystem defines.
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): msalter
+// Contributors: msalter
+// Date: 2001-06-25
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#ifndef CYGONCE_REDBOOT_E2FS_H
+#define CYGONCE_REDBOOT_E2FS_H
+
+//
+// Structure of the super block
+//
+struct e2fs_super_block {
+ cyg_uint32 inodes_count;
+ cyg_uint32 blocks_count;
+ cyg_uint32 r_blocks_count;
+ cyg_uint32 free_blocks_count;
+ cyg_uint32 free_inodes_count;
+ cyg_uint32 first_data_block;
+ cyg_uint32 log_block_size;
+ cyg_int32 log_frag_size;
+ cyg_uint32 blocks_per_group;
+ cyg_uint32 frags_per_group;
+ cyg_uint32 inodes_per_group;
+ cyg_uint32 mtime;
+ cyg_uint32 wtime;
+ cyg_uint16 mnt_count;
+ cyg_int16 max_mnt_count;
+ cyg_uint16 magic;
+ cyg_uint16 state;
+ cyg_uint16 errors;
+ cyg_uint16 minor_rev_level;
+ cyg_uint32 lastcheck;
+ cyg_uint32 checkinterval;
+ cyg_uint32 creator_os;
+ cyg_uint32 rev_level;
+ cyg_uint16 def_resuid;
+ cyg_uint16 def_resgid;
+};
+
+#define E2FS_PRE_02B_MAGIC 0xEF51
+#define E2FS_SUPER_MAGIC 0xEF53
+
+#define E2FS_PTRS_PER_BLOCK(e) ((e)->blocksize / sizeof(cyg_uint32))
+
+#define E2FS_BLOCK_SIZE(s) (E2FS_MIN_BLOCK_SIZE << SWAB_LE32((s)->log_block_size))
+#define E2FS_ADDR_PER_BLOCK(s) (E2FS_BLOCK_SIZE(s) / sizeof(unsigned int))
+#define E2FS_BLOCK_SIZE_BITS(s) (SWAB_LE32((s)->log_block_size) + 10)
+
+#define E2FS_NR_DIR_BLOCKS 12
+
+#define E2FS_IND_BLOCK E2FS_NR_DIR_BLOCKS
+#define E2FS_DIND_BLOCK (E2FS_IND_BLOCK + 1)
+#define E2FS_TIND_BLOCK (E2FS_DIND_BLOCK + 1)
+
+#define E2FS_N_BLOCKS (E2FS_TIND_BLOCK + 1)
+
+
+// Structure of an inode on the disk
+//
+typedef struct e2fs_inode {
+ cyg_uint16 mode;
+ cyg_uint16 uid;
+ cyg_uint32 size;
+ cyg_uint32 atime;
+ cyg_uint32 ctime;
+ cyg_uint32 mtime;
+ cyg_uint32 dtime;
+ cyg_uint16 gid;
+ cyg_uint16 links_count;
+ cyg_uint32 blocks;
+ cyg_uint32 flags;
+ cyg_uint32 reserved1;
+ cyg_uint32 block[E2FS_N_BLOCKS];
+ cyg_uint32 version;
+ cyg_uint32 file_acl;
+ cyg_uint32 dir_acl;
+ cyg_uint32 faddr;
+ cyg_uint8 frag;
+ cyg_uint8 fsize;
+ cyg_uint16 pad1;
+ cyg_uint32 reserved2[2];
+} e2fs_inode_t;
+
+
+#define E2FS_INODES_PER_BLOCK(e) ((e)->blocksize / sizeof (struct e2fs_inode))
+
+#define E2FS_MIN_BLOCK_SIZE 1024
+#define E2FS_MAX_BLOCK_SIZE 4096
+
+// Special inode numbers
+//
+#define E2FS_BAD_INO 1
+#define E2FS_ROOT_INO 2
+
+typedef struct e2fs_dir_entry {
+ cyg_uint32 inode;
+ cyg_uint16 reclen;
+ cyg_uint8 namelen;
+ cyg_uint8 filetype;
+ char name[2];
+} e2fs_dir_entry_t;
+
+#define E2FS_FTYPE_UNKNOWN 0
+#define E2FS_FTYPE_REG_FILE 1
+#define E2FS_FTYPE_DIR 2
+#define E2FS_FTYPE_CHRDEV 3
+#define E2FS_FTYPE_BLKDEV 4
+#define E2FS_FTYPE_FIFO 5
+#define E2FS_FTYPE_SOCK 6
+#define E2FS_FTYPE_SYMLINK 7
+
+typedef struct e2fs_group
+{
+ cyg_uint32 block_bitmap; // blocks bitmap block
+ cyg_uint32 inode_bitmap; // inodes bitmap block
+ cyg_uint32 inode_table; // inodes table block
+ cyg_uint16 free_blocks_count;
+ cyg_uint16 free_inodes_count;
+ cyg_uint16 used_dirs_count;
+ cyg_uint16 pad;
+ cyg_uint32 reserved[3];
+} e2fs_group_t;
+
+#define E2FS_BLOCKS_PER_GROUP(s) (SWAB_LE32((s)->blocks_per_group))
+#define E2FS_INODES_PER_GROUP(s) (SWAB_LE32((s)->inodes_per_group))
+
+#define E2FS_GDESC_PER_BLOCK(e) ((e)->blocksize / sizeof (struct e2fs_e2fs_group_desc))
+#define E2FS_GDESC_PER_SECTOR (SECTOR_SIZE/sizeof(e2fs_group_t))
+#define E2FS_GDESC_CACHE_SIZE (E2FS_GDESC_PER_SECTOR * 1)
+#define E2FS_GDESC_PER_SECTOR (SECTOR_SIZE/sizeof(e2fs_group_t))
+
+typedef struct e2fs_desc {
+ partition_t *part; // partition holding this filesystem
+ cyg_uint32 blocksize; // fs blocksize
+ cyg_uint32 ngroups; // number of groups in fs
+ cyg_uint32 blocks_per_group;
+ cyg_uint32 inodes_per_group;
+ cyg_uint32 gdesc_block; // block nr of group descriptors
+ cyg_int32 gdesc_first; // which gdesc is first in cache
+ e2fs_group_t gdesc_cache[E2FS_GDESC_CACHE_SIZE];
+ cyg_uint32 nr_ind_blocks;
+ cyg_uint32 nr_dind_blocks;
+ cyg_uint32 nr_tind_blocks;
+} e2fs_desc_t;
+
+#define E2FS_BLOCK_TO_SECTOR(e,b) ((b) * ((e)->blocksize / SECTOR_SIZE))
+
+extern fs_funs_t redboot_e2fs_funs;
+
+#endif // CYGONCE_REDBOOT_E2FS_H
diff --git a/ecos/packages/redboot/current/include/fs/fileio.h b/ecos/packages/redboot/current/include/fs/fileio.h
new file mode 100644
index 0000000..4c7ef0e
--- /dev/null
+++ b/ecos/packages/redboot/current/include/fs/fileio.h
@@ -0,0 +1,60 @@
+//==========================================================================
+//
+// fileio.h
+//
+// Fileio subsystem support for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): dwmw2
+// Contributors: dwmw2
+// Date: 2003-11-24
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#ifndef CYGONCE_REDBOOT_FILEIO_H
+#define CYGONCE_REDBOOT_FILEIO_H
+
+extern getc_io_funcs_t fileio_io;
+extern int fileio_mounted;
+
+#endif // CYGONCE_REDBOOT_FILEIO_H
diff --git a/ecos/packages/redboot/current/include/fs/ide.h b/ecos/packages/redboot/current/include/fs/ide.h
new file mode 100644
index 0000000..23444f9
--- /dev/null
+++ b/ecos/packages/redboot/current/include/fs/ide.h
@@ -0,0 +1,103 @@
+//==========================================================================
+//
+// ide.h
+//
+// IDE Interface Driver Tables for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): msalter
+// Contributors: msalter
+// Date: 2001-07-06
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#ifndef CYGONCE_REDBOOT_IDE_H
+#define CYGONCE_REDBOOT_IDE_H
+
+// IDE Register Indices
+#define IDE_REG_DATA 0
+#define IDE_REG_ERROR 1
+#define IDE_REG_FEATURES 1
+#define IDE_REG_COUNT 2
+#define IDE_REG_REASON 2 // ATAPI
+#define IDE_REG_LBALOW 3
+#define IDE_REG_LBAMID 4
+#define IDE_REG_LBAHI 5
+#define IDE_REG_DEVICE 6
+#define IDE_REG_STATUS 7
+#define IDE_REG_COMMAND 7
+
+#define IDE_STAT_BSY 0x80
+#define IDE_STAT_DRDY 0x40
+#define IDE_STAT_SERVICE 0x10
+#define IDE_STAT_DRQ 0x08
+#define IDE_STAT_CORR 0x04
+#define IDE_STAT_ERR 0x01
+
+#define IDE_REASON_REL 0x04
+#define IDE_REASON_IO 0x02
+#define IDE_REASON_COD 0x01
+
+//
+// Drive ID offsets of interest
+//
+#define IDE_DEVID_GENCONFIG 0
+#define IDE_DEVID_SERNO 20
+#define IDE_DEVID_MODEL 54
+#define IDE_DEVID_LBA_CAPACITY 120
+
+struct ide_priv {
+ cyg_uint8 controller;
+ cyg_uint8 drive;
+ cyg_uint16 flags;
+};
+
+/* flag values */
+#define IDE_DEV_PRESENT 1 // Device is present
+#define IDE_DEV_PACKET 2 // Supports packet interface
+#define IDE_DEV_ADDR48 3 // Supports 48bit addressing
+
+#define CDROM_SECTOR_SIZE 2048
+#define SECTORS_PER_CDROM_SECTOR (CDROM_SECTOR_SIZE/SECTOR_SIZE)
+
+#endif // CYGONCE_REDBOOT_IDE_H
diff --git a/ecos/packages/redboot/current/include/net/bootp.h b/ecos/packages/redboot/current/include/net/bootp.h
new file mode 100644
index 0000000..a1480af
--- /dev/null
+++ b/ecos/packages/redboot/current/include/net/bootp.h
@@ -0,0 +1,316 @@
+//==========================================================================
+//
+// net/bootp.h
+//
+// Stand-alone BOOTP support for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+/************************************************************************
+ Copyright 1988, 1991 by Carnegie Mellon University
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted, provided
+that the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation, and that the name of Carnegie Mellon University not be used
+in advertising or publicity pertaining to distribution of the software
+without specific, written prior permission.
+
+CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+************************************************************************/
+
+#ifndef _BOOTP_H_
+#define _BOOTP_H_
+
+/*
+ * Bootstrap Protocol (BOOTP). RFC951 and RFC1395.
+ *
+ * This file specifies the "implementation-independent" BOOTP protocol
+ * information which is common to both client and server.
+ *
+ */
+
+#define BP_CHADDR_LEN 16
+#define BP_SNAME_LEN 64
+#define BP_FILE_LEN 128
+#define BP_VEND_LEN 312
+#define BP_MINPKTSZ 300 /* to check sizeof(struct bootp) */
+#define BP_MIN_VEND_SIZE 64 /* minimum actual vendor area */
+
+typedef struct bootp {
+ unsigned char bp_op; /* packet opcode type */
+ unsigned char bp_htype; /* hardware addr type */
+ unsigned char bp_hlen; /* hardware addr length */
+ unsigned char bp_hops; /* gateway hops */
+ unsigned int bp_xid; /* transaction ID */
+ unsigned short bp_secs; /* seconds since boot began */
+ unsigned short bp_flags; /* RFC1532 broadcast, etc. */
+ struct in_addr bp_ciaddr; /* client IP address */
+ struct in_addr bp_yiaddr; /* 'your' IP address */
+ struct in_addr bp_siaddr; /* server IP address */
+ struct in_addr bp_giaddr; /* gateway IP address */
+ unsigned char bp_chaddr[BP_CHADDR_LEN]; /* client hardware address */
+ char bp_sname[BP_SNAME_LEN]; /* server host name */
+ char bp_file[BP_FILE_LEN]; /* boot file name */
+ unsigned char bp_vend[BP_VEND_LEN]; /* vendor-specific area */
+ /* note that bp_vend can be longer, extending to end of packet. */
+} bootp_header_t;
+
+/*
+ * UDP port numbers, server and client.
+ */
+#define IPPORT_BOOTPS 67
+#define IPPORT_BOOTPC 68
+
+#define BOOTREPLY 2
+#define BOOTREQUEST 1
+
+/*
+ * Hardware types from Assigned Numbers RFC.
+ */
+#define HTYPE_ETHERNET 1
+#define HTYPE_EXP_ETHERNET 2
+#define HTYPE_AX25 3
+#define HTYPE_PRONET 4
+#define HTYPE_CHAOS 5
+#define HTYPE_IEEE802 6
+#define HTYPE_ARCNET 7
+
+/*
+ * Vendor magic cookie (v_magic) for CMU
+ */
+#define VM_CMU "CMU"
+
+/*
+ * Vendor magic cookie (v_magic) for RFC1048
+ */
+#define VM_RFC1048 { 99, 130, 83, 99 }
+
+
+
+/*
+ * Tag values used to specify what information is being supplied in
+ * the vendor (options) data area of the packet.
+ */
+/* RFC 1048 */
+/* End of cookie */
+#define TAG_END ((unsigned char) 255)
+/* padding for alignment */
+#define TAG_PAD ((unsigned char) 0)
+/* Subnet mask */
+#define TAG_SUBNET_MASK ((unsigned char) 1)
+/* Time offset from UTC for this system */
+#define TAG_TIME_OFFSET ((unsigned char) 2)
+/* List of routers on this subnet */
+#define TAG_GATEWAY ((unsigned char) 3)
+/* List of rfc868 time servers available to client */
+#define TAG_TIME_SERVER ((unsigned char) 4)
+/* List of IEN 116 name servers */
+#define TAG_NAME_SERVER ((unsigned char) 5)
+/* List of DNS name servers */
+#define TAG_DOMAIN_SERVER ((unsigned char) 6)
+/* List of MIT-LCS UDL log servers */
+#define TAG_LOG_SERVER ((unsigned char) 7)
+/* List of rfc865 cookie servers */
+#define TAG_COOKIE_SERVER ((unsigned char) 8)
+/* List of rfc1179 printer servers (in order to try) */
+#define TAG_LPR_SERVER ((unsigned char) 9)
+/* List of Imagen Impress servers (in prefered order) */
+#define TAG_IMPRESS_SERVER ((unsigned char) 10)
+/* List of rfc887 Resourse Location servers */
+#define TAG_RLP_SERVER ((unsigned char) 11)
+/* Hostname of client */
+#define TAG_HOST_NAME ((unsigned char) 12)
+/* boot file size */
+#define TAG_BOOT_SIZE ((unsigned char) 13)
+/* RFC 1395 */
+/* path to dump to in case of crash */
+#define TAG_DUMP_FILE ((unsigned char) 14)
+/* domain name for use with the DNS */
+#define TAG_DOMAIN_NAME ((unsigned char) 15)
+/* IP address of the swap server for this machine */
+#define TAG_SWAP_SERVER ((unsigned char) 16)
+/* The path name to the root filesystem for this machine */
+#define TAG_ROOT_PATH ((unsigned char) 17)
+/* RFC 1497 */
+/* filename to tftp with more options in it */
+#define TAG_EXTEN_FILE ((unsigned char) 18)
+/* RFC 1533 */
+/* The following are in rfc1533 and may be used by BOOTP/DHCP */
+/* IP forwarding enable/disable */
+#define TAG_IP_FORWARD ((unsigned char) 19)
+/* Non-Local source routing enable/disable */
+#define TAG_IP_NLSR ((unsigned char) 20)
+/* List of pairs of addresses/masks to allow non-local source routing to */
+#define TAG_IP_POLICY_FILTER ((unsigned char) 21)
+/* Maximum size of datagrams client should be prepared to reassemble */
+#define TAG_IP_MAX_DRS ((unsigned char) 22)
+/* Default IP TTL */
+#define TAG_IP_TTL ((unsigned char) 23)
+/* Timeout in seconds to age path MTU values found with rfc1191 */
+#define TAG_IP_MTU_AGE ((unsigned char) 24)
+/* Table of MTU sizes to use when doing rfc1191 MTU discovery */
+#define TAG_IP_MTU_PLAT ((unsigned char) 25)
+/* MTU to use on this interface */
+#define TAG_IP_MTU ((unsigned char) 26)
+/* All subnets are local option */
+#define TAG_IP_SNARL ((unsigned char) 27)
+/* broadcast address */
+#define TAG_IP_BROADCAST ((unsigned char) 28)
+/* perform subnet mask discovery using ICMP */
+#define TAG_IP_SMASKDISC ((unsigned char) 29)
+/* act as a subnet mask server using ICMP */
+#define TAG_IP_SMASKSUPP ((unsigned char) 30)
+/* perform rfc1256 router discovery */
+#define TAG_IP_ROUTERDISC ((unsigned char) 31)
+/* address to send router solicitation requests */
+#define TAG_IP_ROUTER_SOL_ADDR ((unsigned char) 32)
+/* list of static routes to addresses (addr, router) pairs */
+#define TAG_IP_STATIC_ROUTES ((unsigned char) 33)
+/* use trailers (rfc893) when using ARP */
+#define TAG_IP_TRAILER_ENC ((unsigned char) 34)
+/* timeout in seconds for ARP cache entries */
+#define TAG_ARP_TIMEOUT ((unsigned char) 35)
+/* use either Ethernet version 2 (rfc894) or IEEE 802.3 (rfc1042) */
+#define TAG_ETHER_IEEE ((unsigned char) 36)
+/* default TCP TTL when sending TCP segments */
+#define TAG_IP_TCP_TTL ((unsigned char) 37)
+/* time for client to wait before sending a keepalive on a TCP connection */
+#define TAG_IP_TCP_KA_INT ((unsigned char) 38)
+/* don't send keepalive with an octet of garbage for compatability */
+#define TAG_IP_TCP_KA_GARBAGE ((unsigned char) 39)
+/* NIS domainname */
+#define TAG_NIS_DOMAIN ((unsigned char) 40)
+/* list of NIS servers */
+#define TAG_NIS_SERVER ((unsigned char) 41)
+/* list of NTP servers */
+#define TAG_NTP_SERVER ((unsigned char) 42)
+/* and stuff vendors may want to add */
+#define TAG_VEND_SPECIFIC ((unsigned char) 43)
+/* NetBios over TCP/IP name server */
+#define TAG_NBNS_SERVER ((unsigned char) 44)
+/* NetBios over TCP/IP NBDD servers (rfc1001/1002) */
+#define TAG_NBDD_SERVER ((unsigned char) 45)
+/* NetBios over TCP/IP node type option for use with above */
+#define TAG_NBOTCP_OTPION ((unsigned char) 46)
+/* NetBios over TCP/IP scopt option for use with above */
+#define TAG_NB_SCOPE ((unsigned char) 47)
+/* list of X Window system font servers */
+#define TAG_XFONT_SERVER ((unsigned char) 48)
+/* list of systems running X Display Manager (xdm) available to this client */
+#define TAG_XDISPLAY_SERVER ((unsigned char) 49)
+
+/* While the following are only allowed for DHCP */
+/* DHCP requested IP address */
+#define TAG_DHCP_REQ_IP ((unsigned char) 50)
+/* DHCP time for lease of IP address */
+#define TAG_DHCP_LEASE_TIME ((unsigned char) 51)
+/* DHCP options overload */
+#define TAG_DHCP_OPTOVER ((unsigned char) 52)
+/* DHCP message type */
+#define TAG_DHCP_MESS_TYPE ((unsigned char) 53)
+/* DHCP server identification */
+#define TAG_DHCP_SERVER_ID ((unsigned char) 54)
+/* DHCP ordered list of requested parameters */
+#define TAG_DHCP_PARM_REQ_LIST ((unsigned char) 55)
+/* DHCP reply message */
+#define TAG_DHCP_TEXT_MESSAGE ((unsigned char) 56)
+/* DHCP maximum packet size willing to accept */
+#define TAG_DHCP_MAX_MSGSZ ((unsigned char) 57)
+/* DHCP time 'til client needs to renew */
+#define TAG_DHCP_RENEWAL_TIME ((unsigned char) 58)
+/* DHCP time 'til client needs to rebind */
+#define TAG_DHCP_REBIND_TIME ((unsigned char) 59)
+/* DHCP class identifier */
+#define TAG_DHCP_CLASSID ((unsigned char) 60)
+/* DHCP client unique identifier */
+#define TAG_DHCP_CLIENTID ((unsigned char) 61)
+
+/* XXX - Add new tags here */
+
+/* DHCP Message Types */
+#define DHCP_MESS_TYPE_DISCOVER ((unsigned char) 1)
+#define DHCP_MESS_TYPE_OFFER ((unsigned char) 2)
+#define DHCP_MESS_TYPE_REQUEST ((unsigned char) 3)
+#define DHCP_MESS_TYPE_DECLINE ((unsigned char) 4)
+#define DHCP_MESS_TYPE_ACK ((unsigned char) 5)
+#define DHCP_MESS_TYPE_NAK ((unsigned char) 6)
+#define DHCP_MESS_TYPE_RELEASE ((unsigned char) 7)
+
+/*
+ * "vendor" data permitted for CMU bootp clients.
+ */
+
+struct cmu_vend {
+ char v_magic[4]; /* magic number */
+ unsigned int v_flags; /* flags/opcodes, etc. */
+ struct in_addr v_smask; /* Subnet mask */
+ struct in_addr v_dgate; /* Default gateway */
+ struct in_addr v_dns1, v_dns2; /* Domain name servers */
+ struct in_addr v_ins1, v_ins2; /* IEN-116 name servers */
+ struct in_addr v_ts1, v_ts2; /* Time servers */
+ int v_unused[6]; /* currently unused */
+};
+
+
+/* v_flags values */
+#define VF_SMASK 1 /* Subnet mask field contains valid data */
+
+#define IPPORT_BOOTPS 67
+#define IPPORT_BOOTPC 68
+
+#endif // _BOOTP_H_
diff --git a/ecos/packages/redboot/current/include/net/http.h b/ecos/packages/redboot/current/include/net/http.h
new file mode 100644
index 0000000..5ba864d
--- /dev/null
+++ b/ecos/packages/redboot/current/include/net/http.h
@@ -0,0 +1,71 @@
+//==========================================================================
+//
+// net/http.h
+//
+// Stand-alone HTTP (client) support for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2002-05-22
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#ifndef _HTTP_H_
+#define _HTTP_H_
+
+extern int http_stream_open(connection_info_t *info, int *err);
+extern int http_stream_read(char *buf, int len, int *err);
+extern void http_stream_close(int *err);
+extern char *http_error(int err);
+
+#define HTTP_NOERR 0 // No error
+#define HTTP_BADHDR 1 // Invalid HTTP header (response)
+#define HTTP_OPEN 2 // Problems opening connection
+#define HTTP_IO 3 // Misc I/O problems
+#define HTTP_BADREQ 4 // Bad request
+#define HTTP_NOFILE 5 // No such file
+#define HTTP_FORBIDDEN 6 // Forbidden
+
+extern getc_io_funcs_t http_io;
+#endif // _HTTP_H_
diff --git a/ecos/packages/redboot/current/include/net/net.h b/ecos/packages/redboot/current/include/net/net.h
new file mode 100644
index 0000000..d41e360
--- /dev/null
+++ b/ecos/packages/redboot/current/include/net/net.h
@@ -0,0 +1,644 @@
+//==========================================================================
+//
+// net/net.h
+//
+// Stand-alone networking support for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#ifndef _NET_H_
+#define _NET_H_
+
+#include <pkgconf/system.h>
+#include <pkgconf/redboot.h>
+#include <cyg/hal/hal_arch.h>
+#include <cyg/hal/basetype.h>
+#include <string.h>
+
+extern bool net_debug;
+#ifdef CYGPKG_IO_ETH_DRIVERS
+# include <pkgconf/io_eth_drivers.h>
+# include <cyg/io/eth/eth_drv.h> // Logical driver interfaces
+# ifdef CYGDBG_IO_ETH_DRIVERS_DEBUG
+extern int cyg_io_eth_net_debug;
+# endif
+#endif
+
+/* #define NET_SUPPORT_RARP 1 */
+#define NET_SUPPORT_ICMP 1
+#define NET_SUPPORT_UDP 1
+#define NET_SUPPORT_TCP 1
+
+#if (CYG_BYTEORDER == CYG_LSBFIRST)
+#ifndef __LITTLE_ENDIAN__
+#define __LITTLE_ENDIAN__
+#endif
+extern unsigned long ntohl(unsigned long x);
+extern unsigned short ntohs(unsigned short x);
+#else
+#define ntohl(x) (x)
+#define ntohs(x) (x)
+#endif
+
+#define htonl(x) ntohl(x)
+#define htons(x) ntohs(x)
+
+/*
+ * Minimum ethernet packet length.
+ */
+#define ETH_MIN_PKTLEN 60
+#define ETH_MAX_PKTLEN (1540-14)
+#define ETH_HDR_SIZE 14
+
+typedef unsigned char enet_addr_t[6];
+typedef unsigned char ip_addr_t[4];
+
+typedef unsigned char octet;
+typedef unsigned short word;
+typedef unsigned int dword;
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+// IPv4 support
+typedef struct in_addr {
+ unsigned long s_addr; // IPv4 address
+} in_addr_t;
+
+// Socket/connection information
+struct sockaddr_in {
+ struct in_addr sin_addr;
+ unsigned short sin_port;
+ unsigned short sin_family;
+ short sin_len;
+};
+#define AF_INET 1
+#define INADDR_ANY 0
+
+struct timeval {
+ unsigned long tv_sec;
+ unsigned long tv_usec;
+};
+
+/*
+ * Simple timer support structure.
+ */
+typedef void (*tmr_handler_t)(void *user_data);
+
+/*
+ * Timer structure.
+ * When expiration time is met or exceeded, the handler is
+ * called and the timer struct is removed from the list.
+ */
+typedef struct _timer {
+ struct _timer *next; /* next timer in list */
+ unsigned long delay; /* expiration time relative to start time */
+ unsigned long start; /* when the timer was set */
+ tmr_handler_t handler; /* user procedure to call when timer 'fires' */
+ void *user_data; /* user pointer passed to above procedure */
+} timer_t;
+
+
+/*
+ * Ethernet header.
+ */
+typedef struct {
+ enet_addr_t destination;
+ enet_addr_t source;
+ word type;
+#define ETH_TYPE_IP 0x800
+#define ETH_TYPE_ARP 0x806
+#define ETH_TYPE_RARP 0x8053
+} eth_header_t;
+
+
+/*
+ * ARP/RARP header.
+ */
+typedef struct {
+ word hw_type;
+#define ARP_HW_ETHER 1
+#define ARP_HW_EXP_ETHER 2
+ word protocol;
+ octet hw_len;
+ octet proto_len;
+ word opcode;
+#define ARP_REQUEST 1
+#define ARP_REPLY 2
+#define RARP_REQUEST 3
+#define RARP_REPLY 4
+ enet_addr_t sender_enet;
+ ip_addr_t sender_ip;
+ enet_addr_t target_enet;
+ ip_addr_t target_ip;
+} arp_header_t;
+
+
+#define ARP_PKT_SIZE (sizeof(arp_header_t) + ETH_HDR_SIZE)
+
+/*
+ * Internet Protocol header.
+ */
+typedef struct {
+#ifdef __LITTLE_ENDIAN__
+ octet hdr_len:4,
+ version:4;
+#else
+ octet version:4,
+ hdr_len:4;
+#endif
+ octet tos;
+ word length;
+ word ident;
+ word fragment;
+ octet ttl;
+ octet protocol;
+#define IP_PROTO_ICMP 1
+#define IP_PROTO_TCP 6
+#define IP_PROTO_UDP 17
+ word checksum;
+ ip_addr_t source;
+ ip_addr_t destination;
+} ip_header_t;
+
+
+#define IP_PKT_SIZE (60 + ETH_HDR_SIZE)
+
+
+/*
+ * A IP<->ethernet address mapping.
+ */
+typedef struct {
+ ip_addr_t ip_addr;
+ enet_addr_t enet_addr;
+} ip_route_t;
+
+
+/*
+ * UDP header.
+ */
+typedef struct {
+ word src_port;
+ word dest_port;
+ word length;
+ word checksum;
+} udp_header_t;
+
+
+/*
+ * TCP header.
+ */
+typedef struct {
+ word src_port;
+ word dest_port;
+ dword seqnum;
+ dword acknum;
+#ifdef __LITTLE_ENDIAN__
+ octet reserved:4,
+ hdr_len:4;
+#else
+ octet hdr_len:4,
+ reserved:4;
+#endif
+ octet flags;
+#define TCP_FLAG_FIN 1
+#define TCP_FLAG_SYN 2
+#define TCP_FLAG_RST 4
+#define TCP_FLAG_PSH 8
+#define TCP_FLAG_ACK 16
+#define TCP_FLAG_URG 32
+ word window;
+ word checksum;
+ word urgent;
+} tcp_header_t;
+
+
+/*
+ * ICMP header.
+ */
+typedef struct {
+ octet type;
+#define ICMP_TYPE_ECHOREPLY 0
+#define ICMP_TYPE_ECHOREQUEST 8
+ octet code;
+ word checksum;
+ word ident;
+ word seqnum;
+} icmp_header_t;
+
+typedef struct _pktbuf {
+ struct _pktbuf *next;
+ union {
+ ip_header_t *__iphdr; /* pointer to IP header */
+ arp_header_t *__arphdr; /* pointer to ARP header */
+ } u1;
+#define ip_hdr u1.__iphdr
+#define arp_hdr u1.__arphdr
+ union {
+ udp_header_t *__udphdr; /* pointer to UDP header */
+ tcp_header_t *__tcphdr; /* pointer to TCP header */
+ icmp_header_t *__icmphdr; /* pointer to ICMP header */
+ } u2;
+#define udp_hdr u2.__udphdr
+#define tcp_hdr u2.__tcphdr
+#define icmp_hdr u2.__icmphdr
+ word pkt_bytes; /* number of data bytes in buf */
+ word bufsize; /* size of buf */
+ word *buf;
+} pktbuf_t;
+
+
+/* protocol handler */
+typedef void (*pkt_handler_t)(pktbuf_t *pkt, eth_header_t *eth_hdr);
+
+/* ICMP fielder */
+typedef void (*icmp_handler_t)(pktbuf_t *pkt, ip_route_t *src_route);
+
+typedef struct _udp_socket {
+ struct _udp_socket *next;
+ word our_port;
+ word pad;
+ void (*handler)(struct _udp_socket *skt, char *buf, int len,
+ ip_route_t *src_route, word src_port);
+} udp_socket_t;
+
+
+typedef void (*udp_handler_t)(udp_socket_t *skt, char *buf, int len,
+ ip_route_t *src_route, word src_port);
+
+
+typedef struct _tcp_socket {
+ struct _tcp_socket *next;
+ int state; /* connection state */
+#define _CLOSED 0
+#define _LISTEN 1
+#define _SYN_RCVD 2
+#define _SYN_SENT 3
+#define _ESTABLISHED 4
+#define _CLOSE_WAIT 5
+#define _LAST_ACK 6
+#define _FIN_WAIT_1 7
+#define _FIN_WAIT_2 8
+#define _CLOSING 9
+#define _TIME_WAIT 10
+ ip_route_t his_addr; /* address of other end of connection */
+ word our_port;
+ word his_port;
+ word data_bytes; /* number of data bytes in pkt */
+ char reuse; /* SO_REUSEADDR, no 2MSL */
+ timer_t timer;
+ pktbuf_t pkt; /* dedicated xmit packet */
+ pktbuf_t *rxlist; /* list of unread incoming data packets */
+ char *rxptr; /* pointer to next byte to read */
+ int rxcnt; /* bytes left in current read packet */
+ dword ack;
+ dword seq;
+ char pktbuf[ETH_MAX_PKTLEN];
+} tcp_socket_t;
+
+/*
+ * Address information for local device
+ */
+#define __local_enet_addr __local_enet_sc->sc_arpcom.esa
+extern ip_addr_t __local_ip_addr;
+#ifdef CYGSEM_REDBOOT_NETWORKING_USE_GATEWAY
+extern ip_addr_t __local_ip_gate;
+extern ip_addr_t __local_ip_mask;
+#endif
+
+#ifdef CYGPKG_REDBOOT_NETWORKING_DNS
+#ifdef CYGPKG_REDBOOT_NETWORKING_DNS_DHCP_DOMAIN
+extern char __bootp_dns_domain[CYGNUM_REDBOOT_NETWORK_DNS_DOMAIN_BUFSIZE];
+extern cyg_bool __bootp_dns_domain_set;
+#endif
+extern struct in_addr __bootp_dns_addr;
+extern cyg_bool __bootp_dns_set;
+#endif
+
+
+/*
+ * Set a timer. Caller is responsible for providing the timer_t struct.
+ */
+extern void __timer_set(timer_t *t, unsigned long delay,
+ tmr_handler_t handler, void *user_data);
+
+/*
+ * Cancel the given timer.
+ */
+extern void __timer_cancel(timer_t *t);
+
+/*
+ * Poll timer list for timer expirations.
+ */
+extern void __timer_poll(void);
+
+/*
+ * Initialize the free list.
+ */
+extern void __pktbuf_init(void);
+
+/*
+ * simple pktbuf allocation.
+ * allocates at least nbytes for packet data including ethernet header.
+ */
+extern pktbuf_t *__pktbuf_alloc(int nbytes);
+
+/*
+ * return a pktbuf for reuse.
+ */
+extern void __pktbuf_free(pktbuf_t *pkt);
+
+/*
+ * Dump packet structures (debug, in case of running out)
+ */
+extern void __pktbuf_dump(void);
+
+
+/*
+ * Install handlers for ethernet packets.
+ * Returns old handler.
+ */
+extern pkt_handler_t __eth_install_listener(int eth_type,
+ pkt_handler_t handler);
+extern void __eth_remove_listener(int eth_type);
+
+/*
+ * Non-blocking poll of ethernet link. Processes all pending
+ * input packets.
+ */
+extern void __enet_poll(void);
+
+/*
+ * Send an ethernet packet.
+ */
+extern void __enet_send(pktbuf_t *pkt, enet_addr_t *dest, int eth_type);
+
+#ifdef CYGSEM_REDBOOT_NETWORKING_USE_GATEWAY
+/*
+ * return true if addr is on local subnet
+ */
+extern int __ip_addr_local(ip_addr_t *addr);
+#endif
+
+/*
+ * Handle incoming ARP packets.
+ */
+extern void __arp_handler(pktbuf_t *pkt);
+
+/*
+ * Find the ethernet address of the machine with the given
+ * ip address.
+ * Return true and fills in 'eth_addr' if successful, false
+ * if unsuccessful.
+ */
+extern int __arp_request(ip_addr_t *ip_addr, enet_addr_t *eth_addr, int allow_self);
+
+/*
+ * Lookup an address from the local ARP cache. If not found,
+ * then call 'arp_request' to find it. [Basically just a cached
+ * version of 'arp_request']
+ */
+extern int __arp_lookup(ip_addr_t *host, ip_route_t *rt);
+
+/*
+ * Do a one's complement checksum.
+ * The data being checksum'd is in network byte order.
+ * The returned checksum is in network byte order.
+ */
+extern unsigned short __sum(word *w, int len, int init_sum);
+
+/*
+ * Compute a partial checksum for the UDP/TCP pseudo header.
+ */
+extern int __pseudo_sum(ip_header_t *ip);
+
+/*
+ * Handle IP packets coming from the polled ethernet interface.
+ */
+extern void __ip_handler(pktbuf_t *pkt, enet_addr_t *src_enet_addr);
+
+/*
+ * Send an IP packet.
+ *
+ * The IP data field should contain pkt->pkt_bytes of data.
+ * pkt->[udp|tcp|icmp]_hdr points to the IP data field. Any
+ * IP options are assumed to be already in place in the IP
+ * options field. Returns 0 for success.
+ */
+extern int __ip_send(pktbuf_t *pkt, int protocol, ip_route_t *dest);
+
+/*
+ * Abort connection.
+ */
+extern void __tcp_abort(tcp_socket_t *s, unsigned long delay);
+
+/*
+ * Handle incoming ICMP packets.
+ */
+extern void __icmp_handler(pktbuf_t *pkt, ip_route_t *r);
+extern int __icmp_install_listener(icmp_handler_t handler);
+extern void __icmp_remove_listener(void);
+
+/*
+ * Handle incoming UDP packets.
+ */
+extern void __udp_handler(pktbuf_t *pkt, ip_route_t *r);
+
+/*
+ * Install a handler for incoming udp packets.
+ * Caller provides the udp_socket_t structure.
+ * Returns zero if successful, -1 if socket is already used.
+ */
+extern int __udp_install_listener(udp_socket_t *s, word port,
+ udp_handler_t handler);
+
+/*
+ * Remove the handler for the given socket.
+ */
+extern void __udp_remove_listener(word port);
+
+/*
+ * Send a UDP packet.
+ */
+extern int __udp_send(char *buf, int len, ip_route_t *dest_ip,
+ word dest_port, word src_port);
+
+// Send a UDP packet
+extern int __udp_sendto(char *buf, int len,
+ struct sockaddr_in *server, struct sockaddr_in *local);
+
+// Receive a UDP packet
+extern int __udp_recvfrom(char *buf, int len,
+ struct sockaddr_in *from, struct sockaddr_in *local,
+ struct timeval *timeout);
+
+/*
+ * TCP poll function. Should be called as often as possible.
+ */
+extern void __tcp_poll(void);
+
+/*
+ * Initiate outgoing connection, waiting for at most timeout seconds.
+ */
+extern int __tcp_open(tcp_socket_t *s, struct sockaddr_in *host,
+ word port, int timeout, int *err);
+
+/*
+ * Set up a listening socket on the given port.
+ * Does not block.
+ */
+extern int __tcp_listen(tcp_socket_t *s, word port);
+
+/*
+ * SO_REUSEADDR, no 2MSL.
+ */
+extern void __tcp_so_reuseaddr(tcp_socket_t *s);
+
+/*
+ * Block while waiting for all outstanding socket data to
+ * be transmitted.
+ */
+extern void __tcp_drain(tcp_socket_t *s);
+
+/*
+ * Initiate connection close.
+ */
+extern void __tcp_close(tcp_socket_t *s);
+
+/*
+ * Wait until connection has fully closed.
+ */
+extern void __tcp_close_wait(tcp_socket_t *s);
+
+/*
+ * Read up to 'len' bytes without blocking.
+ * Returns number of bytes read.
+ * If connection is closed, returns -1.
+ */
+extern int __tcp_read(tcp_socket_t *s, char *buf, int len);
+
+/*
+ * Write up to 'len' bytes without blocking.
+ * Returns number of bytes written.
+ * If connection is closed, returns -1.
+ */
+extern int __tcp_write(tcp_socket_t *s, char *buf, int len);
+
+/*
+ * Write up to 'len' bytes, blocking until sent (not ACK'd).
+ * Returns number of bytes written.
+ * If connection is closed, returns -1.
+ */
+extern int __tcp_write_block(tcp_socket_t *s, char *buf, int len);
+
+
+/*
+ * The following are a higher-level tcp socket interface.
+ */
+
+/*
+ * Initialize a socket for given port.
+ */
+extern void __skt_init(tcp_socket_t *s, unsigned short port);
+
+/*
+ * Return true if socket connection is closed.
+ */
+#define __skt_is_closed(s) (((tcp_socket_t *)(s))->state == _CLOSED)
+
+/*
+ * Block while listening for an incoming connection.
+ */
+extern void __skt_wait_for_connect(tcp_socket_t *s);
+
+/*
+ * Read up to 'len' bytes from the given socket.
+ * Returns number of bytes read.
+ * Doesn't block.
+ */
+extern int __skt_read(tcp_socket_t *s, char *buf, int len);
+
+/*
+ * Write 'len' bytes to the given socket.
+ * Returns number of bytes written.
+ * May not write all data if connection closes.
+ */
+extern int __skt_write(tcp_socket_t *s, char *buf, int len);
+
+// Initialize the network stack - logical driver layer, etc.
+extern void net_init(void);
+
+// Test for new network I/O connections
+extern void net_io_test(bool is_idle);
+
+// Conversion between IP addresses and printable strings
+extern bool inet_aton(const char *, in_addr_t *);
+extern char *inet_ntoa(in_addr_t *);
+
+// Network device table access
+extern const char *net_devname(unsigned index);
+extern int net_devindex(char *name);
+
+// FIXME
+/* #define NET_SUPPORT_RARP 1 */
+#define NET_SUPPORT_ICMP 1
+#define NET_SUPPORT_UDP 1
+#define NET_SUPPORT_TCP 1
+
+#ifdef BSP_LOG
+#define BSPLOG(x) { int old_console = start_console(); x; end_console(old_console); }
+#define bsp_log diag_printf
+#else
+#define BSPLOG(x)
+#endif
+
+// Need tick functions
+#include <redboot.h>
+
+#endif // _NET_H_
diff --git a/ecos/packages/redboot/current/include/net/tftp.h b/ecos/packages/redboot/current/include/net/tftp.h
new file mode 100644
index 0000000..f50fb08
--- /dev/null
+++ b/ecos/packages/redboot/current/include/net/tftp.h
@@ -0,0 +1,141 @@
+//==========================================================================
+//
+// net/tftp.h
+//
+// Stand-alone TFTP support for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+// ####BSDALTCOPYRIGHTBEGIN####
+// -------------------------------------------
+// Portions of this software may have been derived from FreeBSD, OpenBSD,
+// or other sources, and if so are covered by the appropriate copyright
+// and license included herein.
+// -------------------------------------------
+// ####BSDALTCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)tftp.h 5.4 (Berkeley) 4/3/91
+ */
+
+#ifndef _ARPA_TFTP_H_
+#define _ARPA_TFTP_H_
+
+/*
+ * Trivial File Transfer Protocol (IEN-133)
+ * Now, rev 2 - RFC 1350
+ */
+#define SEGSIZE 512 /* data segment size */
+
+/*
+ * Packet types.
+ */
+#define RRQ 01 /* read request */
+#define WRQ 02 /* write request */
+#define DATA 03 /* data packet */
+#define ACK 04 /* acknowledgement */
+#define ERROR 05 /* error code */
+
+struct tftphdr {
+ short th_opcode; /* packet type */
+ union {
+ unsigned short tu_block; /* block # */
+ short tu_code; /* error code */
+ char tu_stuff[1]; /* request packet stuff */
+ } __attribute__ ((packed)) th_u;
+ char th_data[0]; /* data or error string */
+} __attribute__ ((packed));
+
+#define th_block th_u.tu_block
+#define th_code th_u.tu_code
+#define th_stuff th_u.tu_stuff
+#define th_msg th_data
+
+/*
+ * Error codes.
+ */
+#define EUNDEF 0 /* not defined */
+#define ENOTFOUND 1 /* file not found */
+#define EACCESS 2 /* access violation */
+#define ENOSPACE 3 /* disk full or allocation exceeded */
+#define EBADOP 4 /* illegal TFTP operation */
+#define EBADID 5 /* unknown transfer ID */
+#define EEXISTS 6 /* file already exists */
+#define ENOUSER 7 /* no such user */
+
+#endif /* !_ARPA_TFTP_H_ */
diff --git a/ecos/packages/redboot/current/include/net/tftp_support.h b/ecos/packages/redboot/current/include/net/tftp_support.h
new file mode 100644
index 0000000..44deb3e
--- /dev/null
+++ b/ecos/packages/redboot/current/include/net/tftp_support.h
@@ -0,0 +1,99 @@
+//==========================================================================
+//
+// net/tftp_support.h
+//
+// Stand-alone TFTP support for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#ifndef _TFTP_SUPPORT_H_
+#define _TFTP_SUPPORT_H_
+
+#include "net.h"
+
+/*
+ * File transfer modes
+ */
+#define TFTP_NETASCII 0 // Text files
+#define TFTP_OCTET 1 // Binary files
+
+/*
+ * Errors
+ */
+#define TFTP_ENOTFOUND 1 /* file not found */
+#define TFTP_EACCESS 2 /* access violation */
+#define TFTP_ENOSPACE 3 /* disk full or allocation exceeded */
+#define TFTP_EBADOP 4 /* illegal TFTP operation */
+#define TFTP_EBADID 5 /* unknown transfer ID */
+#define TFTP_EEXISTS 6 /* file already exists */
+#define TFTP_ENOUSER 7 /* no such user */
+#define TFTP_TIMEOUT 8 /* operation timed out */
+#define TFTP_NETERR 9 /* some sort of network error */
+#define TFTP_INVALID 10 /* invalid parameter */
+#define TFTP_PROTOCOL 11 /* protocol violation */
+#define TFTP_TOOLARGE 12 /* file is larger than buffer */
+
+/*
+ * Client support
+ */
+
+extern int tftp_stream_open(connection_info_t *info, int *err);
+extern int tftp_stream_read(char *buf, int len, int *err);
+extern void tftp_stream_close(int *err);
+extern void tftp_stream_terminate(bool abort, int (*getc)(void));
+extern char *tftp_error(int err);
+
+#define TFTP_TIMEOUT_PERIOD 5
+#define TFTP_TIMEOUT_MAX 15
+#define TFTP_RETRIES_MAX 5
+
+#define TFTP_PORT 69
+
+extern getc_io_funcs_t tftp_io;
+
+#endif // _TFTP_SUPPORT_H_
diff --git a/ecos/packages/redboot/current/include/redboot.h b/ecos/packages/redboot/current/include/redboot.h
new file mode 100644
index 0000000..3b3de47
--- /dev/null
+++ b/ecos/packages/redboot/current/include/redboot.h
@@ -0,0 +1,526 @@
+//==========================================================================
+//
+// redboot.h
+//
+// Standard interfaces for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas, tkoeller
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#ifndef _REDBOOT_H_
+#define _REDBOOT_H_
+
+#include <pkgconf/redboot.h>
+#include <pkgconf/hal.h>
+#include <cyg/hal/hal_if.h>
+#include <cyg/hal/hal_tables.h>
+#include <cyg/hal/hal_endian.h>
+#include <cyg/infra/diag.h>
+#include <cyg/crc/crc.h>
+#include <string.h>
+
+#ifdef CYGPKG_REDBOOT_NETWORKING
+#include <net/net.h>
+#include <net/bootp.h>
+// Determine an IP address for this node, using BOOTP
+#ifdef CYGPKG_REDBOOT_NETWORKING_BOOTP
+extern int __bootp_find_local_ip(bootp_header_t *info);
+#endif
+#endif
+
+#ifdef DEFINE_VARS
+#define EXTERN
+#else
+#define EXTERN extern
+#endif
+
+// Global variables
+EXTERN int argc;
+#define MAX_ARGV 16
+EXTERN char *argv[MAX_ARGV];
+EXTERN unsigned char *ram_start, *ram_end;
+EXTERN struct _mem_segment {
+ unsigned char *start, *end;
+} mem_segments[CYGBLD_REDBOOT_MAX_MEM_SEGMENTS];
+#define NO_MEMORY (unsigned char *)0xFFFFFFFF
+EXTERN bool valid_address(unsigned char *addr);
+EXTERN void cyg_plf_memory_segment(int seg, unsigned char **start, unsigned char **end);
+EXTERN unsigned char *workspace_start, *workspace_end, *workspace_end_init;
+
+// Data squirreled away after a load operation
+EXTERN unsigned long entry_address;
+EXTERN unsigned long load_address;
+EXTERN unsigned long load_address_end;
+
+
+#ifdef CYGPKG_REDBOOT_ANY_CONSOLE
+EXTERN bool console_selected;
+#endif
+EXTERN bool console_echo;
+EXTERN bool gdb_active;
+#if CYGNUM_REDBOOT_CMD_LINE_EDITING != 0
+EXTERN bool cmd_history;
+#endif
+
+#ifdef CYGPKG_REDBOOT_NETWORKING
+EXTERN bool have_net, use_bootp;
+EXTERN bootp_header_t my_bootp_info;
+EXTERN int gdb_port;
+EXTERN bool net_debug;
+#endif
+
+#ifdef CYGFUN_REDBOOT_BOOT_SCRIPT
+EXTERN char *script;
+EXTERN int script_timeout;
+#ifdef CYGSEM_REDBOOT_VARIABLE_BAUD_RATE
+EXTERN int console_baud_rate;
+#endif
+#endif
+
+#ifdef CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER
+EXTERN unsigned char *fis_zlib_common_buffer;
+#endif
+
+#ifdef CYGSEM_REDBOOT_PLF_STARTUP
+EXTERN void cyg_plf_redboot_startup(void);
+#endif
+
+// Prototypes
+typedef int _printf_fun(const char *fmt, ...);
+externC int strcasecmp(const char *s1, const char *s2);
+externC int strncasecmp(const char *s1, const char *s2, size_t len);
+
+externC void mon_write_char(unsigned char c);
+externC bool mon_read_char_with_timeout(unsigned char *c);
+externC void mon_set_read_char_timeout(int ms);
+externC bool verify_action(char *fmt, ...);
+externC bool verify_action_with_timeout(int timeout, char *fmt, ...);
+
+// Read a single line of input from the console, possibly with timeout
+externC int _rb_gets(char *line, int len, int timeout);
+// Just like _rb_gets(), except that the line buffer is assumed to contain
+// valid input data. This provides an easy mechanism for edit-in-place.
+externC int _rb_gets_preloaded(char *line, int len, int timeout);
+// Result codes from 'gets()'
+#define _GETS_TIMEOUT -1
+#define _GETS_CTRLC -2
+#define _GETS_GDB 0
+#define _GETS_OK 1
+// Test for ^C on the console. This function should only be used if any
+// other console input can be discarded, e.g. while performing some long
+// computation, waiting for the network, etc. Returns 'true' if ^C typed.
+externC bool _rb_break(int timeout);
+
+// "console" selection
+externC int start_console(void);
+externC void end_console(int old_console);
+
+// Tick functions
+__externC unsigned long do_ms_tick(void);
+__externC unsigned long get_ms_ticks(void);
+__externC void ms_ticks_add_us(long);
+
+#define MS_TICKS() get_ms_ticks()
+#define MS_TICKS_DELAY() do_ms_tick()
+
+// Alias functions
+#ifdef CYGSEM_REDBOOT_FLASH_ALIASES
+externC char *flash_lookup_alias(char *alias, char *alias_buf);
+#endif
+externC void expand_aliases(char *line, int len);
+
+//
+// Stream I/O support
+//
+
+typedef struct {
+ char *filename;
+ int mode;
+ int chan;
+#ifdef CYGPKG_REDBOOT_NETWORKING
+ struct sockaddr_in *server;
+#endif
+} connection_info_t;
+
+typedef struct {
+ int (*open)(connection_info_t *info, int *err);
+ void (*close)(int *err);
+ void (*terminate)(bool abort, int (*getc)(void));
+ int (*read)(char *buf, int size, int *err);
+ char *(*error)(int err);
+} getc_io_funcs_t;
+
+#define GETC_IO_FUNCS(_label_, _open_, _close_, _terminate_, _read_, _error_) \
+getc_io_funcs_t _label_ = { \
+ _open_, _close_, _terminate_, _read_, _error_ \
+};
+
+struct load_io_entry {
+ char *name;
+ getc_io_funcs_t *funcs;
+ bool can_verbose;
+ bool need_filename;
+ int mode;
+} CYG_HAL_TABLE_TYPE;
+#define _RedBoot_load(_name_,_funcs_,_verbose_,_filename_,_mode_) \
+struct load_io_entry _load_tab_##_funcs_##_name_ \
+ CYG_HAL_TABLE_QUALIFIED_ENTRY(RedBoot_load,_funcs_##_name) = \
+ { #_name_, &_funcs_, _verbose_, _filename_, _mode_ };
+#define RedBoot_load(_name_,_funcs_,_verbose_,_filename_, _mode_) \
+ _RedBoot_load(_name_,_funcs_,_verbose_,_filename_,_mode_)
+
+#ifdef CYGPKG_COMPRESS_ZLIB
+// Decompression support
+typedef struct _pipe {
+ unsigned char* in_buf; // only changed by producer
+ int in_avail; // only changed by producer
+ unsigned char* out_buf; // only changed by consumer (init by producer)
+ int out_size; // only changed by consumer (init by producer)
+ int out_max; // set by producer
+ const char* msg; // message from consumer
+ void* priv; // handler's data
+} _pipe_t;
+
+typedef int _decompress_fun_init(_pipe_t*);
+typedef int _decompress_fun_inflate(_pipe_t*);
+typedef int _decompress_fun_close(_pipe_t*, int);
+
+externC _decompress_fun_init* _dc_init;
+externC _decompress_fun_inflate* _dc_inflate;
+externC _decompress_fun_close* _dc_close;
+#endif // CYGPKG_COMPRESS_ZLIB
+
+// CLI support functions
+externC bool parse_num(char *s, unsigned long *val, char **es, char *delim);
+externC bool parse_bool(char *s, bool *val);
+
+typedef void cmd_fun(int argc, char *argv[]);
+struct cmd {
+ char *str;
+ char *help;
+ char *usage;
+ cmd_fun *fun;
+ struct cmd *sub_cmds, *sub_cmds_end;
+} CYG_HAL_TABLE_TYPE;
+externC struct cmd *cmd_search(struct cmd *tab, struct cmd *tabend, char *arg);
+externC void cmd_usage(struct cmd *tab, struct cmd *tabend, char *prefix);
+#define RedBoot_cmd(_s_,_h_,_u_,_f_) cmd_entry(_s_,_h_,_u_,_f_,0,0,RedBoot_commands)
+#define RedBoot_nested_cmd(_s_,_h_,_u_,_f_,_subs_,_sube_) cmd_entry(_s_,_h_,_u_,_f_,_subs_,_sube_,RedBoot_commands)
+#define _cmd_entry(_s_,_h_,_u_,_f_,_subs_,_sube_,_n_) \
+cmd_fun _f_; \
+struct cmd _cmd_tab_##_f_ CYG_HAL_TABLE_QUALIFIED_ENTRY(_n_,_f_) = {_s_, _h_, _u_, _f_, _subs_, _sube_};
+#define cmd_entry(_s_,_h_,_u_,_f_,_subs_,_sube_,_n_) \
+extern _cmd_entry(_s_,_h_,_u_,_f_,_subs_,_sube_,_n_)
+#define local_cmd_entry(_s_,_h_,_u_,_f_,_n_) \
+static _cmd_entry(_s_,_h_,_u_,_f_,0,0,_n_)
+
+// Initialization functions
+#define RedBoot_INIT_FIRST 0000
+#define RedBoot_INIT_SECOND 0100
+// Specify a 3 digit numeric value for proper prioritizing
+#define RedBoot_INIT_PRIO(_n_) 1##_n_
+#define RedBoot_INIT_BEFORE_NET 6900
+#define RedBoot_INIT_NET 7000
+#define RedBoot_INIT_AFTER_NET 7100
+#define RedBoot_INIT_LAST 9999
+typedef void void_fun(void);
+typedef void_fun *void_fun_ptr;
+struct init_tab_entry {
+ void_fun_ptr fun;
+} CYG_HAL_TABLE_TYPE;
+#define _RedBoot_init(_f_,_p_) \
+struct init_tab_entry _init_tab_##_p_##_f_ \
+ CYG_HAL_TABLE_QUALIFIED_ENTRY(RedBoot_inits,_p_##_f_) = { _f_ };
+#define RedBoot_init(_f_,_p_) _RedBoot_init(_f_,_p_)
+
+// Main loop [idle] call-back functions
+#define RedBoot_IDLE_FIRST 0000
+#define RedBoot_IDLE_BEFORE_NETIO 3000
+#define RedBoot_IDLE_NETIO 5000
+#define RedBoot_IDLE_AFTER_NETIO 7000
+#define RedBoot_IDLE_LAST 9999
+typedef void idle_fun(bool);
+typedef idle_fun *idle_fun_ptr;
+struct idle_tab_entry {
+ idle_fun_ptr fun;
+} CYG_HAL_TABLE_TYPE;
+#define _RedBoot_idle(_f_,_p_) \
+struct idle_tab_entry _idle_tab_##_p_##_f_ \
+ CYG_HAL_TABLE_QUALIFIED_ENTRY(RedBoot_idle,_p_##_f_) = { _f_ };
+#define RedBoot_idle(_f_,_p_) _RedBoot_idle(_f_,_p_)
+
+// This function called when changing idle/not - mostly used by I/O
+// to support idle when timeout, etc.
+void do_idle(bool state);
+
+// Option processing support
+
+struct option_info {
+ char flag;
+ bool takes_arg;
+ int arg_type;
+ void *arg;
+ bool *arg_set;
+ char *name;
+};
+
+#define NUM_ELEMS(s) (sizeof(s)/sizeof(s[0]))
+
+#define OPTION_ARG_TYPE_NUM 0 // Numeric data
+#define OPTION_ARG_TYPE_STR 1 // Generic string
+#define OPTION_ARG_TYPE_FLG 2 // Flag only
+
+// Command line parsing
+externC struct cmd *parse(char **line, int *argc, char **argv);
+
+externC void init_opts(struct option_info *opts, char flag, bool takes_arg,
+ int arg_type, void *arg, bool *arg_set, char *name);
+externC bool scan_opts(int argc, char *argv[], int first,
+ struct option_info *opts, int num_opts,
+ void *def_arg, int def_arg_type, char *def_descr);
+
+externC int redboot_exec( char *command, ... );
+
+externC void err_printf( const char *fmt, ... );
+
+#ifdef CYGNUM_HAL_VIRTUAL_VECTOR_AUX_CHANNELS
+#define CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS \
+ (CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS+CYGNUM_HAL_VIRTUAL_VECTOR_AUX_CHANNELS)
+#else
+#define CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS \
+ CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS
+#endif
+
+#ifdef CYGPKG_REDBOOT_NETWORKING
+//-----------------------------------------------------------------------------
+// DNS wrapper
+#ifdef CYGPKG_REDBOOT_NETWORKING_DNS
+
+// I would really like if we could just pull in cyg/ns/dns/dns.h, but
+// that would require adding dummy <network.h> and <netinet/in.h> files.
+
+// Host name / IP mapping
+struct hostent {
+ char *h_name; /* official name of host */
+ char **h_aliases; /* alias list */
+ int h_addrtype; /* host address type */
+ int h_length; /* length of address */
+ char **h_addr_list; /* list of addresses */
+};
+#define h_addr h_addr_list[0] /* for backward compatibility */
+
+externC int redboot_dns_res_init(void);
+externC void set_dns(char* new_ip);
+externC void show_dns(void);
+externC struct hostent *gethostbyname(const char *host);
+externC int setdomainname(const char *, size_t);
+
+// Error reporting
+externC int h_errno;
+
+#define DNS_SUCCESS 0
+#define HOST_NOT_FOUND 1
+#define TRY_AGAIN 2
+#define NO_RECOVERY 3
+#define NO_DATA 4
+
+static inline bool
+_gethostbyname(const char* name, in_addr_t* host)
+{
+ struct hostent* hent = gethostbyname(name);
+ if (hent) {
+ memcpy(host, hent->h_addr_list[0], sizeof(in_addr_t));
+ return true;
+ }
+ // Fall back to inet_aton - gethostbyname may already have tried
+ // it, but we can't know for sure (the DNS IP may not have been
+ // valid, preventing the inet_aton).
+ return inet_aton(name, host);
+}
+#else
+static inline bool
+_gethostbyname(const char* name, in_addr_t* host)
+{
+ return inet_aton(name, host);
+}
+#endif // CYGPKG_REDBOOT_NETWORKING_DNS
+#endif // CYGPKG_REDBOOT_NETWORKING
+
+//-----------------------------------------------------------------------------
+// String functions. Some of these are duplicates of the same functions in
+// the I18N package.
+
+// Validate a hex character
+__inline__ static bool
+_is_hex(char c)
+{
+ return (((c >= '0') && (c <= '9')) ||
+ ((c >= 'A') && (c <= 'F')) ||
+ ((c >= 'a') && (c <= 'f')));
+}
+
+// Convert a single hex nibble
+__inline__ static int
+_from_hex(char c)
+{
+ int ret = 0;
+
+ if ((c >= '0') && (c <= '9')) {
+ ret = (c - '0');
+ } else if ((c >= 'a') && (c <= 'f')) {
+ ret = (c - 'a' + 0x0a);
+ } else if ((c >= 'A') && (c <= 'F')) {
+ ret = (c - 'A' + 0x0A);
+ }
+ return ret;
+}
+
+// Convert a character to lower case
+__inline__ static char
+_tolower(char c)
+{
+ if ((c >= 'A') && (c <= 'Z')) {
+ c = (c - 'A') + 'a';
+ }
+ return c;
+}
+
+// Validate alpha
+__inline__ static bool
+isalpha(int c)
+{
+ return (((c >= 'a') && (c <= 'z')) ||
+ ((c >= 'A') && (c <= 'Z')));
+}
+
+// Validate digit
+__inline__ static bool
+isdigit(int c)
+{
+ return ((c >= '0') && (c <= '9'));
+}
+
+// Validate alphanum
+__inline__ static bool
+isalnum(int c)
+{
+ return (isalpha(c) || isdigit(c));
+}
+
+//----------------------------------------------------------------------------
+// syscall values
+#if defined(CYGSEM_REDBOOT_BSP_SYSCALLS)
+
+// These are required by the ANSI C part of newlib (excluding system() of
+// course).
+#define SYS_exit 1
+#define SYS_open 2
+#define SYS_close 3
+#define SYS_read 4
+#define SYS_write 5
+#define SYS_lseek 6
+#define SYS_unlink 7
+#define SYS_getpid 8
+#define SYS_kill 9
+#define SYS_fstat 10
+//#define SYS_sbrk 11 - not currently a system call, but reserved.
+
+// ARGV support.
+#define SYS_argvlen 12
+#define SYS_argv 13
+
+// These are extras added for one reason or another.
+#define SYS_chdir 14
+#define SYS_stat 15
+#define SYS_chmod 16
+#define SYS_utime 17
+#define SYS_time 18
+#define SYS_gettimeofday 19
+#define SYS_times 20
+
+#define SYS_interrupt 1000
+#define SYS_meminfo 1001
+
+#define __GET_SHARED 0xbaad // 47789 decimal
+
+#ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
+
+#define SYS_timer_call_back 2001
+#define SYS_timer_frequency 2002
+#define SYS_timer_reset 2003
+
+#endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
+#define SYS_rename 3001
+#define SYS_isatty 3002
+#define SYS_system 3003
+
+#endif // CYGSEM_REDBOOT_BSP_SYSCALLS
+
+
+//----------------------------------------------------------------------------
+// Allow HAL to override RedBoot flash read/program operations.
+#ifdef HAL_FLASH_READ
+#define FLASH_READ(f, r, l, e) HAL_FLASH_READ((f),(r),(l),(e))
+#else
+#define FLASH_READ(f, r, l, e) flash_read((f), (r), (l), (e))
+#endif
+
+#ifdef HAL_FLASH_PROGRAM
+#define FLASH_PROGRAM(f, r, l, e) HAL_FLASH_PROGRAM((f),(r),(l),(e))
+#else
+#define FLASH_PROGRAM(f, r, l, e) flash_program((f), (r), (l), (e))
+#endif
+
+
+// Define REDBOOT_FLASH_REVERSE_BYTEORDER if config and fis info is stored in flash
+// with byte ordering opposite from CYG_BYTEORDER.
+#if (defined(CYGOPT_REDBOOT_FLASH_BYTEORDER_MSBFIRST) && (CYG_BYTEORDER != CYG_MSBFIRST)) || \
+ (defined(CYGOPT_REDBOOT_FLASH_BYTEORDER_LSBFIRST) && (CYG_BYTEORDER != CYG_LSBFIRST))
+#define REDBOOT_FLASH_REVERSE_BYTEORDER
+#endif
+
+#endif // _REDBOOT_H_
diff --git a/ecos/packages/redboot/current/include/sib.h b/ecos/packages/redboot/current/include/sib.h
new file mode 100644
index 0000000..67afe64
--- /dev/null
+++ b/ecos/packages/redboot/current/include/sib.h
@@ -0,0 +1,142 @@
+#ifndef _SIB_H_
+#define _SIB_H_
+//==========================================================================
+//
+// sib.h
+//
+// RedBoot - structure of ARM flash file format
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): Philippe Robin
+// Contributors: Philippe Robin, jskov
+// Date: 2001-10-31
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <cyg/hal/hal_io.h>
+
+/* type information :-
+ * 0xffff ffff - deleted (usual flash erased value)
+ * 0x0000 xxxx - Reserved for ARM usage:
+ * Bit 0 - ARM Executable Image
+ * Bit 1 - System Information Block
+ * Bit 2 - File System Block
+ * 0xyyyy 0000 - Available for customers (y != 0)
+ */
+#define TYPE_DELETED 0xFFFFFFFF
+#define TYPE_ARM_MASK 0x0000FFFF
+#define TYPE_CUSTOM_MASK 0xFFFF0000
+#define TYPE_ARM_EXEC 0x00000001
+#define TYPE_ARM_SIB 0x00000002
+#define TYPE_ARM_SYSBLOCK 0x00000004
+
+/* This is the type we use for RedBoot blocks */
+#define TYPE_REDHAT_REDBOOT 0x52420000
+
+/* The ARM monitor may be using a different memory mapping than RedBoot */
+#ifndef _ADDR_REDBOOT_TO_ARM
+# define _ADDR_REDBOOT_TO_ARM(x)
+#endif
+
+/* Filetypes */
+
+#define UNKNOWN_FILE 0x00000000
+#define MOT_S_RECORD 0x00000001
+#define INTEL_HEX 0x00000002
+#define ELF 0x00000004
+#define DWARF 0x00000008
+#define ARM_AOF 0x00000010
+#define ARM_AIF 0x00000020
+#define PLAIN_BINARY 0x00000040
+#define ARM_AIF_BIN 0x00000080
+#define MCS_TYPE 0x00000100
+
+#define CONVERT_TYPE (MOT_S_RECORD | INTEL_HEX | MCS_TYPE | ELF)
+
+#define SIB_OWNER_STRING_SIZE 32
+#define MAX_SIB_SIZE 512
+#define MAX_SIB_INDEX 64
+
+#define SIB_HEADER_SIGNATURE 0xA00FFF9F /* This is an invalid instruction - MULGE pc,pc,pc */
+#define FLASH_FOOTER_SIGNATURE 0xA0FFFF9F /* This is an invalid instruction - SMULALGES pc,pc,pc */
+
+
+typedef struct SIBType {
+ cyg_uint32 signature;
+ cyg_uint32 size;
+ char owner[SIB_OWNER_STRING_SIZE];
+ cyg_uint32 index;
+ cyg_uint32 revision;
+ cyg_uint32 checksum;
+} tSIB;
+
+typedef struct SIBInfoType {
+ cyg_uint32 SIB_number; /* Unique number of SIB Block */
+ cyg_uint32 SIB_Extension; /* Base of SIB Flash Block */
+ char Label[16]; /* String space for ownership string */
+ cyg_uint32 checksum; /* SIB Image checksum */
+} tSIBInfo;
+
+typedef struct FooterType {
+ void *infoBase; /* Address of first word of ImageFooter */
+ char *blockBase; /* Start of area reserved by this footer */
+ cyg_uint32 signature; /* 'Magic' number proves it's a footer */
+ cyg_uint32 type; /* Area type: ARM Image, SIB, customer */
+ cyg_uint32 checksum; /* Just this structure */
+} tFooter ;
+
+typedef struct ImageInfoType {
+ cyg_uint32 bootFlags; /* Boot flags, compression etc. */
+ cyg_uint32 imageNumber; /* Unique number, selects for boot etc. */
+ char *loadAddress; /* Address program should be loaded to */
+ cyg_uint32 length; /* Actual size of image */
+ char *address; /* Image is executed from here */
+ char name[16]; /* Null terminated */
+ char *headerBase; /* Flash Address of any stripped header */
+ cyg_uint32 header_length; /* Length of header in memory */
+ cyg_uint32 headerType; /* AIF, RLF, s-record etc. */
+ cyg_uint32 checksum; /* Image checksum (inc. this struct) */
+} tImageInfo;
+
+
+#endif // _SIB_H_
diff --git a/ecos/packages/redboot/current/src/alias.c b/ecos/packages/redboot/current/src/alias.c
new file mode 100644
index 0000000..7298f24
--- /dev/null
+++ b/ecos/packages/redboot/current/src/alias.c
@@ -0,0 +1,172 @@
+//==========================================================================
+//
+// alias.c
+//
+// RedBoot - alias support
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas, jskov
+// Date: 2002-05-15
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+
+#ifdef CYGNUM_REDBOOT_FLASH_STRING_SIZE
+# define MAX_STRING_LENGTH CYGNUM_REDBOOT_FLASH_STRING_SIZE
+#else
+# define MAX_STRING_LENGTH 32
+#endif
+
+// Lookup an alias. First try plain string aliases. If that fails try
+// other types so allowing access to all configured values. This allows
+// for alias (macro) expansion of normal 'fconfig' data, such as the
+// board IP address.
+static char *
+lookup_alias(char *alias, char *alias_buf)
+{
+ if (0 == strcasecmp("FREEMEMLO", alias)) {
+ diag_sprintf(alias_buf,"0x%x", ((CYG_ADDRWORD)mem_segments[0].start + 0x03ff) & ~0x03ff);
+ return alias_buf;
+ } else if (0 == strcasecmp("FREEMEMHI", alias)) {
+ diag_sprintf(alias_buf,"0x%x", ((CYG_ADDRWORD)mem_segments[0].end) & ~0x03ff);
+ return alias_buf;
+ }
+
+#ifdef CYGSEM_REDBOOT_FLASH_ALIASES
+ return flash_lookup_alias(alias, alias_buf);
+#else
+ return NULL;
+#endif
+}
+
+// Expand aliases, this is recursive. ie if one alias contains other
+// aliases, these will also be expanded from the insertion point
+// onwards.
+//
+// If 'iter' is zero, then quoted strings are not expanded
+//
+static bool
+_expand_aliases(char *line, int len, int iter)
+{
+ char *lp = line;
+ char *ms, *me, *ep;
+ char *alias;
+ char c;
+ int offset, line_len, alias_len;
+ char alias_buf[MAX_STRING_LENGTH];
+ bool macro_found = false;
+
+ if ((line_len = strlen(line)) != 0) {
+ while (*lp) {
+ c = *lp++;
+ if ((c == '%') && (*lp == '{')) {
+ // Found a macro/alias to expand
+ ms = lp+1;
+ lp += 2;
+ while (*lp && (*lp != '}')) lp++;
+ if (!*lp) {
+ diag_printf("Invalid macro/alias '%s'\n", ms);
+ line[0] = '\0'; // Destroy line
+ return false;
+ }
+ me = lp;
+ *me = '\0';
+ lp++;
+ if ((alias = lookup_alias(ms,alias_buf)) != (char *)NULL) {
+ alias_len = strlen(alias);
+ // See if there is room in the line to expand this macro/alias
+ if ((line_len+alias_len) < len) {
+ // Make a hole by moving data within the line
+ offset = alias_len-strlen(ms)-2; // Number of bytes being inserted
+ ep = &lp[strlen(lp)-1];
+ if (offset > 1) {
+ ep[offset] = '\0';
+ while (ep != (lp-1)) {
+ ep[offset-1] = *ep;
+ ep--;
+ }
+ } else {
+ if (offset <=0) {
+ while ((lp-1) != ep) {
+ lp[offset-1] = *lp;
+ lp++;
+ }
+ lp[offset-1]='\0';
+ }
+ }
+ // Insert the macro/alias data
+ lp = ms-2;
+ while (*alias) {
+ if ((alias[0] == '%') && (alias[1] == '{')) macro_found = true;
+ *lp++ = *alias++;
+ }
+ line_len = strlen(line);
+ lp = lp - alias_len;
+ } else {
+ diag_printf("No room to expand '%s'\n", ms);
+ line[0] = '\0'; // Destroy line
+ return false;
+ }
+ } else {
+ diag_printf("Alias '%s' not defined\n", ms);
+ *me = '|';
+ }
+ } else if ((c == '"') && (iter == 0)) {
+ // Skip quoted strings
+ while (*lp && (*lp != '"')) lp++;
+ }
+ }
+ }
+ return macro_found;
+}
+
+void
+expand_aliases(char *line, int len)
+{
+ int iter = 0;
+
+ while (_expand_aliases(line, len, iter++)) {
+ }
+}
diff --git a/ecos/packages/redboot/current/src/caches.c b/ecos/packages/redboot/current/src/caches.c
new file mode 100644
index 0000000..61c2f4c
--- /dev/null
+++ b/ecos/packages/redboot/current/src/caches.c
@@ -0,0 +1,99 @@
+//==========================================================================
+//
+// caches.c
+//
+// RedBoot cache control functions
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2002-08-06
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+#include <cyg/hal/hal_arch.h>
+#include <cyg/hal/hal_intr.h>
+#include <cyg/hal/hal_cache.h>
+
+RedBoot_cmd("cache",
+ "Manage machine caches",
+ "[ON | OFF]",
+ do_caches
+ );
+
+void
+do_caches(int argc, char *argv[])
+{
+ unsigned long oldints;
+ int dcache_on=0, icache_on=0;
+
+ if (argc == 2) {
+ if (strcasecmp(argv[1], "on") == 0) {
+ HAL_DISABLE_INTERRUPTS(oldints);
+ HAL_ICACHE_ENABLE();
+ HAL_DCACHE_ENABLE();
+ HAL_RESTORE_INTERRUPTS(oldints);
+ } else if (strcasecmp(argv[1], "off") == 0) {
+ HAL_DISABLE_INTERRUPTS(oldints);
+ HAL_DCACHE_SYNC();
+ HAL_ICACHE_DISABLE();
+ HAL_DCACHE_DISABLE();
+ HAL_DCACHE_SYNC();
+ HAL_ICACHE_INVALIDATE_ALL();
+ HAL_DCACHE_INVALIDATE_ALL();
+ HAL_RESTORE_INTERRUPTS(oldints);
+ } else {
+ diag_printf("Invalid cache mode: %s\n", argv[1]);
+ }
+ } else {
+#ifdef HAL_DCACHE_IS_ENABLED
+ HAL_DCACHE_IS_ENABLED(dcache_on);
+#endif
+#ifdef HAL_ICACHE_IS_ENABLED
+ HAL_ICACHE_IS_ENABLED(icache_on);
+#endif
+ diag_printf("Data cache: %s, Instruction cache: %s\n",
+ dcache_on?"On":"Off", icache_on?"On":"Off");
+ }
+}
diff --git a/ecos/packages/redboot/current/src/cksum.c b/ecos/packages/redboot/current/src/cksum.c
new file mode 100644
index 0000000..cdeba10
--- /dev/null
+++ b/ecos/packages/redboot/current/src/cksum.c
@@ -0,0 +1,94 @@
+//==========================================================================
+//
+// cksum.c
+//
+// RedBoot POSIX CRC calculation/command
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2001-01-31
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+
+// Compute a CRC, using the POSIX 1003 definition
+
+RedBoot_cmd("cksum",
+ "Compute a 32bit checksum [POSIX algorithm] for a range of memory",
+ "-b <location> -l <length>",
+ do_cksum
+ );
+
+void
+do_cksum(int argc, char *argv[])
+{
+ struct option_info opts[2];
+ unsigned long base, len, crc;
+ bool base_set, len_set;
+
+ init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM,
+ (void *)&base, (bool *)&base_set, "base address");
+ init_opts(&opts[1], 'l', true, OPTION_ARG_TYPE_NUM,
+ (void *)&len, (bool *)&len_set, "length");
+ if (!scan_opts(argc, argv, 1, opts, 2, 0, 0, "")) {
+ return;
+ }
+ if (!base_set || !len_set) {
+ if (load_address >= (CYG_ADDRESS)ram_start &&
+ load_address_end < (CYG_ADDRESS)ram_end &&
+ load_address < load_address_end) {
+ base = load_address;
+ len = load_address_end - load_address;
+ diag_printf("Computing cksum for area %lx-%lx\n",
+ base, load_address_end);
+ } else {
+ diag_printf("usage: cksum -b <addr> -l <length>\n");
+ return;
+ }
+ }
+ crc = cyg_posix_crc32((unsigned char *)base, len);
+ diag_printf("POSIX cksum = %lu %lu (0x%08lx 0x%08lx)\n", crc, len, crc, len);
+}
+
diff --git a/ecos/packages/redboot/current/src/decompress.c b/ecos/packages/redboot/current/src/decompress.c
new file mode 100644
index 0000000..756b593
--- /dev/null
+++ b/ecos/packages/redboot/current/src/decompress.c
@@ -0,0 +1,314 @@
+//==========================================================================
+//
+// decompress.c
+//
+// RedBoot decompress support
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): jskov
+// Contributors: jskov, gthomas, tkoeller
+// Date: 2001-03-08
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+
+#ifdef CYGPKG_COMPRESS_ZLIB
+#include <cyg/compress/zlib.h>
+static z_stream stream;
+static bool stream_end;
+
+#define __ZLIB_MAGIC__ 0x5A4C4942 // 'ZLIB'
+
+//
+// Free memory [blocks] are stored as a linked list of "struct _block"
+// The 'magic' is kept to insure that the block being freed is reasonable
+//
+// One of either next or size might be removable, if a sentinal block
+// is placed at the end of the region at initialisation time.
+struct _block {
+ int size; // always the total length of the block, including this header
+ long magic; // Must be __ZLIB_MAGIC__ if allocated and 0 if free
+ struct _block *next;
+ struct _block *prev;
+};
+static struct _block *memlist;
+
+#ifdef CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER
+# define ZLIB_COMPRESSION_OVERHEAD CYGNUM_REDBOOT_FIS_ZLIB_COMMON_BUFFER_SIZE
+#else
+# define ZLIB_COMPRESSION_OVERHEAD 0xC000
+#endif
+static void *zlib_workspace;
+
+//
+// This function is run as part of RedBoot's initialization.
+// It will allocate some memory from the "workspace" pool for
+// use by the gzip/zlib routines. This allows the memory usage
+// of RedBoot to be more finely controlled than if we simply
+// used the generic 'malloc() from the heap' functionality.
+//
+static void
+_zlib_init(void)
+{
+ struct _block *bp;
+#ifdef CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER
+ zlib_workspace = fis_zlib_common_buffer;
+#else
+ // Allocate some RAM for use by the gzip/zlib routines
+ workspace_end -= ZLIB_COMPRESSION_OVERHEAD;
+ zlib_workspace = workspace_end;
+#endif
+ bp = (struct _block *)zlib_workspace;
+ memlist = bp;
+ bp->next = bp->prev = 0;
+ bp->size = ZLIB_COMPRESSION_OVERHEAD;
+ bp->magic = 0;
+#ifdef DEBUG_ZLIB_MALLOC
+ show_memlist(__FUNCTION__);
+#endif
+}
+
+RedBoot_init(_zlib_init, RedBoot_INIT_FIRST);
+
+// #define DEBUG_ZLIB_MALLOC
+#ifdef DEBUG_ZLIB_MALLOC
+static void
+show_memlist(char *when)
+{
+ struct _block *bp = memlist;
+
+ diag_printf("memory list after %s\n", when);
+ diag_printf(" --START--- --END----- --SIZE---- --PREV---- --NEXT---- TYPE-----\n");
+ while (bp != (struct _block *)0) {
+ diag_printf(" %08p-%08p 0x%08x %08p %08p %s\n", bp, (unsigned char *)bp+bp->size,
+ bp->size, bp->prev, bp->next, bp->magic == 0 ? "FREE" : "ALLOCATED" );
+ bp = bp->next;
+ }
+ diag_printf("\n");
+}
+#endif
+
+// Note: these have to be global and match the prototype used by the
+// gzip/zlib package since we are exactly replacing them.
+
+void
+*zcalloc(void *opaque, unsigned int items, unsigned int size)
+{
+ voidpf res = 0;
+ int len = (items*size) + sizeof(struct _block);
+ struct _block *bp = memlist;
+ struct _block *nbp;
+
+#ifdef DEBUG_ZLIB_MALLOC
+ /* do this here because when int is called output is not setup yet */
+ static int first_alloc = 1;
+ if ( first_alloc ) {
+ show_memlist("initialization");
+ first_alloc = 0;
+ }
+#endif
+
+ // Simple, first-fit algorithm
+ while (bp) {
+ if (bp->magic == 0 && bp->size > len) {
+ nbp = (struct _block *)((char *)bp + len);
+ /* link new block into chain */
+ nbp->next = bp->next;
+ bp->next = nbp;
+ nbp->prev = bp;
+ /* split size between the two blocks */
+ nbp->size = bp->size - len;
+ bp->size = len;
+ /* mark the new block as free */
+ nbp->magic = 0;
+ /* mark allocated block as allocated */
+ bp->magic = __ZLIB_MAGIC__;
+ res = bp +1;
+ memset(res, 0, len - sizeof(struct _block));
+ break;
+ }
+ bp = bp->next;
+ }
+#ifdef DEBUG_ZLIB_MALLOC
+ diag_printf("%s(0x%x,0x%x) = %p\n", __FUNCTION__, items, size, res);
+ show_memlist(__FUNCTION__);
+#endif
+ if ( res == NULL )
+ diag_printf("zcalloc: failed to allocate 0x%x items of 0x%x bytes == 0x%x bytes\n", items, size, len);
+ return res;
+}
+
+void
+zcfree(void *opaque, void *ptr)
+{
+ struct _block *bp;
+
+ if (!ptr) return; // Safety
+ bp = (struct _block *)((char *)ptr - sizeof(struct _block));
+ if (bp->magic != __ZLIB_MAGIC__) {
+ diag_printf("%s(%p) - invalid block\n", __FUNCTION__, ptr);
+ return;
+ }
+
+ /* mark as free */
+ bp->magic = 0;
+
+#ifdef DEBUG_ZLIB_MALLOC
+ diag_printf("%s(%p) = 0x%x bytes\n", __FUNCTION__, ptr, bp->size);
+#endif
+
+ while(bp->next && bp->next->magic == 0) {
+#ifdef DEBUG_ZLIB_MALLOC
+ diag_printf(" merging %08p and %08p (after)\n", bp, bp->next);
+#endif
+ bp->size += bp->next->size;
+ bp->next = bp->next->next;
+ }
+
+ while(bp->prev && bp->prev->magic == 0) {
+#ifdef DEBUG_ZLIB_MALLOC
+ diag_printf(" merging %08p and %08p (before)\n", bp->prev, bp);
+#endif
+ bp->prev->size += bp->size;
+ bp->prev->next = bp->next;
+ bp = bp->prev;
+ }
+
+#ifdef DEBUG_ZLIB_MALLOC
+ show_memlist(__FUNCTION__);
+#endif
+}
+
+//
+// This function is called to initialize a gzip/zlib stream.
+//
+static int
+gzip_init(_pipe_t* p)
+{
+ int err;
+
+ // Note: this code used to [re]initialize the memory pool used
+ // by zlib. This is now done in _zlib_init(), but only once.
+ stream.zalloc = zcalloc;
+ stream.zfree = zcfree;
+ stream.next_in = NULL;
+ stream.avail_in = 0;
+ stream.next_out = NULL;
+ stream.avail_out = 0;
+ err = inflateInit(&stream);
+ stream_end = false;
+
+ return err;
+}
+
+//
+// This function is called during the decompression cycle to
+// actually cause a buffer to be filled with uncompressed data.
+//
+static int
+gzip_inflate(_pipe_t* p)
+{
+ int err, bytes_out;
+
+ if (stream_end)
+ return Z_STREAM_END;
+
+ stream.next_in = p->in_buf;
+ stream.avail_in = p->in_avail;
+ stream.next_out = p->out_buf;
+ stream.avail_out = p->out_max;
+ err = inflate(&stream, Z_SYNC_FLUSH);
+ bytes_out = stream.next_out - p->out_buf;
+ p->out_size += bytes_out;
+ p->out_buf = stream.next_out;
+ p->msg = stream.msg;
+ p->in_avail = stream.avail_in;
+ p->in_buf = stream.next_in;
+
+ // Let upper layers process any inflated bytes at
+ // end of stream.
+ if (err == Z_STREAM_END && bytes_out) {
+ stream_end = true;
+ err = Z_OK;
+ }
+
+ return err;
+}
+
+//
+// Called when the input data is completed or an error has
+// occured. This allows for clean up as well as passing error
+// information up.
+//
+static int
+gzip_close(_pipe_t* p, int err)
+{
+ switch (err) {
+ case Z_STREAM_END:
+ err = 0;
+ break;
+ case Z_OK:
+ if (stream_end) {
+ break;
+ }
+ // Decompression didn't complete
+ p->msg = "premature end of input";
+ // fall-through
+ default:
+ err = -1;
+ break;
+ }
+
+ inflateEnd(&stream);
+
+ return err;
+}
+
+//
+// Exported interfaces
+//
+_decompress_fun_init* _dc_init = gzip_init;
+_decompress_fun_inflate* _dc_inflate = gzip_inflate;
+_decompress_fun_close* _dc_close = gzip_close;
+#endif // CYGPKG_COMPRESS_ZLIB
diff --git a/ecos/packages/redboot/current/src/dump.c b/ecos/packages/redboot/current/src/dump.c
new file mode 100644
index 0000000..03f45f8
--- /dev/null
+++ b/ecos/packages/redboot/current/src/dump.c
@@ -0,0 +1,156 @@
+//==========================================================================
+//
+// dump.c
+//
+// RedBoot dump support
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2002-08-06
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+
+RedBoot_cmd("dump",
+ "Display (hex dump) a range of memory",
+ "-b <location> [-l <length>] [-s] [-1|-2|-4]",
+ do_dump
+ );
+RedBoot_cmd("x",
+ "Display (hex dump) a range of memory",
+ "-b <location> [-l <length>] [-s] [-1|-2|-4]",
+ do_x
+ );
+
+void
+do_dump(int argc, char *argv[])
+{
+ struct option_info opts[6];
+ unsigned long base, len;
+ bool base_set, len_set;
+ static unsigned long _base, _len;
+ static char _size = 1;
+ bool srec_dump, set_32bit, set_16bit, set_8bit;
+ int i, n, off, cksum;
+ cyg_uint8 ch;
+
+ init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM,
+ (void *)&base, (bool *)&base_set, "base address");
+ init_opts(&opts[1], 'l', true, OPTION_ARG_TYPE_NUM,
+ (void *)&len, (bool *)&len_set, "length");
+ init_opts(&opts[2], 's', false, OPTION_ARG_TYPE_FLG,
+ (void *)&srec_dump, 0, "dump data using Morotola S-records");
+ init_opts(&opts[3], '4', false, OPTION_ARG_TYPE_FLG,
+ (void *)&set_32bit, (bool *)0, "dump 32 bit units");
+ init_opts(&opts[4], '2', false, OPTION_ARG_TYPE_FLG,
+ (void *)&set_16bit, (bool *)0, "dump 16 bit units");
+ init_opts(&opts[5], '1', false, OPTION_ARG_TYPE_FLG,
+ (void *)&set_8bit, (bool *)0, "dump 8 bit units");
+ if (!scan_opts(argc, argv, 1, opts, 6, 0, 0, "")) {
+ return;
+ }
+ if (!base_set) {
+ if (_base == 0) {
+ diag_printf("Dump what [location]?\n");
+ return;
+ }
+ base = _base;
+ if (!len_set) {
+ len = _len;
+ len_set = true;
+ }
+ }
+
+ if (set_32bit) {
+ _size = 4;
+ } else if (set_16bit) {
+ _size = 2;
+ } else if (set_8bit) {
+ _size = 1;
+ }
+
+ if (!len_set) {
+ len = 32;
+ }
+ if (srec_dump) {
+ off = 0;
+ while (off < len) {
+ n = (len > 16) ? 16 : len;
+ cksum = n+5;
+ diag_printf("S3%02X%08lX", n+5, off+base);
+ for (i = 0; i < 4; i++) {
+ cksum += (((base+off)>>(i*8)) & 0xFF);
+ }
+ for (i = 0; i < n; i++) {
+ ch = *(cyg_uint8 *)(base+off+i);
+ diag_printf("%02X", ch);
+ cksum += ch;
+ }
+ diag_printf("%02X\n", ~cksum & 0xFF);
+ off += n;
+ }
+ } else {
+ switch( _size ) {
+ case 1:
+ diag_dump_buf((void *)base, len);
+ break;
+ case 2:
+ diag_dump_buf_16bit((void *)base, len);
+ break;
+ case 4:
+ diag_dump_buf_32bit((void *)base, len);
+ break;
+ }
+ }
+ _base = base + len;
+ _len = len;
+}
+
+// Simple alias for the dump command
+void
+do_x(int argc, char *argv[])
+{
+ do_dump(argc, argv);
+}
diff --git a/ecos/packages/redboot/current/src/fconfig.c b/ecos/packages/redboot/current/src/fconfig.c
new file mode 100644
index 0000000..6f4eae3
--- /dev/null
+++ b/ecos/packages/redboot/current/src/fconfig.c
@@ -0,0 +1,1201 @@
+//==========================================================================
+//
+// fconfig.c
+//
+// RedBoot - persistent data storage support (FLASH or EEPROM)
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas, tkoeller
+// Date: 2000-07-28
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+#include <cyg/io/flash.h>
+#ifdef CYGOPT_REDBOOT_FIS
+#include <fis.h>
+#endif
+
+#ifdef CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG
+// Note horrid intertwining of functions, to save precious FLASH
+externC void fis_read_directory(void);
+externC void fis_update_directory(void);
+#endif
+
+#ifdef CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA_EEPROM
+externC void write_eeprom(void *buf, int len);
+externC void read_eeprom(void *buf, int len);
+#endif
+
+#ifdef CYGSEM_REDBOOT_PLF_ESA_VALIDATE
+externC bool cyg_plf_redboot_esa_validate(unsigned char *val);
+#endif
+
+#ifdef CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA_FLASH
+externC int do_flash_init(void);
+#include <cyg/io/flash.h>
+#endif
+
+// Round a quantity up
+#define _rup(n,s) ((((n)+(s-1))/s)*s)
+
+#include <flash_config.h>
+
+// Configuration data, saved in FLASH, used to set/update RedBoot
+// normal "configuration" data items.
+struct _config *config, *backup_config;
+
+// Local data used by these routines
+#ifdef CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA_FLASH
+extern cyg_flashaddr_t flash_start, flash_end;
+extern size_t flash_block_size;
+extern cyg_uint32 flash_num_blocks;
+extern int __flash_init;
+#ifdef CYGOPT_REDBOOT_FIS
+extern void *fis_work_block;
+extern cyg_flashaddr_t fis_addr;
+extern int fisdir_size; // Size of FIS directory.
+#endif
+#ifdef CYGSEM_REDBOOT_FLASH_CONFIG_READONLY_FALLBACK
+static struct _config *readonly_config;
+#endif
+cyg_flashaddr_t cfg_base; // Location in Flash of config data
+size_t cfg_size; // Length of config data - rounded to Flash block size
+#endif // FLASH MEDIA
+
+// Prototypes for local functions
+static char *flash_lookup_config(char *key);
+
+static bool config_ok;
+
+#define CONFIG_KEY1 0x0BADFACE
+#define CONFIG_KEY2 0xDEADDEAD
+
+#define CONFIG_DONE 0
+#define CONFIG_ABORT -1
+#define CONFIG_CHANGED 1
+#define CONFIG_OK 2
+#define CONFIG_BACK 3
+#define CONFIG_BAD 4
+
+// Note: the following options are related. If 'boot_script' is false, then
+// the other values are used in the configuration. Because of the way
+// that configuration tables are generated, they should have names which
+// are related. The configuration options will show up lexicographically
+// ordered, thus the peculiar naming.
+RedBoot_config_option("Run script at boot",
+ boot_script,
+ ALWAYS_ENABLED, true,
+ CONFIG_BOOL,
+ false
+ );
+RedBoot_config_option("Boot script",
+ boot_script_data,
+ "boot_script", true,
+ CONFIG_SCRIPT,
+ ""
+ );
+// Some preprocessor magic for building the [constant] prompt string
+#define __cat(s1,c2,s3) s1 #c2 s3
+#define _cat(s1,c2,s3) __cat(s1,c2,s3)
+RedBoot_config_option(_cat("Boot script timeout (",
+ CYGNUM_REDBOOT_BOOT_SCRIPT_TIMEOUT_RESOLUTION,
+ "ms resolution)"),
+ boot_script_timeout,
+ "boot_script", true,
+ CONFIG_INT,
+ 0
+ );
+#undef __cat
+#undef _cat
+
+#ifdef CYGSEM_REDBOOT_VARIABLE_BAUD_RATE
+RedBoot_config_option("Console baud rate",
+ console_baud_rate,
+ ALWAYS_ENABLED, true,
+ CONFIG_INT,
+ CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD
+ );
+#endif
+
+CYG_HAL_TABLE_BEGIN( __CONFIG_options_TAB__, RedBoot_config_options);
+CYG_HAL_TABLE_END( __CONFIG_options_TAB_END__, RedBoot_config_options);
+
+extern struct config_option __CONFIG_options_TAB__[], __CONFIG_options_TAB_END__[];
+
+//
+// Layout of config data
+// Each data item is variable length, with the name, type and dependencies
+// encoded into the object.
+// offset contents
+// 0 data type
+// 1 length of name (N)
+// 2 enable sense
+// 3 length of enable key (M)
+// 4 key name
+// N+4 enable key
+// M+N+4 data value
+//
+
+#define CONFIG_OBJECT_TYPE(dp) (dp)[0]
+#define CONFIG_OBJECT_KEYLEN(dp) (dp)[1]
+#define CONFIG_OBJECT_ENABLE_SENSE(dp) (dp)[2]
+#define CONFIG_OBJECT_ENABLE_KEYLEN(dp) (dp)[3]
+#define CONFIG_OBJECT_KEY(dp) ((dp)+4)
+#define CONFIG_OBJECT_ENABLE_KEY(dp) ((dp)+4+CONFIG_OBJECT_KEYLEN(dp))
+#define CONFIG_OBJECT_VALUE(dp) ((dp)+4+CONFIG_OBJECT_KEYLEN(dp)+CONFIG_OBJECT_ENABLE_KEYLEN(dp))
+
+#define LIST_OPT_LIST_ONLY (1)
+#define LIST_OPT_NICKNAMES (2)
+#define LIST_OPT_FULLNAMES (4)
+#define LIST_OPT_DUMBTERM (8)
+
+static void config_init(void);
+static int config_length(int type);
+
+// Change endianness of config data
+void
+conf_endian_fixup(void *ptr)
+{
+#ifdef REDBOOT_FLASH_REVERSE_BYTEORDER
+ struct _config *p = (struct _config *)ptr;
+ char *dp = p->config_data;
+ void *val_ptr;
+ int len;
+ cyg_uint16 u16;
+ cyg_uint32 u32;
+
+ p->len = CYG_SWAP32(p->len);
+ p->key1 = CYG_SWAP32(p->key1);
+ p->key2 = CYG_SWAP32(p->key2);
+ p->cksum = CYG_SWAP32(p->cksum);
+
+ while (dp < &p->config_data[sizeof(config->config_data)]) {
+ len = 4 + CONFIG_OBJECT_KEYLEN(dp) + CONFIG_OBJECT_ENABLE_KEYLEN(dp) +
+ config_length(CONFIG_OBJECT_TYPE(dp));
+ val_ptr = (void *)CONFIG_OBJECT_VALUE(dp);
+
+ switch (CONFIG_OBJECT_TYPE(dp)) {
+ // Note: the data may be unaligned in the configuration data
+ case CONFIG_BOOL:
+ if (sizeof(bool) == 2) {
+ memcpy(&u16, val_ptr, 2);
+ u16 = CYG_SWAP16(u16);
+ memcpy(val_ptr, &u16, 2);
+ } else if (sizeof(bool) == 4) {
+ memcpy(&u32, val_ptr, 4);
+ u32 = CYG_SWAP32(u32);
+ memcpy(val_ptr, &u32, 4);
+ }
+ break;
+ case CONFIG_INT:
+ if (sizeof(unsigned long) == 2) {
+ memcpy(&u16, val_ptr, 2);
+ u16 = CYG_SWAP16(u16);
+ memcpy(val_ptr, &u16, 2);
+ } else if (sizeof(unsigned long) == 4) {
+ memcpy(&u32, val_ptr, 4);
+ u32 = CYG_SWAP32(u32);
+ memcpy(val_ptr, &u32, 4);
+ }
+ break;
+ }
+
+ dp += len;
+ }
+#endif
+}
+
+static int
+get_config(char *dp, char *title, int list_opt, char *newvalue )
+{
+ char line[256], hold_line[256], *sp, *lp;
+ int ret;
+ bool hold_bool_val, new_bool_val, enable;
+ unsigned long hold_int_val, new_int_val;
+#ifdef CYGPKG_REDBOOT_NETWORKING
+ in_addr_t hold_ip_val, new_ip_val;
+ enet_addr_t hold_esa_val;
+ int esa_ptr;
+ char *esp;
+#endif
+ void *val_ptr;
+ int type, script_len;
+
+ if (CONFIG_OBJECT_ENABLE_KEYLEN(dp)) {
+ flash_get_config(CONFIG_OBJECT_ENABLE_KEY(dp), &enable, CONFIG_BOOL);
+ if (((bool)CONFIG_OBJECT_ENABLE_SENSE(dp) && !enable) ||
+ (!(bool)CONFIG_OBJECT_ENABLE_SENSE(dp) && enable)) {
+ return CONFIG_OK; // Disabled field
+ }
+ }
+ lp = line; *lp = '\0';
+ val_ptr = (void *)CONFIG_OBJECT_VALUE(dp);
+ if (LIST_OPT_NICKNAMES & list_opt)
+ diag_printf("%s: ", CONFIG_OBJECT_KEY(dp));
+ if (LIST_OPT_FULLNAMES & list_opt) {
+ if (title != (char *)NULL) {
+ diag_printf("%s: ", title);
+ } else {
+ diag_printf("%s: ", CONFIG_OBJECT_KEY(dp));
+ }
+ }
+ switch (type = CONFIG_OBJECT_TYPE(dp)) {
+ case CONFIG_BOOL:
+ memcpy(&hold_bool_val, val_ptr, sizeof(bool));
+ lp += diag_sprintf(lp, "%s", hold_bool_val ? "true" : "false");
+ break;
+ case CONFIG_INT:
+ memcpy(&hold_int_val, val_ptr, sizeof(unsigned long));
+ lp += diag_sprintf(lp, "%ld", hold_int_val);
+ break;
+#ifdef CYGPKG_REDBOOT_NETWORKING
+ case CONFIG_IP:
+ lp += diag_sprintf(lp, "%s", inet_ntoa((in_addr_t *)val_ptr));
+ if (0 == strcmp("0.0.0.0", line) && !(LIST_OPT_LIST_ONLY & list_opt)) {
+ // then we have a deeply unhelpful starting text - kill it off
+ // (unless we are just listing all values)
+ lp = line; *lp = '\0';
+ }
+ break;
+ case CONFIG_ESA:
+ for (esa_ptr = 0; esa_ptr < sizeof(enet_addr_t); esa_ptr++) {
+ lp += diag_sprintf(lp, "0x%02X", ((unsigned char *)val_ptr)[esa_ptr]);
+ if (esa_ptr < (sizeof(enet_addr_t)-1)) lp += diag_sprintf(lp, ":");
+ }
+ break;
+#if defined(CYGHWR_NET_DRIVERS) && (CYGHWR_NET_DRIVERS > 1)
+ case CONFIG_NETPORT:
+ lp += diag_sprintf(lp, "%s", (unsigned char *)val_ptr);
+ break;
+#endif
+#endif
+ case CONFIG_STRING:
+ lp += diag_sprintf(lp, "%s", (unsigned char *)val_ptr);
+ break;
+ case CONFIG_SCRIPT:
+ diag_printf("\n");
+ sp = lp = (char *)val_ptr;
+ while (*sp) {
+ while (*lp != '\n') lp++;
+ *lp = '\0';
+ diag_printf(".. %s\n", sp);
+ *lp++ = '\n';
+ sp = lp;
+ }
+ break;
+ }
+ if (LIST_OPT_LIST_ONLY & list_opt) {
+ diag_printf("%s\n", line);
+ return CONFIG_OK;
+ }
+ if (type != CONFIG_SCRIPT) {
+ if (NULL != newvalue) {
+ ret = strlen(newvalue);
+ if (ret > sizeof(line))
+ return CONFIG_BAD;
+ strcpy(hold_line, line); // Hold the old value for comparison
+ strcpy(line, newvalue);
+ diag_printf("Setting to %s\n", newvalue);
+ } else {
+ // read from terminal
+ strcpy(hold_line, line);
+ if (LIST_OPT_DUMBTERM & list_opt) {
+ diag_printf( (CONFIG_STRING == type ?
+ "%s > " :
+ "%s ? " ), line);
+ *line = '\0';
+ }
+ ret = _rb_gets_preloaded(line, sizeof(line), 0);
+ }
+ if (ret < 0) return CONFIG_ABORT;
+ // empty input - leave value untouched (else DNS goes away for a
+ // minute to try to look it up) but we must accept empty value for strings.
+ if (0 == line[0] && CONFIG_STRING != type) return CONFIG_OK;
+ if (strcmp(line, hold_line) == 0) return CONFIG_OK; // Just a CR - leave value untouched
+ lp = &line[strlen(line)-1];
+ if (*lp == '.') return CONFIG_DONE;
+ if (*lp == '^') return CONFIG_BACK;
+ }
+ switch (type) {
+ case CONFIG_BOOL:
+ memcpy(&hold_bool_val, val_ptr, sizeof(bool));
+ if (!parse_bool(line, &new_bool_val)) {
+ return CONFIG_BAD;
+ }
+ if (hold_bool_val != new_bool_val) {
+ memcpy(val_ptr, &new_bool_val, sizeof(bool));
+ return CONFIG_CHANGED;
+ } else {
+ return CONFIG_OK;
+ }
+ break;
+ case CONFIG_INT:
+ memcpy(&hold_int_val, val_ptr, sizeof(unsigned long));
+ if (!parse_num(line, &new_int_val, 0, 0)) {
+ return CONFIG_BAD;
+ }
+ if (hold_int_val != new_int_val) {
+ memcpy(val_ptr, &new_int_val, sizeof(unsigned long));
+ return CONFIG_CHANGED;
+ } else {
+ return CONFIG_OK;
+ }
+ break;
+#ifdef CYGPKG_REDBOOT_NETWORKING
+ case CONFIG_IP:
+ memcpy(&hold_ip_val, val_ptr, sizeof(in_addr_t));
+ if (!_gethostbyname(line, &new_ip_val)) {
+ return CONFIG_BAD;
+ }
+ if (hold_ip_val.s_addr != new_ip_val.s_addr) {
+ memcpy(val_ptr, &new_ip_val, sizeof(in_addr_t));
+ return CONFIG_CHANGED;
+ } else {
+ return CONFIG_OK;
+ }
+ break;
+ case CONFIG_ESA:
+ memcpy(&hold_esa_val, val_ptr, sizeof(enet_addr_t));
+ esp = line;
+ for (esa_ptr = 0; esa_ptr < sizeof(enet_addr_t); esa_ptr++) {
+ unsigned long esa_byte;
+ if (!parse_num(esp, &esa_byte, &esp, ":")) {
+ memcpy(val_ptr, &hold_esa_val, sizeof(enet_addr_t));
+ return CONFIG_BAD;
+ }
+ ((unsigned char *)val_ptr)[esa_ptr] = esa_byte;
+ }
+#ifdef CYGSEM_REDBOOT_PLF_ESA_VALIDATE
+ if (!cyg_plf_redboot_esa_validate(val_ptr)) {
+ memcpy(val_ptr, &hold_esa_val, sizeof(enet_addr_t));
+ return CONFIG_BAD;
+ }
+#endif
+ return CONFIG_CHANGED;
+ break;
+#if defined(CYGHWR_NET_DRIVERS) && (CYGHWR_NET_DRIVERS > 1)
+ case CONFIG_NETPORT:
+ if (strlen(line) >= MAX_STRING_LENGTH || net_devindex(line) < 0) {
+ int index;
+ const char *name;
+ diag_printf("Sorry, Port name must be one of:\n");
+ for (index = 0; (name = net_devname(index)) != NULL; index++)
+ diag_printf(" %s\n", name);
+ return CONFIG_BAD;
+ }
+ strcpy((unsigned char *)val_ptr, line);
+ break;
+#endif
+#endif
+ case CONFIG_SCRIPT:
+ // Assume it always changes
+ sp = (char *)val_ptr;
+ script_len = 0;
+ diag_printf("Enter script, terminate with empty line\n");
+ while (true) {
+ *sp = '\0';
+ diag_printf(">> ");
+ ret = _rb_gets(line, sizeof(line), 0);
+ if (ret < 0) return CONFIG_ABORT;
+ if (strlen(line) == 0) break;
+ script_len += strlen(line) + 1;
+ if (script_len > config_length(CONFIG_SCRIPT)) {
+ diag_printf("script longer than %d not allowed!\n",
+ config_length(CONFIG_SCRIPT));
+ return CONFIG_ABORT;
+ }
+ lp = line;
+ while (*lp) {
+ *sp++ = *lp++;
+ }
+ *sp++ = '\n';
+ }
+ break;
+ case CONFIG_STRING:
+ if (strlen(line) >= MAX_STRING_LENGTH) {
+ diag_printf("Sorry, value is too long\n");
+ return CONFIG_BAD;
+ }
+ strcpy((char *)val_ptr, line);
+ break;
+ }
+ return CONFIG_CHANGED;
+}
+
+//
+// Manage configuration information with the FLASH
+//
+
+static int
+config_length(int type)
+{
+ switch (type) {
+ case CONFIG_BOOL:
+ return sizeof(bool);
+ case CONFIG_INT:
+ return sizeof(unsigned long);
+#ifdef CYGPKG_REDBOOT_NETWORKING
+ case CONFIG_IP:
+ return sizeof(in_addr_t);
+ case CONFIG_ESA:
+ // Would like this to be sizeof(enet_addr_t), but that causes much
+ // pain since it fouls the alignment of data which follows.
+ return 8;
+#if defined(CYGHWR_NET_DRIVERS) && (CYGHWR_NET_DRIVERS > 1)
+ case CONFIG_NETPORT:
+ return MAX_STRING_LENGTH;
+#endif
+#endif
+ case CONFIG_STRING:
+ return MAX_STRING_LENGTH;
+ case CONFIG_SCRIPT:
+ return MAX_SCRIPT_LENGTH;
+ default:
+ return 0;
+ }
+}
+
+static cmd_fun do_flash_config;
+RedBoot_cmd("fconfig",
+ "Manage configuration kept in FLASH memory",
+ "[-i] [-l] [-n] [-f] [-d] | [-d] nickname [value]",
+ do_flash_config
+ );
+
+static void
+do_flash_config(int argc, char *argv[])
+{
+ bool need_update = false;
+ struct config_option *optend = __CONFIG_options_TAB_END__;
+ struct config_option *opt = __CONFIG_options_TAB__;
+ struct option_info opts[5];
+ bool list_only;
+ bool nicknames;
+ bool fullnames;
+ bool dumbterminal;
+ int list_opt = 0;
+ char *dp;
+ int len, ret;
+ char *title;
+ char *onlyone = NULL;
+ char *onevalue = NULL;
+ bool doneone = false;
+ bool init = false;
+
+#ifdef CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA_FLASH
+ if (!__flash_init) {
+ diag_printf("Sorry, no FLASH memory is available\n");
+ return;
+ }
+#endif
+ memcpy(backup_config, config, sizeof(struct _config));
+ script = NULL;
+
+ init_opts(&opts[0], 'l', false, OPTION_ARG_TYPE_FLG,
+ (void *)&list_only, (bool *)0, "list configuration only");
+ init_opts(&opts[1], 'n', false, OPTION_ARG_TYPE_FLG,
+ (void *)&nicknames, (bool *)0, "show nicknames");
+ init_opts(&opts[2], 'f', false, OPTION_ARG_TYPE_FLG,
+ (void *)&fullnames, (bool *)0, "show full names");
+ init_opts(&opts[3], 'i', false, OPTION_ARG_TYPE_FLG,
+ (void *)&init, (bool *)0, "initialize configuration database");
+ init_opts(&opts[4], 'd', false, OPTION_ARG_TYPE_FLG,
+ (void *)&dumbterminal, (bool *)0, "dumb terminal: no clever edits");
+
+ // First look to see if we are setting or getting a single option
+ // by just quoting its nickname
+ if ( (2 == argc && '-' != argv[1][0]) ||
+ (3 == argc && '-' != argv[1][0] && '-' != argv[2][0])) {
+ // then the command was "fconfig foo [value]"
+ onlyone = argv[1];
+ onevalue = (3 == argc) ? argv[2] : NULL;
+ list_opt = LIST_OPT_NICKNAMES;
+ }
+ // Next see if we are setting or getting a single option with a dumb
+ // terminal invoked, ie. no line editing.
+ else if (3 == argc &&
+ '-' == argv[1][0] && 'd' == argv[1][1] && 0 == argv[1][2] &&
+ '-' != argv[2][0]) {
+ // then the command was "fconfig -d foo"
+ onlyone = argv[2];
+ onevalue = NULL;
+ list_opt = LIST_OPT_NICKNAMES | LIST_OPT_DUMBTERM;
+ }
+ else {
+ if (!scan_opts(argc, argv, 1, opts, 5, 0, 0, ""))
+ return;
+ list_opt |= list_only ? LIST_OPT_LIST_ONLY : 0;
+ list_opt |= nicknames ? LIST_OPT_NICKNAMES : LIST_OPT_FULLNAMES;
+ list_opt |= fullnames ? LIST_OPT_FULLNAMES : 0;
+ list_opt |= dumbterminal ? LIST_OPT_DUMBTERM : 0;
+ }
+
+ if (init && verify_action("Initialize non-volatile configuration")) {
+ config_init();
+ need_update = true;
+ }
+
+ dp = &config->config_data[0];
+ while (dp < &config->config_data[sizeof(config->config_data)]) {
+ if (CONFIG_OBJECT_TYPE(dp) == CONFIG_EMPTY) {
+ break;
+ }
+ len = 4 + CONFIG_OBJECT_KEYLEN(dp) + CONFIG_OBJECT_ENABLE_KEYLEN(dp) +
+ config_length(CONFIG_OBJECT_TYPE(dp));
+ // Provide a title for well known [i.e. builtin] objects
+ title = (char *)NULL;
+ opt = __CONFIG_options_TAB__;
+ while (opt != optend) {
+ if (strcmp(opt->key, CONFIG_OBJECT_KEY(dp)) == 0) {
+ title = opt->title;
+ break;
+ }
+ opt++;
+ }
+ if ( onlyone && 0 != strcmp(CONFIG_OBJECT_KEY(dp), onlyone) )
+ ret = CONFIG_OK; // skip this entry
+ else {
+ doneone = true;
+ ret = get_config(dp, title, list_opt, onevalue); // do this opt
+ }
+ switch (ret) {
+ case CONFIG_DONE:
+ goto done;
+ case CONFIG_ABORT:
+ memcpy(config, backup_config, sizeof(struct _config));
+ return;
+ case CONFIG_CHANGED:
+ need_update = true;
+ case CONFIG_OK:
+ dp += len;
+ break;
+ case CONFIG_BACK:
+ dp = &config->config_data[0];
+ continue;
+ case CONFIG_BAD:
+ // Nothing - make him do it again
+ diag_printf ("** invalid entry\n");
+ onevalue = NULL; // request a good value be typed in - or abort/whatever
+ }
+ }
+
+ done:
+ if (NULL != onlyone && !doneone) {
+#ifdef CYGSEM_REDBOOT_ALLOW_DYNAMIC_FLASH_CONFIG_DATA
+ if (verify_action("** entry '%s' not found - add", onlyone)) {
+ struct config_option opt;
+ diag_printf("Trying to add value\n");
+ }
+#else
+ diag_printf("** entry '%s' not found\n", onlyone);
+#endif
+ }
+ if (!need_update)
+ return;
+ flash_write_config(true);
+}
+
+
+#ifdef CYGSEM_REDBOOT_FLASH_ALIASES
+static cmd_fun do_alias;
+RedBoot_cmd("alias",
+ "Manage aliases kept in FLASH memory",
+ "name [value]",
+ do_alias
+ );
+
+static void
+make_alias(char *alias, char *name)
+{
+ diag_sprintf(alias, "alias/%s", name);
+}
+
+static void
+do_alias(int argc, char *argv[])
+{
+ char name[80];
+ char *val;
+ struct config_option opt;
+
+ switch (argc) {
+ case 2:
+ make_alias(name, argv[1]);
+ if (flash_get_config(name, &val, CONFIG_STRING)) {
+ diag_printf("'%s' = '%s'\n", argv[1], val);
+ } else {
+ diag_printf("'%s' not found\n", argv[1]);
+ }
+ break;
+ case 3:
+ if (strlen(argv[2]) >= MAX_STRING_LENGTH) {
+ diag_printf("Sorry, value is too long\n");
+ break;
+ }
+ make_alias(name, argv[1]);
+ opt.type = CONFIG_STRING;
+ opt.enable = (char *)0;
+ opt.enable_sense = 1;
+ opt.key = name;
+ opt.dflt = (CYG_ADDRESS)argv[2];
+ flash_add_config(&opt, true);
+ break;
+ default:
+ diag_printf("usage: alias name [value]\n");
+ }
+}
+
+// Lookup an alias. First try plain string aliases. If that fails try
+// other types so allowing access to all configured values. This allows
+// for alias (macro) expansion of normal 'fconfig' data, such as the
+// board IP address.
+char *
+flash_lookup_alias(char *alias, char *alias_buf)
+{
+ char name[80];
+ char *val;
+ char * dp;
+ void *val_ptr;
+ int type;
+ bool hold_bool_val;
+ long hold_long_val;
+#ifdef CYGPKG_REDBOOT_NETWORKING
+ int esa_ptr;
+#endif
+
+ make_alias(name, alias);
+ if (flash_get_config(name, &val, CONFIG_STRING)) {
+ return val;
+ } else {
+ dp = flash_lookup_config(alias);
+ if (dp) {
+ val_ptr = (void *)CONFIG_OBJECT_VALUE(dp);
+ switch (type = CONFIG_OBJECT_TYPE(dp)) {
+ case CONFIG_BOOL:
+ memcpy(&hold_bool_val, val_ptr, sizeof(bool));
+ diag_sprintf(alias_buf, "%s", hold_bool_val ? "true" : "false");
+ break;
+ case CONFIG_INT:
+ memcpy(&hold_long_val, val_ptr, sizeof(unsigned long));
+ diag_sprintf(alias_buf,"%ld", hold_long_val);
+ break;
+#ifdef CYGPKG_REDBOOT_NETWORKING
+ case CONFIG_IP:
+ diag_sprintf(alias_buf,"%s", inet_ntoa((in_addr_t *)val_ptr));
+ break;
+ case CONFIG_ESA:
+ for (esa_ptr = 0; esa_ptr < sizeof(enet_addr_t); esa_ptr++) {
+ diag_sprintf(alias_buf+(3*esa_ptr), "0x%02X", ((unsigned char *)val_ptr)[esa_ptr]);
+ if (esa_ptr < (sizeof(enet_addr_t)-1)) diag_printf(":");
+ }
+ break;
+#endif
+ case CONFIG_SCRIPT:
+ return (char *) val_ptr;
+ break;
+ default:
+ return (char *)NULL;
+ }
+ return alias_buf;
+ }
+ return (char *)NULL;
+ }
+}
+
+#endif // CYGSEM_REDBOOT_FLASH_ALIASES
+
+cyg_uint32
+flash_crc(struct _config *conf)
+{
+ cyg_uint32 crc;
+#ifdef REDBOOT_FLASH_REVERSE_BYTEORDER
+ int swabbed = 0;
+
+ if (conf->key1 == CONFIG_KEY1 && conf->key2 == CONFIG_KEY2) {
+ swabbed = 1;
+ conf_endian_fixup(conf);
+ }
+#endif
+
+ crc = cyg_crc32((unsigned char *)conf, sizeof(*conf)-sizeof(conf->cksum));
+
+#ifdef REDBOOT_FLASH_REVERSE_BYTEORDER
+ if (swabbed)
+ conf_endian_fixup(conf);
+#endif
+ return crc;
+}
+
+//
+// Write the in-memory copy of the configuration data to the flash device.
+//
+void
+flash_write_config(bool prompt)
+{
+#if defined(CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA_FLASH)
+#if !defined(CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG)
+ cyg_flashaddr_t err_addr;
+ int stat;
+#endif
+#endif
+
+ config->len = sizeof(struct _config);
+ config->key1 = CONFIG_KEY1;
+ config->key2 = CONFIG_KEY2;
+ config->cksum = flash_crc(config);
+ if (!prompt || verify_action("Update RedBoot non-volatile configuration")) {
+#ifdef CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA_FLASH
+#ifdef CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG
+ fis_read_directory();
+ fis_update_directory();
+#else
+#ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL
+ // Insure [quietly] that the config page is unlocked before trying to update
+ cyg_flash_unlock(cfg_base, cfg_size, &err_addr);
+#endif
+ if ((stat = cyg_flash_erase(cfg_base, cfg_size, &err_addr)) != 0) {
+ diag_printf(" initialization failed at %p: %s\n", (void*)err_addr,
+ cyg_flash_errmsg(stat));
+ } else {
+ conf_endian_fixup(config);
+ if ((stat = cyg_flash_program(cfg_base, (void *)config, sizeof(struct _config),
+ &err_addr)) != 0) {
+ diag_printf("Error writing config data at %p: %s\n",
+ (void*)err_addr, cyg_flash_errmsg(stat));
+ }
+ conf_endian_fixup(config);
+ }
+#ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL
+ // Insure [quietly] that the config data is locked after the update
+ cyg_flash_lock(cfg_base, cfg_size, &err_addr);
+#endif
+#endif // CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG
+#else // CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA_FLASH
+ write_eeprom(config, sizeof(struct _config)); // into 'config'
+#endif
+ }
+}
+
+//
+// Find the configuration entry for a particular key
+//
+static char *
+flash_lookup_config(char *key)
+{
+ char *dp;
+ int len;
+
+ if (!config_ok) return NULL;
+
+ dp = &config->config_data[0];
+ while (dp < &config->config_data[sizeof(config->config_data)]) {
+ len = 4 + CONFIG_OBJECT_KEYLEN(dp) + CONFIG_OBJECT_ENABLE_KEYLEN(dp) +
+ config_length(CONFIG_OBJECT_TYPE(dp));
+ if (strcmp(key, CONFIG_OBJECT_KEY(dp)) == 0) {
+ return dp;
+ }
+ // Sanity check to prevent RedBoot going into an infinite loop when
+ // there is something dodgy in the fconfig area.
+ if (len <= 0) {
+ break;
+ }
+ dp += len;
+ }
+// diag_printf("Can't find config data for '%s'\n", key);
+ return NULL;
+}
+
+//
+// Enumerate the keys from the configuration
+//
+bool
+flash_next_key(char *key, int keylen, int *type, int *offset)
+{
+ char *dp;
+ int len;
+
+ if (!config_ok) return false;
+ if ((*offset < 0) || (*offset >= MAX_CONFIG_DATA)) return false;
+
+ dp = &config->config_data[*offset];
+ if ((*type = CONFIG_OBJECT_TYPE(dp)) == CONFIG_EMPTY) return false;
+ if ((len = CONFIG_OBJECT_KEYLEN(dp)) > keylen) return false;
+ memcpy(key, CONFIG_OBJECT_KEY(dp), len);
+ *offset += 4 + CONFIG_OBJECT_KEYLEN(dp) + CONFIG_OBJECT_ENABLE_KEYLEN(dp) +
+ config_length(CONFIG_OBJECT_TYPE(dp));
+ return true;
+}
+
+//
+// Retrieve a data object from the data base (in memory copy)
+//
+bool
+flash_get_config(char *key, void *val, int type)
+{
+ char *dp;
+ void *val_ptr;
+#ifdef CYGSEM_REDBOOT_FLASH_CONFIG_READONLY_FALLBACK
+ struct _config *save_config = 0;
+ bool res;
+#endif
+
+ if (!config_ok) return false;
+
+ if ((dp = flash_lookup_config(key)) != NULL) {
+ if (CONFIG_OBJECT_TYPE(dp) == type) {
+ val_ptr = (void *)CONFIG_OBJECT_VALUE(dp);
+ switch (type) {
+ // Note: the data may be unaligned in the configuration data
+ case CONFIG_BOOL:
+ memcpy(val, val_ptr, sizeof(bool));
+ break;
+ case CONFIG_INT:
+ memcpy(val, val_ptr, sizeof(unsigned long));
+ break;
+#ifdef CYGPKG_REDBOOT_NETWORKING
+ case CONFIG_IP:
+ memcpy(val, val_ptr, sizeof(in_addr_t));
+ break;
+ case CONFIG_ESA:
+ memcpy(val, val_ptr, sizeof(enet_addr_t));
+ break;
+#endif
+#if defined(CYGHWR_NET_DRIVERS) && (CYGHWR_NET_DRIVERS > 1)
+ case CONFIG_NETPORT:
+#endif
+ case CONFIG_STRING:
+ case CONFIG_SCRIPT:
+ // Just return a pointer to the script/line
+ *(unsigned char **)val = (unsigned char *)val_ptr;
+ break;
+ }
+ } else {
+ diag_printf("Request for config value '%s' - wrong type\n", key);
+ }
+ return true;
+ }
+#ifdef CYGSEM_REDBOOT_FLASH_CONFIG_READONLY_FALLBACK
+ // Did not find key. Is configuration data valid?
+ // Check to see if the config data is valid, if not, revert to
+ // readonly mode, by setting config to readonly_config. We
+ // will set it back before we leave this function.
+ if ( (config != readonly_config) && ((flash_crc(config) != config->cksum) ||
+ (config->key1 != CONFIG_KEY1)|| (config->key2 != CONFIG_KEY2))) {
+ save_config = config;
+ config = readonly_config;
+ if ((flash_crc(config) != config->cksum) ||
+ (config->key1 != CONFIG_KEY1)|| (config->key2 != CONFIG_KEY2)) {
+ diag_printf("FLASH configuration checksum error or invalid key\n");
+ config = save_config;
+ return false;
+ }
+ else{
+ diag_printf("Getting config information in READONLY mode\n");
+ res = flash_get_config(key, val, type);
+ config = save_config;
+ return res;
+ }
+ }
+#endif
+ return false;
+}
+
+//
+// Update a data object in the data base (in memory copy & backing store)
+//
+bool
+flash_set_config(char *key, void *val, int type)
+{
+ char *dp;
+ void *val_ptr;
+
+ if (!config_ok) return false;
+
+ if ((dp = flash_lookup_config(key)) != NULL) {
+ if (CONFIG_OBJECT_TYPE(dp) == type) {
+ val_ptr = (void *)CONFIG_OBJECT_VALUE(dp);
+ switch (type) {
+ // Note: the data may be unaligned in the configuration data
+ case CONFIG_BOOL:
+ memcpy(val_ptr, val, sizeof(bool));
+ break;
+ case CONFIG_INT:
+ memcpy(val_ptr, val, sizeof(unsigned long));
+ break;
+#ifdef CYGPKG_REDBOOT_NETWORKING
+ case CONFIG_IP:
+ memcpy(val_ptr, val, sizeof(in_addr_t));
+ break;
+ case CONFIG_ESA:
+ memcpy(val_ptr, val, sizeof(enet_addr_t));
+ break;
+#endif
+#if defined(CYGHWR_NET_DRIVERS) && (CYGHWR_NET_DRIVERS > 1)
+ case CONFIG_NETPORT:
+#endif
+ case CONFIG_STRING:
+ case CONFIG_SCRIPT:
+ memcpy(val_ptr, val, config_length(CONFIG_STRING));
+ break;
+ }
+ } else {
+ diag_printf("Can't set config value '%s' - wrong type\n", key);
+ return false;
+ }
+ flash_write_config(false);
+ return true;
+ }
+ return false;
+}
+
+//
+// Copy data into the config area
+//
+static void
+flash_config_insert_value(char *dp, struct config_option *opt)
+{
+ switch (opt->type) {
+ // Note: the data may be unaligned in the configuration data
+ case CONFIG_BOOL:
+ memcpy(dp, (void *)&opt->dflt, sizeof(bool));
+ break;
+ case CONFIG_INT:
+ memcpy(dp, (void *)&opt->dflt, sizeof(unsigned long));
+ break;
+#ifdef CYGPKG_REDBOOT_NETWORKING
+ case CONFIG_IP:
+ memcpy(dp, (void *)&opt->dflt, sizeof(in_addr_t));
+ break;
+ case CONFIG_ESA:
+ memcpy(dp, (void *)opt->dflt, sizeof(enet_addr_t));
+ break;
+#if defined(CYGHWR_NET_DRIVERS) && (CYGHWR_NET_DRIVERS > 1)
+ case CONFIG_NETPORT:
+ // validate dflt and if not acceptable use first port
+ {
+ int index;
+ const char *name;
+ for (index = 0; (name = net_devname(index)) != NULL; index++)
+ if (!strcmp((char *)opt->dflt, name))
+ break;
+ if (name == NULL)
+ name = net_devname(0);
+ memcpy(dp, name, strlen(name) + 1);
+ }
+ break;
+#endif
+#endif
+ case CONFIG_STRING:
+ memcpy(dp, (void *)opt->dflt, config_length(CONFIG_STRING));
+ break;
+ case CONFIG_SCRIPT:
+ break;
+ }
+}
+
+//
+// Add a new option to the database
+//
+bool
+flash_add_config(struct config_option *opt, bool update)
+{
+ char *dp, *kp;
+ int len, elen, size;
+
+ // If data item is already present, just update it
+ // Note: only the data value can be thusly changed
+ if ((dp = flash_lookup_config(opt->key)) != NULL) {
+ flash_config_insert_value(CONFIG_OBJECT_VALUE(dp), opt);
+ if (update) {
+ flash_write_config(true);
+ }
+ return true;
+ }
+ // Add the data item
+ dp = &config->config_data[0];
+ size = 0;
+ while (size < sizeof(config->config_data)) {
+ if (CONFIG_OBJECT_TYPE(dp) == CONFIG_EMPTY) {
+ kp = opt->key;
+ len = strlen(kp) + 1;
+ size += len + 2 + 2 + config_length(opt->type);
+ if (opt->enable) {
+ elen = strlen(opt->enable) + 1;
+ size += elen;
+ } else {
+ elen = 0;
+ }
+ if (size > sizeof(config->config_data)) {
+ break;
+ }
+ CONFIG_OBJECT_TYPE(dp) = opt->type;
+ CONFIG_OBJECT_KEYLEN(dp) = len;
+ CONFIG_OBJECT_ENABLE_SENSE(dp) = opt->enable_sense;
+ CONFIG_OBJECT_ENABLE_KEYLEN(dp) = elen;
+ dp = CONFIG_OBJECT_KEY(dp);
+ while (*kp) *dp++ += *kp++;
+ *dp++ = '\0';
+ if (elen) {
+ kp = opt->enable;
+ while (*kp) *dp++ += *kp++;
+ *dp++ = '\0';
+ }
+ flash_config_insert_value(dp, opt);
+ if (update) {
+ flash_write_config(true);
+ }
+ return true;
+ } else {
+ len = 4 + CONFIG_OBJECT_KEYLEN(dp) + CONFIG_OBJECT_ENABLE_KEYLEN(dp) +
+ config_length(CONFIG_OBJECT_TYPE(dp));
+ dp += len;
+ size += len;
+ }
+ }
+ diag_printf("No space to add '%s'\n", opt->key);
+ return false;
+}
+
+//
+// Reset/initialize configuration data - used only when starting from scratch
+//
+static void
+config_init(void)
+{
+ // Well known option strings
+ struct config_option *optend = __CONFIG_options_TAB_END__;
+ struct config_option *opt = __CONFIG_options_TAB__;
+
+ memset(config, 0, sizeof(struct _config));
+ while (opt != optend) {
+ if (!flash_add_config(opt, false)) {
+ return;
+ }
+ opt++;
+ }
+ config_ok = true;
+}
+
+//
+// Attempt to get configuration information from the FLASH.
+// If available (i.e. good checksum, etc), initialize "known"
+// values for later use.
+//
+static void
+load_flash_config(void)
+{
+ bool use_boot_script;
+ unsigned char *cfg_temp = (unsigned char *)workspace_end;
+#ifdef CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA_FLASH
+ cyg_flashaddr_t err_addr;
+#endif
+
+ config_ok = false;
+ script = NULL;
+ cfg_temp -= sizeof(struct _config); // Space for primary config data
+ config = (struct _config *)cfg_temp;
+ cfg_temp -= sizeof(struct _config); // Space for backup config data
+ backup_config = (struct _config *)cfg_temp;
+#ifdef CYGSEM_REDBOOT_FLASH_CONFIG_READONLY_FALLBACK
+ cfg_temp -= sizeof(struct _config); // Space for readonly copy of config data
+ readonly_config = (struct _config *)cfg_temp;
+#endif
+ workspace_end = cfg_temp;
+#ifdef CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA_FLASH
+ if (do_flash_init()<0) return;
+#ifdef CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG
+ cfg_size = _rup(sizeof(struct _config), sizeof(struct fis_image_desc));
+ if ((fisdir_size-cfg_size) < (CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_COUNT *
+ CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_SIZE)) {
+ // Too bad this can't be checked at compile/build time
+ diag_printf("Sorry, FLASH config exceeds available space in FIS directory\n");
+ return;
+ }
+ cfg_base = (((CYG_ADDRESS)fis_addr + fisdir_size) - cfg_size);
+ fisdir_size -= cfg_size;
+#else
+ cfg_size = (flash_block_size > sizeof(struct _config)) ?
+ sizeof(struct _config) :
+ _rup(sizeof(struct _config), flash_block_size);
+ if (CYGNUM_REDBOOT_FLASH_CONFIG_BLOCK < 0) {
+ cfg_base = ((CYG_ADDRESS)flash_end + 1 -
+ _rup(_rup((-CYGNUM_REDBOOT_FLASH_CONFIG_BLOCK*flash_block_size), cfg_size), flash_block_size));
+ } else {
+ cfg_base = ((CYG_ADDRESS)flash_start +
+ _rup(_rup((CYGNUM_REDBOOT_FLASH_CONFIG_BLOCK*flash_block_size), cfg_size), flash_block_size));
+ }
+#endif
+ cyg_flash_read(cfg_base, (void *)config, sizeof(struct _config), &err_addr);
+ conf_endian_fixup(config);
+#else
+ read_eeprom(config, sizeof(struct _config)); // into 'config'
+#endif
+#ifdef CYGSEM_REDBOOT_FLASH_CONFIG_READONLY_FALLBACK
+ memcpy(readonly_config, config, sizeof(struct _config));
+#endif
+ if ((flash_crc(config) != config->cksum) ||
+ (config->key1 != CONFIG_KEY1)|| (config->key2 != CONFIG_KEY2)) {
+ diag_printf("**Warning** FLASH configuration checksum error or invalid key\n");
+ diag_printf("Use 'fconfig -i' to [re]initialize database\n");
+ config_init();
+ return;
+ }
+ config_ok = true;
+
+ flash_get_config("boot_script", &use_boot_script, CONFIG_BOOL);
+ if (use_boot_script) {
+ flash_get_config("boot_script_data", &script, CONFIG_SCRIPT);
+ flash_get_config("boot_script_timeout", &script_timeout, CONFIG_INT);
+ }
+#ifdef CYGSEM_REDBOOT_VARIABLE_BAUD_RATE
+ if (flash_get_config("console_baud_rate", &console_baud_rate, CONFIG_INT)) {
+ extern int set_console_baud_rate(int);
+ set_console_baud_rate(console_baud_rate);
+ }
+#endif
+}
+
+RedBoot_init(load_flash_config, RedBoot_INIT_SECOND);
+
+// EOF fconfig.c
diff --git a/ecos/packages/redboot/current/src/flash.c b/ecos/packages/redboot/current/src/flash.c
new file mode 100644
index 0000000..8b205fe
--- /dev/null
+++ b/ecos/packages/redboot/current/src/flash.c
@@ -0,0 +1,2012 @@
+//==========================================================================
+//
+// flash.c
+//
+// RedBoot - FLASH memory support
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas, tkoeller
+// Date: 2000-07-28
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+#include <cyg/io/flash.h>
+#include <fis.h>
+#include <sib.h>
+#include <cyg/infra/cyg_ass.h> // assertion macros
+
+#ifdef CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG
+// Note horrid intertwining of functions, to save precious FLASH
+extern void conf_endian_fixup(void *p);
+#endif
+
+// Round a quantity up
+#define _rup(n,s) ((((n)+(s-1))/s)*s)
+
+#ifdef CYGOPT_REDBOOT_FIS
+// Image management functions
+local_cmd_entry("init",
+ "Initialize FLASH Image System [FIS]",
+ "[-f]",
+ fis_init,
+ FIS_cmds
+ );
+#ifdef CYGSEM_REDBOOT_FIS_CRC_CHECK
+# define FIS_LIST_OPTS "[-c] [-d]"
+#else
+# define FIS_LIST_OPTS "[-d]"
+#endif
+local_cmd_entry("list",
+ "Display contents of FLASH Image System [FIS]",
+ FIS_LIST_OPTS,
+ fis_list,
+ FIS_cmds
+ );
+local_cmd_entry("free",
+ "Display free [available] locations within FLASH Image System [FIS]",
+ "",
+ fis_free,
+ FIS_cmds
+ );
+local_cmd_entry("delete",
+ "Delete an image from FLASH Image System [FIS]",
+ "name",
+ fis_delete,
+ FIS_cmds
+ );
+
+static char fis_load_usage[] =
+#ifdef CYGPRI_REDBOOT_ZLIB_FLASH
+ "[-d] "
+#endif
+ "[-b <memory_load_address>] [-c] name";
+
+local_cmd_entry("load",
+ "Load image from FLASH Image System [FIS] into RAM",
+ fis_load_usage,
+ fis_load,
+ FIS_cmds
+ );
+local_cmd_entry("create",
+ "Create an image",
+ "[-b <mem_base>] [-l <image_length>] [-s <data_length>]\n"
+ " [-f <flash_addr>] [-e <entry_point>] [-r <ram_addr>] [-n] <name>",
+ fis_create,
+ FIS_cmds
+ );
+#endif
+
+// Raw flash access functions
+local_cmd_entry("erase",
+ "Erase FLASH contents",
+ "-f <flash_addr> -l <length>",
+ fis_erase,
+ FIS_cmds
+ );
+#ifdef CYGHWR_IO_FLASH_BLOCK_LOCKING
+local_cmd_entry("lock",
+ "LOCK FLASH contents",
+ "[-f <flash_addr> -l <length>] [name]",
+ fis_lock,
+ FIS_cmds
+ );
+local_cmd_entry("unlock",
+ "UNLOCK FLASH contents",
+ "[-f <flash_addr> -l <length>] [name]",
+ fis_unlock,
+ FIS_cmds
+ );
+#endif
+local_cmd_entry("write",
+ "Write raw data directly to FLASH",
+ "-f <flash_addr> -b <mem_base> -l <image_length>",
+ fis_write,
+ FIS_cmds
+ );
+
+// Define table boundaries
+CYG_HAL_TABLE_BEGIN( __FIS_cmds_TAB__, FIS_cmds);
+CYG_HAL_TABLE_END( __FIS_cmds_TAB_END__, FIS_cmds);
+
+extern struct cmd __FIS_cmds_TAB__[], __FIS_cmds_TAB_END__;
+
+// CLI function
+static cmd_fun do_fis;
+RedBoot_nested_cmd("fis",
+ "Manage FLASH images",
+ "{cmds}",
+ do_fis,
+ __FIS_cmds_TAB__, &__FIS_cmds_TAB_END__
+ );
+
+// Local data used by these routines
+cyg_flashaddr_t flash_start, flash_end;
+size_t flash_block_size;
+cyg_uint32 flash_num_blocks;
+#ifdef CYGOPT_REDBOOT_FIS
+void *fis_work_block;
+cyg_flashaddr_t fis_addr;
+#ifdef CYGOPT_REDBOOT_REDUNDANT_FIS
+cyg_flashaddr_t redundant_fis_addr;
+#endif
+int fisdir_size; // Size of FIS directory.
+#endif
+#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
+extern cyg_flashaddr_t cfg_base; // Location in Flash of config data
+extern size_t cfg_size; // Length of config data - rounded to Flash block size
+extern struct _config *config;
+#endif
+
+static void
+fis_usage(char *why)
+{
+ diag_printf("*** invalid 'fis' command: %s\n", why);
+ cmd_usage(__FIS_cmds_TAB__, &__FIS_cmds_TAB_END__, "fis ");
+}
+
+static void
+_show_invalid_flash_address(CYG_ADDRESS flash_addr, int stat)
+{
+ cyg_uint32 i=0;
+ cyg_flash_info_t info;
+ int ret;
+
+ diag_printf("Invalid FLASH address %p: %s\n", (void *)flash_addr,
+ cyg_flash_errmsg(stat));
+ do {
+ ret = cyg_flash_get_info(i, &info);
+ if (ret == CYG_FLASH_ERR_OK) {
+ diag_printf(" valid range is %p - %p\n", (void*)info.start, (void*)info.end);
+ }
+ i++;
+ } while (ret != CYG_FLASH_ERR_INVALID);
+}
+
+// Avoid overwriting the current executable. This is not a complete
+// implementation, there may be code outside the text region, but it
+// is generally good enough. If either the start of the text region or
+// the end of the text region is within the specified range then at
+// least some of the code is in the area of flash about to be erased
+// or programmed.
+static cyg_bool
+check_code_overlaps(cyg_flashaddr_t start, cyg_flashaddr_t end)
+{
+ extern char _stext[], _etext[];
+
+ return ((((unsigned long)&_stext >= (unsigned long)start) &&
+ ((unsigned long)&_stext < (unsigned long)end))
+ ||
+ (((unsigned long)&_etext >= (unsigned long)start) &&
+ ((unsigned long)&_etext < (unsigned long)end)));
+}
+
+#ifdef CYGOPT_REDBOOT_FIS
+
+// fis_endian_fixup() is used to swap endianess if required.
+//
+static inline void fis_endian_fixup(void *addr)
+{
+#ifdef REDBOOT_FLASH_REVERSE_BYTEORDER
+ struct fis_image_desc *p = addr;
+ int cnt = fisdir_size / sizeof(struct fis_image_desc);
+
+ while (cnt-- > 0) {
+ p->flash_base = CYG_SWAP32(p->flash_base);
+ p->mem_base = CYG_SWAP32(p->mem_base);
+ p->size = CYG_SWAP32(p->size);
+ p->entry_point = CYG_SWAP32(p->entry_point);
+ p->data_length = CYG_SWAP32(p->data_length);
+ p->desc_cksum = CYG_SWAP32(p->desc_cksum);
+ p->file_cksum = CYG_SWAP32(p->file_cksum);
+ p++;
+ }
+#endif
+}
+
+void
+fis_read_directory(void)
+{
+ cyg_flashaddr_t err_addr;
+
+ cyg_flash_read(fis_addr, fis_work_block, fisdir_size, &err_addr);
+ fis_endian_fixup(fis_work_block);
+}
+
+struct fis_image_desc *
+fis_lookup(char *name, int *num)
+{
+ int i;
+ struct fis_image_desc *img;
+
+ fis_read_directory();
+
+ img = (struct fis_image_desc *)fis_work_block;
+ for (i = 0; i < fisdir_size/sizeof(*img); i++, img++) {
+ if ((img->u.name[0] != '\xFF') &&
+ (strcasecmp(name, img->u.name) == 0)) {
+ if (num) *num = i;
+ return img;
+ }
+ }
+ return (struct fis_image_desc *)0;
+}
+
+int fis_start_update_directory(int autolock)
+{
+#ifdef CYGOPT_REDBOOT_REDUNDANT_FIS
+#ifdef CYGHWR_IO_FLASH_BLOCK_LOCKING
+#ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL
+ // Ensure [quietly] that the directory is unlocked before trying to update and locked again afterwards
+ int do_autolock=1;
+#else
+ int do_autolock=autolock;
+#endif
+#endif
+
+ struct fis_image_desc* img=NULL;
+ cyg_flashaddr_t err_addr;
+ cyg_flashaddr_t tmp_fis_addr;
+ int stat;
+
+ /*exchange old and new valid fis tables*/
+ tmp_fis_addr=fis_addr;
+ fis_addr=redundant_fis_addr;
+ redundant_fis_addr=tmp_fis_addr;
+
+ //adjust the contents of the new fis table
+ img=(struct fis_image_desc*)fis_work_block;
+
+ memcpy(img->u.valid_info.magic_name, CYG_REDBOOT_RFIS_VALID_MAGIC, CYG_REDBOOT_RFIS_VALID_MAGIC_LENGTH);
+ img->u.valid_info.valid_flag[0]=CYG_REDBOOT_RFIS_IN_PROGRESS;
+ img->u.valid_info.valid_flag[1]=CYG_REDBOOT_RFIS_IN_PROGRESS;
+ img->u.valid_info.version_count=img->u.valid_info.version_count+1;
+
+ //ready to go....
+#ifdef CYGHWR_IO_FLASH_BLOCK_LOCKING
+ if (do_autolock)
+ cyg_flash_unlock(fis_addr, fisdir_size, &err_addr);
+#endif
+
+ if ((stat = cyg_flash_erase(fis_addr, fisdir_size, &err_addr)) != 0) {
+ diag_printf("Error erasing FIS directory at %p: %s\n",
+ (void*)err_addr, cyg_flash_errmsg(stat));
+ return 1;
+ }
+ //now magic is 0xffffffff
+ fis_endian_fixup(fis_work_block);
+ if ((stat = cyg_flash_program(fis_addr, fis_work_block, flash_block_size, &err_addr)) != 0) {
+ diag_printf("Error writing FIS directory at %p: %s\n",
+ (void*)err_addr, cyg_flash_errmsg(stat));
+ return 1;
+ }
+ fis_endian_fixup(fis_work_block);
+ //now magic is 0xff1234ff, valid is IN_PROGRESS, version_count is the old one +1
+
+#else
+ /* nothing to do here without redundant fis */
+#endif
+ return 0;
+
+}
+
+int
+fis_update_directory(int autolock, int error)
+{
+ cyg_flashaddr_t err_addr;
+ int stat;
+
+#ifdef CYGHWR_IO_FLASH_BLOCK_LOCKING
+#ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL
+ // Ensure [quietly] that the directory is unlocked before trying to update and locked again afterwards
+ int do_autolock=1;
+#else
+ int do_autolock=autolock;
+#endif
+#endif
+
+#ifdef CYGOPT_REDBOOT_REDUNDANT_FIS
+
+ struct fis_image_desc* img=(struct fis_image_desc*)fis_work_block;
+
+ // called from invalid state
+ if (img->u.valid_info.valid_flag[0]!=CYG_REDBOOT_RFIS_IN_PROGRESS)
+ return -1;
+
+ //if it failed, reset is0Valid to the state before startUpdateDirectory()
+ //g_data.fisTable hasn't been changed yet, so it doesn't have to be reset now
+ //then reread the contents from flash
+ //setting the valid flag of the failed table to "INVALID" might also be not too bad
+ //but IN_PROGRESS is also good enough I think
+ if (error!=0)
+ {
+ cyg_flashaddr_t swap_fis_addr=fis_addr;
+ fis_addr=redundant_fis_addr;
+ redundant_fis_addr=swap_fis_addr;
+ }
+ else //success
+ {
+ cyg_flashaddr_t tmp_fis_addr=((CYG_ADDRESS)fis_addr+CYG_REDBOOT_RFIS_VALID_MAGIC_LENGTH);
+
+ img->u.valid_info.valid_flag[0]=CYG_REDBOOT_RFIS_VALID;
+ img->u.valid_info.valid_flag[1]=CYG_REDBOOT_RFIS_VALID;
+
+ if ((stat = cyg_flash_program(tmp_fis_addr, img->u.valid_info.valid_flag,
+ sizeof(img->u.valid_info.valid_flag), &err_addr)) != 0) {
+ diag_printf("Error writing FIS directory at %p: %s\n",
+ (void*)err_addr, cyg_flash_errmsg(stat));
+ }
+ }
+#ifdef CYGHWR_IO_FLASH_BLOCK_LOCKING
+ if (do_autolock)
+ flash_lock((void *)fis_addr, fisdir_size, (void **)&err_addr);
+#endif
+
+#else // CYGOPT_REDBOOT_REDUNDANT_FIS
+ int blk_size = fisdir_size;
+
+ fis_endian_fixup(fis_work_block);
+#ifdef CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG
+ memcpy((char *)fis_work_block+fisdir_size, config, cfg_size);
+ conf_endian_fixup((char *)fis_work_block+fisdir_size);
+ blk_size += cfg_size;
+#endif
+#ifdef CYGHWR_IO_FLASH_BLOCK_LOCKING
+ if (do_autolock)
+ cyg_flash_unlock(fis_addr, blk_size, &err_addr);
+#endif
+
+ if ((stat = cyg_flash_erase(fis_addr, blk_size, &err_addr)) != 0) {
+ diag_printf("Error erasing FIS directory at %p: %s\n", (void*)err_addr, cyg_flash_errmsg(stat));
+ } else {
+ if ((stat = cyg_flash_program(fis_addr, fis_work_block, blk_size,
+ &err_addr)) != 0) {
+ diag_printf("Error writing FIS directory at %p: %s\n",
+ (void*)err_addr, cyg_flash_errmsg(stat));
+ }
+ }
+ fis_endian_fixup(fis_work_block);
+#ifdef CYGHWR_IO_FLASH_BLOCK_LOCKING
+ if (do_autolock)
+ cyg_flash_lock(fis_addr, blk_size, &err_addr);
+#endif
+
+#endif // CYGOPT_REDBOOT_REDUNDANT_FIS
+
+ return 0;
+}
+
+#ifdef CYGOPT_REDBOOT_REDUNDANT_FIS
+
+int
+fis_get_valid_buf(struct fis_image_desc* img0, struct fis_image_desc* img1, int* update_was_interrupted)
+{
+ *update_was_interrupted=0;
+ if (strncmp(img1->u.valid_info.magic_name, CYG_REDBOOT_RFIS_VALID_MAGIC, CYG_REDBOOT_RFIS_VALID_MAGIC_LENGTH)!=0) //buf0 must be valid
+ {
+ if (img0->u.valid_info.version_count>0)
+ {
+ *update_was_interrupted=1;
+ }
+ return 0;
+ }
+ else if (strncmp(img0->u.valid_info.magic_name, CYG_REDBOOT_RFIS_VALID_MAGIC, CYG_REDBOOT_RFIS_VALID_MAGIC_LENGTH)!=0) //buf1 must be valid
+ {
+ if (img1->u.valid_info.version_count>0)
+ {
+ *update_was_interrupted=1;
+ }
+ return 1;
+ }
+ //magic is ok for both, now check the valid flag
+ if ((img1->u.valid_info.valid_flag[0]!=CYG_REDBOOT_RFIS_VALID)
+ || (img1->u.valid_info.valid_flag[1]!=CYG_REDBOOT_RFIS_VALID)) //buf0 must be valid
+ {
+ *update_was_interrupted=1;
+ return 0;
+ }
+ else if ((img0->u.valid_info.valid_flag[0]!=CYG_REDBOOT_RFIS_VALID)
+ || (img0->u.valid_info.valid_flag[1]!=CYG_REDBOOT_RFIS_VALID)) //buf1 must be valid
+ {
+ *update_was_interrupted=1;
+ return 1;
+ }
+
+ //now check the version
+ if (img1->u.valid_info.version_count == (img0->u.valid_info.version_count+1)) //buf1 must be valid
+ return 1;
+
+ return 0;
+}
+
+void
+fis_erase_redundant_directory(void)
+{
+ int stat;
+ cyg_flashaddr_t err_addr;
+
+#ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL
+ // Ensure [quietly] that the directory is unlocked before trying
+ // to update
+ cyg_flash_unlock(redundant_fis_addr, fisdir_size,
+ &err_addr);
+#endif
+ if ((stat = cyg_flash_erase(redundant_fis_addr, fisdir_size,
+ &err_addr)) != 0) {
+ diag_printf("Error erasing FIS directory at %p: %s\n",
+ (void*)err_addr, cyg_flash_errmsg(stat));
+ }
+#ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL
+ // Ensure [quietly] that the directory is locked after the update
+ cyg_flash_lock(redundant_fis_addr, fisdir_size, &err_addr);
+#endif
+}
+#endif
+
+static void
+fis_init(int argc, char *argv[])
+{
+ int stat;
+ struct fis_image_desc *img;
+ cyg_flashaddr_t err_addr;
+ bool full_init = false;
+ struct option_info opts[1];
+ CYG_ADDRESS redboot_flash_start;
+ unsigned long redboot_image_size;
+
+ init_opts(&opts[0], 'f', false, OPTION_ARG_TYPE_FLG,
+ (void *)&full_init, (bool *)0, "full initialization, erases all of flash");
+ if (!scan_opts(argc, argv, 2, opts, 1, 0, 0, ""))
+ {
+ return;
+ }
+
+ if (!verify_action("About to initialize [format] FLASH image system")) {
+ diag_printf("** Aborted\n");
+ return;
+ }
+ diag_printf("*** Initialize FLASH Image System\n");
+
+#define MIN_REDBOOT_IMAGE_SIZE CYGBLD_REDBOOT_MIN_IMAGE_SIZE
+ redboot_image_size = flash_block_size > MIN_REDBOOT_IMAGE_SIZE ?
+ flash_block_size : MIN_REDBOOT_IMAGE_SIZE;
+
+ img = (struct fis_image_desc *)fis_work_block;
+ memset(img, '\xFF', fisdir_size); // Start with erased data
+
+#ifdef CYGOPT_REDBOOT_REDUNDANT_FIS
+ //create the valid flag entry
+ memset(img, 0, sizeof(struct fis_image_desc));
+ strcpy(img->u.valid_info.magic_name, CYG_REDBOOT_RFIS_VALID_MAGIC);
+ img->u.valid_info.valid_flag[0]=CYG_REDBOOT_RFIS_VALID;
+ img->u.valid_info.valid_flag[1]=CYG_REDBOOT_RFIS_VALID;
+ img->u.valid_info.version_count=0;
+ img++;
+#endif
+
+ // Create a pseudo image for RedBoot
+#ifdef CYGOPT_REDBOOT_FIS_RESERVED_BASE
+ memset(img, 0, sizeof(*img));
+ strcpy(img->u.name, "(reserved)");
+ img->flash_base = (CYG_ADDRESS)flash_start;
+ img->mem_base = (CYG_ADDRESS)flash_start;
+ img->size = CYGNUM_REDBOOT_FLASH_RESERVED_BASE;
+ img->data_length = img->size;
+ img++;
+#endif
+ redboot_flash_start = (CYG_ADDRESS)flash_start + CYGBLD_REDBOOT_FLASH_BOOT_OFFSET;
+#ifdef CYGOPT_REDBOOT_FIS_REDBOOT
+ memset(img, 0, sizeof(*img));
+ strcpy(img->u.name, "RedBoot");
+ img->flash_base = redboot_flash_start;
+ img->mem_base = redboot_flash_start;
+ img->size = redboot_image_size;
+ img->data_length = img->size;
+ img++;
+ redboot_flash_start += redboot_image_size;
+#endif
+#ifdef CYGOPT_REDBOOT_FIS_REDBOOT_POST
+#ifdef CYGNUM_REDBOOT_FIS_REDBOOT_POST_OFFSET
+ // Take care to place the POST entry at the right offset:
+ redboot_flash_start = (CYG_ADDRESS)flash_start + CYGNUM_REDBOOT_FIS_REDBOOT_POST_OFFSET;
+#endif
+ memset(img, 0, sizeof(*img));
+ strcpy(img->u.name, "RedBoot[post]");
+ img->flash_base = redboot_flash_start;
+ img->mem_base = redboot_flash_start;
+ img->size = redboot_image_size;
+ img->data_length = img->size;
+ img++;
+ redboot_flash_start += redboot_image_size;
+#endif
+#ifdef CYGOPT_REDBOOT_FIS_REDBOOT_BACKUP
+ // And a backup image
+ memset(img, 0, sizeof(*img));
+ strcpy(img->u.name, "RedBoot[backup]");
+ img->flash_base = redboot_flash_start;
+ img->mem_base = redboot_flash_start;
+ img->size = redboot_image_size;
+ img->data_length = img->size;
+ img++;
+ redboot_flash_start += redboot_image_size;
+#endif
+#if defined(CYGSEM_REDBOOT_FLASH_CONFIG) && defined(CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA_FLASH)
+ // And a descriptor for the configuration data
+ memset(img, 0, sizeof(*img));
+ strcpy(img->u.name, "RedBoot config");
+ img->flash_base = (CYG_ADDRESS)cfg_base;
+ img->mem_base = (CYG_ADDRESS)cfg_base;
+ img->size = cfg_size;
+ img->data_length = img->size;
+ img++;
+#endif
+ // And a descriptor for the descriptor table itself
+ memset(img, 0, sizeof(*img));
+ strcpy(img->u.name, "FIS directory");
+ img->flash_base = (CYG_ADDRESS)fis_addr;
+ img->mem_base = (CYG_ADDRESS)fis_addr;
+ img->size = fisdir_size;
+ img->data_length = img->size;
+ img++;
+
+ //create the entry for the redundant fis table
+#ifdef CYGOPT_REDBOOT_REDUNDANT_FIS
+ memset(img, 0, sizeof(*img));
+ strcpy(img->u.name, "Redundant FIS");
+ img->flash_base = (CYG_ADDRESS)redundant_fis_addr;
+ img->mem_base = (CYG_ADDRESS)redundant_fis_addr;
+ img->size = fisdir_size;
+ img++;
+#endif
+
+#ifdef CYGOPT_REDBOOT_FIS_DIRECTORY_ARM_SIB_ID
+ // FIS gets the size of a full block - note, this should be changed
+ // if support is added for multi-block FIS structures.
+ img = (struct fis_image_desc *)((CYG_ADDRESS)fis_work_block + fisdir_size);
+ // Add a footer so the FIS will be recognized by the ARM Boot
+ // Monitor as a reserved area.
+ {
+ tFooter* footer_p = (tFooter*)((CYG_ADDRESS)img - sizeof(tFooter));
+ cyg_uint32 check = 0;
+ cyg_uint32 *check_ptr = (cyg_uint32 *)footer_p;
+ cyg_int32 count = (sizeof(tFooter) - 4) >> 2;
+
+ // Prepare footer. Try to protect all but the reserved space
+ // and the first RedBoot image (which is expected to be
+ // bootable), but fall back to just protecting the FIS if it's
+ // not at the default position in the flash.
+#if defined(CYGOPT_REDBOOT_FIS_RESERVED_BASE) && (-1 == CYGNUM_REDBOOT_FIS_DIRECTORY_BLOCK)
+ footer_p->blockBase = (char*)_ADDR_REDBOOT_TO_ARM(flash_start);
+ footer_p->blockBase += CYGNUM_REDBOOT_FLASH_RESERVED_BASE + redboot_image_size;
+#else
+ footer_p->blockBase = (char*)_ADDR_REDBOOT_TO_ARM(fis_work_block);
+#endif
+ footer_p->infoBase = NULL;
+ footer_p->signature = FLASH_FOOTER_SIGNATURE;
+ footer_p->type = TYPE_REDHAT_REDBOOT;
+
+ // and compute its checksum
+ for ( ; count > 0; count--) {
+ if (*check_ptr > ~check)
+ check++;
+ check += *check_ptr++;
+ }
+ footer_p->checksum = ~check;
+ }
+#endif
+
+ // Do this after creating the initialized table because that inherently
+ // calculates where the high water mark of default RedBoot images is.
+
+ if (full_init) {
+ unsigned long erase_size;
+ CYG_ADDRESS erase_start;
+ // Erase everything except default RedBoot images, fis block,
+ // and config block.
+ // First deal with the possible first part, before RedBoot images:
+#if (CYGBLD_REDBOOT_FLASH_BOOT_OFFSET > CYGNUM_REDBOOT_FLASH_RESERVED_BASE)
+ erase_start = (CYG_ADDRESS)flash_start + CYGNUM_REDBOOT_FLASH_RESERVED_BASE;
+ erase_size = (CYG_ADDRESS)flash_start + CYGBLD_REDBOOT_FLASH_BOOT_OFFSET;
+ if ( erase_size > erase_start ) {
+ erase_size -= erase_start;
+ if ((stat = cyg_flash_erase((void *)erase_start, erase_size,
+ &err_addr)) != 0) {
+ diag_printf(" initialization failed at %p: %s\n",
+ err_addr, cyg_flash_errmsg(stat));
+ }
+ }
+#endif
+ // second deal with the larger part in the main:
+ erase_start = redboot_flash_start; // high water of created images
+ // Now the empty bits between the end of Redboot and the cfg and dir
+ // blocks.
+#if defined(CYGSEM_REDBOOT_FLASH_CONFIG) && \
+ defined(CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA_FLASH) && \
+ !defined(CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG)
+ if (fis_addr > cfg_base) {
+ erase_size = (CYG_ADDRESS)cfg_base - erase_start; // the gap between HWM and config data
+ } else {
+ erase_size = (CYG_ADDRESS)fis_addr - erase_start; // the gap between HWM and fis data
+ }
+ if ((stat = cyg_flash_erase(erase_start, erase_size,&err_addr)) != 0) {
+ diag_printf(" initialization failed %p: %s\n",
+ (void*)err_addr, cyg_flash_errmsg(stat));
+ }
+ erase_start += (erase_size + flash_block_size);
+ if (fis_addr > cfg_base) {
+ erase_size = (CYG_ADDRESS)fis_addr - erase_start; // the gap between config and fis data
+ } else {
+ erase_size = (CYG_ADDRESS)cfg_base - erase_start; // the gap between fis and config data
+ }
+ if ((stat = cyg_flash_erase(erase_start, erase_size,&err_addr)) != 0) {
+ diag_printf(" initialization failed %p: %s\n",
+ (void*)err_addr, cyg_flash_errmsg(stat));
+ }
+ erase_start += (erase_size + flash_block_size);
+#else // !CYGSEM_REDBOOT_FLASH_CONFIG
+ erase_size = (CYG_ADDRESS)fis_addr - erase_start; // the gap between HWM and fis data
+ if ((stat = cyg_flash_erase(erase_start, erase_size,&err_addr)) != 0) {
+ diag_printf(" initialization failed %p: %s\n",
+ (void*)err_addr, cyg_flash_errmsg(stat));
+ }
+ erase_start += (erase_size + flash_block_size);
+#endif
+ // Lastly, anything at the end
+ erase_size = ((CYG_ADDRESS)flash_end - erase_start) + 1;
+ if ((erase_size > 0) &&
+ ((stat = cyg_flash_erase(erase_start, erase_size,
+ &err_addr))) != 0) {
+ diag_printf(" initialization failed at %p: %s\n",
+ (void*)err_addr, cyg_flash_errmsg(stat));
+ }
+#ifndef CYGDAT_REDBOOT_FIS_MAX_FREE_CHUNKS
+ // In this case, 'fis free' works by scanning for erased blocks. Since the
+ // "-f" option was not supplied, there may be areas which are not used but
+ // don't appear to be free since they are not erased - thus the warning
+ } else {
+ diag_printf(" Warning: device contents not erased, some blocks may not be usable\n");
+#endif
+ }
+ fis_start_update_directory(0);
+ fis_update_directory(0, 0);
+#ifdef CYGOPT_REDBOOT_REDUNDANT_FIS
+ fis_erase_redundant_directory();
+#endif
+}
+
+static void
+fis_list(int argc, char *argv[])
+{
+ struct fis_image_desc *img;
+ int i, image_indx;
+ bool show_cksums = false;
+ bool show_datalen = false;
+ struct option_info opts[2];
+ unsigned long last_addr, lowest_addr;
+ bool image_found;
+
+#ifdef CYGHWR_REDBOOT_ARM_FLASH_SIB
+ // FIXME: this is somewhat half-baked
+ extern void arm_fis_list(void);
+ arm_fis_list();
+ return;
+#endif
+
+ init_opts(&opts[0], 'd', false, OPTION_ARG_TYPE_FLG,
+ (void *)&show_datalen, (bool *)0, "display data length");
+#ifdef CYGSEM_REDBOOT_FIS_CRC_CHECK
+ init_opts(&opts[1], 'c', false, OPTION_ARG_TYPE_FLG,
+ (void *)&show_cksums, (bool *)0, "display checksums");
+ i = 2;
+#else
+ i = 1;
+#endif
+ if (!scan_opts(argc, argv, 2, opts, i, 0, 0, "")) {
+ return;
+ }
+ fis_read_directory();
+
+ // Let diag_printf do the formatting in both cases, rather than counting
+ // cols by hand....
+ diag_printf("%-16s %-10s %-10s %-10s %-s\n",
+ "Name","FLASH addr",
+ show_cksums ? "Checksum" : "Mem addr",
+ show_datalen ? "Datalen" : "Length",
+ "Entry point" );
+ last_addr = 0;
+ image_indx = 0;
+ do {
+ image_found = false;
+ lowest_addr = 0xFFFFFFFF;
+ img = (struct fis_image_desc *) fis_work_block;
+ for (i = 0; i < fisdir_size/sizeof(*img); i++, img++) {
+ if (img->u.name[0] != '\xFF') {
+ if ((img->flash_base >= last_addr) && (img->flash_base < lowest_addr)) {
+ lowest_addr = img->flash_base;
+ image_found = true;
+ image_indx = i;
+ }
+ }
+ }
+ if (image_found) {
+ img = (struct fis_image_desc *) fis_work_block;
+ img += image_indx;
+ diag_printf("%-16s 0x%08lX 0x%08lX 0x%08lX 0x%08lX\n", img->u.name,
+ (unsigned long)img->flash_base,
+#ifdef CYGSEM_REDBOOT_FIS_CRC_CHECK
+ show_cksums ? img->file_cksum : img->mem_base,
+ show_datalen ? img->data_length : img->size,
+#else
+ img->mem_base,
+ img->size,
+#endif
+ (unsigned long)img->entry_point);
+ }
+ last_addr = lowest_addr + 1;
+ } while (image_found == true);
+}
+
+#ifdef CYGNUM_REDBOOT_FLASH_RESERVED_DEVICES
+static CYG_ADDRESS flash_reserved_devices[] = { CYGNUM_REDBOOT_FLASH_RESERVED_DEVICES, 0xFFFFFFFF };
+
+static cyg_bool flash_reserved( CYG_ADDRESS start )
+{
+ int i;
+ for( i = 0; flash_reserved_devices[i] != 0xFFFFFFFF; i++ )
+ if( start == flash_reserved_devices[i] )
+ return true;
+ return false;
+}
+#else
+#define flash_reserved(__start) false
+#endif
+
+#ifdef CYGDAT_REDBOOT_FIS_MAX_FREE_CHUNKS
+struct free_chunk {
+ CYG_ADDRESS start, end;
+};
+
+static int
+find_free(struct free_chunk *chunks)
+{
+ cyg_flash_info_t info;
+ struct fis_image_desc *img;
+ int i=0, idx;
+ int num_chunks = 0;
+ int ret;
+
+ do {
+ // get info for each flash device
+ ret = cyg_flash_get_info(i, &info);
+
+ if (ret == CYG_FLASH_ERR_OK && !flash_reserved( info.start )) {
+
+#ifdef CYGNUM_REDBOOT_FLASH_BASE
+ if ( CYGNUM_REDBOOT_FLASH_BASE == info.start )
+#else
+ if (i == 0 )
+#endif
+ {
+ // Do not search the area reserved for pre-RedBoot systems:
+ chunks[num_chunks].start = (info.start +
+ CYGNUM_REDBOOT_FLASH_RESERVED_BASE);
+ chunks[num_chunks].end = info.end;
+ num_chunks++;
+ } else { // Contiguous flash? If so collapse the chunks together.
+ if (chunks[num_chunks-1].end == (info.start -1)) {
+ chunks[num_chunks-1].end = info.end;
+ } else {
+ chunks[num_chunks].start = info.start;
+ chunks[num_chunks].end = info.end;
+ num_chunks++;
+ }
+ }
+ }
+ i++;
+ } while (ret != CYG_FLASH_ERR_INVALID);
+
+ fis_read_directory();
+ img = (struct fis_image_desc *) fis_work_block;
+ for (i = 0; i < fisdir_size/sizeof(*img); i++, img++) {
+ if (img->u.name[0] != '\xFF') {
+ // Figure out which chunk this is in and split it
+ for (idx = 0; idx < num_chunks; idx++) {
+ if ((img->flash_base >= chunks[idx].start) &&
+ (img->flash_base <= chunks[idx].end)) {
+ if (img->flash_base == chunks[idx].start) {
+ chunks[idx].start += img->size;
+ if (chunks[idx].start >= chunks[idx].end) {
+ // This free chunk has collapsed
+ num_chunks--;
+ while (idx < num_chunks) {
+ chunks[idx] = chunks[idx+1];
+ idx++;
+ }
+ }
+ } else if ((img->flash_base+img->size-1) >= chunks[idx].end) {
+ chunks[idx].end = img->flash_base - 1;
+ } else {
+ // Split chunk into two parts
+ int idxtmp;
+
+ // shift chunks along one so we insert the new one
+ for (idxtmp=num_chunks; idxtmp > (idx+1); idxtmp--)
+ {
+ chunks[idxtmp] = chunks[idxtmp-1];
+ }
+
+ chunks[idx+1].start = img->flash_base + img->size;
+ chunks[idx+1].end = chunks[idx].end;
+ chunks[idx].end = img->flash_base - 1;
+ if (++num_chunks == CYGDAT_REDBOOT_FIS_MAX_FREE_CHUNKS) {
+ diag_printf("Warning: too many free chunks\n");
+ return num_chunks;
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+ return num_chunks;
+}
+#endif // CYGDAT_REDBOOT_FIS_MAX_FREE_CHUNKS
+
+static void
+fis_free(int argc, char *argv[])
+{
+#if !defined(CYGDAT_REDBOOT_FIS_MAX_FREE_CHUNKS)
+ cyg_uint32 flash_data;
+ cyg_flashaddr_t area_start;
+ cyg_flashaddr_t err_addr;
+ cyg_uint32 flash_dev_no;
+ int flash_err;
+ cyg_flash_info_t flash_info;
+ cyg_uint32 curr_block, curr_block_info;
+ cyg_flashaddr_t curr_flash_addr, next_flash_addr;
+
+ // For each flash device
+ for (flash_dev_no=0;; flash_dev_no++)
+ {
+ flash_err = cyg_flash_get_info( flash_dev_no, &flash_info );
+ if ( CYG_FLASH_ERR_OK != flash_err ) // assume all done
+ break;
+
+ if( flash_reserved( flash_info.start ) ) // Ignore reserved devices
+ continue;
+
+ // Once more, from the top...
+ curr_flash_addr = area_start = flash_info.start;
+
+ // We must not search the area reserved for pre-RedBoot systems,
+ // but this is only the case for the first flash device, or
+ // the one corresponding to CYGNUM_REDBOOT_FLASH_BASE.
+ // FIXME: this is insufficiently generic by design - can only
+ // reserve on one flash.
+#ifdef CYGNUM_REDBOOT_FLASH_BASE
+ if ( CYGNUM_REDBOOT_FLASH_BASE == area_start )
+#else
+ if ( 0 == flash_dev_no )
+#endif
+ {
+ //cyg_flashaddr_t asold = area_start;
+ area_start += CYGNUM_REDBOOT_FLASH_RESERVED_BASE;
+ //diag_printf("area_start was %08x now %08x\n", asold, area_start );
+ }
+ // For each region of blocks
+ for ( curr_block_info = 0;
+ curr_block_info < flash_info.num_block_infos;
+ curr_block_info++ )
+ {
+ // For each individual block
+ for ( curr_block = 0;
+ curr_block < flash_info.block_info[curr_block_info].blocks;
+ curr_flash_addr = next_flash_addr, curr_block++ )
+ {
+ cyg_ucount32 i;
+ cyg_bool is_blank = true; // until proved otherwise
+ size_t amount_to_check;
+
+ // determine this now to avoid recalculating it later in this block, so we know the
+ // end of this block
+ next_flash_addr = curr_flash_addr + flash_info.block_info[curr_block_info].block_size;
+
+ // If area_start got adjusted further up, skip until we reach it
+ if ( curr_flash_addr < area_start )
+ continue;
+
+ //diag_printf("block region %d, block %d, flashaddr %08x\n",curr_block_info,curr_block,curr_flash_addr);
+
+ // check 32 bytes at most. Reading it all will take too long on many devices.
+ // Perhaps this should be a config option.
+ amount_to_check = 32;
+ if ( amount_to_check > flash_info.block_info[curr_block_info].block_size ) // paranoia
+ amount_to_check = flash_info.block_info[curr_block_info].block_size;
+
+ for ( i=0; i<amount_to_check; i += sizeof(cyg_uint32) )
+ {
+ flash_err = cyg_flash_read(curr_flash_addr+i, &flash_data, sizeof(cyg_uint32), &err_addr);
+ if ( (CYG_FLASH_ERR_OK != flash_err) || (flash_data != 0xffffffff) )
+ {
+ is_blank = false;
+ break; // no point continuing
+ }
+ } // for
+
+ if (!is_blank)
+ {
+ /* If not blank, output the preceding region if any */
+ if ( curr_flash_addr != area_start )
+ {
+ diag_printf(" 0x%08lX .. 0x%08lX\n",
+ area_start,
+ next_flash_addr-1 );
+ }
+ area_start = next_flash_addr;
+ }
+ } // for block
+ } // for block region
+
+ /* If the blank region extended to the very end of the device, we need to do one
+ * final check at the end of the device.
+ */
+ if ( curr_flash_addr != area_start )
+ {
+ diag_printf(" 0x%08lX .. 0x%08lX\n",
+ area_start,
+ next_flash_addr-1 );
+ }
+ } // for flash device
+#else
+ struct free_chunk chunks[CYGDAT_REDBOOT_FIS_MAX_FREE_CHUNKS];
+ int idx, num_chunks;
+
+ num_chunks = find_free(chunks);
+ for (idx = 0; idx < num_chunks; idx++) {
+ diag_printf(" 0x%08lX .. 0x%08lX\n",
+ (unsigned long)chunks[idx].start,
+ (unsigned long)chunks[idx].end);
+ }
+#endif
+}
+
+// Find the first unused area of flash which is long enough
+static bool
+fis_find_free(CYG_ADDRESS *addr, unsigned long length)
+{
+#ifndef CYGDAT_REDBOOT_FIS_MAX_FREE_CHUNKS
+ cyg_uint32 flash_data;
+ cyg_flashaddr_t area_start;
+ cyg_flashaddr_t err_addr;
+ cyg_uint32 flash_dev_no;
+ int flash_err;
+ cyg_flash_info_t flash_info;
+ cyg_uint32 curr_block, curr_block_info;
+ cyg_flashaddr_t curr_flash_addr, next_flash_addr;
+
+ // For each flash device
+ for (flash_dev_no=0;; flash_dev_no++)
+ {
+ flash_err = cyg_flash_get_info( flash_dev_no, &flash_info );
+ if ( CYG_FLASH_ERR_OK != flash_err ) // assume all done
+ break;
+
+ if( flash_reserved( flash_info.start ) ) // Ignore reserved devices
+ continue;
+
+ // Once more, from the top...
+ curr_flash_addr = area_start = flash_info.start;
+
+ // We must not search the area reserved for pre-RedBoot systems,
+ // but this is only the case for the first flash device, or
+ // the one corresponding to CYGNUM_REDBOOT_FLASH_BASE.
+ // FIXME: this is insufficiently generic by design - can only
+ // reserve on one flash.
+#ifdef CYGNUM_REDBOOT_FLASH_BASE
+ if ( CYGNUM_REDBOOT_FLASH_BASE == area_start )
+#else
+ if ( 0 == flash_dev_no )
+#endif
+ {
+ //cyg_flashaddr_t asold = area_start;
+ area_start += CYGNUM_REDBOOT_FLASH_RESERVED_BASE;
+ //diag_printf("area_start was %08x now %08x\n", asold, area_start );
+ }
+ // For each region of blocks
+ for ( curr_block_info = 0;
+ curr_block_info < flash_info.num_block_infos;
+ curr_block_info++ )
+ {
+ // For each individual block
+ for ( curr_block = 0;
+ curr_block < flash_info.block_info[curr_block_info].blocks;
+ curr_flash_addr = next_flash_addr, curr_block++ )
+ {
+ cyg_ucount32 i;
+ cyg_bool is_blank = true; // until proved otherwise
+ size_t amount_to_check;
+
+ // determine this now to avoid recalculating it later in this block, so we know the
+ // end of this block
+ next_flash_addr = curr_flash_addr + flash_info.block_info[curr_block_info].block_size;
+
+ // If area_start got adjusted further up, skip until we reach it
+ if ( curr_flash_addr < area_start )
+ continue;
+
+ //diag_printf("block region %d, block %d, flashaddr %08x\n",curr_block_info,curr_block,curr_flash_addr);
+
+ // check 32 bytes at most. Reading it all will take too long on many devices.
+ // Perhaps this should be a config option.
+ amount_to_check = 32;
+ if ( amount_to_check > flash_info.block_info[curr_block_info].block_size ) // paranoia
+ amount_to_check = flash_info.block_info[curr_block_info].block_size;
+
+ for ( i=0; i<amount_to_check; i += sizeof(cyg_uint32) )
+ {
+ flash_err = cyg_flash_read(curr_flash_addr+i, &flash_data, sizeof(cyg_uint32), &err_addr);
+ if ( (CYG_FLASH_ERR_OK != flash_err) || (flash_data != 0xffffffff) )
+ {
+ is_blank = false;
+ break; // no point continuing
+ }
+ } // for
+
+ if (!is_blank)
+ {
+ /* If not blank, output the preceding region if any */
+ if ( curr_flash_addr != area_start )
+ {
+ if ( length <= (next_flash_addr - area_start) )
+ {
+ *addr = (CYG_ADDRESS)area_start;
+ return true;
+ }
+ }
+ area_start = next_flash_addr;
+ }
+ } // for block
+ } // for block region
+
+ /* If the blank region extended to the very end of the device, we need to do one
+ * final check at the end of the device.
+ */
+ if ( curr_flash_addr != area_start )
+ {
+ if ( length <= (next_flash_addr - area_start) )
+ {
+ *addr = (CYG_ADDRESS)area_start;
+ return true;
+ }
+ }
+ } // for flash device
+#else
+ struct free_chunk chunks[CYGDAT_REDBOOT_FIS_MAX_FREE_CHUNKS];
+ int idx, num_chunks;
+
+ num_chunks = find_free(chunks);
+ for (idx = 0; idx < num_chunks; idx++) {
+ if ((chunks[idx].end - chunks[idx].start + 1) >= length) {
+ *addr = (CYG_ADDRESS)chunks[idx].start;
+ return true;
+ }
+ }
+#endif
+ return false;
+}
+
+static void
+fis_create(int argc, char *argv[])
+{
+ int i, stat;
+ unsigned long length, img_size;
+ CYG_ADDRESS mem_addr, exec_addr, flash_addr, entry_addr, flash_offset;
+ char *name;
+ bool mem_addr_set = false;
+ bool exec_addr_set = false;
+ bool entry_addr_set = false;
+ bool flash_addr_set = false;
+ bool length_set = false;
+ bool img_size_set = false;
+ bool no_copy = false;
+ cyg_flashaddr_t err_addr;
+ struct fis_image_desc *img = NULL;
+ bool defaults_assumed;
+ struct option_info opts[7];
+ bool prog_ok = true;
+ size_t block_size;
+
+ init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM,
+ (void *)&mem_addr, (bool *)&mem_addr_set, "memory base address");
+ init_opts(&opts[1], 'r', true, OPTION_ARG_TYPE_NUM,
+ (void *)&exec_addr, (bool *)&exec_addr_set, "ram base address");
+ init_opts(&opts[2], 'e', true, OPTION_ARG_TYPE_NUM,
+ (void *)&entry_addr, (bool *)&entry_addr_set, "entry point address");
+ init_opts(&opts[3], 'f', true, OPTION_ARG_TYPE_NUM,
+ (void *)&flash_addr, (bool *)&flash_addr_set, "FLASH memory base address");
+ init_opts(&opts[4], 'l', true, OPTION_ARG_TYPE_NUM,
+ (void *)&length, (bool *)&length_set, "image length [in FLASH]");
+ init_opts(&opts[5], 's', true, OPTION_ARG_TYPE_NUM,
+ (void *)&img_size, (bool *)&img_size_set, "image size [actual data]");
+ init_opts(&opts[6], 'n', false, OPTION_ARG_TYPE_FLG,
+ (void *)&no_copy, (bool *)0, "don't copy from RAM to FLASH, just update directory");
+ if (!scan_opts(argc, argv, 2, opts, 7, (void *)&name, OPTION_ARG_TYPE_STR, "file name"))
+ {
+ fis_usage("invalid arguments");
+ return;
+ }
+
+ fis_read_directory();
+ defaults_assumed = false;
+ if (name) {
+ // Search existing files to acquire defaults for params not specified:
+ img = fis_lookup(name, NULL);
+ if (img) {
+ // Found it, so get image size from there
+ if (!length_set) {
+ length_set = true;
+ length = img->size;
+ defaults_assumed = true;
+ }
+ }
+ }
+ if ((!mem_addr_set || mem_addr == load_address) && !no_copy && (load_address >= (CYG_ADDRESS)ram_start) &&
+ (load_address_end) < (CYG_ADDRESS)ram_end) {
+ mem_addr = load_address;
+ mem_addr_set = true;
+ defaults_assumed = true;
+ // Get entry address from loader, unless overridden
+ if (!entry_addr_set) {
+ entry_addr = entry_address;
+ entry_addr_set = true;
+ }
+ if (!length_set) {
+ length = load_address_end - load_address;
+ length_set = true;
+ } else if (defaults_assumed && !img_size_set) {
+ /* We got length from the FIS table, so the size of the
+ actual loaded image becomes img_size */
+ img_size = load_address_end - load_address;
+ img_size_set = true;
+ }
+ }
+ // Get the remaining fall-back values from the fis
+ if (img) {
+ if (!exec_addr_set) {
+ // Preserve "normal" behaviour
+ exec_addr_set = true;
+ exec_addr = flash_addr_set ? flash_addr : mem_addr;
+ }
+ if (!flash_addr_set) {
+ flash_addr_set = true;
+ flash_addr = img->flash_base;
+ defaults_assumed = true;
+ }
+ }
+
+ if ((!no_copy && !mem_addr_set) ||
+ !length_set || !name) {
+ fis_usage("required parameter missing");
+ return;
+ }
+ if (!img_size_set) {
+ img_size = length;
+ }
+ if (length < img_size) {
+ diag_printf("Invalid FLASH image size/length combination\n");
+ return;
+ }
+
+ if (strlen(name) >= sizeof(img->u.name)) {
+ diag_printf("Name is too long, must be less than %d chars\n", (int)sizeof(img->u.name));
+ return;
+ }
+
+ if (flash_addr_set &&
+ ((stat = flash_verify_addr((void *)flash_addr)) ||
+ (stat = flash_verify_addr((void *)(flash_addr+length-1))))) {
+ _show_invalid_flash_address(flash_addr, stat);
+ return;
+ }
+ if (!no_copy) {
+ if ((mem_addr < (CYG_ADDRESS)ram_start) ||
+ ((mem_addr+img_size) >= (CYG_ADDRESS)ram_end)) {
+ diag_printf("** WARNING: RAM address: %p may be invalid\n", (void *)mem_addr);
+ diag_printf(" valid range is %p-%p\n", (void *)ram_start, (void *)ram_end);
+ }
+ }
+ if (!flash_addr_set && !fis_find_free(&flash_addr, length)) {
+ diag_printf("Can't locate %lx(%ld) bytes free in FLASH\n", length, length);
+ return;
+ }
+ flash_addr_set = true;
+
+ block_size = cyg_flash_block_size(flash_addr + length);
+ length = ((length + block_size - 1) / block_size) * block_size;
+ if (length < img_size) {
+ diag_printf("Invalid FLASH image size/length combination\n");
+ return;
+ }
+ if ((stat = cyg_flash_verify_addr(flash_addr)) ||
+ (stat = cyg_flash_verify_addr((flash_addr+length-1)))) {
+ _show_invalid_flash_address(flash_addr, stat);
+ return;
+ }
+ block_size = cyg_flash_block_size(flash_addr);
+ flash_offset = (flash_addr-flash_start)/block_size;
+ if( flash_start + (flash_offset * block_size) != flash_addr ) {
+ diag_printf("Invalid FLASH address: %p\n", (void *)flash_addr);
+ diag_printf(" must be 0x%x aligned\n", (unsigned int)flash_block_size);
+ return;
+ }
+
+ // First, see if the image by this name has agreable properties
+ if (img) {
+ if (img->flash_base != flash_addr) {
+ diag_printf("Image found, but flash address (%p)\n"
+ " is incorrect (present image location %p)\n",
+ (void*)flash_addr, (void*)img->flash_base);
+
+ return;
+ }
+ if (img->size != length) {
+ diag_printf("Image found, but length (0x%lx, necessitating image size 0x%lx)\n"
+ " is incorrect (present image size 0x%lx)\n",
+ img_size, length, img->size);
+ return;
+ }
+ if (!verify_action("An image named '%s' exists", name)) {
+ return;
+ } else {
+ if (defaults_assumed) {
+ if (no_copy &&
+ !verify_action("* CAUTION * about to program '%s'\n at %p..%p from %p",
+ name, (void *)flash_addr, (void *)(flash_addr+img_size-1),
+ (void *)mem_addr)) {
+ return; // The guy gave up
+ }
+ }
+ }
+ } else {
+#ifdef CYGDAT_REDBOOT_FIS_MAX_FREE_CHUNKS
+ // Make sure that any FLASH address specified directly is truly free
+ if (!no_copy) {
+ struct free_chunk chunks[CYGDAT_REDBOOT_FIS_MAX_FREE_CHUNKS];
+ int idx, num_chunks;
+ bool is_free = false;
+
+ num_chunks = find_free(chunks);
+ for (idx = 0; idx < num_chunks; idx++) {
+ //diag_printf("addr %08x, length %d chunk start %08x, end %08x\n",flash_addr, length, chunks[idx].start, chunks[idx].end);
+ if ((flash_addr >= chunks[idx].start) &&
+ ((flash_addr+length-1) <= chunks[idx].end)) {
+ is_free = true;
+ }
+ }
+ if (!is_free) {
+ diag_printf("Invalid FLASH address - not free!\n");
+ return;
+ }
+ }
+#endif
+ // If no image by that name, try and find an empty slot
+ img = (struct fis_image_desc *)fis_work_block;
+ for (i = 0; i < fisdir_size/sizeof(*img); i++, img++) {
+ if (img->u.name[0] == '\xFF') {
+ break;
+ }
+ }
+ if (i >= fisdir_size/sizeof(*img)) {
+ diag_printf("Can't find an empty slot in FIS directory!\n");
+ return;
+ }
+ }
+ if (!no_copy) {
+ // Safety check - make sure the address range is not within the code we're running
+ if (check_code_overlaps(flash_addr, (flash_addr+img_size-1))) {
+ diag_printf("Can't program this region - contains code in use!\n");
+ return;
+ }
+#ifdef CYGHWR_IO_FLASH_BLOCK_LOCKING
+ if (prog_ok) {
+ // Unlock area to be programmed
+ if ((stat = cyg_flash_unlock((cyg_flashaddr_t)flash_addr, length, &err_addr)) != 0) {
+ diag_printf("Can't unlock region at %p: %s\n", (void*)err_addr, flash_errmsg(stat));
+ prog_ok = false;
+ }
+ }
+#endif
+ if (prog_ok) {
+ // Erase area to be programmed
+ if ((stat = cyg_flash_erase(flash_addr, length, &err_addr)) != 0) {
+ diag_printf("Can't erase region at %p: %s\n", (void*)err_addr, cyg_flash_errmsg(stat));
+ prog_ok = false;
+ }
+ }
+ if (prog_ok) {
+ // Now program it
+ if ((stat = cyg_flash_program(flash_addr, (void *)mem_addr, img_size,
+ &err_addr)) != 0) {
+ diag_printf("Can't program region at %p: %s\n", (void*)err_addr,
+ cyg_flash_errmsg(stat));
+ prog_ok = false;
+ }
+ }
+#ifdef CYGHWR_IO_FLASH_BLOCK_LOCKING
+ if (prog_ok) {
+ // Lock area programmed
+ if ((stat = cyg_flash_lock((cyg_flashaddr_t)flash_addr, length, &err_addr)) != 0) {
+ diag_printf("Can't lock region at %p: %s\n", (void*)err_addr, flash_errmsg(stat));
+ prog_ok = false;
+ }
+ }
+#endif
+ }
+ if (prog_ok) {
+ // Update directory
+ memset(img, 0, sizeof(*img));
+ strcpy(img->u.name, name);
+ img->flash_base = flash_addr;
+ img->mem_base = exec_addr_set ? exec_addr : (mem_addr_set ? mem_addr : flash_addr);
+ img->entry_point = entry_addr_set ? entry_addr : (CYG_ADDRESS)entry_address; // Hope it's been set
+ img->size = length;
+ img->data_length = img_size;
+#ifdef CYGSEM_REDBOOT_FIS_CRC_CHECK
+ if (!no_copy) {
+ img->file_cksum = cyg_crc32((unsigned char *)mem_addr, img_size);
+ } else {
+ // No way to compute this, sorry
+ img->file_cksum = 0;
+ }
+#endif
+ fis_start_update_directory(0);
+ fis_update_directory(0, 0);
+ }
+}
+
+extern void arm_fis_delete(char *);
+static void
+fis_delete(int argc, char *argv[])
+{
+ char *name;
+ int num_reserved, i, stat;
+ cyg_flashaddr_t err_addr;
+ struct fis_image_desc *img;
+
+ if (!scan_opts(argc, argv, 2, 0, 0, (void *)&name, OPTION_ARG_TYPE_STR, "image name"))
+ {
+ fis_usage("invalid arguments");
+ return;
+ }
+#ifdef CYGHWR_REDBOOT_ARM_FLASH_SIB
+ // FIXME: this is somewhat half-baked
+ arm_fis_delete(name);
+ return;
+#endif
+ img = (struct fis_image_desc *)fis_work_block;
+ num_reserved = 0;
+#ifdef CYGOPT_REDBOOT_FIS_RESERVED_BASE
+ num_reserved++;
+#endif
+#ifdef CYGOPT_REDBOOT_FIS_REDBOOT
+ num_reserved++;
+#endif
+#ifdef CYGOPT_REDBOOT_FIS_REDBOOT_BACKUP
+ num_reserved++;
+#endif
+#ifdef CYGOPT_REDBOOT_FIS_REDBOOT_POST
+ num_reserved++;
+#endif
+#if defined(CYGSEM_REDBOOT_FLASH_CONFIG) && defined(CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA_FLASH)
+ num_reserved++;
+#endif
+#if 1 // And the descriptor for the descriptor table itself
+ num_reserved++;
+#endif
+
+ img = fis_lookup(name, &i);
+ if (img) {
+ if (i < num_reserved) {
+ diag_printf("Sorry, '%s' is a reserved image and cannot be deleted\n", img->u.name);
+ return;
+ }
+ if (!verify_action("Delete image '%s'", name)) {
+ return;
+ }
+ } else {
+ diag_printf("No image '%s' found\n", name);
+ return;
+ }
+ // Erase Data blocks (free space)
+ if ((stat = cyg_flash_erase(img->flash_base, img->size, &err_addr)) != 0) {
+ diag_printf("Error erasing at %p: %s\n", (void*)err_addr, cyg_flash_errmsg(stat));
+ } else {
+ img->u.name[0] = '\xFF';
+ fis_start_update_directory(0);
+ fis_update_directory(0, 0);
+ }
+}
+
+static void
+fis_load(int argc, char *argv[])
+{
+ char *name;
+ struct fis_image_desc *img;
+ CYG_ADDRESS mem_addr;
+ bool mem_addr_set = false;
+ bool show_cksum = false;
+ struct option_info opts[3];
+#if defined(CYGSEM_REDBOOT_FIS_CRC_CHECK)
+ unsigned long cksum;
+#endif
+ int num_options;
+#if defined(CYGPRI_REDBOOT_ZLIB_FLASH) || defined(CYGSEM_REDBOOT_FIS_CRC_CHECK)
+ bool decompress = false;
+#endif
+ cyg_flashaddr_t err_addr;
+
+ init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM,
+ (void *)&mem_addr, (bool *)&mem_addr_set, "memory [load] base address");
+ init_opts(&opts[1], 'c', false, OPTION_ARG_TYPE_FLG,
+ (void *)&show_cksum, (bool *)0, "display checksum");
+ num_options = 2;
+#ifdef CYGPRI_REDBOOT_ZLIB_FLASH
+ init_opts(&opts[num_options], 'd', false, OPTION_ARG_TYPE_FLG,
+ (void *)&decompress, 0, "decompress");
+ num_options++;
+#endif
+
+ CYG_ASSERT(num_options <= NUM_ELEMS(opts), "Too many options");
+
+ if (!scan_opts(argc, argv, 2, opts, num_options, (void *)&name, OPTION_ARG_TYPE_STR, "image name"))
+ {
+ fis_usage("invalid arguments");
+ return;
+ }
+ if ((img = fis_lookup(name, NULL)) == (struct fis_image_desc *)0) {
+ diag_printf("No image '%s' found\n", name);
+ return;
+ }
+ if (!mem_addr_set) {
+ mem_addr = img->mem_base;
+ }
+ // Load image from FLASH into RAM
+#ifdef CYGSEM_REDBOOT_VALIDATE_USER_RAM_LOADS
+ if (!valid_address((void *)mem_addr)) {
+ diag_printf("Not a loadable image - try using -b ADDRESS option\n");
+ return;
+ }
+#endif
+#ifdef CYGPRI_REDBOOT_ZLIB_FLASH
+ if (decompress) {
+ int err;
+ _pipe_t fis_load_pipe;
+ _pipe_t* p = &fis_load_pipe;
+ p->out_buf = (unsigned char*) mem_addr;
+ p->out_max = p->out_size = -1;
+ p->in_buf = (unsigned char*) img->flash_base;
+ p->in_avail = img->data_length;
+
+ err = (*_dc_init)(p);
+
+ if (0 == err)
+ err = (*_dc_inflate)(p);
+
+ // Free used resources, do final translation of
+ // error value.
+ err = (*_dc_close)(p, err);
+
+ if (0 != err && p->msg) {
+ diag_printf("decompression error: %s\n", p->msg);
+ } else {
+ diag_printf("Image loaded from %p-%p\n", (unsigned char *)mem_addr, p->out_buf);
+ }
+
+ // Set load address/top
+ load_address = mem_addr;
+ load_address_end = (unsigned long)p->out_buf;
+
+ // Reload fis directory
+ fis_read_directory();
+ } else // dangling block
+#endif
+ {
+ cyg_flash_read(img->flash_base, (void *)mem_addr, img->data_length,
+ &err_addr);
+
+ // Set load address/top
+ load_address = mem_addr;
+ load_address_end = mem_addr + img->data_length;
+ }
+ entry_address = (unsigned long)img->entry_point;
+
+#ifdef CYGSEM_REDBOOT_FIS_CRC_CHECK
+ cksum = cyg_crc32((unsigned char *)mem_addr, img->data_length);
+ if (show_cksum) {
+ diag_printf("Checksum: 0x%08lx\n", cksum);
+ }
+ // When decompressing, leave CRC checking to decompressor
+ if (!decompress && img->file_cksum) {
+ if (cksum != img->file_cksum) {
+ diag_printf("** Warning - checksum failure. stored: 0x%08lx, computed: 0x%08lx\n",
+ img->file_cksum, cksum);
+ entry_address = (unsigned long)NO_MEMORY;
+ }
+ }
+#endif
+}
+#endif // CYGOPT_REDBOOT_FIS
+
+static void
+fis_write(int argc, char *argv[])
+{
+ int stat;
+ unsigned long length;
+ CYG_ADDRESS mem_addr, flash_addr, flash_offset;
+ bool mem_addr_set = false;
+ bool flash_addr_set = false;
+ bool length_set = false;
+ cyg_flashaddr_t err_addr;
+ struct option_info opts[3];
+ bool prog_ok;
+ size_t block_size;
+
+ init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM,
+ (void *)&mem_addr, (bool *)&mem_addr_set, "memory base address");
+ init_opts(&opts[1], 'f', true, OPTION_ARG_TYPE_NUM,
+ (void *)&flash_addr, (bool *)&flash_addr_set, "FLASH memory base address");
+ init_opts(&opts[2], 'l', true, OPTION_ARG_TYPE_NUM,
+ (void *)&length, (bool *)&length_set, "image length [in FLASH]");
+ if (!scan_opts(argc, argv, 2, opts, 3, 0, 0, 0))
+ {
+ fis_usage("invalid arguments");
+ return;
+ }
+
+ if (!mem_addr_set || !flash_addr_set || !length_set) {
+ fis_usage("required parameter missing");
+ return;
+ }
+
+ // Round up length to FLASH block size
+ block_size = cyg_flash_block_size(flash_addr + length);
+ length = ((length + block_size - 1) / block_size) * block_size;
+ if ((stat = cyg_flash_verify_addr(flash_addr)) ||
+ (stat = cyg_flash_verify_addr((flash_addr+length-1)))) {
+ _show_invalid_flash_address(flash_addr, stat);
+ return;
+ }
+
+ block_size = cyg_flash_block_size(flash_addr);
+ flash_offset = (flash_addr-flash_start)/block_size;
+ if( flash_start + (flash_offset * block_size) != flash_addr ) {
+ diag_printf("Invalid FLASH address: %p\n", (void *)flash_addr);
+ diag_printf(" must be 0x%x aligned\n", (unsigned int)block_size);
+ return;
+ }
+ if ((mem_addr < (CYG_ADDRESS)ram_start) ||
+ ((mem_addr+length) >= (CYG_ADDRESS)ram_end)) {
+ diag_printf("** WARNING: RAM address: %p may be invalid\n", (void *)mem_addr);
+ diag_printf(" valid range is %p-%p\n", (void *)ram_start, (void *)ram_end);
+ }
+ // Safety check - make sure the address range is not within the code we're running
+ if (check_code_overlaps(flash_addr, (flash_addr+length-1))) {
+ diag_printf("Can't program this region - contains code in use!\n");
+ return;
+ }
+ if (!verify_action("* CAUTION * about to program FLASH\n at %p..%p from %p",
+ (void *)flash_addr, (void *)(flash_addr+length-1),
+ (void *)mem_addr)) {
+ return; // The guy gave up
+ }
+ prog_ok = true;
+ if (prog_ok) {
+ // Erase area to be programmed
+ if ((stat = cyg_flash_erase(flash_addr, length, &err_addr)) != 0) {
+ diag_printf("Can't erase region at %p: %s\n", (void*)err_addr,
+ cyg_flash_errmsg(stat));
+ prog_ok = false;
+ }
+ }
+ if (prog_ok) {
+ // Now program it
+ if ((stat = cyg_flash_program(flash_addr, (void *)mem_addr, length,
+ &err_addr)) != 0) {
+ diag_printf("Can't program region at %p: %s\n", (void*)err_addr,
+ cyg_flash_errmsg(stat));
+ prog_ok = false;
+ }
+ }
+}
+
+static void
+fis_erase(int argc, char *argv[])
+{
+ int stat;
+ unsigned long length;
+ CYG_ADDRESS flash_addr, flash_offset;
+ bool flash_addr_set = false;
+ bool length_set = false;
+ cyg_flashaddr_t err_addr;
+ struct option_info opts[2];
+ size_t block_size;
+
+
+ init_opts(&opts[0], 'f', true, OPTION_ARG_TYPE_NUM,
+ (void *)&flash_addr, (bool *)&flash_addr_set, "FLASH memory base address");
+ init_opts(&opts[1], 'l', true, OPTION_ARG_TYPE_NUM,
+ (void *)&length, (bool *)&length_set, "length");
+ if (!scan_opts(argc, argv, 2, opts, 2, (void **)0, 0, ""))
+ {
+ fis_usage("invalid arguments");
+ return;
+ }
+
+ if (!flash_addr_set || !length_set) {
+ fis_usage("missing argument");
+ return;
+ }
+ if (flash_addr_set &&
+ ((stat = cyg_flash_verify_addr(flash_addr)) ||
+ (stat = cyg_flash_verify_addr((flash_addr+length-1))))) {
+ _show_invalid_flash_address(flash_addr, stat);
+ return;
+ }
+ block_size = cyg_flash_block_size(flash_addr);
+ flash_offset = (flash_addr-flash_start)/block_size;
+ if( flash_addr_set && (flash_start + (flash_offset * block_size) != flash_addr) ) {
+ diag_printf("Invalid FLASH address: %p\n", (void *)flash_addr);
+ diag_printf(" must be 0x%x aligned\n", (unsigned int)flash_block_size);
+ return;
+ }
+ // Safety check - make sure the address range is not within the code we're running
+ if (check_code_overlaps(flash_addr, (flash_addr+length-1))) {
+ diag_printf("Can't erase this region - contains code in use!\n");
+ return;
+ }
+ if ((stat = cyg_flash_erase(flash_addr, length, &err_addr)) != 0) {
+ diag_printf("Error erasing at %p: %s\n", (void*)err_addr, cyg_flash_errmsg(stat));
+ }
+}
+
+#ifdef CYGHWR_IO_FLASH_BLOCK_LOCKING
+
+static void
+fis_lock(int argc, char *argv[])
+{
+ char *name;
+ int stat;
+ unsigned long length;
+ CYG_ADDRESS flash_addr;
+ bool flash_addr_set = false;
+ bool length_set = false;
+ cyg_flashaddr_t err_addr;
+ struct option_info opts[2];
+
+ init_opts(&opts[0], 'f', true, OPTION_ARG_TYPE_NUM,
+ (void *)&flash_addr, (bool *)&flash_addr_set, "FLASH memory base address");
+ init_opts(&opts[1], 'l', true, OPTION_ARG_TYPE_NUM,
+ (void *)&length, (bool *)&length_set, "length");
+ if (!scan_opts(argc, argv, 2, opts, 2, &name, OPTION_ARG_TYPE_STR, "image name"))
+ {
+ fis_usage("invalid arguments");
+ return;
+ }
+#ifdef CYGOPT_REDBOOT_FIS
+ /* Get parameters from image if specified */
+ if (name) {
+ struct fis_image_desc *img;
+ if ((img = fis_lookup(name, NULL)) == (struct fis_image_desc *)0) {
+ diag_printf("No image '%s' found\n", name);
+ return;
+ }
+
+ flash_addr = img->flash_base;
+ length = img->size;
+ } else
+#endif
+ if (!flash_addr_set || !length_set) {
+ fis_usage("missing argument");
+ return;
+ }
+ if (flash_addr_set &&
+ ((stat = cyg_flash_verify_addr(flash_addr)) ||
+ (stat = cyg_flash_verify_addr((flash_addr+length-1))))) {
+ _show_invalid_flash_address(flash_addr, stat);
+ return;
+ }
+ if ((stat = cyg_flash_lock(flash_addr, length, &err_addr)) != 0) {
+ diag_printf("Error locking at %p: %s\n", (void*)err_addr, cyg_flash_errmsg(stat));
+ }
+}
+
+static void
+fis_unlock(int argc, char *argv[])
+{
+ char *name;
+ int stat;
+ unsigned long length;
+ CYG_ADDRESS flash_addr;
+ bool flash_addr_set = false;
+ bool length_set = false;
+ cyg_flashaddr_t err_addr;
+ struct option_info opts[2];
+
+ init_opts(&opts[0], 'f', true, OPTION_ARG_TYPE_NUM,
+ (void *)&flash_addr, (bool *)&flash_addr_set, "FLASH memory base address");
+ init_opts(&opts[1], 'l', true, OPTION_ARG_TYPE_NUM,
+ (void *)&length, (bool *)&length_set, "length");
+ if (!scan_opts(argc, argv, 2, opts, 2, &name, OPTION_ARG_TYPE_STR, "image name"))
+ {
+ fis_usage("invalid arguments");
+ return;
+ }
+#ifdef CYGOPT_REDBOOT_FIS
+ if (name) {
+ struct fis_image_desc *img;
+ if ((img = fis_lookup(name, NULL)) == (struct fis_image_desc *)0) {
+ diag_printf("No image '%s' found\n", name);
+ return;
+ }
+
+ flash_addr = img->flash_base;
+ length = img->size;
+ } else
+#endif
+ if (!flash_addr_set || !length_set) {
+ fis_usage("missing argument");
+ return;
+ }
+ if (flash_addr_set &&
+ ((stat = cyg_flash_verify_addr(flash_addr)) ||
+ (stat = cyg_flash_verify_addr((flash_addr+length-1))))) {
+ _show_invalid_flash_address(flash_addr, stat);
+ return;
+ }
+
+ if ((stat = cyg_flash_unlock(flash_addr, length, &err_addr)) != 0) {
+ diag_printf("Error unlocking at %p: %s\n", (void*)err_addr, cyg_flash_errmsg(stat));
+ }
+}
+#endif
+
+// This is set non-zero if the FLASH subsystem has successfully been initialized
+int __flash_init;
+
+void
+_flash_info(void)
+{
+ cyg_uint32 i=0,j;
+ cyg_flash_info_t info;
+ int ret;
+
+ if (!__flash_init) return;
+
+ do {
+ ret = cyg_flash_get_info(i, &info);
+ if (ret == CYG_FLASH_ERR_OK) {
+ diag_printf("FLASH: %p-%p", (void*)info.start, (void*)info.end);
+ for (j=0;j < info.num_block_infos; j++) {
+ diag_printf(", %d x 0x%x blocks",
+ info.block_info[j].blocks,
+ (unsigned int)info.block_info[j].block_size);
+ }
+ diag_printf("\n");
+ }
+ i++;
+ } while (ret != CYG_FLASH_ERR_INVALID);
+}
+
+/* Returns -1 on failure, 0 on success, 1 if it was successfull
+ but a failed fis update was detected */
+int
+do_flash_init(void)
+{
+ int stat, i;
+ cyg_flash_info_t info;
+
+#ifdef CYGOPT_REDBOOT_REDUNDANT_FIS
+ struct fis_image_desc img0;
+ struct fis_image_desc img1;
+ int fis_update_was_interrupted=0;
+ cyg_flashaddr_t err_addr;
+
+ //check the size of fis_valid_info
+ CYG_ASSERT((sizeof(struct fis_valid_info)<=sizeof(img0.u.name)), "fis_valid_info size mismatch");
+ //try to check the alignment of version_count
+ CYG_ASSERT((((unsigned long)&img0.u.valid_info.version_count - (unsigned long)&img0) % sizeof(unsigned long) == 0), "alignment problem");
+#endif
+
+
+
+ if (!__flash_init) {
+ __flash_init = 1;
+
+ cyg_flash_set_global_printf((cyg_flash_printf *)&diag_printf);
+ if ((stat = cyg_flash_init(NULL)) != 0) {
+ diag_printf("FLASH: driver init failed: %s\n", cyg_flash_errmsg(stat));
+ return -1;
+ }
+
+#ifdef CYGNUM_REDBOOT_FLASH_BASE
+ stat = cyg_flash_get_info_addr(CYGNUM_REDBOOT_FLASH_BASE, &info);
+#else
+ stat = cyg_flash_get_info(0, &info);
+#endif
+ if (stat != CYG_FLASH_ERR_OK) {
+ diag_printf("FLASH: driver init failed: %s\n",
+ cyg_flash_errmsg(stat));
+ return false;
+ }
+ flash_start = info.start;
+ flash_end = info.end;
+
+ // No bootblock support yet, so we merge any bootblocks we might
+ // find into full size blocks
+ for (i=0; i < info.num_block_infos; i++) {
+ if (info.block_info[i].block_size > flash_block_size) {
+ flash_block_size = info.block_info[i].block_size;
+ }
+ }
+ flash_num_blocks = 0;
+ for (i=0; i < info.num_block_infos; i++) {
+ flash_num_blocks += (info.block_info[i].block_size *
+ info.block_info[i].blocks) /
+ flash_block_size;
+ }
+
+#ifdef CYGOPT_REDBOOT_FIS
+ fisdir_size = CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_COUNT * CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_SIZE;
+ fisdir_size = ((fisdir_size + flash_block_size - 1) / flash_block_size) * flash_block_size;
+# if defined(CYGPRI_REDBOOT_ZLIB_FLASH) && defined(CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER)
+ fis_work_block = fis_zlib_common_buffer;
+ if(CYGNUM_REDBOOT_FIS_ZLIB_COMMON_BUFFER_SIZE < fisdir_size) {
+ diag_printf("FLASH: common buffer too small\n");
+ return -1;
+ }
+# else
+ workspace_end = (unsigned char *)(workspace_end-fisdir_size);
+ fis_work_block = workspace_end;
+# endif
+
+ if (CYGNUM_REDBOOT_FIS_DIRECTORY_BLOCK < 0) {
+ fis_addr = ((CYG_ADDRESS)flash_end + 1 +
+ (CYGNUM_REDBOOT_FIS_DIRECTORY_BLOCK*flash_block_size));
+ } else {
+ fis_addr = ((CYG_ADDRESS)flash_start +
+ (CYGNUM_REDBOOT_FIS_DIRECTORY_BLOCK*flash_block_size));
+ }
+
+ if (((CYG_ADDRESS)fis_addr + fisdir_size - 1) > (CYG_ADDRESS)flash_end) {
+ diag_printf("FIS directory doesn't fit\n");
+ return -1;
+ }
+#ifdef CYGOPT_REDBOOT_REDUNDANT_FIS
+
+ if (CYGNUM_REDBOOT_FIS_REDUNDANT_DIRECTORY_BLOCK < 0) {
+ redundant_fis_addr = ((CYG_ADDRESS)flash_end + 1 +
+ (CYGNUM_REDBOOT_FIS_REDUNDANT_DIRECTORY_BLOCK*flash_block_size));
+ } else {
+ redundant_fis_addr = ((CYG_ADDRESS)flash_start +
+ (CYGNUM_REDBOOT_FIS_REDUNDANT_DIRECTORY_BLOCK*flash_block_size));
+ }
+
+ if (((CYG_ADDRESS)redundant_fis_addr + fisdir_size - 1) > (CYG_ADDRESS)flash_end) {
+ diag_printf("Redundant FIS directory doesn't fit\n");
+ return -1;
+ }
+ cyg_flash_read(fis_addr, &img0, sizeof(img0), &err_addr);
+ cyg_flash_read(redundant_fis_addr, &img1, sizeof(img1), &err_addr);
+
+ if (strncmp(img0.u.valid_info.magic_name, CYG_REDBOOT_RFIS_VALID_MAGIC, CYG_REDBOOT_RFIS_VALID_MAGIC_LENGTH)!=0)
+ {
+ memset(&img0, 0, sizeof(img0));
+ }
+
+ if (strncmp(img1.u.valid_info.magic_name, CYG_REDBOOT_RFIS_VALID_MAGIC, CYG_REDBOOT_RFIS_VALID_MAGIC_LENGTH)!=0)
+ {
+ memset(&img1, 0, sizeof(img0));
+ }
+
+#ifdef REDBOOT_FLASH_REVERSE_BYTEORDER
+ img0.u.valid_info.version_count = CYG_SWAP32(img0.u.valid_info.version_count);
+ img1.u.valid_info.version_count = CYG_SWAP32(img1.u.valid_info.version_count);
+#endif
+
+ if (fis_get_valid_buf(&img0, &img1, &fis_update_was_interrupted)==1)
+ {
+ // Valid, so swap primary and secondary
+ cyg_flashaddr_t tmp;
+ tmp = fis_addr;
+ fis_addr = redundant_fis_addr;
+ redundant_fis_addr = tmp;
+ }
+#endif
+ fis_read_directory();
+#endif
+ }
+#ifdef CYGOPT_REDBOOT_REDUNDANT_FIS
+ if (fis_update_was_interrupted)
+ return 1;
+ else
+ return 0;
+#else
+ return 0;
+#endif
+}
+
+// Wrapper to avoid compiler warnings
+static void
+_do_flash_init(void)
+{
+ static int init_done = 0;
+ if (init_done) return;
+ init_done = 1;
+ do_flash_init();
+}
+
+RedBoot_init(_do_flash_init, RedBoot_INIT_FIRST);
+
+static void
+do_fis(int argc, char *argv[])
+{
+ struct cmd *cmd;
+
+ if (argc < 2) {
+ fis_usage("too few arguments");
+ return;
+ }
+ if (do_flash_init()<0) {
+ diag_printf("Sorry, no FLASH memory is available\n");
+ return;
+ }
+ if ((cmd = cmd_search(__FIS_cmds_TAB__, &__FIS_cmds_TAB_END__,
+ argv[1])) != (struct cmd *)0) {
+ (cmd->fun)(argc, argv);
+ return;
+ }
+ fis_usage("unrecognized command");
+}
+
+// EOF flash.c
diff --git a/ecos/packages/redboot/current/src/flash_load.c b/ecos/packages/redboot/current/src/flash_load.c
new file mode 100644
index 0000000..1cb3fb7
--- /dev/null
+++ b/ecos/packages/redboot/current/src/flash_load.c
@@ -0,0 +1,182 @@
+//==========================================================================
+//
+// flash_load.c
+//
+// RedBoot file/image loader into flash
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2006 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): Oliver Munz
+// Contributors: om, asl
+// Date: 2006-02-21
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+#include <flash_load.h>
+
+#include <cyg/io/flash.h>
+#include <cyg/infra/cyg_ass.h>
+
+static int flash_block_size;
+
+static cyg_uint8 * current_flash_page;
+
+/* Allocation of the flash-sector size RAM-buffer is done */
+static bool init_done = false;
+
+/* We have initialized the current page ready for writing */
+static bool flash_page_init = false;
+
+static cyg_uint8 *flash_buffer;
+
+// If the io flash code outputs when erasing/writing it will upset the
+// download over the communications channel. So we install a dummy
+// print function.
+static int dummy_printf(const char *fmt, ...){
+ return 0;
+}
+
+// Calculate the address of the first byte in a flash block
+static cyg_uint8 * flash_block_begin(cyg_uint32 addr)
+{
+ return (cyg_uint8 *)
+ ((addr / flash_block_size) * flash_block_size);
+}
+
+// Initialize the loading process
+void flash_load_start(void)
+{
+ flash_init(dummy_printf);
+
+ init_done = true;
+ flash_page_init = false;
+}
+
+// Write a byte into flash. We maintain a copy in RAM of the FLASH
+// page we are currently "writing" into. This copy is loaded with the
+// current contents of the FLASH page when the first byte is "written"
+// to the page. The "writes" are then made into the RAM copy. We only
+// write to FLASH when there is a "write" outside of the current page,
+// or the flash_load_finish function is called.
+void flash_load_write(cyg_uint8 *flash_addr, cyg_uint8 value)
+{
+
+ cyg_uint32 retcode = FLASH_ERR_OK;
+ void * err_addr;
+ cyg_uint32 addr = (cyg_uint32)flash_addr;
+ cyg_uint32 offset;
+
+ if (!flash_page_init) {
+ /* First Byte for the current flash block. Read the current contents */
+ current_flash_page = flash_block_begin(addr);
+ flash_read(flash_buffer, current_flash_page, flash_block_size, &err_addr);
+ flash_page_init = true;
+ }
+ if (flash_block_begin(addr) != current_flash_page) {
+ /* We have moved into the next flash page. Write the current
+ page so we can move on */
+ retcode = flash_erase(current_flash_page, flash_block_size, &err_addr);
+ if (retcode != FLASH_ERR_OK){ /* Flash ERROR */
+ diag_printf("Error erase at %p: %s\n", err_addr, flash_errmsg(retcode));
+ return;
+ }
+
+ retcode = flash_program(current_flash_page, flash_buffer,
+ flash_block_size, &err_addr);
+ if (retcode != FLASH_ERR_OK){
+ diag_printf("Error writing at %p: %s\n",
+ err_addr, flash_errmsg(retcode));
+ return;
+ }
+ current_flash_page = flash_block_begin(addr);
+ flash_read(flash_buffer, current_flash_page, flash_block_size, &err_addr);
+ }
+
+ offset = flash_addr - current_flash_page;
+ CYG_ASSERT(offset < flash_block_size, "offset not inside flash block");
+
+ flash_buffer[offset] = value;
+}
+
+// Program the current page into flash.
+void flash_load_finish(void)
+{
+ cyg_uint32 retcode = FLASH_ERR_OK;
+ void * err_addr;
+
+ if (init_done && flash_page_init) {
+ flash_page_init = false;
+
+ retcode = flash_erase(current_flash_page, flash_block_size, &err_addr);
+ if (retcode != FLASH_ERR_OK){
+ diag_printf("Error erase at %p: %s\n", err_addr, flash_errmsg(retcode));
+ } else {
+ retcode = flash_program(current_flash_page, flash_buffer,
+ flash_block_size, &err_addr);
+ if (retcode != FLASH_ERR_OK){
+ diag_printf("Error writing at %p: %s\n",
+ err_addr, flash_errmsg(retcode));
+ }
+ }
+ }
+ flash_init(diag_printf);
+}
+
+// This is called during redboot start up. We allocate a buffer the
+// size of the flash page.
+void
+flash_load_init(void)
+{
+ int flash_blocks;
+
+ flash_get_block_info(&flash_block_size, &flash_blocks);
+ workspace_end -= flash_block_size;
+
+ flash_buffer = workspace_end;
+}
+
+// Register this initialization function in the table
+RedBoot_init(flash_load_init, RedBoot_INIT_LAST);
+
+
+
diff --git a/ecos/packages/redboot/current/src/flash_load.h b/ecos/packages/redboot/current/src/flash_load.h
new file mode 100644
index 0000000..14e1b8c
--- /dev/null
+++ b/ecos/packages/redboot/current/src/flash_load.h
@@ -0,0 +1,68 @@
+//==========================================================================
+//
+// flash_load.h
+//
+// Interfaces to byte writing into FLASH during load
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2006 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): Oliver Munz
+// Contributors: om, asl
+// Date: 2005-02-21
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#ifndef FLASH_LOAD_H
+#define FLASH_LOAd_H
+
+// Prepare a write to flash.
+void flash_load_start(void);
+
+// Finish a write to flash
+void flash_load_finish(void);
+
+// Write a single byte. This will be buffered until either a full page
+// is available or flash_write_finish is called.
+void flash_load_write(cyg_uint8 *addr, cyg_uint8 value);
+
+#endif // FLASH_LOAD_H
+
diff --git a/ecos/packages/redboot/current/src/fs/disk.c b/ecos/packages/redboot/current/src/fs/disk.c
new file mode 100644
index 0000000..432a2bc
--- /dev/null
+++ b/ecos/packages/redboot/current/src/fs/disk.c
@@ -0,0 +1,439 @@
+//==========================================================================
+//
+// disk.c
+//
+// RedBoot disk support
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): msalter
+// Contributors: msalter
+// Date: 2001-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+#include <fs/disk.h>
+
+#ifdef CYGSEM_REDBOOT_DISK_EXT2FS
+#include <fs/e2fs.h>
+#endif
+#ifdef CYGSEM_REDBOOT_DISK_ISO9660
+#include <fs/iso9660fs.h>
+#endif
+
+static void do_disks(int argc, char *argv[]);
+
+RedBoot_cmd("disks",
+ "Display disks/partitions.",
+ "",
+ do_disks
+ );
+
+static disk_t disk_table[CYGNUM_REDBOOT_MAX_DISKS];
+static int disk_count = 0;
+
+static inline cyg_uint32
+u32_unaligned(void *p)
+{
+ cyg_uint32 val;
+ char *d = (char *)&val;
+ char *s = p;
+ int i;
+
+ for (i = 0; i < 4; i++)
+ *d++ = *s++;
+
+ return val;
+}
+
+static int
+find_dos_partitions(disk_t *d, cyg_uint8 *mbr)
+{
+ cyg_uint32 s, n;
+ struct mbr_partition *p;
+ int i, found = 0;
+
+ p = (struct mbr_partition *)(mbr + MBR_PTABLE_OFFSET);
+
+ // Look for primary partitions
+ for (i = 0; i < 4 && i < CYGNUM_REDBOOT_MAX_PARTITIONS; i++) {
+
+ s = SWAB_LE32(u32_unaligned(p->start_sect));
+ n = SWAB_LE32(u32_unaligned(p->nr_sects));
+
+ if (s && n) {
+ ++found;
+ d->partitions[i].disk = d;
+ d->partitions[i].start_sector = s;
+ d->partitions[i].nr_sectors = n;
+ d->partitions[i].systype = p->sys_ind;
+ d->partitions[i].bootflag = p->boot_ind;
+ }
+ p++;
+ }
+
+#if CYGNUM_REDBOOT_MAX_PARTITIONS > 4
+ {
+ cyg_uint32 buf[SECTOR_SIZE/sizeof(cyg_uint32)], xoffset;
+ cyg_uint16 magic;
+ int nextp;
+
+ // Go back through and find extended partitions
+ for (i = 0, nextp = 4; i < 4 && nextp < CYGNUM_REDBOOT_MAX_PARTITIONS; i++) {
+ if (d->partitions[i].systype == SYSTYPE_EXTENDED) {
+ // sector offsets in partition tables are relative to start
+ // of extended partition.
+ xoffset = d->partitions[i].start_sector;
+ for ( ; nextp < CYGNUM_REDBOOT_MAX_PARTITIONS; ++nextp) {
+
+ // read partition boot record (same format as mbr except
+ // there should only be 2 entries max: a normal partition
+ // and another extended partition
+ if (DISK_READ(d, xoffset, buf, 1) <= 0)
+ break;
+
+ magic = *(cyg_uint16 *)((char *)buf + MBR_MAGIC_OFFSET);
+ if (SWAB_LE16(magic) != MBR_MAGIC)
+ break;
+
+ p = (struct mbr_partition *)((char *)buf + MBR_PTABLE_OFFSET);
+
+ s = SWAB_LE32(u32_unaligned(p->start_sect));
+ n = SWAB_LE32(u32_unaligned(p->nr_sects));
+
+ if (s && n) {
+ ++found;
+ d->partitions[nextp].disk = d;
+ d->partitions[nextp].start_sector = s + xoffset;
+ d->partitions[nextp].nr_sectors = n;
+ d->partitions[nextp].systype = p->sys_ind;
+ d->partitions[nextp].bootflag = p->boot_ind;
+ }
+ ++p;
+
+ s = SWAB_LE32(u32_unaligned(p->start_sect));
+ n = SWAB_LE32(u32_unaligned(p->nr_sects));
+
+ // more extended partitions?
+ if (p->sys_ind != SYSTYPE_EXTENDED || !s || !n)
+ break;
+
+ xoffset += s;
+ }
+ }
+ }
+ }
+#endif
+ return found;
+}
+
+
+// Find partitions on given disk.
+// Return number of partitions found
+static int
+find_partitions(disk_t *d)
+{
+ cyg_uint32 buf[SECTOR_SIZE/sizeof(cyg_uint32)];
+ cyg_uint16 magic;
+ partition_t *p;
+ int i, found = 0;
+
+
+ if (d->kind == DISK_IDE_CDROM) {
+#ifdef CYGSEM_REDBOOT_DISK_ISO9660
+ // no partition table, so fake it
+ p = d->partitions;
+ p->disk = d;
+ p->start_sector = 0;
+ p->nr_sectors = d->nr_sectors;
+ p->funs = &redboot_iso9660fs_funs;
+ return 1;
+#else
+ return 0;
+#endif
+ }
+
+ // read Master Boot Record
+ if (DISK_READ(d, 0, buf, 1) <= 0)
+ return 0;
+
+ // Check for DOS MBR
+ magic = *(cyg_uint16 *)((char *)buf + MBR_MAGIC_OFFSET);
+ if (SWAB_LE16(magic) == MBR_MAGIC) {
+ found = find_dos_partitions(d, (cyg_uint8 *)buf);
+ } else {
+ // Might want to handle other MBR types, here...
+ }
+
+ // Now go through all partitions and install the correct
+ // funcs for supported filesystems.
+ for (i = 0, p = d->partitions; i < CYGNUM_REDBOOT_MAX_PARTITIONS; i++, p++) {
+ switch (p->systype) {
+#ifdef CYGSEM_REDBOOT_DISK_EXT2FS
+ case SYSTYPE_LINUX:
+ p->funs = &redboot_e2fs_funs;
+ break;
+#endif
+#ifdef CYGSEM_REDBOOT_DISK_FAT16
+ case SYSTYPE_FAT16:
+ p->funs = &redboot_fat16_funs;
+ break;
+#endif
+#ifdef CYGSEM_REDBOOT_DISK_FAT32
+ case SYSTYPE_FAT32:
+ p->funs = &redboot_fat32_funs;
+ break;
+#endif
+ default:
+ break; // ignore unsupported filesystems
+ }
+ }
+
+ return found;
+}
+
+// Add a disk to the disk table.
+// Return zero if no more room in table.
+externC int
+disk_register(disk_t *d)
+{
+ int i;
+
+ // make sure we have room for it
+ if (disk_count >= CYGNUM_REDBOOT_MAX_DISKS)
+ return 0;
+
+ // Set the index
+ d->index = 0;
+ for (i = 0; i < disk_count; i++)
+ if (disk_table[i].kind == d->kind)
+ d->index++;
+
+ // put it in the table
+ disk_table[disk_count] = *d;
+
+ // fill in partition info
+ find_partitions(&disk_table[disk_count++]);
+
+ return 1;
+}
+
+// Convert a filename in the form <partition_name>:<filename> into
+// a partition and path.
+//
+static int
+disk_parse_filename(const char *name, partition_t **part, const char **path)
+{
+ int i, kind, index, pindex;
+
+ kind = index = pindex = 0;
+
+ if (name[0] == 'h' && name[1] == 'd') {
+ // IDE hard drives
+ kind = DISK_IDE_HD;
+ if (name[2] < 'a' || name[2] > 'z')
+ return 0;
+ index = name[2] - 'a';
+ if (name[3] < '1' || name[3] >= ('1' + CYGNUM_REDBOOT_MAX_PARTITIONS))
+ return 0;
+ pindex = name[3] - '1';
+ if (name[4] != ':')
+ return 0;
+ *path = &name[5];
+ }
+#ifdef CYGSEM_REDBOOT_DISK_ISO9660
+ else if (name[0] == 'c' && name[1] == 'd') {
+ // CD drives
+ kind = DISK_IDE_CDROM;
+ if (name[2] < '0' || name[2] > '9')
+ return 0;
+ index = name[2] - '0';
+ if (name[3] != ':')
+ return 0;
+ *path = &name[4];
+ }
+#endif
+
+ if (kind) {
+ for (i = 0; i < CYGNUM_REDBOOT_MAX_DISKS; i++) {
+ if (disk_table[i].kind == kind && disk_table[i].index == index) {
+ *part = &disk_table[i].partitions[pindex];
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+static const struct {
+ int kind;
+ const char *str;
+} systype_names[] = {
+ { SYSTYPE_FAT12, "FAT12" },
+ { SYSTYPE_FAT16_32M, "FAT16 <32M" },
+ { SYSTYPE_FAT16, "FAT16" },
+ { SYSTYPE_EXTENDED, "Extended" },
+ { SYSTYPE_LINUX_SWAP, "Linux Swap" },
+ { SYSTYPE_LINUX, "Linux" }
+};
+
+static const char *
+systype_name(int systype)
+{
+ int i;
+
+ for (i = 0; i < sizeof(systype_names)/sizeof(systype_names[0]); i++)
+ if (systype_names[i].kind == systype)
+ return systype_names[i].str;
+ return "Unknown";
+}
+
+// List disk partitions
+static void
+do_disks(int argc, char *argv[])
+{
+ int i, j;
+ disk_t *d;
+ partition_t *p;
+ char name[16];
+
+ for (i = 0, d = disk_table; i < disk_count; i++, d++) {
+ switch (d->kind) {
+ case DISK_IDE_HD:
+ for (j = 0, p = d->partitions;
+ j < CYGNUM_REDBOOT_MAX_PARTITIONS;
+ j++, p++) {
+ if (p->systype) {
+ diag_sprintf(name, "hd%c%d", 'a' + d->index, j+1);
+ diag_printf("%-8s %s\n", name, systype_name(p->systype));
+ }
+ }
+ break;
+ case DISK_IDE_CDROM:
+ diag_sprintf(name, "cd%d", d->index);
+ diag_printf("%-8s ISO9660\n", name);
+ break;
+ }
+ }
+}
+
+static void *fileptr;
+static partition_t *file_part;
+
+externC int
+disk_stream_open(connection_info_t *info, int *err)
+{
+ const char *filepath;
+ char *filename = info->filename;
+
+ // The filename is in <disk>:<path> format.
+ // Convert to a partition and path.
+ if (!disk_parse_filename(filename, &file_part, &filepath)) {
+ *err = diskerr_badname;
+ return -1;
+ }
+
+ if (file_part->disk->kind != DISK_IDE_CDROM && file_part->systype == 0) {
+ *err = diskerr_partition;
+ return -1;
+ }
+
+ if (file_part->funs == (fs_funs_t *)0) {
+ *err = diskerr_partition;
+ return -1;
+ }
+
+ fileptr = (file_part->funs->open)(file_part, filepath);
+ if (fileptr == NULL) {
+ *err = diskerr_open;
+ return -1;
+ }
+ return 0;
+}
+
+externC int
+disk_stream_read(char *buf, int size, int *err)
+{
+ int nread;
+
+ if ((nread = (file_part->funs->read)(fileptr, buf, size)) < 0) {
+ *err = diskerr_read;
+ return -1;
+ }
+ return nread;
+}
+
+externC void
+disk_stream_close(int *err)
+{
+ fileptr = NULL;
+}
+
+externC char *
+disk_error(int err)
+{
+ switch (err) {
+ case diskerr_badname:
+ return "Bad filename";
+ break;
+ case diskerr_partition:
+ return "Unsupported filesystem";
+ break;
+ case diskerr_open:
+ return "Can't open file";
+ break;
+ case diskerr_read:
+ return "Can't read file";
+ break;
+ default:
+ return "Unknown error";
+ break;
+ }
+}
+
+//
+// RedBoot interface
+//
+GETC_IO_FUNCS(disk_io, disk_stream_open, disk_stream_close,
+ 0, disk_stream_read, disk_error);
+RedBoot_load(disk, disk_io, true, true, 0);
diff --git a/ecos/packages/redboot/current/src/fs/e2fs.c b/ecos/packages/redboot/current/src/fs/e2fs.c
new file mode 100644
index 0000000..84433ad
--- /dev/null
+++ b/ecos/packages/redboot/current/src/fs/e2fs.c
@@ -0,0 +1,614 @@
+//==========================================================================
+//
+// e2fs.c
+//
+// RedBoot support for second extended filesystem
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2008 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): msalter
+// Contributors: msalter
+// Date: 2001-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+#include <fs/disk.h>
+#include <fs/e2fs.h>
+
+#define DEBUG_E2FS 0
+
+#if DEBUG_E2FS > 4
+static void dump_sb(struct e2fs_super_block *s);
+static void dump_inode(struct e2fs_inode *i);
+#endif
+
+static void *e2fs_open(partition_t *p, const char *path);
+static int e2fs_read(void *fp, char *buf, cyg_uint32 nbytes);
+
+// This structure is the only thing exported by this module.
+// These filesystem function pointers are attached to disk
+// partitions in the generic disk handling code.
+//
+fs_funs_t redboot_e2fs_funs = {
+ e2fs_open,
+ e2fs_read
+};
+
+// A single block buffer to be shared carefully.
+static cyg_uint32 blockbuf[E2FS_MAX_BLOCK_SIZE/sizeof(cyg_uint32)];
+
+#define __READ_BLOCK(n) \
+ PARTITION_READ(e2fs->part, E2FS_BLOCK_TO_SECTOR(e2fs, (n)), \
+ blockbuf, e2fs->blocksize/SECTOR_SIZE)
+
+// Get a group descriptor. Returns non-zero for success.
+//
+static int
+e2fs_get_gdesc(e2fs_desc_t *e2fs, cyg_uint32 group_nr, e2fs_group_t *gdesc)
+{
+ cyg_uint32 sec_nr;
+
+ if (group_nr < e2fs->gdesc_first ||
+ group_nr >= (e2fs->gdesc_first + E2FS_GDESC_CACHE_SIZE)) {
+
+ // cache miss
+ sec_nr = E2FS_BLOCK_TO_SECTOR(e2fs, e2fs->gdesc_block);
+ sec_nr += (group_nr / E2FS_GDESC_PER_SECTOR);
+
+#if DEBUG_E2FS > 2
+ diag_printf("%s: group[%d] cache miss, sec_nr[%d]\n",
+ __FUNCTION__, group_nr, sec_nr);
+#endif
+ if (!PARTITION_READ(e2fs->part, sec_nr, (cyg_uint32 *)e2fs->gdesc_cache,
+ sizeof(e2fs->gdesc_cache)/SECTOR_SIZE))
+ return 0;
+
+ e2fs->gdesc_first = (group_nr / E2FS_GDESC_CACHE_SIZE) * E2FS_GDESC_CACHE_SIZE;
+ }
+ *gdesc = e2fs->gdesc_cache[group_nr - e2fs->gdesc_first];
+
+ return 1;
+}
+
+// Read the requested inode from disk. Return non-zero if successful
+//
+static int
+e2fs_get_inode(e2fs_desc_t *e2fs, int ino, e2fs_inode_t *ip)
+{
+ cyg_uint32 offset, sec_nr, buf[SECTOR_SIZE/sizeof(cyg_uint32)];
+ e2fs_group_t gdesc;
+
+ // get descriptor for group which this inode belongs to
+ if (!e2fs_get_gdesc(e2fs, (ino - 1) / e2fs->inodes_per_group, &gdesc))
+ return 0;
+ if (gdesc.inode_table == 0)
+ return 0;
+
+ // byte offset within group inode table
+ offset = ((ino - 1) % e2fs->inodes_per_group) * sizeof(struct e2fs_inode);
+
+ // figure out which sector holds the inode
+ sec_nr = E2FS_BLOCK_TO_SECTOR(e2fs, SWAB_LE32(gdesc.inode_table));
+ sec_nr += offset / SECTOR_SIZE;
+
+ // and the offset within that sector.
+ offset %= SECTOR_SIZE;
+
+#if DEBUG_E2FS > 0x08
+ diag_printf("%s: ino[%d], sec_nr[%d] offset[%d]\n", __FUNCTION__,
+ ino, sec_nr, offset);
+#endif
+
+ if (!PARTITION_READ(e2fs->part, sec_nr, buf, 1))
+ return 0;
+
+ *ip = *(e2fs_inode_t *)((char *)buf + offset);
+
+#if DEBUG_E2FS > 0
+ diag_printf("%s: inode size[%d]\n", __FUNCTION__, SWAB_LE32(ip->size));
+#endif
+
+ return 1;
+}
+
+// Mount an e2fs filesystem on the given partition.
+// Return 0 if successful.
+//
+static int
+e2fs_mount(partition_t *part, e2fs_desc_t *e2fs)
+{
+ int sb_block = 1;
+ union {
+ cyg_uint32 sb_buf[E2FS_MIN_BLOCK_SIZE/sizeof(cyg_uint32)];
+ struct e2fs_super_block sbdata;
+ } sbdata_union;
+ struct e2fs_super_block *sb=&sbdata_union.sbdata;
+
+ e2fs->part = part;
+
+ if (!PARTITION_READ(part, sb_block*(E2FS_MIN_BLOCK_SIZE/SECTOR_SIZE),
+ &sbdata_union.sb_buf[0], E2FS_MIN_BLOCK_SIZE/SECTOR_SIZE))
+ return -1;
+
+ if (SWAB_LE16(sb->magic) != E2FS_SUPER_MAGIC) {
+ diag_printf("ext2_mount: bad magic 0x%x\n", SWAB_LE16(sb->magic));
+ return -1;
+ }
+
+ // save some stuff for easy access
+ e2fs->blocksize = E2FS_BLOCK_SIZE(sb);
+ e2fs->nr_ind_blocks = (e2fs)->blocksize / sizeof(cyg_uint32);
+ e2fs->nr_dind_blocks = e2fs->nr_ind_blocks * ((e2fs)->blocksize / sizeof(cyg_uint32));
+ e2fs->nr_tind_blocks = e2fs->nr_dind_blocks * ((e2fs)->blocksize / sizeof(cyg_uint32));
+ e2fs->blocks_per_group = SWAB_LE32(sb->blocks_per_group);
+ e2fs->ngroups = (SWAB_LE32(sb->blocks_count) + e2fs->blocks_per_group - 1) /
+ e2fs->blocks_per_group;
+ e2fs->inodes_per_group = SWAB_LE32(sb->inodes_per_group);
+
+ // Find the group descriptors which follow superblock
+ e2fs->gdesc_block = ((sb_block * E2FS_MIN_BLOCK_SIZE) / e2fs->blocksize) + 1;
+ e2fs->gdesc_first = 0; // cache group 0 initially
+
+ if (!PARTITION_READ(part, E2FS_BLOCK_TO_SECTOR(e2fs,e2fs->gdesc_block),
+ (cyg_uint32 *)e2fs->gdesc_cache, 1))
+ return -1;
+
+#if DEBUG_E2FS > 1
+ diag_printf("E2FS superblock:\n");
+ diag_printf(" [%d] inodes\n", SWAB_LE32(sb->inodes_count));
+ diag_printf(" [%d] blocks\n", SWAB_LE32(sb->blocks_count));
+ diag_printf(" [%d] blocksize\n", e2fs->blocksize);
+ diag_printf(" [%d] blocks per group\n", e2fs->blocks_per_group);
+ diag_printf(" [%d] ngroups\n", e2fs->ngroups);
+#endif
+
+#if DEBUG_E2FS > 4
+ dump_sb(sb);
+#endif
+
+ return 0;
+}
+
+// Convert a block index into inode data into a block_nr.
+// If successful, store block number in pblknr and return non-zero.
+//
+// NB: This needs some block/sector caching to be speedier. But
+// that takes memory and speed is not too bad now for files
+// small enough to avoid double and triple indirection.
+//
+static int
+e2fs_inode_block(e2fs_desc_t *e2fs, e2fs_inode_t *inode,
+ cyg_uint32 bindex, cyg_uint32 *pblknr)
+{
+ if (bindex < E2FS_NR_DIR_BLOCKS) {
+ *pblknr = SWAB_LE32(inode->block[bindex]);
+ return 1;
+ }
+ bindex -= E2FS_NR_DIR_BLOCKS;
+
+ if (bindex < e2fs->nr_ind_blocks) {
+ // Indirect block
+ if (!__READ_BLOCK(SWAB_LE32(inode->block[E2FS_IND_BLOCK])))
+ return 0;
+ *pblknr = SWAB_LE32(blockbuf[bindex]);
+ return 1;
+ }
+ bindex -= e2fs->nr_ind_blocks;
+
+ if (bindex < e2fs->nr_dind_blocks) {
+ // Double indirect block
+ if (!__READ_BLOCK(SWAB_LE32(inode->block[E2FS_DIND_BLOCK])))
+ return 0;
+ if (!__READ_BLOCK(SWAB_LE32(blockbuf[bindex / e2fs->nr_ind_blocks])))
+ return 0;
+ *pblknr = SWAB_LE32(blockbuf[bindex % e2fs->nr_ind_blocks]);
+ return 1;
+ }
+ bindex -= e2fs->nr_dind_blocks;
+
+ // Triple indirect block
+ if (!__READ_BLOCK(SWAB_LE32(inode->block[E2FS_TIND_BLOCK])))
+ return 0;
+ if (!__READ_BLOCK(SWAB_LE32(blockbuf[bindex / e2fs->nr_dind_blocks])))
+ return 0;
+ bindex %= e2fs->nr_dind_blocks;
+ if (!__READ_BLOCK(SWAB_LE32(blockbuf[bindex / e2fs->nr_ind_blocks])))
+ return 0;
+ *pblknr = SWAB_LE32(blockbuf[bindex % e2fs->nr_ind_blocks]);
+ return 1;
+}
+
+
+// search a single directory block in memory looking for an
+// entry with the given name. Return pointer to entry if
+// found, NULL if not.
+//
+static e2fs_dir_entry_t *
+search_dir_block(e2fs_desc_t *e2fs, cyg_uint32 *blkbuf,
+ const char *name, int namelen)
+{
+ e2fs_dir_entry_t *dir;
+ cyg_uint16 reclen, len;
+ cyg_uint32 offset;
+
+#if DEBUG_E2FS > 0
+ diag_dump_buf(blkbuf, e2fs->blocksize);
+#endif
+ offset = 0;
+ while (offset < e2fs->blocksize) {
+ dir = (e2fs_dir_entry_t *)((char *)blkbuf + offset);
+ reclen = SWAB_LE16(dir->reclen);
+ offset += reclen;
+ len = dir->namelen;
+
+ // terminate on anything which doesn't make sense
+ if (reclen < 8 || (len + 8) > reclen || offset > (e2fs->blocksize + 1))
+ return NULL;
+
+ if (dir->inode && len == namelen && !strncmp(dir->name, name, len))
+ return dir;
+ }
+ return NULL;
+}
+
+
+// Look in the given directory for an entry with the given name.
+// If found, return a pointer to that entry. Return NULL if not
+// found.
+//
+static e2fs_dir_entry_t *
+e2fs_dir_lookup(e2fs_desc_t *e2fs, cyg_uint32 dir_ino,
+ const char *name, int namelen)
+{
+ e2fs_inode_t inode;
+ e2fs_dir_entry_t *dir;
+ cyg_uint32 nblocks, last_block_size, i, block_nr, nbytes;
+
+#if DEBUG_E2FS > 0
+ diag_printf("%s: looking for %s [%d] in ino[%d]\n",
+ __FUNCTION__, name, namelen, dir_ino);
+#endif
+
+ if (!e2fs_get_inode(e2fs, dir_ino, &inode)) {
+#if DEBUG_E2FS > 0
+ diag_printf("%s: e2fs_get_inode [%d] failed\n", __FUNCTION__, dir_ino);
+#endif
+ return NULL;
+ }
+
+ nbytes = SWAB_LE32(inode.size);
+ nblocks = (nbytes + e2fs->blocksize - 1) / e2fs->blocksize;
+
+ last_block_size = nbytes % e2fs->blocksize;
+ if (last_block_size == 0)
+ last_block_size = e2fs->blocksize;
+
+ for (i = 0; i < nblocks; i++) {
+ if (!e2fs_inode_block(e2fs, &inode, i, &block_nr))
+ return NULL;
+
+ if (block_nr) {
+ if (!__READ_BLOCK(block_nr))
+ return NULL;
+ } else
+ memset(blockbuf, 0, e2fs->blocksize);
+
+ dir = search_dir_block(e2fs, blockbuf, name, namelen);
+
+ if (dir != NULL)
+ return dir;
+ }
+ return NULL;
+}
+
+typedef struct ino_info {
+ cyg_uint32 ino;
+ cyg_uint32 parent_ino;
+ cyg_uint8 filetype;
+} ino_info_t;
+
+static int e2fs_inode_lookup(e2fs_desc_t *e2fs, cyg_uint32 dir_ino,
+ const char *pathname, ino_info_t *info);
+
+// Starting from the given directory, find the inode number, filetype, and
+// parent inode for the file pointed to by the given symbolic link inode.
+// If successful, fills out ino_info_t and return true.
+//
+static int
+e2fs_follow_symlink(e2fs_desc_t *e2fs, cyg_uint32 dir_ino, cyg_uint32 sym_ino, ino_info_t *info)
+{
+#define MAX_SYMLINK_NAME 255
+ char symlink[MAX_SYMLINK_NAME+1];
+ int pathlen;
+ cyg_uint32 block_nr;
+ e2fs_inode_t inode;
+
+ if (!e2fs_get_inode(e2fs, sym_ino, &inode)) {
+#if DEBUG_E2FS > 0
+ diag_printf("%s: e2fs_get_inode [%d] failed\n", __FUNCTION__, sym_ino);
+#endif
+ return 0;
+ }
+
+ pathlen = SWAB_LE32(inode.size);
+ if (pathlen > MAX_SYMLINK_NAME)
+ return 0;
+
+ if (inode.blocks) {
+ if (!e2fs_inode_block(e2fs, &inode, 0, &block_nr))
+ return 0;
+ if (block_nr) {
+ if (!PARTITION_READ(e2fs->part, E2FS_BLOCK_TO_SECTOR(e2fs, block_nr),
+ blockbuf, e2fs->blocksize/SECTOR_SIZE))
+ return 0;
+ memcpy(symlink, blockbuf, pathlen);
+ } else
+ return 0;
+ } else {
+ // small enough path to fit in inode struct
+ memcpy(symlink, (char *)&inode.block[0], pathlen);
+ }
+ symlink[pathlen] = 0;
+
+ return e2fs_inode_lookup(e2fs, dir_ino, symlink, info);
+}
+
+
+// Starting from the given directory, find the inode number, filetype, and
+// parent inode for the given file pathname.
+// If successful, fills out ino_info_t and return true.
+//
+static int
+e2fs_inode_lookup(e2fs_desc_t *e2fs, cyg_uint32 dir_ino, const char *pathname, ino_info_t *info)
+{
+ int len, pathlen;
+ const char *p;
+ e2fs_dir_entry_t *dir = NULL;
+
+ if (!pathname || (pathlen = strlen(pathname)) == 0)
+ return 0;
+
+ if (*pathname == '/') {
+ if (--pathlen == 0) {
+ info->ino = info->parent_ino = E2FS_ROOT_INO;
+ info->filetype = E2FS_FTYPE_DIR;
+ return 1;
+ }
+ ++pathname;
+ dir_ino = E2FS_ROOT_INO;
+ }
+
+ while (pathlen) {
+ // find next delimiter in path.
+ for (p = pathname, len = 0; len < pathlen; len++, p++) {
+ // skip delimiter if found.
+ if (*p == '/') {
+ ++p;
+ --pathlen;
+ break;
+ }
+ }
+ dir = e2fs_dir_lookup(e2fs, dir_ino, pathname, len);
+ if (dir == NULL)
+ return 0;
+
+ pathlen -= len;
+ pathname = p;
+
+ switch (dir->filetype) {
+ case E2FS_FTYPE_SYMLINK:
+ // follow the symbolic link (this will cause recursion)
+ if (!e2fs_follow_symlink(e2fs, dir_ino, SWAB_LE32(dir->inode), info))
+ return 0;
+ if (pathlen == 0)
+ return 1;
+ // must be a dir if we want to continue
+ if (info->filetype != E2FS_FTYPE_DIR)
+ return 0;
+ dir_ino = info->ino;
+ break;
+
+ case E2FS_FTYPE_DIR:
+ if (pathlen)
+ dir_ino = SWAB_LE32(dir->inode);
+ break;
+
+ case E2FS_FTYPE_REG_FILE:
+ if (pathlen)
+ return 0; // regular file embedded in middle of path
+ break;
+
+ case E2FS_FTYPE_UNKNOWN:
+ case E2FS_FTYPE_CHRDEV:
+ case E2FS_FTYPE_BLKDEV:
+ case E2FS_FTYPE_FIFO:
+ case E2FS_FTYPE_SOCK:
+ default:
+ return 0;
+ }
+ }
+ info->ino = SWAB_LE32(dir->inode);
+ info->parent_ino = dir_ino;
+ info->filetype = dir->filetype;
+ return 1;
+}
+
+struct read_info {
+ e2fs_desc_t e2fs_desc;
+ e2fs_inode_t inode;
+ cyg_uint32 fsize;
+ cyg_uint32 fpos;
+};
+
+static void *
+e2fs_open(partition_t *p, const char *filepath)
+{
+ static struct read_info rinfo;
+ ino_info_t ino_info;
+
+ // mount partition
+ if (e2fs_mount(p, &rinfo.e2fs_desc) != 0) {
+ diag_printf("mount failed.\n");
+ return NULL;
+ }
+
+ // find file inode
+ if (!e2fs_inode_lookup(&rinfo.e2fs_desc, E2FS_ROOT_INO, filepath, &ino_info)) {
+ diag_printf("%s: e2fs_inode_lookup failed\n", __FUNCTION__);
+ return NULL;
+ }
+
+ // read inode
+ if (!e2fs_get_inode(&rinfo.e2fs_desc, ino_info.ino, &rinfo.inode)) {
+ diag_printf("%s: e2fs_get_inode failed for ino[%d]\n", __FUNCTION__, ino_info.ino);
+ return NULL;
+ }
+
+ rinfo.fsize = SWAB_LE32(rinfo.inode.size);
+ rinfo.fpos = 0;
+
+ return &rinfo;
+}
+
+static int
+e2fs_read(void *fp, char *buf, cyg_uint32 nbytes)
+{
+ struct read_info *info = fp;
+ e2fs_desc_t *e2fs;
+ cyg_uint32 nread = 0, rem, block_nr, bindex, to_read;
+
+ if ((info->fpos + nbytes) > info->fsize)
+ nbytes = info->fsize - info->fpos;
+
+ e2fs = &info->e2fs_desc;
+
+ // see if we need to copy leftover data from last read call
+ rem = e2fs->blocksize - (info->fpos % e2fs->blocksize);
+ if (rem != e2fs->blocksize) {
+ char *p = (char *)blockbuf + e2fs->blocksize - rem;
+
+ if (rem > nbytes)
+ rem = nbytes;
+
+ memcpy(buf, p, rem);
+
+ nread += rem;
+ buf += rem;
+ info->fpos += rem;
+ }
+
+ // now loop through blocks if we're not done
+ bindex = info->fpos / e2fs->blocksize;
+ while (nread < nbytes) {
+ if (!e2fs_inode_block(e2fs, &info->inode, bindex, &block_nr))
+ return -1;
+
+ if (block_nr) {
+ if (!PARTITION_READ(e2fs->part, E2FS_BLOCK_TO_SECTOR(e2fs, block_nr),
+ blockbuf, e2fs->blocksize/SECTOR_SIZE))
+ return 0;
+ } else
+ memset(blockbuf, 0, e2fs->blocksize);
+
+ to_read = nbytes - nread;
+ if (to_read > e2fs->blocksize)
+ to_read = e2fs->blocksize;
+
+ memcpy(buf, blockbuf, to_read);
+
+ nread += to_read;
+ buf += to_read;
+ info->fpos += to_read;
+ ++bindex;
+ }
+
+ return nread;
+}
+
+#if DEBUG_E2FS > 4
+static void dump_sb(struct e2fs_super_block *s)
+{
+ diag_printf("inode_count: %d\n", SWAB_LE32(s->inodes_count));
+ diag_printf("blocks_count: %d\n", SWAB_LE32(s->blocks_count));
+ diag_printf("r_blocks_count: %d\n", SWAB_LE32(s->r_blocks_count));
+ diag_printf("free_blocks_count: %d\n", SWAB_LE32(s->free_blocks_count));
+ diag_printf("free_inodes_count: %d\n", SWAB_LE32(s->free_inodes_count));
+ diag_printf("first_data_block: %d\n", SWAB_LE32(s->first_data_block));
+ diag_printf("log_block_size: %d\n", SWAB_LE32(s->log_block_size));
+ diag_printf("log_frag_size: %d\n", SWAB_LE32(s->log_frag_size));
+ diag_printf("blocks_per_group: %d\n", SWAB_LE32(s->blocks_per_group));
+ diag_printf("frags_per_group: %d\n", SWAB_LE32(s->frags_per_group));
+ diag_printf("inodes_per_group: %d\n", SWAB_LE32(s->inodes_per_group));
+ diag_printf("mnt_count: %d\n", SWAB_LE16(s->mnt_count));
+ diag_printf("max_mnt_count: %d\n", SWAB_LE16(s->max_mnt_count));
+ diag_printf("magic: %d\n", SWAB_LE16(s->magic));
+ diag_printf("state: %d\n", SWAB_LE16(s->state));
+ diag_printf("errors: %d\n", SWAB_LE16(s->errors));
+ diag_printf("minor_rev_level: %d\n", SWAB_LE16(s->minor_rev_level));
+ diag_printf("lastcheck: %d\n", SWAB_LE32(s->lastcheck));
+ diag_printf("checkinterval: %d\n", SWAB_LE32(s->checkinterval));
+ diag_printf("creator_os: %d\n", SWAB_LE32(s->creator_os));
+ diag_printf("rev_level: %d\n", SWAB_LE32(s->rev_level));
+}
+
+static void dump_inode(struct e2fs_inode *i)
+{
+ int j, n;
+
+ diag_printf("mode: %o\n", SWAB_LE16(i->mode));
+ diag_printf("uid: %o\n", SWAB_LE16(i->uid));
+ diag_printf("size: %d\n", SWAB_LE32(i->size));
+ diag_printf("gid: %o\n", SWAB_LE16(i->gid));
+ diag_printf("links: %d\n", SWAB_LE16(i->links_count));
+ diag_printf("blocks: %d\n", SWAB_LE32(i->blocks));
+
+ n = i->blocks;
+ if (n > E2FS_N_BLOCKS)
+ n = E2FS_N_BLOCKS;
+
+ for (j = 0; j < n; j++)
+ diag_printf(" block: %d\n", SWAB_LE32(i->block[j]));
+}
+#endif
+
+
diff --git a/ecos/packages/redboot/current/src/fs/fileio.c b/ecos/packages/redboot/current/src/fs/fileio.c
new file mode 100644
index 0000000..4333797
--- /dev/null
+++ b/ecos/packages/redboot/current/src/fs/fileio.c
@@ -0,0 +1,765 @@
+//==========================================================================
+//
+// fileio.c
+//
+// RedBoot fileio support
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): nickg
+// Contributors: dwmw2, msalter
+// Date: 2004-11-21
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+// Shoot me. But I don't want struct timeval because redboot provides it.
+#define _POSIX_SOURCE
+#include <time.h>
+#undef _POSIX_SOURCE
+
+#include <redboot.h>
+#include <errno.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#ifdef CYGPKG_IO_FLASH
+#include <pkgconf/io_flash.h>
+#include <cyg/io/io.h>
+#include <cyg/io/flash.h>
+#include <cyg/io/config_keys.h>
+#endif
+#include <cyg/io/devtab.h>
+#include <cyg/fileio/fileio.h>
+#include <cyg/infra/cyg_ass.h> // assertion macros
+
+//==========================================================================
+
+// Define table boundaries
+CYG_HAL_TABLE_BEGIN( __FS_cmds_TAB__, FS_cmds);
+CYG_HAL_TABLE_END( __FS_cmds_TAB_END__, FS_cmds);
+
+extern struct cmd __FS_cmds_TAB__[], __FS_cmds_TAB_END__;
+
+//==========================================================================
+
+static void
+fs_usage(char *why)
+{
+ diag_printf("*** invalid 'fs' command: %s\n", why);
+ cmd_usage(__FS_cmds_TAB__, &__FS_cmds_TAB_END__, "fs ");
+}
+
+
+//==========================================================================
+
+#define MAX_MOUNTS 4
+
+static int mount_count = 0;
+
+static struct
+{
+ char dev_str[PATH_MAX];
+ char mp_str[PATH_MAX];
+ char type_str[PATH_MAX];
+} mounts[MAX_MOUNTS];
+
+//==========================================================================
+
+static void do_mount(int argc, char *argv[]);
+static void do_umount(int argc, char *argv[]);
+
+/* Temporary hack until flashv2 merged to trunk. We can't tell whether we're
+ * working with flash v1 or v2 from the package version. So if legacy device isn't
+ * defined we check whether, if there is a block device, there's a tell-tale define
+ * that only exists with the v1 version.
+ */
+#if !defined(CYGPKG_IO_FLASH_BLOCK_DEVICE_LEGACY) && \
+ defined(CYGPKG_IO_FLASH_BLOCK_DEVICE) && \
+ defined(CYGINT_IO_FLASH_BLOCK_CFG_1)
+# define CYGPKG_IO_FLASH_BLOCK_DEVICE_LEGACY 1
+#endif
+
+#ifdef CYGPKG_IO_FLASH_BLOCK_DEVICE_LEGACY
+#define FLASHPART "[-f <partition>] "
+#else
+#define FLASHPART
+#endif
+
+local_cmd_entry("mount",
+ "Mount file system",
+ FLASHPART "[-d <device>] -t <fstype> [<mountpoint>]",
+ do_mount,
+ FS_cmds
+ );
+local_cmd_entry("umount",
+ "Unmount file system",
+ "<mountpoint>",
+ do_umount,
+ FS_cmds
+ );
+
+//==========================================================================
+
+// Mount disk/filesystem
+static void
+do_mount(int argc, char *argv[])
+{
+ char *dev_str = "<undefined>", *type_str, *mp_str;
+ bool dev_set = false, type_set = false;
+ struct option_info opts[3];
+ int err, num_opts = 2;
+ int i,m=0; /* Set to 0 to silence warning */
+#ifdef CYGPKG_IO_FLASH_BLOCK_DEVICE_LEGACY
+ char *part_str;
+ bool part_set = false;
+#endif
+
+ init_opts(&opts[0], 'd', true, OPTION_ARG_TYPE_STR,
+ (void *)&dev_str, &dev_set, "device");
+ init_opts(&opts[1], 't', true, OPTION_ARG_TYPE_STR,
+ (void *)&type_str, &type_set, "fstype");
+#ifdef CYGPKG_IO_FLASH_BLOCK_DEVICE_LEGACY
+ init_opts(&opts[2], 'f', true, OPTION_ARG_TYPE_STR,
+ (void *)&part_str, &part_set, "partition");
+ num_opts++;
+#endif
+
+ CYG_ASSERT(num_opts <= NUM_ELEMS(opts), "Too many options");
+
+ if (!scan_opts(argc, argv, 1, opts, num_opts, &mp_str, OPTION_ARG_TYPE_STR, "mountpoint"))
+ return;
+
+ if (!type_set) {
+ err_printf("fs mount: Must specify file system type\n");
+ return;
+ }
+
+ if( mp_str == 0 )
+ mp_str = "/";
+
+ if( mount_count >= MAX_MOUNTS )
+ {
+ err_printf("fs mount: Maximum number of mounts exceeded\n");
+ return;
+ }
+
+#ifdef CYGPKG_IO_FLASH_BLOCK_DEVICE_LEGACY
+ if (part_set) {
+ cyg_uint32 len;
+ cyg_io_handle_t h;
+
+ if (dev_set && strcmp(dev_str, CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_1)) {
+ err_printf("fs mount: May only set one of <device> or <partition>\n");
+ return;
+ }
+
+ dev_str = CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_1;
+ len = (cyg_uint32)strlen(part_str);
+
+ err = cyg_io_lookup(dev_str, &h);
+ if (err < 0) {
+ err_printf("fs mount: cyg_io_lookup of \"%s\" returned %d\n", dev_str, err);
+ return;
+ }
+ err = cyg_io_set_config(h, CYG_IO_SET_CONFIG_FLASH_FIS_NAME,
+ part_str, &len);
+ if (err < 0) {
+ diag_printf("fs mount: FIS partition \"%s\" not found\n",
+ part_str);
+ return;
+ }
+ }
+#endif
+
+ for( i = 0; i < MAX_MOUNTS; i++ )
+ {
+ if( mounts[i].mp_str[0] != '\0' )
+ {
+ if( strcmp(mounts[i].dev_str, dev_str ) == 0 )
+ {
+ err_printf("fs mount: Device %s already mounted\n",dev_str);
+ return;
+ }
+ }
+ else
+ m = i;
+ }
+
+ strcpy( mounts[m].mp_str, mp_str );
+ strcpy( mounts[m].dev_str, dev_str );
+ strcpy( mounts[m].type_str, type_str );
+
+ err = mount(mounts[m].dev_str, mounts[m].mp_str, mounts[m].type_str);
+
+ if (err)
+ {
+ err_printf("fs mount: mount(%s,%s,%s) failed %d\n", dev_str, mp_str, type_str, errno);
+ mounts[m].mp_str[0] = '\0'; // mount failed so don't let it appear mounted
+ }
+ else
+ {
+ if( mount_count == 0 )
+ chdir( "/" );
+ mount_count++;
+ }
+}
+
+//==========================================================================
+
+static void
+do_umount(int argc, char *argv[])
+{
+ char *dir_str;
+ int err;
+ int i;
+
+ if( mount_count == 0 )
+ {
+ err_printf("fs: No filesystems mounted\n");
+ return;
+ }
+
+ if (!scan_opts(argc, argv, 1, NULL, 0, &dir_str, OPTION_ARG_TYPE_STR, "mountpoint"))
+ return;
+
+ if( dir_str == 0 )
+ dir_str = "/";
+
+ for( i = 0; i < MAX_MOUNTS; i++ )
+ {
+ if( strcmp(mounts[i].mp_str, dir_str ) == 0 )
+ break;
+ }
+
+ if( i == MAX_MOUNTS )
+ {
+ err_printf("fs unmount: unknown mountpoint %s\n",dir_str);
+ return;
+ }
+
+ err = umount (dir_str);
+
+ if (err)
+ err_printf("fs umount: unmount failed %d\n", errno);
+ else
+ {
+ mounts[i].mp_str[0] = '\0';
+ mount_count--;
+ if( mount_count == 0 )
+ chdir( "/" );
+ }
+
+}
+
+//==========================================================================
+
+#include <dirent.h>
+
+static char rwx[8][4] = { "---", "r--", "-w-", "rw-", "--x", "r-x", "-wx", "rwx" };
+
+static void
+do_list(int argc, char * argv[])
+{
+ char * dir_str;
+ DIR *dirp;
+ char filename[PATH_MAX];
+ char cwd[PATH_MAX];
+ struct stat sbuf;
+ int err;
+
+ if( mount_count == 0 )
+ {
+ err_printf("fs: No filesystems mounted\n");
+ return;
+ }
+
+ if (!scan_opts(argc, argv, 1, NULL, 0, &dir_str, OPTION_ARG_TYPE_STR, "directory"))
+ return;
+
+ if( dir_str == 0 )
+ {
+ dir_str = getcwd(cwd, sizeof(cwd));
+ }
+
+ dirp = opendir(dir_str);
+ if (dirp==NULL) {
+ err_printf("fs list: no such directory %s\n",dir_str);
+ return;
+ }
+
+ for (;;) {
+ struct dirent *entry = readdir(dirp);
+
+ if( entry == NULL )
+ break;
+
+ strcpy(filename, dir_str);
+ strcat(filename, "/");
+ strcat(filename, entry->d_name);
+
+ err = stat(filename, &sbuf);
+ if (err < 0) {
+ diag_printf("Unable to stat file %s\n", filename);
+ continue;
+ }
+ diag_printf("%4d ", sbuf.st_ino);
+ if (S_ISDIR(sbuf.st_mode)) diag_printf("d");
+ if (S_ISCHR(sbuf.st_mode)) diag_printf("c");
+ if (S_ISBLK(sbuf.st_mode)) diag_printf("b");
+ if (S_ISREG(sbuf.st_mode)) diag_printf("-");
+ if (S_ISLNK(sbuf.st_mode)) diag_printf("l");
+ diag_printf("%s%s%s", // Ho, humm, have to hard code the shifts
+ rwx[(sbuf.st_mode & S_IRWXU) >> 16],
+ rwx[(sbuf.st_mode & S_IRWXG) >> 19],
+ rwx[(sbuf.st_mode & S_IRWXO) >> 22]);
+ diag_printf(" %2d size %6d %s\n",
+ sbuf.st_nlink,(int)sbuf.st_size,
+ entry->d_name);
+ }
+
+ closedir(dirp);
+ return;
+}
+
+local_cmd_entry("list",
+ "list directory contents",
+ "[<directory>]",
+ do_list,
+ FS_cmds
+ );
+
+
+//==========================================================================
+
+
+static void
+do_mkdir(int argc, char * argv[])
+{
+ char *dir_str;
+ int err;
+
+ if( mount_count == 0 )
+ {
+ err_printf("fs: No filesystems mounted\n");
+ return;
+ }
+
+ if (!scan_opts(argc, argv, 1, NULL, 0, &dir_str, OPTION_ARG_TYPE_STR, "directory") ||
+ dir_str == NULL)
+ {
+ fs_usage("invalid arguments");
+ return;
+ }
+
+ err = mkdir( dir_str, 0 );
+
+ if( err != 0 )
+ err_printf("fs mkdir: failed to create directory %s\n",dir_str);
+}
+
+local_cmd_entry("mkdir",
+ "create directory",
+ "<directory>",
+ do_mkdir,
+ FS_cmds
+ );
+
+//==========================================================================
+
+static void
+do_deldir(int argc, char * argv[])
+{
+ char *dir_str;
+ int err;
+
+ if( mount_count == 0 )
+ {
+ err_printf("fs: No filesystems mounted\n");
+ return;
+ }
+
+ if (!scan_opts(argc, argv, 1, NULL, 0, &dir_str, OPTION_ARG_TYPE_STR, "directory") ||
+ dir_str == NULL)
+ {
+ fs_usage("invalid arguments");
+ return;
+ }
+
+ err = rmdir( dir_str );
+
+ if( err != 0 )
+ err_printf("fs deldir: failed to remove directory %s\n",dir_str);
+}
+
+local_cmd_entry("deldir",
+ "delete directory",
+ "<directory>",
+ do_deldir,
+ FS_cmds
+ );
+
+//==========================================================================
+
+static void
+do_del(int argc, char * argv[])
+{
+ char *name_str = NULL;
+ int err;
+
+ if( mount_count == 0 )
+ {
+ err_printf("fs: No filesystems mounted\n");
+ return;
+ }
+
+ if (!scan_opts(argc, argv, 1, NULL, 0, &name_str, OPTION_ARG_TYPE_STR, "file") ||
+ name_str == NULL)
+ {
+ fs_usage("invalid arguments");
+ return;
+ }
+
+ err = unlink( name_str );
+
+ if( err != 0 )
+ err_printf("fs del: failed to delete file %s\n",name_str);
+}
+
+local_cmd_entry("del",
+ "delete file",
+ "<file>",
+ do_del,
+ FS_cmds
+ );
+
+//==========================================================================
+
+static void
+do_move(int argc, char * argv[])
+{
+ int err;
+ __externC int rename( const char *oldname, const char *newname );
+ if( mount_count == 0 )
+ {
+ err_printf("fs: No filesystems mounted\n");
+ return;
+ }
+
+ if( argc != 3 )
+ fs_usage("bad arguments to move command\n");
+
+ err = rename( argv[1], argv[2] );
+
+ if( err != 0 )
+ err_printf("fs move: failed to move file %s to %s\n",argv[1],argv[2]);
+}
+
+local_cmd_entry("move",
+ "move file",
+ "<from> <to>",
+ do_move,
+ FS_cmds
+ );
+
+//==========================================================================
+
+static void
+do_cd(int argc, char * argv[])
+{
+ char *dir_str;
+ int err;
+
+ if( mount_count == 0 )
+ {
+ err_printf("fs: No filesystems mounted\n");
+ return;
+ }
+
+ if (!scan_opts(argc, argv, 1, NULL, 0, &dir_str, OPTION_ARG_TYPE_STR, "directory"))
+ return;
+
+ if( dir_str == NULL )
+ dir_str = "/";
+
+ err = chdir( dir_str );
+
+ if( err != 0 )
+ err_printf("fs cd: failed to change directory %s\n",dir_str);
+}
+
+local_cmd_entry("cd",
+ "change directory",
+ "[<directory>]",
+ do_cd,
+ FS_cmds
+ );
+
+//==========================================================================
+
+static void
+do_write(int argc, char * argv[])
+{
+ char *name_str = NULL;
+ int err;
+ struct option_info opts[2];
+ CYG_ADDRESS mem_addr = 0;
+ unsigned long length = 0;
+ bool mem_addr_set = false;
+ bool length_set = false;
+ int fd;
+
+ if( mount_count == 0 )
+ {
+ err_printf("fs: No filesystems mounted\n");
+ return;
+ }
+
+ init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM,
+ (void *)&mem_addr, (bool *)&mem_addr_set, "memory base address");
+ init_opts(&opts[1], 'l', true, OPTION_ARG_TYPE_NUM,
+ (void *)&length, (bool *)&length_set, "image length");
+
+ if (!scan_opts(argc, argv, 1, opts, 2, &name_str, OPTION_ARG_TYPE_STR, "file name") ||
+ name_str == NULL)
+ {
+ fs_usage("invalid arguments");
+ return;
+ }
+
+// diag_printf("load_address %08x %08x\n",load_address,load_address_end);
+// diag_printf("ram %08x %08x\n",ram_start, ram_end);
+// diag_printf("file name %08x >%s<\n",name_str,name_str);
+
+ if (!mem_addr_set &&
+ (load_address >= (CYG_ADDRESS)ram_start) &&
+ ((load_address_end) < (CYG_ADDRESS)ram_end))
+ {
+ mem_addr = load_address;
+ mem_addr_set = true;
+ if (!length_set)
+ {
+ length = load_address_end - load_address;
+ length_set = true;
+ // maybe get length from existing file size if no loaded
+ // image?
+ }
+ }
+
+ fd = open( name_str, O_WRONLY|O_CREAT|O_TRUNC );
+
+ if( fd < 0 )
+ {
+ err_printf("fs write: Cannot open %s\n", name_str );
+ return;
+ }
+
+// diag_printf("write %08x %08x\n",mem_addr, length );
+
+ err = write( fd, (void *)mem_addr, length );
+
+ if( err != length )
+ {
+ err_printf("fs write: failed to write to file %d(%d) %d\n",err,length,errno);
+ }
+
+ err = close( fd );
+
+ if( err != 0 )
+ err_printf("fs write: close failed\n");
+}
+
+local_cmd_entry("write",
+ "write data to file",
+ "-b <mem_base> -l <image_length> <file_name>",
+ do_write,
+ FS_cmds
+ );
+
+//==========================================================================
+
+__externC cyg_fstab_entry cyg_fstab[];
+__externC cyg_fstab_entry cyg_fstab_end;
+__externC cyg_mtab_entry cyg_mtab[];
+__externC cyg_mtab_entry cyg_mtab_end;
+
+static void
+do_info(int argc, char * argv[])
+{
+ cyg_bool found = false;
+ cyg_fstab_entry *f;
+ cyg_devtab_entry_t *t;
+
+ for( f = &cyg_fstab[0] ; f != &cyg_fstab_end; f++ )
+ {
+ if( !found )
+ {
+ diag_printf("Filesystems available:\n");
+ found = true;
+ }
+ diag_printf("%s\n",f->name);
+ }
+
+ found = false;
+ for (t = &__DEVTAB__[0]; t != &__DEVTAB_END__; t++)
+ {
+ if( (t->status & CYG_DEVTAB_STATUS_BLOCK) == 0 ||
+ (t->status & CYG_DEVTAB_STATUS_AVAIL) == 0 )
+ continue;
+
+ if( !found )
+ {
+ diag_printf("\nDevices available:\n");
+ found = true;
+ }
+ diag_printf("%s\n",t->name);
+ }
+
+ if( mount_count != 0 )
+ {
+ int i;
+
+ diag_printf("\nMounted filesystems:\n");
+ diag_printf(" Device Filesystem Mounted on\n");
+
+ for( i = 0; i < MAX_MOUNTS; i++ )
+ {
+ if( mounts[i].mp_str[0] != '\0' )
+ diag_printf("%32s %10s %s\n", mounts[i].dev_str, mounts[i].type_str, mounts[i].mp_str);
+ }
+ }
+}
+
+local_cmd_entry("info",
+ "filesystem info",
+ "",
+ do_info,
+ FS_cmds
+ );
+
+//==========================================================================
+
+static void
+do_fs(int argc, char *argv[])
+{
+ struct cmd *cmd;
+
+ if (argc < 2) {
+ fs_usage("too few arguments");
+ return;
+ }
+ if ((cmd = cmd_search(__FS_cmds_TAB__, &__FS_cmds_TAB_END__,
+ argv[1])) != (struct cmd *)0) {
+ (cmd->fun)(argc-1, argv+1);
+ return;
+ }
+ fs_usage("unrecognized command");
+}
+
+RedBoot_nested_cmd("fs",
+ "Manage Filesystem files",
+ "{cmds}",
+ do_fs,
+ __FS_cmds_TAB__, &__FS_cmds_TAB_END__
+ );
+
+
+//==========================================================================
+
+static int fd;
+
+externC int
+fileio_stream_open(connection_info_t *info, int *err)
+{
+ char *filename = info->filename;
+
+ if( mount_count == 0 )
+ {
+ diag_printf("fs: No filesystems mounted\n");
+ return -1;
+ }
+
+ fd = open(filename, O_RDONLY);
+ if (fd < 0) {
+ diag_printf("fs: Open failed, error %d\n", errno);
+ return -1;
+ }
+ return 0;
+}
+
+externC int
+fileio_stream_read(char *buf, int size, int *err)
+{
+ int nread;
+
+ if ((nread = read(fd, buf, size)) < 0) {
+ *err = errno;
+ return -1;
+ }
+ return nread;
+}
+
+externC void
+fileio_stream_close(int *err)
+{
+ close(fd);
+}
+
+externC char *
+fileio_error(int err)
+{
+ static char myerr[10];
+
+ diag_sprintf(myerr, "error %d", err);
+ return myerr;
+}
+
+//
+// RedBoot interface
+//
+GETC_IO_FUNCS(fileio_io, fileio_stream_open, fileio_stream_close,
+ 0, fileio_stream_read, fileio_error);
+RedBoot_load(file, fileio_io, true, true, 0);
+
+//==========================================================================
+// End of fileio.c
+
diff --git a/ecos/packages/redboot/current/src/fs/ide.c b/ecos/packages/redboot/current/src/fs/ide.c
new file mode 100644
index 0000000..d55bc42
--- /dev/null
+++ b/ecos/packages/redboot/current/src/fs/ide.c
@@ -0,0 +1,527 @@
+//==========================================================================
+//
+// ide.c
+//
+// RedBoot IDE support
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): msalter
+// Contributors: msalter
+// Date: 2001-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+#include <cyg/hal/hal_io.h>
+#include <fs/disk.h>
+#include <fs/ide.h>
+
+static int ide_read(struct disk *d,
+ cyg_uint32 start_sector,
+ cyg_uint32 *buf,
+ cyg_uint8 nr_sectors);
+
+static disk_funs_t ide_funs = { ide_read };
+
+static struct ide_priv ide_privs[HAL_IDE_NUM_CONTROLLERS * 2];
+
+static inline void
+__wait_for_ready(int ctlr)
+{
+ cyg_uint8 status;
+ do {
+ HAL_IDE_READ_UINT8(ctlr, IDE_REG_STATUS, status);
+ } while (status & (IDE_STAT_BSY | IDE_STAT_DRQ));
+}
+
+static inline int
+__wait_for_drq(int ctlr)
+{
+ cyg_uint8 status;
+ cyg_ucount32 tries;
+
+ CYGACC_CALL_IF_DELAY_US(10);
+ for (tries=0; tries<1000000; tries++) {
+ HAL_IDE_READ_UINT8(ctlr, IDE_REG_STATUS, status);
+ if (!(status & IDE_STAT_BSY)) {
+ if (status & IDE_STAT_DRQ)
+ return 1;
+ else
+ return 0;
+ }
+ }
+}
+
+static int
+ide_reset(int ctlr)
+{
+ cyg_uint8 status;
+ int delay;
+//
+// VMware note:
+// VMware virtual IDE device handler obviously expects that
+// the reset and setup functions were already done
+// by it's bios and complais if one uses reset here...
+//
+#ifndef CYGSEM_REDBOOT_DISK_IDE_VMWARE
+ HAL_IDE_WRITE_CONTROL(ctlr, 6); // polled mode, reset asserted
+ CYGACC_CALL_IF_DELAY_US(5000);
+ HAL_IDE_WRITE_CONTROL(ctlr, 2); // polled mode, reset cleared
+ CYGACC_CALL_IF_DELAY_US((cyg_uint32)50000);
+#endif
+
+ // wait 30 seconds max for not busy and drive ready
+ for (delay = 0; delay < 300; ++delay) {
+ CYGACC_CALL_IF_DELAY_US((cyg_uint32)100000);
+ HAL_IDE_READ_UINT8(ctlr, IDE_REG_STATUS, status);
+ if (!(status & IDE_STAT_BSY)) {
+ if (status & IDE_STAT_DRDY) {
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+// Return true if any devices attached to controller
+static int
+ide_presence_detect(int ctlr)
+{
+ cyg_uint8 sel, val;
+ int i;
+
+ for (i = 0; i < 2; i++) {
+ sel = (i << 4) | 0xA0;
+ CYGACC_CALL_IF_DELAY_US((cyg_uint32)50000);
+ HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_DEVICE, sel);
+ CYGACC_CALL_IF_DELAY_US((cyg_uint32)50000);
+ HAL_IDE_READ_UINT8(ctlr, IDE_REG_DEVICE, val);
+ if (val == sel) {
+#ifndef CYGSEM_REDBOOT_DISK_IDE_VMWARE
+ if (i)
+ HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_DEVICE, 0);
+#endif
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static int
+ide_ident(int ctlr, int dev, int is_packet_dev, cyg_uint16 *buf)
+{
+ int i;
+
+ HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_DEVICE, dev << 4);
+ HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_COMMAND, is_packet_dev ? 0xA1 : 0xEC);
+ CYGACC_CALL_IF_DELAY_US((cyg_uint32)50000);
+
+ if (!__wait_for_drq(ctlr))
+ return 0;
+
+ for (i = 0; i < (SECTOR_SIZE / sizeof(cyg_uint16)); i++, buf++)
+ HAL_IDE_READ_UINT16(ctlr, IDE_REG_DATA, *buf);
+
+ return 1;
+}
+
+static int
+ide_read_sectors(int ctlr, int dev, cyg_uint32 start, cyg_uint8 count, cyg_uint16 *buf)
+{
+ int i, j;
+ cyg_uint16 *p;
+
+ HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_COUNT, count);
+ HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_LBALOW, start & 0xff);
+ HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_LBAMID, (start >> 8) & 0xff);
+ HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_LBAHI, (start >> 16) & 0xff);
+ HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_DEVICE,
+ ((start >> 24) & 0xf) | (dev << 4) | 0x40);
+ HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_COMMAND, 0x20);
+
+ for(p = buf, i = 0; i < count; i++) {
+
+ if (!__wait_for_drq(ctlr)) {
+ diag_printf("%s: NO DRQ for ide%d, device %d.\n",
+ __FUNCTION__, ctlr, dev);
+ return 0;
+ }
+
+ for (j = 0; j < (SECTOR_SIZE / sizeof(cyg_uint16)); j++, p++)
+ HAL_IDE_READ_UINT16(ctlr, IDE_REG_DATA, *p);
+ }
+ return 1;
+}
+
+// max number of sectors to xfer during a single packet command
+#define MAX_CD_XFER 16
+
+static inline int
+send_packet_command(int ctlr, int dev, cyg_uint16 len, cyg_uint16 *pkt, int pktlen)
+{
+ int i;
+ cyg_uint8 status, reason;
+
+ HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_FEATURES, 0);
+ HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_COUNT, 0);
+ HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_LBALOW, 0);
+ HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_LBAMID, len & 0xff);
+ HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_LBAHI, (len >> 8) & 0xff);
+ HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_DEVICE, dev << 4);
+ HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_COMMAND, 0xA0);
+
+ if (!__wait_for_drq(ctlr)) {
+ diag_printf("%s: NO DRQ for ide%d, device %d.\n",
+ __FUNCTION__, ctlr, dev);
+ return 0;
+ }
+
+ // send packet
+ for (i = 0; i < (pktlen/sizeof(cyg_uint16)); i++)
+ HAL_IDE_WRITE_UINT16(ctlr, IDE_REG_DATA, pkt[i]);
+
+ // wait for not busy transferring packet
+ do {
+ HAL_IDE_READ_UINT8(ctlr, IDE_REG_STATUS, status);
+ HAL_IDE_READ_UINT8(ctlr, IDE_REG_REASON, reason);
+
+ if ((status & (IDE_STAT_BSY | IDE_STAT_DRQ)) == IDE_STAT_DRQ)
+ if (reason & IDE_REASON_COD)
+ continue; // still wanting packet data (should timeout here)
+
+ } while (status & IDE_STAT_BSY);
+
+ return 1;
+}
+
+#define READ_COUNT(x) \
+ { unsigned char tmp; \
+ HAL_IDE_READ_UINT8(ctlr, IDE_REG_LBAMID, tmp); \
+ (x) = tmp; \
+ HAL_IDE_READ_UINT8(ctlr, IDE_REG_LBAHI, tmp); \
+ (x) = (x) | (tmp << 8); \
+ }
+
+
+// Read the sense data
+static int
+request_sense(int ctlr, int dev, cyg_uint16 count, cyg_uint16 *buf)
+{
+ int i;
+ cyg_uint16 cdcount, pkt[6];
+ unsigned char status, *cpkt = (unsigned char *)pkt;
+
+
+ // Fill in REQUEST SENSE packet command block
+ memset(cpkt, 0, sizeof(pkt));
+ cpkt[0] = 0x03;
+ cpkt[4] = 254; // allocation length
+
+ if (!send_packet_command(ctlr, dev, count, pkt, sizeof(pkt)))
+ return 0;
+
+ HAL_IDE_READ_UINT8(ctlr, IDE_REG_STATUS, status);
+ if (!(status & IDE_STAT_DRQ)) {
+ if (status & IDE_STAT_SERVICE) {
+ unsigned char reason;
+ HAL_IDE_READ_UINT8(ctlr, IDE_REG_REASON, reason);
+ diag_printf("%s: SERVICE request for ide%d, device %d, status[%02x], reason[%02x].\n",
+ __FUNCTION__, ctlr, dev, status, reason);
+ }
+ return 0;
+ }
+
+ READ_COUNT(cdcount);
+ if (cdcount != count)
+ diag_printf("%s: ide%d, dev%d: his cnt[%d] our count[%d].\n",
+ __FUNCTION__, ctlr, dev, cdcount, count);
+
+ for(i = 0; i < (cdcount / sizeof(*buf)); i++, buf++)
+ HAL_IDE_READ_UINT16(ctlr, IDE_REG_DATA, *buf);
+
+ // wait for not busy transferring data
+ do {
+ HAL_IDE_READ_UINT8(ctlr, IDE_REG_STATUS, status);
+ } while ((status & (IDE_STAT_BSY | IDE_STAT_DRQ)) == IDE_STAT_DRQ);
+
+ return cdcount;
+}
+
+// Interpret the sense data
+static int
+handle_sense(int ctlr, int dev, cyg_uint8 count, cyg_uint16 *buf)
+{
+#if 0
+ unsigned char *p = (char *)buf;
+
+ diag_printf("%s: %d bytes:\n", __FUNCTION__, count);
+ diag_printf("sense key[%02x] additional sense[%02x]\n",
+ p[2], p[12]);
+#endif
+ return 1;
+}
+
+static int
+do_packet_read(int ctlr, int dev, cyg_uint32 start, cyg_uint8 count, cyg_uint16 *buf)
+{
+ int i, retry_cnt;
+ cyg_uint16 cdcount, pkt[6], sense[127];
+ unsigned char status, *cpkt = (unsigned char *)pkt;
+
+ // get count number of whole cdrom sectors
+ while (count) {
+
+ retry_cnt = 3;
+
+ i = (count > MAX_CD_XFER) ? MAX_CD_XFER : count;
+
+ retry:
+ // Fill in READ(10) packet command block
+ memset(cpkt, 0, sizeof(pkt));
+ cpkt[0] = 0x28; // READ(10)
+ cpkt[2] = (start >> 24) & 0xff;
+ cpkt[3] = (start >> 16) & 0xff;
+ cpkt[4] = (start >> 8) & 0xff;
+ cpkt[5] = (start >> 0) & 0xff;
+ cpkt[7] = (i >> 8) & 0xff;
+ cpkt[8] = i & 0xff;
+
+ if (!send_packet_command(ctlr, dev, i * CDROM_SECTOR_SIZE,
+ pkt, sizeof(pkt)))
+ return 0;
+
+ HAL_IDE_READ_UINT8(ctlr, IDE_REG_STATUS, status);
+ if (!(status & IDE_STAT_DRQ)) {
+ if (status & IDE_STAT_SERVICE) {
+ unsigned char reason;
+ int sense_count;
+ HAL_IDE_READ_UINT8(ctlr, IDE_REG_REASON, reason);
+#if 1
+ diag_printf("%s: SERVICE request for ide%d, device %d, status[%02x], reason[%02x].\n",
+ __FUNCTION__, ctlr, dev, status, reason);
+#endif
+ sense_count = request_sense(ctlr, dev, sizeof(sense), sense);
+ if (sense_count) {
+ handle_sense(ctlr, dev, sense_count, sense);
+ if (retry_cnt--)
+ goto retry;
+ }
+ }
+ return 0;
+ }
+
+ count -= i;
+ start += i;
+
+ READ_COUNT(cdcount);
+ if (cdcount != (i * CDROM_SECTOR_SIZE))
+ diag_printf("%s: ide%d, dev%d: his cnt[%d] our count[%d].\n",
+ __FUNCTION__, ctlr, dev,
+ cdcount, i * CDROM_SECTOR_SIZE);
+
+ for(i = 0; i < (cdcount / sizeof(*buf)); i++, buf++)
+ HAL_IDE_READ_UINT16(ctlr, IDE_REG_DATA, *buf);
+
+ // wait for not busy transferring data
+ do {
+ HAL_IDE_READ_UINT8(ctlr, IDE_REG_STATUS, status);
+ } while ((status & (IDE_STAT_BSY | IDE_STAT_DRQ)) == IDE_STAT_DRQ);
+ }
+ return 1;
+}
+
+
+static int
+ide_packet_read_sectors(int ctlr, int dev, cyg_uint32 start, cyg_uint8 count, cyg_uint16 *buf)
+{
+ int i, extra;
+ cyg_uint32 cdstart;
+ static cyg_uint16 cdsec_buf[CDROM_SECTOR_SIZE/sizeof(cyg_uint16)];
+
+ cdstart = (start + SECTORS_PER_CDROM_SECTOR-1) / SECTORS_PER_CDROM_SECTOR;
+
+ // align to cdrom sector boundary.
+ if (start % SECTORS_PER_CDROM_SECTOR) {
+ if (!ide_packet_read_sectors(ctlr, dev,
+ cdstart * SECTORS_PER_CDROM_SECTOR,
+ SECTORS_PER_CDROM_SECTOR, cdsec_buf))
+ return 0;
+
+ i = SECTORS_PER_CDROM_SECTOR - (start % SECTORS_PER_CDROM_SECTOR);
+ if (i > count)
+ i = count;
+ memcpy(buf, cdsec_buf + ((start % CDROM_SECTOR_SIZE) * SECTOR_SIZE),
+ i * SECTOR_SIZE);
+
+ count -= i;
+ buf += (i * SECTOR_SIZE) / sizeof(*buf);
+ ++cdstart;
+ }
+
+ extra = count % SECTORS_PER_CDROM_SECTOR;
+ count /= SECTORS_PER_CDROM_SECTOR;
+
+ if (count) {
+ if (!do_packet_read(ctlr, dev, cdstart, count, buf))
+ return 0;
+ buf += count * SECTORS_PER_CDROM_SECTOR * SECTOR_SIZE;
+ }
+
+ if (extra) {
+ // read cdrom sector
+ if (!ide_packet_read_sectors(ctlr, dev,
+ cdstart * SECTORS_PER_CDROM_SECTOR,
+ extra, cdsec_buf))
+ return 0;
+ memcpy(buf, cdsec_buf, extra * SECTOR_SIZE);
+ }
+
+ return 1;
+}
+
+static int
+ide_read(struct disk *d,
+ cyg_uint32 start_sec, cyg_uint32 *buf, cyg_uint8 nr_secs)
+{
+ struct ide_priv *p = (struct ide_priv *)(d->private);
+
+ if (p->flags & IDE_DEV_PACKET)
+ return ide_packet_read_sectors(p->controller, p->drive,
+ start_sec, nr_secs, (cyg_uint16 *)buf);
+
+ return ide_read_sectors(p->controller, p->drive,
+ start_sec, nr_secs, (cyg_uint16 *)buf);
+}
+
+
+static void
+ide_init(void)
+{
+ cyg_uint32 buf[SECTOR_SIZE/sizeof(cyg_uint32)], u32;
+ cyg_uint16 u16;
+ cyg_uint8 u8;
+ int i, j, num_controllers;
+ disk_t disk;
+ struct ide_priv *priv;
+
+#define DEV_INIT_VAL ((j << 4) | 0xA0)
+
+ num_controllers = HAL_IDE_INIT();
+
+ CYGACC_CALL_IF_DELAY_US(5);
+
+ priv = ide_privs;
+ for (i = 0; i < num_controllers; i++) {
+
+ if (!ide_presence_detect(i)) {
+ diag_printf("No devices on IDE controller %d\n", i);
+ continue;
+ }
+
+ // soft reset the devices on this controller
+ if (!ide_reset(i))
+ continue;
+
+ // 2 devices per controller
+ for (j = 0; j < 2; j++, priv++) {
+
+ priv->controller = i;
+ priv->drive = j;
+ priv->flags = 0;
+
+ // This is reminiscent of a memory test. We write a value
+ // to a certain location (device register), then write a
+ // different value somewhere else so that the first value
+ // is not hanging on the bus, then we read back the first
+ // value to see if the write was succesful.
+ //
+ HAL_IDE_WRITE_UINT8(i, IDE_REG_DEVICE, DEV_INIT_VAL);
+ HAL_IDE_WRITE_UINT8(i, IDE_REG_FEATURES, 0);
+ CYGACC_CALL_IF_DELAY_US(50000);
+ HAL_IDE_READ_UINT8(i, IDE_REG_DEVICE, u8);
+ if (u8 != DEV_INIT_VAL) {
+ diag_printf("IDE failed to identify unit %d - wrote: %x, read: %x\n",
+ i, DEV_INIT_VAL, u8);
+ continue;
+ }
+
+ // device present
+ priv->flags |= IDE_DEV_PRESENT;
+
+ if (ide_ident(i, j, 0, (cyg_uint16 *)buf) <= 0) {
+ if (ide_ident(i, j, 1, (cyg_uint16 *)buf) <= 0) {
+ priv->flags = 0;
+ continue; // can't identify device
+ } else {
+ u16 = *(cyg_uint16 *)((char *)buf + IDE_DEVID_GENCONFIG);
+ if (((u16 >> 8) & 0x1f) != 5) {
+ diag_printf("Non-CDROM ATAPI device #%d - skipped\n", i);
+ continue;
+ }
+ priv->flags |= IDE_DEV_PACKET;
+ }
+ }
+
+ memset(&disk, 0, sizeof(disk));
+ disk.funs = &ide_funs;
+ disk.private = priv;
+
+ disk.kind = DISK_IDE_HD; // until proven otherwise
+
+ if (priv->flags & IDE_DEV_PACKET) {
+ u16 = *(cyg_uint16 *)((char *)buf + IDE_DEVID_GENCONFIG);
+ if (((u16 >> 8) & 0x1f) == 5)
+ disk.kind = DISK_IDE_CDROM;
+ } else {
+ u32 = *(cyg_uint32 *)((char *)buf + IDE_DEVID_LBA_CAPACITY);
+ disk.nr_sectors = u32;
+ }
+
+ if (!disk_register(&disk))
+ return;
+ }
+ }
+}
+
+RedBoot_init(ide_init, RedBoot_INIT_FIRST);
+
diff --git a/ecos/packages/redboot/current/src/gunzip.c b/ecos/packages/redboot/current/src/gunzip.c
new file mode 100644
index 0000000..79005ca
--- /dev/null
+++ b/ecos/packages/redboot/current/src/gunzip.c
@@ -0,0 +1,119 @@
+//==========================================================================
+//
+// gunzip.c
+//
+// RedBoot GZIP uncompress command
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2005 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): Peter Korsgaard
+// Contributors: Peter Korsgaard
+// Date: 2005-04-04
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+
+RedBoot_cmd("gunzip",
+ "Uncompress GZIP compressed data",
+ "-s <location> -d <location>",
+ do_gunzip
+ );
+
+void
+do_gunzip(int argc, char *argv[])
+{
+ struct option_info opts[2];
+ unsigned long src, dst;
+ bool src_set, dst_set;
+ _pipe_t pipe;
+ _pipe_t* p = &pipe;
+ int err;
+
+ init_opts(&opts[0], 's', true, OPTION_ARG_TYPE_NUM,
+ (void *)&src, (bool *)&src_set, "source address");
+ init_opts(&opts[1], 'd', true, OPTION_ARG_TYPE_NUM,
+ (void *)&dst, (bool *)&dst_set, "destination address");
+ if (!scan_opts(argc, argv, 1, opts, 2, 0, 0, "")) {
+ return;
+ }
+
+ // Must have src and dst
+ if (!src_set || !dst_set) {
+ // try to use load_address for src
+ if (dst_set
+ && load_address >= (CYG_ADDRESS)ram_start
+ && load_address < load_address_end) {
+ src = load_address;
+ diag_printf("Decompressing from %p to %p\n",
+ (void*)src, (void*)dst);
+ }
+ else
+ {
+ diag_printf("usage: gunzip -s <addr> -d <addr>\n");
+ return;
+ }
+ }
+
+ p->out_buf = (unsigned char*)dst;
+ p->out_max = p->out_size = -1;
+ p->in_buf = (unsigned char*)src;
+ p->in_avail = -1;
+
+ err = (*_dc_init)(p);
+
+ if (0 == err)
+ err = (*_dc_inflate)(p);
+
+ // Free used resources, do final translation of error value.
+ err = (*_dc_close)(p, err);
+
+ if (0 != err && p->msg) {
+ entry_address = (CYG_ADDRESS)NO_MEMORY;
+ diag_printf("Decompression error: %s\n", p->msg);
+ } else {
+ load_address = entry_address = (CYG_ADDRESS)dst;
+ load_address_end = (CYG_ADDRESS)p->out_buf;
+ diag_printf("Decompressed %lu bytes\n",
+ load_address_end - load_address);
+ }
+}
diff --git a/ecos/packages/redboot/current/src/io.c b/ecos/packages/redboot/current/src/io.c
new file mode 100644
index 0000000..086b093
--- /dev/null
+++ b/ecos/packages/redboot/current/src/io.c
@@ -0,0 +1,858 @@
+//==========================================================================
+//
+// io.c
+//
+// RedBoot I/O support
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas,hmt,jlarmour
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include "redboot.h"
+
+#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
+// GDB interface functions
+extern void ungetDebugChar(char c);
+#endif
+
+static void
+do_channel(int argc, char *argv[]);
+
+#ifdef CYGPKG_REDBOOT_ANY_CONSOLE
+RedBoot_cmd("channel",
+ "Display/switch console channel",
+ "[-1|<channel number>]",
+ do_channel
+ );
+#else
+RedBoot_cmd("channel",
+ "Display/switch console channel",
+ "[<channel number>]",
+ do_channel
+ );
+#endif
+
+static void
+do_channel(int argc, char *argv[])
+{
+ int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
+
+ if (argc == 2) {
+#ifdef CYGPKG_REDBOOT_ANY_CONSOLE
+ if (strcmp( argv[1], "-1") == 0) {
+ console_selected = false;
+ console_echo = true;
+ } else
+#endif
+ {
+ unsigned long chan;
+ if ( !parse_num( argv[1], &chan, NULL, NULL) ) {
+ diag_printf("** Error: invalid channel '%s'\n", argv[1]);
+ } else {
+ if (chan < CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS) {
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(chan);
+ CYGACC_CALL_IF_SET_DEBUG_COMM(chan);
+ if (chan != cur)
+ console_echo = true;
+ }
+ else {
+ diag_printf("**Error: bad channel number '%s'\n", argv[1]);
+ }
+ }
+ }
+ }
+ /* else display */
+ else {
+ diag_printf("Current console channel id: ");
+#ifdef CYGPKG_REDBOOT_ANY_CONSOLE
+ if (!console_selected)
+ diag_printf("-1\n");
+ else
+#endif
+ diag_printf("%d\n", cur);
+ }
+}
+
+void
+mon_write_char(unsigned char c)
+{
+ hal_virtual_comm_table_t *__chan;
+
+#ifdef CYGPKG_REDBOOT_ANY_CONSOLE
+ if (!console_selected) {
+ int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
+ int i;
+ // Send output to all channels
+ for (i = 0; i < CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS; i++) {
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(i);
+ __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
+ CYGACC_COMM_IF_PUTC(*__chan, c);
+ }
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
+ } else
+#endif
+ {
+ __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
+ if (__chan)
+ CYGACC_COMM_IF_PUTC(*__chan, c);
+ else {
+ __chan = CYGACC_CALL_IF_DEBUG_PROCS();
+ CYGACC_COMM_IF_PUTC(*__chan, c);
+ }
+ }
+}
+
+static void
+mon_read_char(unsigned char *c)
+{
+ hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
+
+ if (__chan)
+ *c = CYGACC_COMM_IF_GETC(*__chan);
+ else {
+ __chan = CYGACC_CALL_IF_DEBUG_PROCS();
+ *c = CYGACC_COMM_IF_GETC(*__chan);
+ }
+}
+
+#ifdef CYGPKG_REDBOOT_ANY_CONSOLE
+static int _mon_timeout;
+#endif
+
+bool
+mon_read_char_with_timeout(unsigned char *c)
+{
+ bool res = false;
+ hal_virtual_comm_table_t *__chan;
+
+#ifdef CYGPKG_REDBOOT_ANY_CONSOLE
+ if (!console_selected) {
+ int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
+ int i, j, tot;
+ // Try input from all channels
+ tot = 0;
+ while (tot < _mon_timeout) {
+ for (i = 0; i < CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS; i++, tot++) {
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(i);
+ __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
+ res = CYGACC_COMM_IF_GETC_TIMEOUT(*__chan, c);
+ if (res) {
+ // Input available on this channel, make it be the console
+ if (*c != '\0') {
+ // Don't chose this unless real data have arrived
+ console_selected = true;
+ CYGACC_CALL_IF_SET_DEBUG_COMM(i);
+ // Disable interrupts on all channels but this one
+ for (j = 0; j < CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS; j++) {
+ if (i != j) {
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(j);
+ __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
+ CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_IRQ_DISABLE);
+ }
+ }
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(i);
+ return res;
+ }
+ }
+ }
+ }
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
+ } else
+#endif
+ {
+ __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
+ if (__chan)
+ res = CYGACC_COMM_IF_GETC_TIMEOUT(*__chan, c);
+ else {
+ __chan = CYGACC_CALL_IF_DEBUG_PROCS();
+ res = CYGACC_COMM_IF_GETC_TIMEOUT(*__chan, c);
+ }
+ }
+ return res;
+}
+
+void
+mon_set_read_char_timeout(int ms)
+{
+ hal_virtual_comm_table_t *__chan;
+
+#ifdef CYGPKG_REDBOOT_ANY_CONSOLE
+ if (!console_selected) {
+ int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
+ int i;
+ // Set timeout to minimum on each channel; total amounts to desired value
+ _mon_timeout = ms;
+ ms = 1;
+ for (i = 0; i < CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS; i++) {
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(i);
+ if ((__chan = CYGACC_CALL_IF_CONSOLE_PROCS()) != 0) {
+ CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_SET_TIMEOUT, ms);
+ }
+ }
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
+ } else
+#endif
+ {
+ if ((__chan = CYGACC_CALL_IF_CONSOLE_PROCS()) != 0) {
+ CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_SET_TIMEOUT, ms);
+ }
+ if ((__chan = CYGACC_CALL_IF_DEBUG_PROCS()) != 0) {
+ CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_SET_TIMEOUT, ms);
+ }
+ }
+}
+
+//
+// Test for ^C on the console. CAUTION! discards all console input
+//
+bool
+_rb_break(int timeout)
+{
+ unsigned char c;
+ mon_set_read_char_timeout(timeout);
+ if (mon_read_char_with_timeout(&c)) {
+ if (c == '\x03') { // Test for ^C
+ return true;
+ }
+ }
+ return false;
+}
+
+#ifdef CYGFUN_REDBOOT_BOOT_SCRIPT
+#define __STRINGIFY(x) #x
+#define _STRINGIFY(x) __STRINGIFY(x)
+#define _STARTUP_STR _STRINGIFY(CYG_HAL_STARTUP) "}"
+
+//
+// Read a character from script.
+// Return true if script character found, false if not.
+//
+static int
+getc_script(char *cp)
+{
+ static bool newline = true;
+ bool skip;
+
+ while (script && *script) {
+ if (newline && *script == '{') {
+ skip = false;
+ ++script;
+
+ // skip if it isn't for this startup type
+ if (strncmp(script, _STARTUP_STR, strlen(_STARTUP_STR)))
+ skip = true;
+
+ // skip past "{...}"
+ while (*script && *script++ != '}')
+ ;
+
+ // skip script line if neccessary
+ if (skip) {
+ while (*script && *script++ != '\n')
+ ;
+ } else
+ newline = false;
+
+ } else {
+ *cp = *script++;
+ if (*cp == '\n') {
+ newline = true;
+ } else {
+ newline = false;
+ }
+ return true;
+ }
+ }
+ return false;
+}
+#endif
+
+#if CYGNUM_REDBOOT_CMD_LINE_EDITING != 0
+#define _CL_NUM_LINES CYGNUM_REDBOOT_CMD_LINE_EDITING // Number of lines to keep
+static char _cl_lines[_CL_NUM_LINES][CYGPKG_REDBOOT_MAX_CMD_LINE];
+static int _cl_index = -1; // Last known command line
+static int _cl_max_index = -1; // Last command in buffers
+static int _cl_real_index = 0; // Virtual command index (0..N)
+
+#ifdef CYGBLD_REDBOOT_CMD_LINE_HISTORY
+static void expand_history(char *);
+#endif
+#endif
+
+//
+// Read a line of input from the user
+// Return:
+// _GETS_OK: 'n' valid characters received
+// _GETS_GDB: '$' (GDB lead-in)
+// _GETS_TIMEOUT: No input before timeout
+// _GETS_CTRLC: ^C typed
+//
+// if CYGNUM_REDBOOT_CMD_LINE_EDITING != 0
+// Command line history support
+// ^P - Select previous line from history
+// ^N - Select next line from history
+// ^A - Move insertion [cursor] to start of line
+// ^E - Move cursor to end of line
+// ^B - Move cursor back [previous character]
+// ^F - Move cursor forward [next character]
+// "standard" arrow keys work as well
+// left ^[[D == ^B
+// right ^[[C == ^F
+// up ^[[A == ^P
+// down ^[[B == ^N
+// home ^[[H/^[1~ == ^A
+// end ^[[F/^[OF == ^E
+// del ^[3~ == ^D
+//
+int
+_rb_gets_preloaded(char *buf, int buflen, int timeout)
+{
+ char *ip = buf; // Insertion point
+ char *eol = buf; // End of line
+ char c;
+ bool res = false;
+ static char last_ch = '\0';
+ int _timeout;
+#if CYGNUM_REDBOOT_CMD_LINE_EDITING != 0
+ int _index = _cl_index; // Last saved line
+ char *xp;
+#ifdef CYGSEM_REDBOOT_CMD_LINE_ANSI_SEQUENCES
+ int ansi_state = 0; // Used to drive ANSI parser
+ char ansi_char = '\0';
+#endif
+#endif
+
+ // Display current buffer data
+ while (*eol) {
+ mon_write_char(*eol++);
+ }
+ ip = eol;
+
+ while (true) {
+#ifdef CYGFUN_REDBOOT_BOOT_SCRIPT
+ if (getc_script(&c))
+ do_idle(false);
+ else
+#endif
+ if ((timeout > 0) && (eol == buf)) {
+#define MIN_TIMEOUT 50
+ _timeout = timeout > MIN_TIMEOUT ? MIN_TIMEOUT : timeout;
+ mon_set_read_char_timeout(_timeout);
+ while (timeout > 0) {
+ res = mon_read_char_with_timeout(&c);
+ if (res) {
+ // Got a character
+ do_idle(false);
+ break;
+ }
+ timeout -= _timeout;
+ }
+ if (res == false) {
+ do_idle(true);
+ return _GETS_TIMEOUT; // Input timed out
+ }
+ } else {
+ mon_read_char(&c);
+ }
+ *eol = '\0';
+#define CTRL(c) ((c)&0x1F)
+#ifdef CYGSEM_REDBOOT_CMD_LINE_ANSI_SEQUENCES
+ // Special handling of ANSI keyboard sequences (arrows, etc)
+ if (c == '\x1B') {
+ // Leadin for ANSI keyboard sequence
+ ansi_state = 1;
+ continue;
+ }
+ switch (ansi_state) {
+ case 0:
+ // No ANSI sequence in progress
+ break;
+ case 1:
+ // ESC seen, look for '['
+ if (c == '[') {
+ ansi_state = 2;
+ } else if (c == 'O') {
+ ansi_state = 4;
+ } else {
+ // Handle bad sequences?
+ ansi_state = 0;
+ }
+ continue;
+ case 2:
+ // ESC+[ seen, process key
+ ansi_state = 0;
+ switch (c) {
+ case 'A':
+ c = CTRL('P');
+ break;
+ case 'B':
+ c = CTRL('N');
+ break;
+ case 'C':
+ c = CTRL('F');
+ break;
+ case 'D':
+ c = CTRL('B');
+ break;
+ case 'F':
+ c = CTRL('E');
+ break;
+ case 'H':
+ c = CTRL('A');
+ break;
+ case '1':
+ ansi_char = CTRL('A');
+ ansi_state = 3;
+ continue;
+ case '3':
+ ansi_char = CTRL('D');
+ ansi_state = 3;
+ continue;
+ default:
+ // Handle bad sequences?
+ continue;
+ }
+ break;
+ case 3:
+ // Sequences like ^[[1~ == ^H
+ ansi_state = 0;
+ if (c == '~') {
+ c = ansi_char;
+ } else {
+ // Handle bad sequences?
+ continue;
+ }
+ break;
+ case 4:
+ // Sequences like ^[OF == ^E
+ ansi_state = 0;
+ if (c == 'F') {
+ c = CTRL('E');
+ } else {
+ // Handle bad sequences?
+ continue;
+ }
+ break;
+ }
+#endif
+ switch (c) {
+#if CYGNUM_REDBOOT_CMD_LINE_EDITING != 0
+ case CTRL('P'):
+ // Fetch the previous line into the buffer
+ if (_index >= 0) {
+ // Erase the previous line [crude]
+ while (ip != buf) {
+ mon_write_char('\b');
+ mon_write_char(' ');
+ mon_write_char('\b');
+ ip--;
+ }
+ strcpy(buf, _cl_lines[_index]);
+ while (*ip) {
+ mon_write_char(*ip++);
+ }
+ eol = ip;
+ // Move to previous line
+ _index--;
+ if (_index < 0) {
+ _index = _cl_max_index;
+ }
+ } else {
+ mon_write_char(0x07); // Audible bell on most devices
+ }
+ break;
+ case CTRL('N'):
+ // Fetch the next line into the buffer
+ if (_index >= 0) {
+ if (++_index > _cl_max_index) _index = 0;
+ // Erase the previous line [crude]
+ while (ip != buf) {
+ mon_write_char('\b');
+ mon_write_char(' ');
+ mon_write_char('\b');
+ ip--;
+ }
+ strcpy(buf, _cl_lines[_index]);
+ while (*ip) {
+ mon_write_char(*ip++);
+ }
+ eol = ip;
+ } else {
+ mon_write_char(0x07); // Audible bell on most devices
+ }
+ break;
+ case CTRL('B'):
+ // Move insertion point backwards
+ if (ip != buf) {
+ mon_write_char('\b');
+ ip--;
+ }
+ break;
+ case CTRL('F'):
+ // Move insertion point forwards
+ if (ip != eol) {
+ mon_write_char(*ip++);
+ }
+ break;
+ case CTRL('E'):
+ // Move insertion point to end of line
+ while (ip != eol) {
+ mon_write_char(*ip++);
+ }
+ break;
+ case CTRL('A'):
+ // Move insertion point to beginning of line
+ if (ip != buf) {
+ xp = ip;
+ while (xp-- != buf) {
+ mon_write_char('\b');
+ }
+ }
+ ip = buf;
+ break;
+ case CTRL('K'):
+ // Kill to the end of line
+ if (ip != eol) {
+ xp = ip;
+ while (xp++ != eol) {
+ mon_write_char(' ');
+ }
+ while (--xp != ip) {
+ mon_write_char('\b');
+ }
+ eol = ip;
+ }
+ break;
+ case CTRL('D'):
+ // Erase the character under the cursor
+ if (ip != eol) {
+ xp = ip;
+ eol--;
+ while (xp != eol) {
+ *xp = *(xp+1);
+ mon_write_char(*xp++);
+ }
+ mon_write_char(' '); // Erases last character
+ mon_write_char('\b');
+ while (xp-- != ip) {
+ mon_write_char('\b');
+ }
+ }
+ break;
+#endif // CYGNUM_REDBOOT_CMD_LINE_EDITING
+ case CTRL('C'): // ^C
+ // Abort current input
+ diag_printf("^C\n");
+ *buf = '\0'; // Nothing useful in buffer
+ return _GETS_CTRLC;
+ case '\n':
+ case '\r':
+ // If previous character was the "other" end-of-line, ignore this one
+ if (((c == '\n') && (last_ch == '\r')) ||
+ ((c == '\r') && (last_ch == '\n'))) {
+ c = '\0';
+ break;
+ }
+ // End of line
+ if (console_echo) {
+ mon_write_char('\r');
+ mon_write_char('\n');
+ }
+ last_ch = c;
+#if CYGNUM_REDBOOT_CMD_LINE_EDITING != 0
+ if (cmd_history) {
+ // History handling - only when enabled
+#ifdef CYGBLD_REDBOOT_CMD_LINE_HISTORY
+ expand_history(buf);
+#endif
+ if (*buf != '\0') {
+ if (++_cl_index == _CL_NUM_LINES) {
+ _cl_index = 0;
+ }
+ if (_cl_index > _cl_max_index) _cl_max_index = _cl_index;
+ strcpy(_cl_lines[_cl_index], buf);
+ _cl_real_index++;
+ }
+ }
+#endif
+ return _GETS_OK;
+ case '\b':
+ case 0x7F: // DEL
+ if (ip != buf) {
+#if CYGNUM_REDBOOT_CMD_LINE_EDITING != 0
+ if (ip != eol) {
+ ip--;
+ mon_write_char('\b');
+ xp = ip;
+ while (xp != (eol-1)) {
+ *xp = *(xp+1);
+ mon_write_char(*xp++);
+ }
+ mon_write_char(' '); // Erases last character
+ mon_write_char('\b');
+ while (xp-- != ip) {
+ mon_write_char('\b');
+ }
+ } else {
+ if (console_echo) {
+ mon_write_char('\b');
+ mon_write_char(' ');
+ mon_write_char('\b');
+ }
+ ip--;
+ }
+ eol--;
+#else
+ if (console_echo) {
+ mon_write_char('\b');
+ mon_write_char(' ');
+ mon_write_char('\b');
+ }
+ ip--;
+ eol--;
+#endif
+ }
+ break;
+#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
+ case '+': // fall through
+ case '$':
+ if (ip == buf || last_ch != '\\')
+ {
+ // Give up and try GDB protocol
+ ungetDebugChar(c); // Push back character so stubs will see it
+ return _GETS_GDB;
+ }
+ if (last_ch == '\\') {
+#if CYGNUM_REDBOOT_CMD_LINE_EDITING != 0
+ if (ip == eol) {
+ // Just save \$ as $
+ eol = --ip;
+ } else {
+ mon_write_char('\b');
+ *--ip = c;
+ mon_write_char(c);
+ break;
+ }
+#else
+ ip--; // Save \$ as $
+#endif
+ }
+ // else fall through
+#endif
+ default:
+#if CYGNUM_REDBOOT_CMD_LINE_EDITING != 0
+ // If the insertion point is not at the end of line, make space for it
+ if (ip != eol) {
+ xp = eol;
+ *++eol = '\0';
+ while (xp != ip) {
+ *xp = *(xp-1);
+ xp--;
+ }
+ }
+#endif
+ if (console_echo) {
+ mon_write_char((unsigned char)c);
+ }
+ if (ip == eol) {
+ // Advance both pointers
+ *ip++ = c;
+ eol = ip;
+#if CYGNUM_REDBOOT_CMD_LINE_EDITING != 0
+ } else {
+ // Just insert the character
+ *ip++ = c;
+ xp = ip;
+ while (xp != eol) {
+ mon_write_char(*xp++);
+ }
+ while (xp-- != ip) {
+ mon_write_char('\b');
+ }
+#endif
+ }
+ }
+ last_ch = c;
+ if (ip == buf + buflen - 1) { // Buffer full
+ *ip = '\0';
+ return buflen;
+ }
+ }
+}
+
+int
+_rb_gets(char *buf, int buflen, int timeout)
+{
+ *buf = '\0'; // Empty buffer
+ return _rb_gets_preloaded(buf, buflen, timeout);
+}
+
+static bool
+_verify_action(int timeout, char *fmt, va_list ap)
+{
+ char ans[8];
+ int ret;
+#ifdef CYGFUN_REDBOOT_BOOT_SCRIPT
+ // Don't ask if we're executing a script
+ if (script && *script)
+ return 1;
+#endif
+
+ diag_vprintf(fmt, ap);
+ diag_printf(" - continue (y/n)? ");
+ if ((ret = _rb_gets(ans, sizeof(ans), timeout)) > 0) {
+ return ((ans[0] == 'y') || (ans[0] == 'Y'));
+ } else {
+ if (ret == _GETS_TIMEOUT) {
+ diag_printf(" ** Timed out!\n");
+ }
+ return 0; // Timed out or ^C
+ }
+}
+
+bool
+verify_action(char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ return _verify_action(0, fmt, ap);
+}
+
+bool
+verify_action_with_timeout(int timeout, char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ return _verify_action(timeout, fmt, ap);
+}
+
+
+#ifdef CYGBLD_REDBOOT_CMD_LINE_HISTORY
+// parse for history index number. Return number or -1 if not
+// an index number.
+static int
+parse_history_index(char *s)
+{
+ int val = 0;
+
+ while ('0' <= *s && *s <= '9')
+ val = (val * 10) + (*s++ - '0');
+
+ if (*s)
+ return -1;
+
+ return val;
+}
+
+// Check input line to see if it needs history expansion. If so,
+// try to find matching command and replace buffer as appropriate.
+static void
+expand_history(char *buf)
+{
+ int ncmds = _cl_max_index + 1;
+ int i, index, len;
+
+ if (buf[0] != '!' || buf[1] == '\0')
+ return;
+
+ if (ncmds > 0) {
+ if (!strcmp(buf, "!!")) {
+ strcpy(buf, _cl_lines[_cl_index]);
+ return;
+ }
+ if ((index = parse_history_index(buf + 1)) >= 0) {
+ if (index <= _cl_real_index) {
+ while (index >= _CL_NUM_LINES) {
+ index -= _CL_NUM_LINES;
+ }
+ strcpy(buf, _cl_lines[index]);
+ return;
+ }
+ } else {
+ len = strlen(buf + 1);
+ for (i = 0, index = _cl_index; i < ncmds; i++) {
+ if (!strncmp(_cl_lines[index], buf+1, len)) {
+ strcpy(buf, _cl_lines[index]);
+ return;
+ }
+ if (--index < 0)
+ index = _cl_max_index;
+ }
+ }
+ }
+
+ diag_printf("%s: event not found\n", buf);
+ *buf = '\0';
+}
+
+static void
+do_history(int argc, char *argv[])
+{
+ int ncmds = _cl_max_index + 1;
+ int i, index;
+
+ if (_cl_index == _cl_max_index) {
+ // history has not wrapped around
+ for (i = 0; i < ncmds; i++)
+ diag_printf("%3d %s\n", i, _cl_lines[i]);
+ } else {
+ diag_printf("_cl_index = %d\n", _cl_index);
+ for (i = 0, index = _cl_index + 1; i < ncmds; i++) {
+ diag_printf("%3d %s\n", i+_cl_real_index-_CL_NUM_LINES, _cl_lines[index++]);
+ if (index > _cl_max_index)
+ index = 0;
+ }
+ }
+}
+
+RedBoot_cmd("history",
+ "Display command history",
+ "",
+ do_history
+ );
+#endif // CYGBLD_REDBOOT_CMD_LINE_HISTORY
diff --git a/ecos/packages/redboot/current/src/iomem.c b/ecos/packages/redboot/current/src/iomem.c
new file mode 100644
index 0000000..a0e6781
--- /dev/null
+++ b/ecos/packages/redboot/current/src/iomem.c
@@ -0,0 +1,170 @@
+//==========================================================================
+//
+// iomem.c
+//
+// RedBoot I/O memory peek and poke
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2004 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): icampbell
+// Contributors: icampbell
+// Date: 2004-11-09
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+#include <cyg/hal/hal_io.h>
+
+RedBoot_cmd("iopeek",
+ "Read I/O location",
+ "[-b <location>] [-1|2|4]",
+ do_iopeek
+ );
+RedBoot_cmd("iopoke",
+ "Write I/O location",
+ "[-b <location>] [-1|2|4] -v <value>",
+ do_iopoke
+ );
+
+void
+do_iopoke(int argc, char *argv[])
+{
+ struct option_info opts[5];
+ unsigned long base;
+ bool base_set, value_set;
+ bool set_32bit = false;
+ bool set_16bit = false;
+ bool set_8bit = false;
+ cyg_uint32 value;
+ int size = 1;
+
+ init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM,
+ &base, &base_set, "base address");
+ init_opts(&opts[1], 'v', true, OPTION_ARG_TYPE_NUM,
+ &value, &value_set, "valuex");
+ init_opts(&opts[2], '4', false, OPTION_ARG_TYPE_FLG,
+ &set_32bit, 0, "output 32 bit units");
+ init_opts(&opts[3], '2', false, OPTION_ARG_TYPE_FLG,
+ &set_16bit, 0, "output 16 bit units");
+ init_opts(&opts[4], '1', false, OPTION_ARG_TYPE_FLG,
+ &set_8bit, 0, "output 8 bit units");
+ if (!scan_opts(argc, argv, 1, opts, 5, 0, 0, "")) {
+ return;
+ }
+ if (!base_set) {
+ diag_printf("iopoke what <location>?\n");
+ return;
+ }
+ if (!value_set) {
+ diag_printf("iopoke what <value>?\n");
+ return;
+ }
+ if (set_32bit) {
+ size = 4;
+ } else if (set_16bit) {
+ size = 2;
+ } else if (set_8bit) {
+ size = 1;
+ }
+
+ switch (size) {
+ case 4:
+ HAL_WRITE_UINT32 ( base, value );
+ break;
+ case 2:
+ HAL_WRITE_UINT16 ( base, value );
+ break;
+ case 1:
+ HAL_WRITE_UINT8 ( base, value );
+ break;
+ }
+}
+
+void
+do_iopeek(int argc, char *argv[])
+{
+ struct option_info opts[4];
+ unsigned long base;
+ bool base_set;
+ bool set_32bit = false;
+ bool set_16bit = false;
+ bool set_8bit = false;
+ int size = 1, value;
+
+ init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM,
+ &base, &base_set, "base address");
+ init_opts(&opts[1], '4', false, OPTION_ARG_TYPE_FLG,
+ &set_32bit, 0, "output 32 bit units");
+ init_opts(&opts[2], '2', false, OPTION_ARG_TYPE_FLG,
+ &set_16bit, 0, "output 16 bit units");
+ init_opts(&opts[3], '1', false, OPTION_ARG_TYPE_FLG,
+ &set_8bit, 0, "output 8 bit units");
+ if (!scan_opts(argc, argv, 1, opts, 4, 0, 0, "")) {
+ return;
+ }
+ if (!base_set) {
+ diag_printf("iopeek what <location>?\n");
+ return;
+ }
+ if (set_32bit) {
+ size = 4;
+ } else if (set_16bit) {
+ size = 2;
+ } else if (set_8bit) {
+ size = 1;
+ }
+
+ switch (size) {
+ case 4:
+ HAL_READ_UINT32 ( base, value );
+ diag_printf("0x%04lx = 0x%08x\n", base, value );
+ break;
+ case 2:
+ HAL_READ_UINT16 ( base, value );
+ diag_printf("0x%04lx = 0x%04x\n", base, value );
+ break;
+ case 1:
+ HAL_READ_UINT8 ( base, value );
+ diag_printf("0x%04lx = 0x%02x\n", base, value );
+ break;
+ }
+}
diff --git a/ecos/packages/redboot/current/src/load.c b/ecos/packages/redboot/current/src/load.c
new file mode 100644
index 0000000..3bd3572
--- /dev/null
+++ b/ecos/packages/redboot/current/src/load.c
@@ -0,0 +1,912 @@
+//==========================================================================
+//
+// load.c
+//
+// RedBoot file/image loader
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas, tsmith
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+#include <elf.h>
+#ifdef CYGBLD_BUILD_REDBOOT_WITH_XYZMODEM
+#include <xyzModem.h>
+#endif
+#ifdef CYGPKG_REDBOOT_DISK
+#include <fs/disk.h>
+#endif
+#ifdef CYGPKG_REDBOOT_FILEIO
+#include <fs/fileio.h>
+#endif
+#ifdef CYGPKG_REDBOOT_NETWORKING
+#ifdef CYGSEM_REDBOOT_NET_TFTP_DOWNLOAD
+#include <net/tftp_support.h>
+#endif
+#ifdef CYGSEM_REDBOOT_NET_HTTP_DOWNLOAD
+#include <net/http.h>
+#endif
+#endif
+#include <cyg/infra/cyg_ass.h> // assertion macros
+#ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
+#include <cyg/io/flash.h>
+#include "flash_load.h"
+#endif
+
+static char usage[] = "[-r] [-v] "
+#ifdef CYGBLD_BUILD_REDBOOT_WITH_ZLIB
+ "[-d] "
+#endif
+#ifdef CYGPKG_REDBOOT_NETWORKING
+ "[-h <host>] [-p <TCP port>]"
+#endif
+ "[-m <varies>] "
+#if CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS > 1
+ "[-c <channel_number>] "
+#endif
+#ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
+ "[-f <flash_address>] "
+#endif
+ "\n [-b <base_address>] <file_name>";
+
+// Exported CLI function
+RedBoot_cmd("load",
+ "Load a file",
+ usage,
+ do_load
+ );
+
+//
+// Stream I/O support
+//
+
+// Table describing the various I/O methods
+CYG_HAL_TABLE_BEGIN( __RedBoot_LOAD_TAB__, RedBoot_load );
+CYG_HAL_TABLE_END( __RedBoot_LOAD_TAB_END__, RedBoot_load );
+extern struct load_io_entry __RedBoot_LOAD_TAB__[], __RedBoot_LOAD_TAB_END__;
+
+// Buffers, data used by redboot_getc
+#define BUF_SIZE CYGNUM_REDBOOT_GETC_BUFFER
+struct {
+ getc_io_funcs_t *io;
+ int (*fun)(char *, int len, int *err);
+ char buf[BUF_SIZE];
+ char *bufp;
+ int avail, len, err;
+ int verbose, decompress, tick;
+#ifdef CYGBLD_BUILD_REDBOOT_WITH_ZLIB
+ int (*raw_fun)(char *, int len, int *err);
+ _pipe_t load_pipe;
+ unsigned char _buffer[CYGNUM_REDBOOT_LOAD_ZLIB_BUFFER];
+#endif
+} getc_info;
+
+typedef int (*getc_t)(void);
+
+//
+// Read the next data byte from the stream.
+// Returns:
+// >= 0 - actual data
+// -1 - error or EOF, status in getc_info.err
+//
+static int
+redboot_getc(void)
+{
+ static char spin[] = "|/-\\|-";
+ if (getc_info.avail < 0) {
+ return -1;
+ }
+ if (getc_info.avail == 0) {
+ if (getc_info.verbose) {
+ err_printf("%c\b", spin[getc_info.tick++]);
+ if (getc_info.tick >= sizeof(spin)) {
+ getc_info.tick = 0;
+ }
+ }
+ if (getc_info.len < BUF_SIZE) {
+ // No more data available
+ if (getc_info.verbose) diag_printf("\n");
+ return -1;
+ }
+ getc_info.bufp = getc_info.buf;
+ getc_info.len = (*getc_info.fun)(getc_info.bufp, BUF_SIZE, &getc_info.err);
+ if ((getc_info.avail = getc_info.len) <= 0) {
+ if (getc_info.len < 0) {
+ diag_printf("I/O error: %s\n", (getc_info.io->error)(getc_info.err));
+ }
+ if (getc_info.verbose) diag_printf("\n");
+ return -1;
+ }
+ }
+ getc_info.avail--;
+ return ((int)*getc_info.bufp++) & 0x00FF;
+}
+
+#ifdef CYGBLD_BUILD_REDBOOT_WITH_ZLIB
+//
+// Called to fetch a new chunk of data and decompress it
+//
+static int
+_decompress_stream(char *buf, int len, int *err)
+{
+ _pipe_t* p = &getc_info.load_pipe;
+ int res, total;
+
+ total = 0;
+ while (len > 0) {
+ if (p->in_avail == 0) {
+ p->in_buf = &getc_info._buffer[0];
+ res = (*getc_info.raw_fun)(p->in_buf, CYGNUM_REDBOOT_LOAD_ZLIB_BUFFER,
+ &getc_info.err);
+ if ((p->in_avail = res) <= 0) {
+ // No more data
+ return total;
+ }
+ }
+ p->out_buf = buf;
+ p->out_size = 0;
+ p->out_max = len;
+ res = (*_dc_inflate)(p);
+ if (res != 0) {
+ *err = res;
+ return total;
+ }
+ len -= p->out_size;
+ buf += p->out_size;
+ total += p->out_size;
+ }
+ return total;
+}
+#endif
+
+static int
+redboot_getc_init(connection_info_t *info, getc_io_funcs_t *funcs,
+ int verbose, int decompress)
+{
+ int res;
+
+ res = (funcs->open)(info, &getc_info.err);
+ if (res < 0) {
+ err_printf("Can't load '%s': %s\n", info->filename, (funcs->error)(getc_info.err));
+ return res;
+ }
+ getc_info.io = funcs;
+ getc_info.fun = funcs->read;
+ getc_info.avail = 0;
+ getc_info.len = BUF_SIZE;
+ getc_info.verbose = verbose;
+ getc_info.decompress = decompress;
+ getc_info.tick = 0;
+#ifdef CYGBLD_BUILD_REDBOOT_WITH_ZLIB
+ if (decompress) {
+ _pipe_t* p = &getc_info.load_pipe;
+ p->out_buf = &getc_info.buf[0];
+ p->out_size = 0;
+ p->in_avail = 0;
+ getc_info.raw_fun = getc_info.fun;
+ getc_info.fun = _decompress_stream;
+ getc_info.err = (*_dc_init)(p);
+ if (0 != getc_info.err && p->msg) {
+ err_printf("open decompression error: %s\n", p->msg);
+ }
+ }
+#endif
+ return 0;
+}
+
+static void
+redboot_getc_rewind(void)
+{
+ getc_info.bufp = getc_info.buf;
+ getc_info.avail = getc_info.len;
+}
+
+static void
+redboot_getc_terminate(bool abort)
+{
+ if (getc_info.io->terminate) {
+ (getc_info.io->terminate)(abort, redboot_getc);
+ }
+}
+
+static void
+redboot_getc_close(void)
+{
+ (getc_info.io->close)(&getc_info.err);
+#ifdef CYGBLD_BUILD_REDBOOT_WITH_ZLIB
+ if (getc_info.decompress) {
+ _pipe_t* p = &getc_info.load_pipe;
+ int err = getc_info.err;
+ if (0 != err && p->msg) {
+ diag_printf("decompression error: %s\n", p->msg);
+ }
+ err = (*_dc_close)(p, getc_info.err);
+ }
+#endif
+}
+
+#ifdef CYGSEM_REDBOOT_ELF
+//
+// Support function - used to read bytes into a buffer
+// Returns the number of bytes read (stops short on errors)
+//
+static int
+_read(int (*getc)(void), unsigned char *buf, int len)
+{
+ int total = 0;
+ int ch;
+ while (len-- > 0) {
+ ch = (*getc)();
+ if (ch < 0) {
+ // EOF or error
+ break;
+ }
+ *buf++ = ch;
+ total++;
+ }
+ return total;
+}
+#endif
+
+//
+// Load an ELF [binary] image
+//
+static unsigned long
+load_elf_image(getc_t getc, unsigned long base)
+{
+#ifdef CYGSEM_REDBOOT_ELF
+ Elf32_Ehdr ehdr;
+#define MAX_PHDR 8
+ Elf32_Phdr phdr[MAX_PHDR];
+ unsigned long offset = 0;
+ int phx, len, ch;
+ unsigned char *addr;
+ unsigned long addr_offset = 0;
+ unsigned long highest_address = 0;
+ unsigned long lowest_address = 0xFFFFFFFF;
+ const char SHORT_DATA[] = "Short data reading ELF file\n";
+
+ // Read the header
+ if (_read(getc, (unsigned char *)&ehdr, sizeof(ehdr)) != sizeof(ehdr)) {
+ err_printf("Can't read ELF header\n");
+ redboot_getc_terminate(true);
+ return 0;
+ }
+ offset += sizeof(ehdr);
+#if 0 // DEBUG
+ diag_printf("Type: %d, Machine: %d, Version: %d, Entry: %p, PHoff: %p/%d/%d, SHoff: %p/%d/%d\n",
+ ehdr.e_type, ehdr.e_machine, ehdr.e_version, ehdr.e_entry,
+ ehdr.e_phoff, ehdr.e_phentsize, ehdr.e_phnum,
+ ehdr.e_shoff, ehdr.e_shentsize, ehdr.e_shnum);
+#endif
+ if (ehdr.e_type != ET_EXEC) {
+ err_printf("Only absolute ELF images supported\n");
+ redboot_getc_terminate(true);
+ return 0;
+ }
+ if (ehdr.e_phnum > MAX_PHDR) {
+ err_printf("Too many program headers\n");
+ redboot_getc_terminate(true);
+ return 0;
+ }
+ while (offset < ehdr.e_phoff) {
+ if ((*getc)() < 0) {
+ err_printf(SHORT_DATA);
+ redboot_getc_terminate(true);
+ return 0;
+ }
+ offset++;
+ }
+ for (phx = 0; phx < ehdr.e_phnum; phx++) {
+ if (_read(getc, (unsigned char *)&phdr[phx], sizeof(phdr[0])) != sizeof(phdr[0])) {
+ err_printf("Can't read ELF program header\n");
+ redboot_getc_terminate(true);
+ return 0;
+ }
+#if 0 // DEBUG
+ diag_printf("Program header: type: %d, off: %p, va: %p, pa: %p, len: %d/%d, flags: %d\n",
+ phdr[phx].p_type, phdr[phx].p_offset, phdr[phx].p_vaddr, phdr[phx].p_paddr,
+ phdr[phx].p_filesz, phdr[phx].p_memsz, phdr[phx].p_flags);
+#endif
+ offset += sizeof(phdr[0]);
+ }
+ if (base) {
+ // Set address offset based on lowest address in file.
+ addr_offset = 0xFFFFFFFF;
+ for (phx = 0; phx < ehdr.e_phnum; phx++) {
+#ifdef CYGOPT_REDBOOT_ELF_VIRTUAL_ADDRESS
+ if ((phdr[phx].p_type == PT_LOAD) && (phdr[phx].p_vaddr < addr_offset)) {
+ addr_offset = phdr[phx].p_vaddr;
+#else
+ if ((phdr[phx].p_type == PT_LOAD) && (phdr[phx].p_paddr < addr_offset)) {
+ addr_offset = phdr[phx].p_paddr;
+#endif
+ }
+ }
+ addr_offset = (unsigned long)base - addr_offset;
+ } else {
+ addr_offset = 0;
+ }
+ for (phx = 0; phx < ehdr.e_phnum; phx++) {
+ if (phdr[phx].p_type == PT_LOAD) {
+ // Loadable segment
+#ifdef CYGOPT_REDBOOT_ELF_VIRTUAL_ADDRESS
+ addr = (unsigned char *)phdr[phx].p_vaddr;
+#else
+ addr = (unsigned char *)phdr[phx].p_paddr;
+#endif
+ len = phdr[phx].p_filesz;
+ if ((unsigned long)addr < lowest_address) {
+ lowest_address = (unsigned long)addr;
+ }
+ addr += addr_offset;
+ if (offset > phdr[phx].p_offset) {
+ if ((phdr[phx].p_offset + len) < offset) {
+ err_printf("Can't load ELF file - program headers out of order\n");
+ redboot_getc_terminate(true);
+ return 0;
+ }
+ addr += offset - phdr[phx].p_offset;
+ } else {
+ while (offset < phdr[phx].p_offset) {
+ if ((*getc)() < 0) {
+ err_printf(SHORT_DATA);
+ redboot_getc_terminate(true);
+ return 0;
+ }
+ offset++;
+ }
+ }
+
+ // Copy data into memory
+ while (len-- > 0) {
+#ifdef CYGSEM_REDBOOT_VALIDATE_USER_RAM_LOADS
+ if (!(valid_address(addr)
+#ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
+ || (flash_verify_addr(addr) == FLASH_ERR_OK)
+#endif
+ )) {
+ redboot_getc_terminate(true);
+ err_printf("*** Abort! Attempt to load ELF data to address: %p which is not valid\n", (void*)addr);
+ return 0;
+ }
+#endif
+ if ((ch = (*getc)()) < 0) {
+ err_printf(SHORT_DATA);
+ redboot_getc_terminate(true);
+ return 0;
+ }
+#ifdef CYGSEM_REDBOOT_VALIDATE_USER_RAM_LOADS
+ if (valid_address(addr))
+#endif
+ *addr++ = ch;
+
+#ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
+ else {
+ flash_load_write(addr, ch);
+ addr++;
+ }
+#endif
+ offset++;
+ if ((unsigned long)(addr-addr_offset) > highest_address) {
+ highest_address = (unsigned long)(addr - addr_offset);
+ }
+ }
+ }
+ }
+
+ // Save load base/top and entry
+ if (base) {
+ load_address = base;
+ load_address_end = base + (highest_address - lowest_address);
+ entry_address = base + (ehdr.e_entry - lowest_address);
+ } else {
+ load_address = lowest_address;
+ load_address_end = highest_address;
+ entry_address = ehdr.e_entry;
+ }
+
+ // nak everything to stop the transfer, since redboot
+ // usually doesn't read all the way to the end of the
+ // elf files.
+ redboot_getc_terminate(true);
+ if (addr_offset) diag_printf("Address offset = %p\n", (void *)addr_offset);
+ diag_printf("Entry point: %p, address range: %p-%p\n",
+ (void*)entry_address, (void *)load_address, (void *)load_address_end);
+ return 1;
+#else // CYGSEM_REDBOOT_ELF
+ err_printf("Loading ELF images not supported\n");
+ return 0;
+#endif // CYGSEM_REDBOOT_ELF
+}
+
+
+//
+// Scan a string of hex bytes and update the checksum
+//
+static long
+_hex2(int (*getc)(void), int len, long *sum)
+{
+ int val, byte;
+ char c1, c2;
+
+ val = 0;
+ while (len-- > 0) {
+ c1 = (*getc)();
+ c2 = (*getc)();
+ if (_is_hex(c1) && _is_hex(c2)) {
+ val <<= 8;
+ byte = (_from_hex(c1)<<4) | _from_hex(c2);
+ val |= byte;
+ if (sum) {
+ *sum += byte;
+ }
+ } else {
+ return (-1);
+ }
+ }
+ return (val);
+}
+
+//
+// Process a set of S-records, loading the contents into memory.
+// Note: if a "base" value is provided, the data will be relocated
+// relative to that location. Of course, this can only work for
+// the first section of the data, so if there are non-contiguous
+// pieces of data, they will end up relocated in the same fashion.
+// Because of this, "base" probably only makes sense for a set of
+// data which has only one section, e.g. a ROM image.
+//
+static unsigned long
+load_srec_image(getc_t getc, unsigned long base)
+{
+ int c;
+ long offset = 0, count, sum, val, cksum;
+ unsigned char *addr, *base_addr;
+ char type;
+ bool first_addr = true;
+ unsigned long addr_offset = 0;
+ unsigned long highest_address = 0;
+ unsigned long lowest_address = 0xFFFFFFFF;
+
+ while ((c = (*getc)()) > 0) {
+ // Start of line
+ if (c != 'S') {
+ redboot_getc_terminate(true);
+ err_printf("Invalid S-record at offset %p, input: %c\n",
+ (void *)offset, c);
+ return 0;
+ }
+ type = (*getc)();
+ offset += 2;
+ sum = 0;
+ if ((count = _hex2(getc, 1, &sum)) < 0) {
+ redboot_getc_terminate(true);
+ err_printf("Bad S-record count at offset %p\n", (void *)offset);
+ return 0;
+ }
+ offset += 1;
+ switch (type) {
+ case '0':
+ break;
+ case '1':
+ case '2':
+ case '3':
+ base_addr = addr = (unsigned char *)_hex2(getc, (type-'1'+2), &sum);
+ offset += (type-'1'+2);
+ if (first_addr) {
+ if (base) {
+ addr_offset = (unsigned long)base - (unsigned long)addr;
+ } else {
+ addr_offset = 0;
+ }
+ first_addr = false;
+ }
+ addr += addr_offset;
+ if ((unsigned long)(addr-addr_offset) < lowest_address) {
+ lowest_address = (unsigned long)(addr - addr_offset);
+ }
+#ifdef CYGSEM_REDBOOT_VALIDATE_USER_RAM_LOADS
+ if (!(valid_address(addr)
+#ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
+ || (flash_verify_addr(addr) == FLASH_ERR_OK)
+#endif
+ )) {
+ // Only if there is no need to stop the download before printing
+ // output can we ask confirmation questions.
+ redboot_getc_terminate(true);
+ err_printf("*** Abort! Attempt to load S-record to address: %p, which is not valid\n",(void*)addr);
+ return 0;
+ }
+#endif
+ count -= ((type-'1'+2)+1);
+ offset += count;
+ while (count-- > 0) {
+ val = _hex2(getc, 1, &sum);
+#ifdef CYGSEM_REDBOOT_VALIDATE_USER_RAM_LOADS
+ if (valid_address(addr))
+#endif
+ *addr++ = val;
+
+#ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
+ else {
+ flash_load_write(addr, val);
+ addr++;
+ }
+#endif
+ }
+ cksum = _hex2(getc, 1, 0);
+ offset += 1;
+ sum = sum & 0xFF;
+ cksum = (~cksum & 0xFF);
+ if (cksum != sum) {
+ redboot_getc_terminate(true);
+ err_printf("*** Warning! Checksum failure - Addr: %lx, %02lX <> %02lX\n",
+ (unsigned long)base_addr, sum, cksum);
+ return 0;
+ }
+ if ((unsigned long)(addr-addr_offset) > highest_address) {
+ highest_address = (unsigned long)(addr - addr_offset);
+ }
+ break;
+ case '7':
+ case '8':
+ case '9':
+ addr = (unsigned char *)_hex2(getc, ('9'-type+2), &sum);
+ offset += ('9'-type+2);
+ // Save load base/top, entry address
+ if (base) {
+ load_address = base;
+ load_address_end = base + (highest_address - lowest_address);
+ entry_address = (unsigned long)(base + (addr - lowest_address));
+ } else {
+ load_address = lowest_address;
+ load_address_end = highest_address;
+ entry_address = (unsigned long)addr;
+ }
+ redboot_getc_terminate(false);
+ if (addr_offset) diag_printf("Address offset = %p\n", (void *)addr_offset);
+ diag_printf("Entry point: %p, address range: %p-%p\n",
+ (void*)entry_address, (void *)load_address, (void *)load_address_end);
+
+ return load_address_end;
+ default:
+ redboot_getc_terminate(true);
+ err_printf("Invalid S-record at offset 0x%lx, type: %x\n",
+ (unsigned long)offset, type);
+ return 0;
+ }
+ while ((c = (*getc)()) != '\n') offset++;
+ }
+ return 0;
+}
+
+//
+// 'load' CLI command processing
+// -b - specify a load [base] address
+// -m - specify an I/O stream/method
+// -c - Alternate serial I/O channel
+#ifdef CYGBLD_BUILD_REDBOOT_WITH_ZLIB
+// -d - Decompress data [packed via 'zlib']
+#endif
+#ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
+// -f - specify a flash address
+#endif
+//
+void
+do_load(int argc, char *argv[])
+{
+ int res, num_options;
+ int i, err;
+ bool verbose, raw;
+ bool base_addr_set, mode_str_set;
+ char *mode_str;
+#ifdef CYGPKG_REDBOOT_NETWORKING
+ struct sockaddr_in host;
+ bool hostname_set, port_set;
+ unsigned int port; // int because it's an OPTION_ARG_TYPE_NUM,
+ // but will be cast to short
+ char *hostname;
+#endif
+#ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
+ bool flash_addr_set = false;
+#endif
+ bool decompress = false;
+ int chan = -1;
+#if CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS > 1
+ bool chan_set;
+#endif
+ unsigned long base = 0;
+ unsigned long end = 0;
+ char type[4];
+ char *filename = 0;
+ struct option_info opts[9];
+ connection_info_t info;
+ getc_io_funcs_t *io = NULL;
+ struct load_io_entry *io_tab;
+#ifdef CYGSEM_REDBOOT_VALIDATE_USER_RAM_LOADS
+ bool spillover_ok = false;
+#endif
+
+#ifdef CYGPKG_REDBOOT_NETWORKING
+ memset((char *)&host, 0, sizeof(host));
+ host.sin_len = sizeof(host);
+ host.sin_family = AF_INET;
+ host.sin_addr = my_bootp_info.bp_siaddr;
+ host.sin_port = 0;
+#endif
+
+ init_opts(&opts[0], 'v', false, OPTION_ARG_TYPE_FLG,
+ (void *)&verbose, 0, "verbose");
+ init_opts(&opts[1], 'r', false, OPTION_ARG_TYPE_FLG,
+ (void *)&raw, 0, "load raw data");
+ init_opts(&opts[2], 'b', true, OPTION_ARG_TYPE_NUM,
+ (void *)&base, (bool *)&base_addr_set, "load address");
+ init_opts(&opts[3], 'm', true, OPTION_ARG_TYPE_STR,
+ (void *)&mode_str, (bool *)&mode_str_set, "download mode (TFTP, xyzMODEM, or disk)");
+ num_options = 4;
+#if CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS > 1
+ init_opts(&opts[num_options], 'c', true, OPTION_ARG_TYPE_NUM,
+ (void *)&chan, (bool *)&chan_set, "I/O channel");
+ num_options++;
+#endif
+#ifdef CYGPKG_REDBOOT_NETWORKING
+ init_opts(&opts[num_options], 'h', true, OPTION_ARG_TYPE_STR,
+ (void *)&hostname, (bool *)&hostname_set, "host name or IP address");
+ num_options++;
+ init_opts(&opts[num_options], 'p', true, OPTION_ARG_TYPE_NUM,
+ (void *)&port, (bool *)&port_set, "TCP port");
+ num_options++;
+#endif
+#ifdef CYGBLD_BUILD_REDBOOT_WITH_ZLIB
+ init_opts(&opts[num_options], 'd', false, OPTION_ARG_TYPE_FLG,
+ (void *)&decompress, 0, "decompress");
+ num_options++;
+#endif
+#ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
+ init_opts(&opts[num_options], 'f', true, OPTION_ARG_TYPE_NUM,
+ (void *)&base, (bool *)&flash_addr_set, "flash address");
+ num_options++;
+#endif
+ CYG_ASSERT(num_options <= NUM_ELEMS(opts), "Too many options");
+
+ if (!scan_opts(argc, argv, 1, opts, num_options,
+ (void *)&filename, OPTION_ARG_TYPE_STR, "file name")) {
+ return;
+ }
+
+ /* make sure any future go/exec's will fail until a successful upload */
+ entry_address = (unsigned long)NO_MEMORY;
+
+#ifdef CYGPKG_REDBOOT_NETWORKING
+ if (hostname_set) {
+ ip_route_t rt;
+ if (!_gethostbyname(hostname, (in_addr_t *)&host)) {
+ err_printf("Invalid host: %s\n", hostname);
+ return;
+ }
+ /* check that the host can be accessed */
+ if (__arp_lookup((ip_addr_t *)&host.sin_addr, &rt) < 0) {
+ err_printf("Unable to reach host %s (%s)\n",
+ hostname, inet_ntoa((in_addr_t *)&host));
+ return;
+ }
+ }
+ if (port_set)
+ host.sin_port = port;
+#endif
+ if (chan >= CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS) {
+ err_printf("Invalid I/O channel: %d\n", chan);
+ return;
+ }
+ if (mode_str_set) {
+ for (io_tab = __RedBoot_LOAD_TAB__;
+ io_tab != &__RedBoot_LOAD_TAB_END__; io_tab++) {
+ if (strncasecmp(&mode_str[0], io_tab->name, strlen(&mode_str[0])) == 0) {
+ io = io_tab->funcs;
+ break;
+ }
+ }
+ if (!io) {
+ diag_printf("Invalid 'mode': %s. Valid modes are:", mode_str);
+ for (io_tab = __RedBoot_LOAD_TAB__;
+ io_tab != &__RedBoot_LOAD_TAB_END__; io_tab++) {
+ diag_printf(" %s", io_tab->name);
+ }
+ err_printf("\n");
+ }
+ if (!io) {
+ return;
+ }
+ verbose &= io_tab->can_verbose;
+ if (io_tab->need_filename && !filename) {
+ diag_printf("File name required\n");
+ err_printf("usage: load %s\n", usage);
+ return;
+ }
+ } else {
+ char *which = "";
+ io_tab = (struct load_io_entry *)NULL; // Default
+#ifdef CYGPKG_REDBOOT_NETWORKING
+#ifdef CYGSEM_REDBOOT_NET_TFTP_DOWNLOAD
+ which = "TFTP";
+ io = &tftp_io;
+#elif defined(CYGSEM_REDBOOT_NET_HTTP_DOWNLOAD)
+ which = "HTTP";
+ io = &http_io;
+#endif
+#endif
+#if 0 //def CYGPKG_REDBOOT_FILEIO
+ // Make file I/O default if mounted
+ if (fileio_mounted) {
+ which = "file";
+ io = &fileio_io;
+ }
+#endif
+ if (!io) {
+#ifdef CYGBLD_BUILD_REDBOOT_WITH_XYZMODEM
+ which = "Xmodem";
+ io = &xyzModem_io;
+ verbose = false;
+#else
+ err_printf("No default protocol!\n");
+ return;
+#endif
+ }
+ diag_printf("Using default protocol (%s)\n", which);
+ }
+#ifdef CYGSEM_REDBOOT_VALIDATE_USER_RAM_LOADS
+#ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
+ if (flash_addr_set && flash_verify_addr((unsigned char *)base)) {
+ if (!verify_action("Specified address (%p) is not believed to be in FLASH", (void*)base))
+ return;
+ spillover_ok = true;
+ }
+#endif
+ if (base_addr_set && !valid_address((unsigned char *)base)) {
+ if (!verify_action("Specified address (%p) is not believed to be in RAM", (void*)base))
+ return;
+ spillover_ok = true;
+ }
+#endif
+ if (raw && !(base_addr_set
+#ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
+ || flash_addr_set
+#endif
+ )) {
+ err_printf("Raw load requires a memory address\n");
+ return;
+ }
+ info.filename = filename;
+ info.chan = chan;
+ info.mode = io_tab ? io_tab->mode : 0;
+#ifdef CYGPKG_REDBOOT_NETWORKING
+ info.server = &host;
+#endif
+ res = redboot_getc_init(&info, io, verbose, decompress);
+ if (res < 0) {
+ return;
+ }
+#ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
+ flash_load_start();
+#endif
+ // Stream open, process the data
+ if (raw) {
+ unsigned char *mp = (unsigned char *)base;
+ err = 0;
+ while ((res = redboot_getc()) >= 0) {
+#ifdef CYGSEM_REDBOOT_VALIDATE_USER_RAM_LOADS
+#ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
+ if (flash_addr_set && flash_verify_addr(mp) && !spillover_ok) {
+ // Only if there is no need to stop the download
+ // before printing output can we ask confirmation
+ // questions.
+ redboot_getc_terminate(true);
+ err_printf("*** Abort! RAW data spills over limit of FLASH at %p\n",(void*)mp);
+ err = -1;
+ break;
+ }
+#endif
+ if (base_addr_set && !valid_address(mp) && !spillover_ok) {
+ // Only if there is no need to stop the download
+ // before printing output can we ask confirmation
+ // questions.
+ redboot_getc_terminate(true);
+ err_printf("*** Abort! RAW data spills over limit of user RAM at %p\n",(void*)mp);
+ err = -1;
+ break;
+ }
+#endif
+#ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
+ if (flash_addr_set) {
+ flash_load_write(mp, res);
+ mp++;
+ res++;
+ } else
+#endif
+ *mp++ = res;
+ }
+ end = (unsigned long) mp;
+
+ // Save load base/top
+ load_address = base;
+ load_address_end = end;
+ entry_address = base; // best guess
+
+ redboot_getc_terminate(false);
+ if (0 == err)
+ diag_printf("Raw file loaded %p-%p, assumed entry at %p\n",
+ (void *)base, (void *)(end - 1), (void*)base);
+ } else {
+ // Read initial header - to determine file [image] type
+ for (i = 0; i < sizeof(type); i++) {
+ if ((res = redboot_getc()) < 0) {
+ err = getc_info.err;
+ break;
+ }
+ type[i] = res;
+ }
+ if (res >= 0) {
+ redboot_getc_rewind(); // Restore header to stream
+ // Treat data as some sort of executable image
+ if (strncmp(&type[1], "ELF", 3) == 0) {
+ end = load_elf_image(redboot_getc, base);
+ } else if ((type[0] == 'S') &&
+ ((type[1] >= '0') && (type[1] <= '9'))) {
+ end = load_srec_image(redboot_getc, base);
+ } else {
+ redboot_getc_terminate(true);
+ err_printf("Unrecognized image type: 0x%lx\n", *(unsigned long *)type);
+ }
+ }
+ }
+#ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
+ flash_load_finish();
+#endif
+
+ redboot_getc_close(); // Clean up
+ return;
+}
diff --git a/ecos/packages/redboot/current/src/main.c b/ecos/packages/redboot/current/src/main.c
new file mode 100644
index 0000000..b27e613
--- /dev/null
+++ b/ecos/packages/redboot/current/src/main.c
@@ -0,0 +1,787 @@
+//==========================================================================
+//
+// main.c
+//
+// RedBoot main routine
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas, tkoeller, eCosCentric
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#define DEFINE_VARS
+#include <redboot.h>
+#include <cyg/hal/hal_arch.h>
+#include <cyg/hal/hal_intr.h>
+#include <cyg/hal/hal_if.h>
+#include <cyg/hal/hal_cache.h>
+#include CYGHWR_MEMORY_LAYOUT_H
+
+#ifdef CYGPKG_IO_ETH_DRIVERS
+#include <cyg/io/eth/eth_drv.h> // Logical driver interfaces
+#endif
+
+#include <cyg/hal/hal_tables.h>
+#include <cyg/infra/cyg_ass.h> // assertion macros
+#include <cyg/infra/cyg_type.h>
+#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
+#ifdef CYGBLD_HAL_PLATFORM_STUB_H
+#include CYGBLD_HAL_PLATFORM_STUB_H
+#else
+#include <cyg/hal/plf_stub.h>
+#endif
+// GDB interfaces
+extern void breakpoint(void);
+#endif
+
+// Builtin Self Test (BIST)
+externC void bist(void);
+
+// Path to code run from a go command or to GDB stubs
+static void trampoline(unsigned long entry);
+
+// Return path for code run from a go command or for GDB stubs
+static void return_to_redboot(int status);
+
+// Address of area where current context is saved before executing
+// trampoline procedure
+static void * saved_context;
+
+// Status returned after trampoline execution
+static int return_status;
+
+
+// CLI command processing (defined in this file)
+RedBoot_cmd("version",
+ "Display RedBoot version information",
+ "",
+ do_version
+ );
+RedBoot_cmd("help",
+ "Help about help?",
+ "[<topic>]",
+ do_help
+ );
+
+static char go_usage[] = "[-w <timeout>] [-c] "
+#ifdef CYGPKG_IO_ETH_DRIVERS
+ "[-n] "
+#endif
+ "[entry]";
+
+RedBoot_cmd("go",
+ "Execute code at a location",
+ go_usage,
+ do_go
+ );
+#ifdef HAL_PLATFORM_RESET
+RedBoot_cmd("reset",
+ "Reset the system",
+ "",
+ do_reset
+ );
+#endif
+#ifdef CYGSEM_REDBOOT_VARIABLE_BAUD_RATE
+RedBoot_cmd("baudrate",
+ "Set/Query the system console baud rate",
+ "[-b <rate>]",
+ do_baud_rate
+ );
+#endif
+
+// Define table boundaries
+CYG_HAL_TABLE_BEGIN( __RedBoot_INIT_TAB__, RedBoot_inits );
+CYG_HAL_TABLE_END( __RedBoot_INIT_TAB_END__, RedBoot_inits );
+extern struct init_tab_entry __RedBoot_INIT_TAB__[], __RedBoot_INIT_TAB_END__;
+
+CYG_HAL_TABLE_BEGIN( __RedBoot_CMD_TAB__, RedBoot_commands );
+CYG_HAL_TABLE_END( __RedBoot_CMD_TAB_END__, RedBoot_commands );
+extern struct cmd __RedBoot_CMD_TAB__[], __RedBoot_CMD_TAB_END__;
+
+CYG_HAL_TABLE_BEGIN( __RedBoot_IDLE_TAB__, RedBoot_idle );
+CYG_HAL_TABLE_END( __RedBoot_IDLE_TAB_END__, RedBoot_idle );
+extern struct idle_tab_entry __RedBoot_IDLE_TAB__[], __RedBoot_IDLE_TAB_END__;
+
+#ifdef HAL_ARCH_PROGRAM_NEW_STACK
+extern void HAL_ARCH_PROGRAM_NEW_STACK(void *fun);
+#endif
+
+//
+// [Null] Builtin [Power On] Self Test
+//
+void bist(void) CYGBLD_ATTRIB_WEAK;
+
+void
+bist(void)
+{
+}
+
+//
+// 'version' command
+//
+void
+do_version(int argc, char *argv[])
+{
+#if CYGBLD_REDBOOT_MAX_MEM_SEGMENTS > 1
+ int seg;
+#endif
+#ifdef CYGPKG_REDBOOT_FLASH
+ externC void _flash_info(void);
+#endif
+ char *version = CYGACC_CALL_IF_MONITOR_VERSION();
+
+ diag_printf(version);
+ diag_printf("Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009\nFree Software Foundation, Inc.\n");
+ /* The following line fulfils requirement 2(c) of the GPL. If you modify it, ensure
+ * you remain compliant with the GPL requirements. Removing it entirely constitutes
+ * a breach of the GPL, and you should note section 4 of the GPL as to what that means!
+ */
+ diag_printf("RedBoot is free software, covered by the eCos license, derived from the\n"
+ "GNU General Public License. You are welcome to change it and/or distribute\n"
+ "copies of it under certain conditions. Under the license terms, RedBoot's\n"
+ "source code and full license terms must have been made available to you.\n"
+ "Redboot comes with ABSOLUTELY NO WARRANTY.\n\n");
+#ifdef HAL_PLATFORM_CPU
+ diag_printf("Platform: %s (%s) %s\n", HAL_PLATFORM_BOARD, HAL_PLATFORM_CPU, HAL_PLATFORM_EXTRA);
+#endif
+ diag_printf("RAM: %p-%p ", (void*)ram_start, (void*)ram_end);
+ diag_printf("[%p-%p available]\n", mem_segments[0].start, mem_segments[0].end);
+#if CYGBLD_REDBOOT_MAX_MEM_SEGMENTS > 1
+ for (seg = 1; seg < CYGBLD_REDBOOT_MAX_MEM_SEGMENTS; seg++) {
+ if (mem_segments[seg].start != NO_MEMORY) {
+ diag_printf(" %p-%p ", mem_segments[seg].start, mem_segments[seg].end);
+ diag_printf("[%p-%p available]\n", mem_segments[seg].start, mem_segments[seg].end);
+ }
+ }
+#endif
+#ifdef CYGPKG_REDBOOT_FLASH
+ _flash_info();
+#endif
+}
+
+//
+// This function is called when RedBoot is idle (waiting for user
+// input). It will call any registered "idle" routines, e.g. scan
+// for incoming network connections, blank an LCD screen, etc.
+//
+void
+do_idle(bool is_idle)
+{
+ struct idle_tab_entry *idle_entry;
+
+ for (idle_entry = __RedBoot_IDLE_TAB__;
+ idle_entry != &__RedBoot_IDLE_TAB_END__; idle_entry++) {
+ (*idle_entry->fun)(is_idle);
+ }
+}
+
+// Wrapper used by diag_printf()
+static void
+_mon_write_char(char c, void **param)
+{
+ if (c == '\n') {
+ mon_write_char('\r');
+ }
+ mon_write_char(c);
+}
+
+//
+// Handle illegal memory accesses (and other abort conditions)
+//
+static hal_jmp_buf error_jmpbuf;
+#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
+__externC void* volatile __mem_fault_handler;
+
+static void error_handler(void)
+{
+ hal_longjmp(error_jmpbuf, 1);
+}
+#endif
+
+
+//
+// This is the main entry point for RedBoot
+//
+
+void
+cyg_start(void)
+{
+ int res = 0;
+ bool prompt = true;
+ static char line[CYGPKG_REDBOOT_MAX_CMD_LINE];
+ char *command;
+ struct cmd *cmd;
+ int cur;
+ struct init_tab_entry *init_entry;
+ extern char RedBoot_version[];
+#if CYGBLD_REDBOOT_MAX_MEM_SEGMENTS > 1
+ int seg;
+#endif
+
+ // Export version information
+ CYGACC_CALL_IF_MONITOR_VERSION_SET(RedBoot_version);
+
+ CYGACC_CALL_IF_MONITOR_RETURN_SET(return_to_redboot);
+
+ // Make sure the channels are properly initialized.
+ diag_init_putc(_mon_write_char);
+ hal_if_diag_init();
+
+ // Force console to output raw text - but remember the old setting
+ // so it can be restored if interaction with a debugger is
+ // required.
+ cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL);
+#ifdef CYGPKG_REDBOOT_ANY_CONSOLE
+ console_selected = false;
+#endif
+ console_echo = true;
+
+ ram_start = (unsigned char *)CYGMEM_REGION_ram;
+ ram_end = (unsigned char *)(CYGMEM_REGION_ram+CYGMEM_REGION_ram_SIZE);
+#ifdef HAL_MEM_REAL_REGION_TOP
+ {
+ unsigned char *ram_end_tmp = ram_end;
+ ram_end = HAL_MEM_REAL_REGION_TOP( ram_end_tmp );
+ }
+#endif
+#ifdef CYGMEM_SECTION_heap1
+ workspace_start = (unsigned char *)CYGMEM_SECTION_heap1;
+ workspace_end = (unsigned char *)CYGMEM_SECTION_heap1+CYGMEM_SECTION_heap1_SIZE;
+#else
+ workspace_start = (unsigned char *)CYGMEM_REGION_ram;
+ workspace_end = (unsigned char *)CYGMEM_REGION_ram+CYGMEM_REGION_ram_SIZE;
+#endif
+
+ if ( ram_end < workspace_end ) {
+ // when *less* SDRAM is installed than the possible maximum,
+ // but the heap1 region remains greater...
+ workspace_end = ram_end;
+ }
+
+#if defined(CYGMEM_REDBOOT_WORKSPACE_HEAP)
+ {
+ extern cyg_bool cyg_memalloc_heap_reinit( cyg_uint8 *base, cyg_uint32 size );
+
+ workspace_end -= CYGMEM_REDBOOT_WORKSPACE_HEAP_SIZE;
+
+ if( !cyg_memalloc_heap_reinit( (cyg_uint8 *)workspace_end, CYGMEM_REDBOOT_WORKSPACE_HEAP_SIZE ) )
+ diag_printf("Heap reinitialization failed\n");
+ }
+#endif
+
+ workspace_end_init=workspace_end;
+
+ // Nothing has ever been loaded into memory
+ entry_address = (unsigned long)NO_MEMORY;
+
+ bist();
+
+#if defined(CYGPRI_REDBOOT_ZLIB_FLASH) && defined(CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER)
+ fis_zlib_common_buffer =
+ workspace_end -= CYGNUM_REDBOOT_FIS_ZLIB_COMMON_BUFFER_SIZE;
+#endif
+
+#ifdef CYGFUN_REDBOOT_BOOT_SCRIPT
+ script_timeout = CYGNUM_REDBOOT_BOOT_SCRIPT_DEFAULT_TIMEOUT;
+#endif
+
+ for (init_entry = __RedBoot_INIT_TAB__; init_entry != &__RedBoot_INIT_TAB_END__; init_entry++) {
+ (*init_entry->fun)();
+ }
+
+ mem_segments[0].start = workspace_start;
+ mem_segments[0].end = workspace_end;
+#if CYGBLD_REDBOOT_MAX_MEM_SEGMENTS > 1
+ for (seg = 1; seg < CYGBLD_REDBOOT_MAX_MEM_SEGMENTS; seg++) {
+ cyg_plf_memory_segment(seg, &mem_segments[seg].start, &mem_segments[seg].end);
+ }
+#endif
+
+#ifdef CYGSEM_REDBOOT_PLF_STARTUP
+
+ cyg_plf_redboot_startup();
+#endif
+ do_version(0,0);
+
+#ifdef CYGFUN_REDBOOT_BOOT_SCRIPT
+# ifdef CYGDAT_REDBOOT_DEFAULT_BOOT_SCRIPT
+ if (!script) {
+ script = CYGDAT_REDBOOT_DEFAULT_BOOT_SCRIPT;
+ }
+# endif
+ if (script) {
+ // Give the guy a chance to abort any boot script
+ char *hold_script = script;
+ int script_timeout_ms = script_timeout * CYGNUM_REDBOOT_BOOT_SCRIPT_TIMEOUT_RESOLUTION;
+ diag_printf("== Executing boot script in %d.%03d seconds - enter ^C to abort\n",
+ script_timeout_ms/1000, script_timeout_ms%1000);
+ script = NULL;
+ res = _GETS_CTRLC; // Treat 0 timeout as ^C
+ while (script_timeout_ms >= CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT) {
+ res = _rb_gets(line, sizeof(line), CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT);
+ if (res >= _GETS_OK) {
+ diag_printf("== Executing boot script in %d.%03d seconds - enter ^C to abort\n",
+ script_timeout_ms/1000, script_timeout_ms%1000);
+ continue; // Ignore anything but ^C
+ }
+ if (res != _GETS_TIMEOUT) break;
+ script_timeout_ms -= CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT;
+ }
+ if (res == _GETS_CTRLC) {
+ script = NULL; // Disable script
+ } else {
+ script = hold_script; // Re-enable script
+ }
+ }
+#endif
+ CYG_ASSERT(workspace_start < workspace_end,
+ "negative workspace size");
+ while (true) {
+ if (prompt) {
+ diag_printf("RedBoot> ");
+ prompt = false;
+ }
+#if CYGNUM_REDBOOT_CMD_LINE_EDITING != 0
+ cmd_history = true; // Enable history collection
+#endif
+ res = _rb_gets(line, sizeof(line), CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT);
+#if CYGNUM_REDBOOT_CMD_LINE_EDITING != 0
+ cmd_history = false; // Enable history collection
+#endif
+ if (res == _GETS_TIMEOUT) {
+ // No input arrived
+ } else {
+#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
+ if (res == _GETS_GDB) {
+ int dbgchan;
+ hal_virtual_comm_table_t *__chan;
+ int i;
+ CYG_ADDRESS gdb_stack_sp;
+
+ // Special case of '$' - need to start GDB protocol
+ gdb_active = true;
+ // Mask interrupts on all channels
+ for (i = 0; i < CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS; i++) {
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(i);
+ __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
+ CYGACC_COMM_IF_CONTROL( *__chan, __COMMCTL_IRQ_DISABLE );
+ }
+
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
+
+ gdb_stack_sp = (CYG_ADDRESS)workspace_end;
+ // set up a temporary context that will take us to the trampoline
+ HAL_THREAD_INIT_CONTEXT(gdb_stack_sp,
+ breakpoint, trampoline,0);
+
+ // switch context to trampoline (get GDB stubs started)
+ HAL_THREAD_SWITCH_CONTEXT(&saved_context, &gdb_stack_sp);
+
+ gdb_active = false;
+
+ dbgchan = CYGACC_CALL_IF_SET_DEBUG_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(dbgchan);
+ } else
+#endif // CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
+ {
+ expand_aliases(line, sizeof(line));
+ command = (char *)&line;
+ if ((*command == '#') || (*command == '=')) {
+ // Special cases
+ if (*command == '=') {
+ // Print line on console
+ diag_printf("%s\n", &line[2]);
+ }
+ } else {
+ while (strlen(command) > 0) {
+ if ((cmd = parse(&command, &argc, &argv[0])) != (struct cmd *)0) {
+ // Try to handle aborts - messy because of the stack unwinding...
+#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
+ __mem_fault_handler = error_handler;
+#endif
+ if (hal_setjmp(error_jmpbuf)) {
+ diag_printf("** command abort - illegal memory access?\n");
+ } else {
+ (cmd->fun)(argc, argv);
+ }
+#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
+ __mem_fault_handler = 0;
+#endif
+ } else {
+ diag_printf("** Error: Illegal command: \"%s\"\n", argv[0]);
+ }
+ }
+ }
+ prompt = true;
+ }
+ }
+ }
+}
+
+void
+show_help(struct cmd *cmd, struct cmd *cmd_end, char *which, char *pre)
+{
+ bool show;
+ int len = 0;
+
+ if (which) {
+ len = strlen(which);
+ }
+ while (cmd != cmd_end) {
+ show = true;
+ if (which && (strncasecmp(which, cmd->str, len) != 0)) {
+ show = false;
+ }
+ if (show) {
+ diag_printf("%s\n %s %s %s\n", cmd->help, pre, cmd->str, cmd->usage);
+ if ((cmd->sub_cmds != (struct cmd *)0) && (which != (char *)0)) {
+ show_help(cmd->sub_cmds, cmd->sub_cmds_end, 0, cmd->str);
+ }
+ }
+ cmd++;
+ }
+}
+
+void
+do_help(int argc, char *argv[])
+{
+ struct cmd *cmd;
+ char *which = (char *)0;
+
+ if (!scan_opts(argc, argv, 1, 0, 0, (void *)&which, OPTION_ARG_TYPE_STR, "<topic>")) {
+ diag_printf("Invalid argument\n");
+ return;
+ }
+ cmd = __RedBoot_CMD_TAB__;
+ show_help(cmd, &__RedBoot_CMD_TAB_END__, which, "");
+ return;
+}
+
+static void
+trampoline(unsigned long entry)
+{
+ typedef void code_fun(void);
+ code_fun *fun = (code_fun *)entry;
+ unsigned long oldints;
+
+ HAL_DISABLE_INTERRUPTS(oldints);
+
+#ifdef HAL_ARCH_PROGRAM_NEW_STACK
+ HAL_ARCH_PROGRAM_NEW_STACK(fun);
+#else
+ (*fun)();
+#endif
+
+ HAL_THREAD_LOAD_CONTEXT(&saved_context);
+}
+
+static void
+return_to_redboot(int status)
+{
+ CYGARC_HAL_SAVE_GP();
+
+ return_status = status;
+ HAL_THREAD_LOAD_CONTEXT(&saved_context);
+ // never returns
+
+ // need this to balance above CYGARC_HAL_SAVE_GP on
+ // some platforms. It will never run, though.
+ CYGARC_HAL_RESTORE_GP();
+}
+
+void
+do_go(int argc, char *argv[])
+{
+ int i, cur, num_options;
+ unsigned long entry;
+ unsigned long oldints;
+ bool wait_time_set;
+ int wait_time, res;
+ bool cache_enabled = false;
+#ifdef CYGPKG_IO_ETH_DRIVERS
+ bool stop_net = false;
+#endif
+ struct option_info opts[3];
+ char line[8];
+ hal_virtual_comm_table_t *__chan;
+ CYG_ADDRESS trampoline_stack_sp;
+
+#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
+ __mem_fault_handler = 0; // Let GDB handle any faults directly
+#endif
+ entry = entry_address; // Default from last 'load' operation
+ init_opts(&opts[0], 'w', true, OPTION_ARG_TYPE_NUM,
+ (void *)&wait_time, (bool *)&wait_time_set, "wait timeout");
+ init_opts(&opts[1], 'c', false, OPTION_ARG_TYPE_FLG,
+ (void *)&cache_enabled, (bool *)0, "go with caches enabled");
+ num_options = 2;
+#ifdef CYGPKG_IO_ETH_DRIVERS
+ init_opts(&opts[2], 'n', false, OPTION_ARG_TYPE_FLG,
+ (void *)&stop_net, (bool *)0, "go with network driver stopped");
+ num_options++;
+#endif
+
+ CYG_ASSERT(num_options <= NUM_ELEMS(opts), "Too many options");
+
+ if (!scan_opts(argc, argv, 1, opts, num_options, (void *)&entry, OPTION_ARG_TYPE_NUM, "starting address"))
+ {
+ return;
+ }
+ if (entry == (unsigned long)NO_MEMORY) {
+ err_printf("No entry point known - aborted\n");
+ return;
+ }
+ if (wait_time_set) {
+ int script_timeout_ms = wait_time * 1000;
+#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
+ char *hold_script = script;
+ script = NULL;
+#endif
+ diag_printf("About to start execution at %p - abort with ^C within %d seconds\n",
+ (void *)entry, wait_time);
+ while (script_timeout_ms >= CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT) {
+ res = _rb_gets(line, sizeof(line), CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT);
+ if (res == _GETS_CTRLC) {
+#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
+ script = hold_script; // Re-enable script
+#endif
+ return;
+ }
+ script_timeout_ms -= CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT;
+ }
+ }
+
+ // Mask interrupts on all channels
+ cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
+ for (i = 0; i < CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS; i++) {
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(i);
+ __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
+ CYGACC_COMM_IF_CONTROL( *__chan, __COMMCTL_IRQ_DISABLE );
+ }
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
+
+ __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
+ CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_ENABLE_LINE_FLUSH);
+
+#ifdef CYGPKG_IO_ETH_DRIVERS
+ if (stop_net)
+ eth_drv_stop();
+#endif
+
+ HAL_DISABLE_INTERRUPTS(oldints);
+ HAL_DCACHE_SYNC();
+ if (!cache_enabled) {
+ HAL_ICACHE_DISABLE();
+ HAL_DCACHE_DISABLE();
+ HAL_DCACHE_SYNC();
+ }
+ HAL_ICACHE_INVALIDATE_ALL();
+ HAL_DCACHE_INVALIDATE_ALL();
+ trampoline_stack_sp = (CYG_ADDRESS)workspace_end;
+ // set up a temporary context that will take us to the trampoline
+ HAL_THREAD_INIT_CONTEXT(trampoline_stack_sp, entry, trampoline, 0);
+
+ // switch context to trampoline
+ HAL_THREAD_SWITCH_CONTEXT(&saved_context, &trampoline_stack_sp);
+
+ // we get back here by way of return_to_redboot()
+
+ // undo the changes we made before switching context
+ if (!cache_enabled) {
+ HAL_ICACHE_ENABLE();
+ HAL_DCACHE_ENABLE();
+ }
+
+ CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_DISABLE_LINE_FLUSH);
+
+ HAL_RESTORE_INTERRUPTS(oldints);
+
+ diag_printf("\nProgram completed with status %d\n", return_status);
+}
+
+#ifdef HAL_PLATFORM_RESET
+void
+do_reset(int argc, char *argv[])
+{
+ diag_printf("... Resetting.");
+ CYGACC_CALL_IF_DELAY_US(2*100000);
+ diag_printf("\n");
+ CYGACC_CALL_IF_RESET();
+ diag_printf("!! oops, RESET not working on this platform\n");
+}
+#endif
+
+#ifdef CYGSEM_REDBOOT_VARIABLE_BAUD_RATE
+#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
+#include <flash_config.h>
+#endif
+
+static int
+set_comm_baud_rate(hal_virtual_comm_table_t *chan, int rate)
+{
+ int current_rate;
+
+ current_rate = CYGACC_COMM_IF_CONTROL(*chan, __COMMCTL_GETBAUD);
+ if (rate != current_rate)
+ return CYGACC_COMM_IF_CONTROL(*chan, __COMMCTL_SETBAUD, rate);
+
+ return 0;
+}
+
+int
+set_console_baud_rate(int rate)
+{
+ int ret = -1;
+#ifdef CYGPKG_REDBOOT_ANY_CONSOLE
+ if (!console_selected) {
+ int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
+ int i;
+ // Set baud for all channels
+ for (i = 0; i < CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS; i++) {
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(i);
+ ret = set_comm_baud_rate(CYGACC_CALL_IF_CONSOLE_PROCS(), rate);
+ if (ret < 0)
+ break;
+ }
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
+ } else
+#endif
+ ret = set_comm_baud_rate(CYGACC_CALL_IF_CONSOLE_PROCS(), rate);
+
+ if (ret < 0)
+ diag_printf("Setting console baud rate to %d failed\n", rate);
+
+ return ret;
+}
+
+static void
+_sleep(int ms)
+{
+ int i;
+ for (i = 0; i < ms; i++) {
+ CYGACC_CALL_IF_DELAY_US((cyg_int32)1000);
+ }
+}
+
+void
+do_baud_rate(int argc, char *argv[])
+{
+ int new_rate, ret, old_rate;
+ bool new_rate_set;
+ hal_virtual_comm_table_t *__chan;
+ struct option_info opts[1];
+#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
+ struct config_option opt;
+#endif
+
+ init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM,
+ (void *)&new_rate, (bool *)&new_rate_set, "new baud rate");
+ if (!scan_opts(argc, argv, 1, opts, 1, 0, 0, "")) {
+ return;
+ }
+ __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
+ if (new_rate_set) {
+ diag_printf("Baud rate will be changed to %d - update your settings\n", new_rate);
+ _sleep(500); // Give serial time to flush
+ old_rate = CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_GETBAUD);
+ ret = set_console_baud_rate(new_rate);
+ if (ret < 0) {
+ if (old_rate > 0) {
+ // Try to restore
+ set_console_baud_rate(old_rate);
+ _sleep(500); // Give serial time to flush
+ diag_printf("\nret = %d\n", ret);
+ }
+ return; // Couldn't set the desired rate
+ }
+ // Make sure this new rate works or back off to previous value
+ // Sleep for a few seconds, then prompt to see if it works
+ _sleep(10000); // Give serial time to flush
+ if (!verify_action_with_timeout(5000, "Baud rate changed to %d", new_rate)) {
+ _sleep(500); // Give serial time to flush
+ set_console_baud_rate(old_rate);
+ _sleep(500); // Give serial time to flush
+ return;
+ }
+#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
+ opt.type = CONFIG_INT;
+ opt.enable = (char *)0;
+ opt.enable_sense = 1;
+ opt.key = "console_baud_rate";
+ opt.dflt = new_rate;
+ flash_add_config(&opt, true);
+#endif
+ } else {
+ ret = CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_GETBAUD);
+ diag_printf("Baud rate = ");
+ if (ret <= 0) {
+ diag_printf("unknown\n");
+ } else {
+ diag_printf("%d\n", ret);
+ }
+ }
+}
+#endif
+
+//
+// Validate an address to see if it is within any known RAM area
+//
+bool
+valid_address(unsigned char *addr)
+{
+ int seg;
+
+ for (seg = 0; seg < CYGBLD_REDBOOT_MAX_MEM_SEGMENTS; seg++) {
+ if (mem_segments[seg].start != NO_MEMORY) {
+ if ((addr >= mem_segments[seg].start) && (addr < mem_segments[seg].end)) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+/* EOF main.c */
diff --git a/ecos/packages/redboot/current/src/mcmp.c b/ecos/packages/redboot/current/src/mcmp.c
new file mode 100644
index 0000000..28a7db6
--- /dev/null
+++ b/ecos/packages/redboot/current/src/mcmp.c
@@ -0,0 +1,133 @@
+//==========================================================================
+//
+// mcmp.c
+//
+// RedBoot memory compare (mcmp) routine
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2002-08-06
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+
+RedBoot_cmd("mcmp",
+ "Compare two blocks of memory",
+ "-s <location> -d <location> -l <length> [-1|-2|-4]",
+ do_mcmp
+ );
+
+void
+do_mcmp(int argc, char *argv[])
+{
+ // Fill a region of memory with a pattern
+ struct option_info opts[6];
+ unsigned long src_base, dst_base;
+ long len;
+ bool src_base_set, dst_base_set, len_set;
+ bool set_32bit, set_16bit, set_8bit;
+
+ init_opts(&opts[0], 's', true, OPTION_ARG_TYPE_NUM,
+ (void *)&src_base, (bool *)&src_base_set, "base address");
+ init_opts(&opts[1], 'l', true, OPTION_ARG_TYPE_NUM,
+ (void *)&len, (bool *)&len_set, "length");
+ init_opts(&opts[2], 'd', true, OPTION_ARG_TYPE_NUM,
+ (void *)&dst_base, (bool *)&dst_base_set, "base address");
+ init_opts(&opts[3], '4', false, OPTION_ARG_TYPE_FLG,
+ (void *)&set_32bit, (bool *)0, "fill 32 bit units");
+ init_opts(&opts[4], '2', false, OPTION_ARG_TYPE_FLG,
+ (void *)&set_16bit, (bool *)0, "fill 16 bit units");
+ init_opts(&opts[5], '1', false, OPTION_ARG_TYPE_FLG,
+ (void *)&set_8bit, (bool *)0, "fill 8 bit units");
+ if (!scan_opts(argc, argv, 1, opts, 6, 0, 0, "")) {
+ return;
+ }
+ if (!src_base_set || !dst_base_set || !len_set) {
+ diag_printf("usage: mcmp -s <addr> -d <addr> -l <length> [-1|-2|-4]\n");
+ return;
+ }
+
+
+
+ if (set_8bit) {
+ cyg_uint8 *s = (cyg_uint8 *)src_base;
+ cyg_uint8 *d = (cyg_uint8 *)dst_base;
+ while ((len -= sizeof(cyg_uint8)) >= 0) {
+ if (*s++ != *d++) {
+ s--;
+ d--;
+ diag_printf("Buffers don't match - %p=0x%02x, %p=0x%02x\n",
+ s, *s, d, *d);
+ return;
+ }
+
+ }
+ } else if (set_16bit) {
+ cyg_uint16 *s = (cyg_uint16 *)src_base;
+ cyg_uint16 *d = (cyg_uint16 *)dst_base;
+ while ((len -= sizeof(cyg_uint16)) >= 0) {
+ if (*s++ != *d++) {
+ s--;
+ d--;
+ diag_printf("Buffers don't match - %p=0x%04x, %p=0x%04x\n",
+ s, *s, d, *d);
+ return;
+ }
+
+ }
+ } else {
+ cyg_uint32 *s = (cyg_uint32 *)src_base;
+ cyg_uint32 *d = (cyg_uint32 *)dst_base;
+ while ((len -= sizeof(cyg_uint32)) >= 0) {
+ if (*s++ != *d++) {
+ s--;
+ d--;
+ diag_printf("Buffers don't match - %p=0x%08x, %p=0x%08x\n",
+ s, *s, d, *d);
+ return;
+ }
+ }
+ }
+}
diff --git a/ecos/packages/redboot/current/src/mcopy.c b/ecos/packages/redboot/current/src/mcopy.c
new file mode 100644
index 0000000..356a95c
--- /dev/null
+++ b/ecos/packages/redboot/current/src/mcopy.c
@@ -0,0 +1,133 @@
+//==========================================================================
+//
+// mcopy.c
+//
+// RedBoot memory copy (mcopy) routine
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): msalter
+// Contributors: msalter
+// Date: 2003-07-01
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+
+static void
+do_mcopy(int argc, char *argv[])
+{
+ struct option_info opts[6];
+ unsigned long src, dst, len, end;
+ bool src_set, dst_set, len_set;
+ bool sz32, sz16, sz8;
+ int incr = 1;
+
+ init_opts(&opts[0], 's', true, OPTION_ARG_TYPE_NUM,
+ (void *)&src, (bool *)&src_set, "base address");
+ init_opts(&opts[1], 'l', true, OPTION_ARG_TYPE_NUM,
+ (void *)&len, (bool *)&len_set, "length");
+ init_opts(&opts[2], 'd', true, OPTION_ARG_TYPE_NUM,
+ (void *)&dst, (bool *)&dst_set, "base address");
+ init_opts(&opts[3], '4', false, OPTION_ARG_TYPE_FLG,
+ (void *)&sz32, (bool *)0, "copy 32 bit data");
+ init_opts(&opts[4], '2', false, OPTION_ARG_TYPE_FLG,
+ (void *)&sz16, (bool *)0, "copy 16 bit data");
+ init_opts(&opts[5], '1', false, OPTION_ARG_TYPE_FLG,
+ (void *)&sz8, (bool *)0, "copy 8 bit data");
+ if (!scan_opts(argc, argv, 1, opts, 6, 0, 0, "")) {
+ return;
+ }
+
+ // Must have src, dst, len. No more than one size specifier.
+ if (!src_set || !dst_set || !len_set || (sz32 + sz16 + sz8) > 1) {
+ diag_printf("usage: mcopy -s <addr> -d <addr> -l <length> [-1|-2|-4]\n");
+ return;
+ }
+
+ // adjust incr and len for data size
+ if (sz16) {
+ len = (len + 1) & ~1;
+ incr = 2;
+ } else if (sz32 || !sz8) {
+ len = (len + 3) & ~3;
+ incr = 4;
+ }
+
+ end = src + len;
+
+ // If overlapping areas, must copy backwards.
+ if (dst > src && dst < (src + len)) {
+ end = src - incr;
+ src += (len - incr);
+ dst += (len - incr);
+ incr = -incr;
+ }
+
+ if (sz8) {
+ while (src != end) {
+ *(cyg_uint8 *)dst = *(cyg_uint8 *)src;
+ src += incr;
+ dst += incr;
+ }
+ } else if (sz16) {
+ while (src != end) {
+ *(cyg_uint16 *)dst = *(cyg_uint16 *)src;
+ src += incr;
+ dst += incr;
+ }
+ } else {
+ // Default - 32 bits
+ while (src != end) {
+ *(cyg_uint32 *)dst = *(cyg_uint32 *)src;
+ src += incr;
+ dst += incr;
+ }
+ }
+}
+
+
+RedBoot_cmd("mcopy",
+ "Copy memory from one address to another",
+ "-s <location> -d <location> -l <length> [-1|-2|-4]",
+ do_mcopy
+ );
diff --git a/ecos/packages/redboot/current/src/mfill.c b/ecos/packages/redboot/current/src/mfill.c
new file mode 100644
index 0000000..80efce6
--- /dev/null
+++ b/ecos/packages/redboot/current/src/mfill.c
@@ -0,0 +1,111 @@
+//==========================================================================
+//
+// mfill.c
+//
+// RedBoot memory fill (mfill) routine
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2002-08-06
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+
+RedBoot_cmd("mfill",
+ "Fill a block of memory with a pattern",
+ "-b <location> -l <length> -p <pattern> [-1|-2|-4]",
+ do_mfill
+ );
+
+void
+do_mfill(int argc, char *argv[])
+{
+ // Fill a region of memory with a pattern
+ struct option_info opts[6];
+ unsigned long base, pat;
+ long len;
+ bool base_set, len_set, pat_set;
+ bool set_32bit, set_16bit, set_8bit;
+
+ init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM,
+ (void *)&base, (bool *)&base_set, "base address");
+ init_opts(&opts[1], 'l', true, OPTION_ARG_TYPE_NUM,
+ (void *)&len, (bool *)&len_set, "length");
+ init_opts(&opts[2], 'p', true, OPTION_ARG_TYPE_NUM,
+ (void *)&pat, (bool *)&pat_set, "pattern");
+ init_opts(&opts[3], '4', false, OPTION_ARG_TYPE_FLG,
+ (void *)&set_32bit, (bool *)0, "fill 32 bit units");
+ init_opts(&opts[4], '2', false, OPTION_ARG_TYPE_FLG,
+ (void *)&set_16bit, (bool *)0, "fill 16 bit units");
+ init_opts(&opts[5], '1', false, OPTION_ARG_TYPE_FLG,
+ (void *)&set_8bit, (bool *)0, "fill 8 bit units");
+ if (!scan_opts(argc, argv, 1, opts, 6, 0, 0, "")) {
+ return;
+ }
+ if (!base_set || !len_set) {
+ diag_printf("usage: mfill -b <addr> -l <length> [-p <pattern>] [-1|-2|-4]\n");
+ return;
+ }
+ if (!pat_set) {
+ pat = 0;
+ }
+ // No checks here
+
+ if (set_8bit) {
+ cyg_uint8 *p = (cyg_uint8 *)base;
+ while ((len -= sizeof(cyg_uint8)) >= 0)
+ *p++ = (cyg_uint8)pat;
+ } else if (set_16bit) {
+ cyg_uint16 *p = (cyg_uint16 *)base;
+ while ((len -= sizeof(cyg_uint16)) >= 0)
+ *p++ = (cyg_uint16)pat;
+ } else {
+ cyg_uint32 *p = (cyg_uint32 *)base;
+ while ((len -= sizeof(cyg_uint32)) >= 0)
+ *p++ = (cyg_uint32)pat;
+ }
+
+}
+
diff --git a/ecos/packages/redboot/current/src/misc_funs.c b/ecos/packages/redboot/current/src/misc_funs.c
new file mode 100644
index 0000000..9b1d19e
--- /dev/null
+++ b/ecos/packages/redboot/current/src/misc_funs.c
@@ -0,0 +1,80 @@
+//==========================================================================
+//
+// misc_funs.c
+//
+// Miscellaneous [library] functions for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+
+int
+strcasecmp(const char *s1, const char *s2)
+{
+ char c1, c2;
+ while ((c1 = _tolower(*s1++)) == (c2 = _tolower(*s2++)))
+ if (c1 == 0)
+ return (0);
+ return ((unsigned char)c1 - (unsigned char)c2);
+}
+
+int
+strncasecmp(const char *s1, const char *s2, size_t len)
+{
+ char c1, c2;
+
+ if (len == 0)
+ return 0;
+ do {
+ if ((c1 = _tolower(*s1++)) != (c2 = _tolower(*s2++)))
+ return ((unsigned char)c1 - (unsigned char)c2);
+ if (c1 == 0)
+ break;
+ } while (--len != 0);
+ return 0;
+}
diff --git a/ecos/packages/redboot/current/src/net/arp.c b/ecos/packages/redboot/current/src/net/arp.c
new file mode 100644
index 0000000..86e3a7d
--- /dev/null
+++ b/ecos/packages/redboot/current/src/net/arp.c
@@ -0,0 +1,210 @@
+//==========================================================================
+//
+// net/arp.c
+//
+// Stand-alone ARP support for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <net/net.h>
+
+static struct {
+ int waiting;
+ char *eth;
+ char *ip;
+} arp_req;
+
+/*
+ * Handle incoming ARP packets.
+ */
+void
+__arp_handler(pktbuf_t *pkt)
+{
+ arp_header_t *arp = pkt->arp_hdr;
+ int hw_type, protocol;
+
+ /*
+ * Only handle ethernet hardware and IP protocol.
+ */
+ protocol = ntohs(arp->protocol);
+ hw_type = ntohs(arp->hw_type);
+ if ((hw_type == ARP_HW_ETHER) && (protocol == ETH_TYPE_IP)) {
+ /*
+ * Handle requests for our ethernet address.
+ */
+ if (!memcmp(arp->target_ip, __local_ip_addr, 4)) {
+ if (ntohs(arp->opcode) == ARP_REQUEST) {
+ /* format response. */
+ arp->opcode = htons(ARP_REPLY);
+ memcpy(arp->target_ip, arp->sender_ip,
+ sizeof(ip_addr_t));
+ memcpy(arp->target_enet, arp->sender_enet,
+ sizeof(enet_addr_t));
+ memcpy(arp->sender_ip, __local_ip_addr,
+ sizeof(ip_addr_t));
+ memcpy(arp->sender_enet, __local_enet_addr,
+ sizeof(enet_addr_t));
+ pkt->pkt_bytes = sizeof(arp_header_t);
+ __enet_send(pkt, &arp->target_enet, ETH_TYPE_ARP);
+
+ } else if (ntohs(arp->opcode) == ARP_REPLY && arp_req.waiting) {
+ if (!memcmp(arp_req.ip, arp->sender_ip, sizeof(ip_addr_t))) {
+ memcpy(arp_req.eth, arp->sender_enet, sizeof(enet_addr_t));
+ arp_req.waiting = 0;
+ }
+ }
+ }
+ }
+ __pktbuf_free(pkt);
+}
+
+
+/*
+ * Find the ethernet address of the machine with the given
+ * ip address.
+ * Return 0 and fills in 'eth_addr' if successful,
+ * -1 if unsuccessful.
+ */
+int
+__arp_request(ip_addr_t *ip_addr, enet_addr_t *eth_addr, int allow_self)
+{
+ pktbuf_t *pkt;
+ arp_header_t *arp;
+ unsigned long retry_start;
+ enet_addr_t bcast_addr;
+ int retry;
+
+ if (!allow_self) {
+ // Special case request for self
+ if (!memcmp(ip_addr, __local_ip_addr, 4)) {
+ memcpy(eth_addr, __local_enet_addr, sizeof(enet_addr_t));
+ return 0;
+ }
+ }
+
+ /* just fail if can't get a buffer */
+ if ((pkt = __pktbuf_alloc(ARP_PKT_SIZE)) == NULL)
+ return -1;
+
+ arp = pkt->arp_hdr;
+ arp->opcode = htons(ARP_REQUEST);
+ arp->hw_type = htons(ARP_HW_ETHER);
+ arp->protocol = htons(0x800);
+ arp->hw_len = sizeof(enet_addr_t);
+ arp->proto_len = sizeof(ip_addr_t);
+
+ memcpy(arp->sender_ip, __local_ip_addr, sizeof(ip_addr_t));
+ memcpy(arp->sender_enet, __local_enet_addr, sizeof(enet_addr_t));
+ memcpy(arp->target_ip, ip_addr, sizeof(ip_addr_t));
+
+ bcast_addr[0] = 255;
+ bcast_addr[1] = 255;
+ bcast_addr[2] = 255;
+ bcast_addr[3] = 255;
+ bcast_addr[4] = 255;
+ bcast_addr[5] = 255;
+
+ arp_req.eth = (char *)eth_addr;
+ arp_req.ip = (char *)ip_addr;
+ arp_req.waiting = 1;
+
+ retry = 8;
+ while (retry-- > 0) {
+
+ /* send the packet */
+ pkt->pkt_bytes = sizeof(arp_header_t);
+ __enet_send(pkt, &bcast_addr, ETH_TYPE_ARP);
+
+ retry_start = MS_TICKS();
+ while ((MS_TICKS_DELAY() - retry_start) < 250) {
+ __enet_poll();
+ if (!arp_req.waiting) {
+ __pktbuf_free(pkt);
+ return 0;
+ }
+ }
+ }
+ __pktbuf_free(pkt);
+ return -1;
+}
+
+#define NUM_ARP 16
+static ip_route_t routes[NUM_ARP];
+
+int
+__arp_lookup(ip_addr_t *host, ip_route_t *rt)
+{
+ int i;
+ static int next_arp = 0;
+
+ for (i = 0; i < NUM_ARP; i++) {
+ if (memcmp(host, &routes[i].ip_addr, sizeof(*host)) == 0) {
+ // This is a known host
+ memcpy(rt, &routes[i], sizeof(*rt));
+ return 0;
+ }
+ }
+ memcpy(&rt->ip_addr, host, sizeof(*host));
+ if (((*host)[0] == 0xFF) && ((*host)[1] == 0xFF) && ((*host)[2] == 0xFF)) {
+ memset(&rt->enet_addr, 0xFF, sizeof(rt->enet_addr));
+ return 0;
+#ifdef CYGSEM_REDBOOT_NETWORKING_USE_GATEWAY
+ } else if (!__ip_addr_local(host)) {
+ // non-local IP address -- look up Gateway's Ethernet address
+ host = &__local_ip_gate;
+#endif
+ }
+ if (__arp_request(host, &rt->enet_addr, 0) < 0) {
+ return -1;
+ } else {
+ memcpy(&routes[next_arp], rt, sizeof(*rt));
+ if (++next_arp == NUM_ARP) next_arp = 0;
+ return 0;
+ }
+}
+
diff --git a/ecos/packages/redboot/current/src/net/bootp.c b/ecos/packages/redboot/current/src/net/bootp.c
new file mode 100644
index 0000000..0570f87
--- /dev/null
+++ b/ecos/packages/redboot/current/src/net/bootp.c
@@ -0,0 +1,397 @@
+//==========================================================================
+//
+// net/bootp.c
+//
+// Stand-alone minimal BOOTP support for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// grant edwards
+// Contributors: gthomas
+// grant edwards
+// Date: 2011-03-18
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+#include <net/net.h>
+#include <net/bootp.h>
+
+#define RETRY_TIME_MS 2000
+#define MAX_RETRIES 4
+
+static unsigned xid; // transaction ID, should be random/unique
+static const ip_route_t broadcast = { {255, 255, 255, 255},
+ {0xff, 0xff, 0xff, 0xff, 0xff, 0xff} };
+static bootp_header_t *bp_info;
+
+#ifdef CYGSEM_REDBOOT_NETWORKING_DHCP
+static const unsigned char dhcpCookie[] = { 99, 130, 83, 99 };
+static const unsigned char dhcpDiscover[] = { 53, 1, 1 };
+static const unsigned char dhcpRequest[] = { 53, 1, 3 };
+static const unsigned char dhcpRequestIP[] = { 50, 4 };
+static const unsigned char dhcpParamRequestList[] = { 55, 3, 1, 3, 6 };
+static const unsigned char dhcpEnd[] = { 255 };
+#endif
+
+// FSM states -- only NONE and DONE are used in BOOTP mode
+static enum {
+ DHCP_NONE = 0,
+ DHCP_WAITING_FOR_OFFER,
+ DHCP_WAITING_FOR_ACK,
+ DHCP_DONE,
+ DHCP_FAILED
+} dhcpState;
+
+#if !defined(CYGSEM_REDBOOT_NETWORKING_BOOTP_VERBOSE)
+# define debug_printf(format, ...) /* noop */
+#else
+# define debug_printf(format, ...) diag_printf(format, ##__VA_ARGS__)
+static const char *dhcpStateString[] = { "NONE", "WAITING_FOR_OFFER", "WAITING_FOR_ACK", "DONE", "FAILED" };
+# ifdef CYGSEM_REDBOOT_NETWORKING_DHCP
+static const char *dhcpTypeString[] = { "0x00", "DISCOVER", "OFFER", "REQUEST", "0x04", "ACK", "NAK", "0x07" };
+# endif
+#endif
+
+// parse network configuration from a DHCP ACK packet or BOOTP REPLY
+static void
+parseConfig(bootp_header_t *bp, int len)
+{
+#ifdef CYGSEM_REDBOOT_NETWORKING_DHCP
+ unsigned char *end,
+ *p;
+ int optlen;
+#endif
+ memcpy(__local_ip_addr, &bp->bp_yiaddr, sizeof __local_ip_addr);
+#ifdef CYGSEM_REDBOOT_NETWORKING_USE_GATEWAY
+ memcpy(__local_ip_gate, &bp->bp_giaddr, sizeof __local_ip_gate);
+#endif
+
+#ifdef CYGSEM_REDBOOT_NETWORKING_DHCP
+
+ // are there option fields to parse?
+ if (memcmp(bp->bp_vend, dhcpCookie, sizeof dhcpCookie))
+ return;
+
+ p = bp->bp_vend + 4;
+ end = (unsigned char *)bp + len;
+ while (p < end) {
+ unsigned char tag = *p;
+ if (tag == TAG_END)
+ break;
+ if (tag == TAG_PAD)
+ optlen = 1;
+ else {
+ optlen = p[1];
+ p += 2;
+ switch (tag) {
+# ifdef CYGSEM_REDBOOT_NETWORKING_USE_GATEWAY
+ case TAG_SUBNET_MASK:
+ memcpy(__local_ip_mask, p, sizeof __local_ip_mask);
+ break;
+ case TAG_GATEWAY:
+ memcpy(__local_ip_gate, p, sizeof __local_ip_gate);
+ break;
+# endif
+# ifdef CYGPKG_REDBOOT_NETWORKING_DNS
+ case TAG_DOMAIN_SERVER:
+ memcpy(&__bootp_dns_addr, p, sizeof __bootp_dns_addr);
+ __bootp_dns_set = 1;
+ break;
+# endif
+ default:
+ break;
+ }
+ }
+ p += optlen;
+ }
+#endif
+}
+
+// functions used to prepare BOOTP/DHCP tx packets
+
+// basic BOOTP request
+static void
+prep_bootp_request(bootp_header_t *b)
+{
+ memset(b, 0, sizeof *b);
+ b->bp_op = BOOTREQUEST;
+ b->bp_htype = HTYPE_ETHERNET;
+ b->bp_hlen = sizeof __local_enet_addr;
+ b->bp_xid = xid;
+ memcpy(b->bp_chaddr, __local_enet_addr, sizeof b->bp_chaddr);
+}
+
+#ifdef CYGSEM_REDBOOT_NETWORKING_DHCP
+
+# define AddOption(p,d) do {memcpy(p,d,sizeof d); p += sizeof d;} while (0)
+
+// add DHCP DISCOVER fields to a basic BOOTP request
+static int
+prep_dhcp_discover(bootp_header_t *b)
+{
+ unsigned char *p = b->bp_vend;
+ AddOption(p, dhcpCookie);
+ AddOption(p, dhcpDiscover);
+ AddOption(p, dhcpParamRequestList);
+ AddOption(p, dhcpEnd);
+ if (p < &b->bp_vend[BP_MIN_VEND_SIZE])
+ p = &b->bp_vend[BP_MIN_VEND_SIZE];
+ return p - (unsigned char *)b;
+}
+
+// add DHCP REQUEST fields to a basic BOOTP request using data from supplied DHCP OFFER
+static int
+prep_dhcp_request(bootp_header_t *b, bootp_header_t *offer)
+{
+ unsigned char *p = b->bp_vend;
+ AddOption(p, dhcpCookie);
+ AddOption(p, dhcpRequest);
+ AddOption(p, dhcpRequestIP);
+ memcpy(p, &offer->bp_yiaddr, dhcpRequestIP[1]);
+ p += dhcpRequestIP[1]; // Ask for the address just given
+ AddOption(p, dhcpParamRequestList);
+ AddOption(p, dhcpEnd);
+ if (p < &b->bp_vend[BP_MIN_VEND_SIZE])
+ p = &b->bp_vend[BP_MIN_VEND_SIZE];
+ return p - (unsigned char *)b;
+}
+#endif
+
+// Macro used to change state of BOOTP/DHCP state machine
+#define NewDhcpState(state) do {dhcpState = state; debug_printf("DHCP state: %s\n",dhcpStateString[state]);}while(0)
+
+// send BOOTP REQUEST or DHCP DISCOVER
+static void
+bootp_start(void)
+{
+ int txSize;
+ bootp_header_t b;
+ // send out a BOOTP request or DHCP DISCOVER
+ prep_bootp_request(&b); // basic BOOTP request
+#ifdef CYGSEM_REDBOOT_NETWORKING_DHCP
+ debug_printf("DHCP send: DISCOVER\n");
+ NewDhcpState(DHCP_WAITING_FOR_OFFER);
+ txSize = prep_dhcp_discover(&b); // make it into DHCP DISCOVER
+#else
+ debug_printf("BOOTP send: REQUEST\n");
+ txSize = sizeof(b);
+#endif
+ __udp_send((char *)&b, txSize, (ip_route_t*)&broadcast, IPPORT_BOOTPS, IPPORT_BOOTPC);
+}
+
+// save packet for use by other commands
+static void
+save_packet(void *b, int len)
+{
+ memset(bp_info, 0, sizeof *bp_info);
+ if ((unsigned)len > sizeof *bp_info)
+ len = sizeof *bp_info;
+ memcpy(bp_info, b, len);
+}
+
+// Handler for received BOOTP/DHCP packets
+static void
+bootp_handler(udp_socket_t *skt, char *buf, int len, ip_route_t *src_route,
+ word src_port)
+{
+ bootp_header_t *b;
+#ifdef CYGSEM_REDBOOT_NETWORKING_DHCP
+ int txSize;
+ int type;
+ bootp_header_t txpkt;
+ unsigned expected = 0;
+#endif
+
+ b = (bootp_header_t *) buf;
+
+ // only accept BOOTP REPLY responses
+ if (b->bp_op != BOOTREPLY)
+ return;
+
+ // must be sent to me
+ if (memcmp(b->bp_chaddr, __local_enet_addr, b->bp_hlen))
+ return;
+
+ // verify XID
+ if (b->bp_xid != xid)
+ return;
+
+#if !defined(CYGSEM_REDBOOT_NETWORKING_DHCP)
+ // simple BOOTP - this is all there is!
+ debug_printf("BOOTP recv: REPLY\n");
+ if (dhcpState != DHCP_DONE) {
+ save_packet(b, len);
+ parseConfig(b, len);
+ NewDhcpState(DHCP_DONE);
+ }
+#else
+ // DHCP support is enabled...
+
+ // Check to see that it's a DHCP packet with a DHCP type field
+
+ type = -1;
+ if (!memcmp(b->bp_vend, dhcpCookie, sizeof dhcpCookie)) {
+ unsigned char *p = b->bp_vend + 4;
+ while (p < (unsigned char *)b + len) {
+ if (*p == TAG_DHCP_MESS_TYPE) {
+ type = p[2];
+ break;
+ }
+ p += p[1] + 2;
+ }
+ }
+
+ if (type == -1) {
+ // apparently we have a BOOTP (but not not DHCP) server
+ debug_printf("DHCP recv: BOOTP-REPLY -- falling back to BOOTP mode\n");
+ if (dhcpState != DHCP_DONE) {
+ save_packet(b, len);
+ parseConfig(b, len);
+ NewDhcpState(DHCP_DONE);
+ }
+ return;
+ }
+
+ // it's a real DHCP packet
+ debug_printf("DHCP recv: %s [%d]\n", dhcpTypeString[type], type);
+
+ switch (dhcpState) {
+ case DHCP_WAITING_FOR_OFFER:
+ if (type == (expected = DHCP_MESS_TYPE_OFFER)) {
+ prep_bootp_request(&txpkt);
+ txSize = prep_dhcp_request(&txpkt, b);
+ debug_printf("DHCP send: REQUEST\n");
+ NewDhcpState(DHCP_WAITING_FOR_ACK);
+ __udp_send((char *)&txpkt, txSize, (ip_route_t *)&broadcast, IPPORT_BOOTPS, IPPORT_BOOTPC);
+ return;
+ }
+ break;
+
+ case DHCP_WAITING_FOR_ACK:
+ if (type == (expected = DHCP_MESS_TYPE_ACK)) {
+ save_packet(b, len);
+ parseConfig(b, len);
+ NewDhcpState(DHCP_DONE);
+ return;
+ }
+ break;
+
+ default:
+ debug_printf("DHCP packet ignored\n");
+ return;
+ }
+
+ if (type == DHCP_MESS_TYPE_NAK && dhcpState != DHCP_DONE) {
+ NewDhcpState(DHCP_FAILED);
+ return;
+ }
+
+ debug_printf("DHCP packet ignored -- expected %d[%s]\n", expected, dhcpTypeString[expected]);
+#endif
+}
+
+
+// Request IP configuration via BOOTP/DHCP.
+// Return zero if successful, -1 if not.
+
+int
+__bootp_find_local_ip(bootp_header_t *info)
+{
+ udp_socket_t udp_skt;
+ int retry;
+ unsigned long start;
+ ip_addr_t saved_ip_addr;
+
+ bp_info = info;
+
+ diag_printf("\nRequesting IP conf via BOOTP/DHCP...\n");
+
+ memcpy(&xid, __local_enet_addr, sizeof xid);
+ xid ^= (__local_enet_addr[4]<<16) + __local_enet_addr[5];
+ xid ^= (unsigned)&retry + (unsigned)&__bootp_find_local_ip;
+
+ debug_printf("XID: %08x\n",xid);
+
+ memcpy(saved_ip_addr, __local_ip_addr, sizeof __local_ip_addr); // save our IP in case of failure
+
+ NewDhcpState(DHCP_NONE);
+
+ __udp_install_listener(&udp_skt, IPPORT_BOOTPC, bootp_handler);
+
+ retry = MAX_RETRIES;
+
+ while (retry > 0) {
+ start = MS_TICKS();
+ memset(__local_ip_addr, 0, sizeof(__local_ip_addr));
+
+ // send bootp REQUEST or dhcp DISCOVER
+ bootp_start();
+
+ // wait for timeout, user-abort, or for receive packet handler to fail/succeed
+ while ((MS_TICKS_DELAY() - start) < RETRY_TIME_MS) {
+ __enet_poll();
+ if (dhcpState == DHCP_FAILED)
+ break;
+ if (dhcpState == DHCP_DONE)
+ goto done;
+ if (_rb_break(1)) // did user hit ^C?
+ goto failed;
+ MS_TICKS_DELAY();
+ }
+ --retry;
+ ++xid;
+ diag_printf("TIMEOUT%s\n", retry ? ", retrying..." : "");
+ }
+
+failed:
+ diag_printf("FAIL\n");
+ __udp_remove_listener(IPPORT_BOOTPC);
+ memcpy(__local_ip_addr, saved_ip_addr, sizeof __local_ip_addr); // restore prev IP
+ return -1;
+
+done:
+ diag_printf("OK\n");
+ __udp_remove_listener(IPPORT_BOOTPC);
+ return 0;
+}
diff --git a/ecos/packages/redboot/current/src/net/cksum.c b/ecos/packages/redboot/current/src/net/cksum.c
new file mode 100644
index 0000000..5a11450
--- /dev/null
+++ b/ecos/packages/redboot/current/src/net/cksum.c
@@ -0,0 +1,123 @@
+//==========================================================================
+//
+// net/cksum.c
+//
+// Stand-alone network checksum support for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <net/net.h>
+
+/*
+ * Do a one's complement checksum.
+ * The data being checksum'd is in network byte order.
+ * The returned checksum is in network byte order.
+ */
+unsigned short
+__sum(word *w, int len, int init_sum)
+{
+ int sum = init_sum;
+
+ union {
+ volatile unsigned char c[2];
+ volatile unsigned short s;
+ } su;
+
+ union {
+ volatile unsigned short s[2];
+ volatile int i;
+ } iu;
+
+ while ((len -= 2) >= 0)
+ sum += *w++;
+
+ if (len == -1) {
+ su.c[0] = *(char *)w;
+ su.c[1] = 0;
+ sum += su.s;
+ }
+
+ iu.i = sum;
+ sum = iu.s[0] + iu.s[1];
+ if (sum > 65535)
+ sum -= 65535;
+
+ su.s = ~sum;
+
+ return (su.c[0] << 8) | su.c[1];
+}
+
+
+/*
+ * Compute a partial checksum for the UDP/TCP pseudo header.
+ */
+int
+__pseudo_sum(ip_header_t *ip)
+{
+ int sum;
+ word *p;
+
+ union {
+ volatile unsigned char c[2];
+ volatile unsigned short s;
+ } su;
+
+ p = (word *)ip->source;
+ sum = *p++;
+ sum += *p++;
+ sum += *p++;
+ sum += *p++;
+
+ su.c[0] = 0;
+ su.c[1] = ip->protocol;
+ sum += su.s;
+
+ sum += ip->length;
+
+ return sum;
+}
diff --git a/ecos/packages/redboot/current/src/net/dns.c b/ecos/packages/redboot/current/src/net/dns.c
new file mode 100644
index 0000000..0f8e8dd
--- /dev/null
+++ b/ecos/packages/redboot/current/src/net/dns.c
@@ -0,0 +1,327 @@
+//=============================================================================
+//
+// dns.c
+//
+// DNS client code
+//
+//=============================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//=============================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): jskov
+// Contributors:jskov
+// Date: 2001-09-26
+// Description: Provides DNS lookup as per RFC 1034/1035.
+//
+// Note: This is a stripped down clone of dns.c from the CYGPKG_NS_DNS
+// package which does not use malloc/free and has been tweaked to
+// use UDP via RedBoot's network stack. Also adds commands
+// to set the DNS server IP at runtime.
+//
+//####DESCRIPTIONEND####
+//
+//=============================================================================
+
+#include <cyg/hal/drv_api.h>
+#include <cyg/infra/cyg_type.h>
+#include <cyg/infra/cyg_trac.h> /* Tracing support */
+
+#include <net/net.h>
+#include <redboot.h>
+/* #include <cyg/ns/dns/dns.h> - it's been moved to redboot.h */
+#include <cyg/ns/dns/dns_priv.h>
+
+#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
+#include <flash_config.h>
+
+RedBoot_config_option("DNS server IP address",
+ dns_ip,
+ ALWAYS_ENABLED, true,
+ CONFIG_IP,
+ 0
+ );
+
+RedBoot_config_option("DNS domain name",
+ dns_domain,
+ ALWAYS_ENABLED, true,
+ CONFIG_STRING,
+ ""
+ );
+#endif
+
+/* So we remember which ports have been used */
+static int get_port = 7700;
+
+#define DOMAIN_PORT 53
+
+/* Some magic to make dns_impl.inl compile under RedBoot */
+#define sprintf diag_sprintf
+
+/* DNS server address possibly returned from bootp */
+struct in_addr __bootp_dns_addr;
+cyg_bool __bootp_dns_set = false;
+
+/* DNS domain name possibly returned from bootp */
+#ifdef CYGPKG_REDBOOT_NETWORKING_DNS_DHCP_DOMAIN
+char __bootp_dns_domain[CYGNUM_REDBOOT_NETWORK_DNS_DOMAIN_BUFSIZE];
+cyg_bool __bootp_dns_domain_set = false;
+#endif
+
+struct sockaddr_in server;
+
+/* static buffers so we can make do without malloc */
+static struct hostent _hent;
+static char* _h_addr_list[2];
+static struct in_addr _h_addr_list0;
+static int _hent_alloc = 0;
+
+#define _STRING_COUNT 2
+#define _STRING_LENGTH 64
+static char _strings[_STRING_COUNT][_STRING_LENGTH];
+static int _strings_alloc = 0;
+
+/* as in dns.c proper */
+static short id = 0; /* ID of the last query */
+static int s = -1; /* Socket to the DNS server */
+static cyg_drv_mutex_t dns_mutex; /* Mutex to stop multiple queries as once */
+static char * domainname=NULL; /* Domain name used for queries */
+
+
+/* Allocate space for string of length (len). Return NULL on
+ failure. */
+static char*
+alloc_string(int len)
+{
+ int i;
+
+ if (len > _STRING_LENGTH)
+ return NULL;
+
+ for (i = 0; i < _STRING_COUNT; i++) {
+ if (_strings_alloc & (1 << i)) continue;
+ _strings_alloc |= (1<<i);
+ return _strings[i];
+ }
+ return NULL;
+}
+
+static void
+free_string(char* s)
+{
+ int i;
+ for (i = 0; i < _STRING_COUNT; i++) {
+ if (_strings[i] == s) {
+ _strings_alloc &= ~(1<<i);
+ break;
+ }
+ }
+}
+
+/* Deallocate the memory taken to hold a hent structure */
+static void
+free_hent(struct hostent * hent)
+{
+ if (hent->h_name) {
+ free_string(hent->h_name);
+ }
+ _hent_alloc = 0;
+}
+
+/* Allocate hent structure with room for one in_addr. Returns NULL on
+ failure. */
+static struct hostent*
+alloc_hent(void)
+{
+ struct hostent *hent;
+
+ if (_hent_alloc) return NULL;
+
+ hent = &_hent;
+ memset(hent, 0, sizeof(struct hostent));
+ hent->h_addr_list = _h_addr_list;
+ hent->h_addr_list[0] = (char*)&_h_addr_list0;
+ hent->h_addr_list[1] = NULL;
+ _hent_alloc = 1;
+
+ return hent;
+}
+
+static __inline__ void
+free_stored_hent(void)
+{
+ free_hent( &_hent );
+}
+
+static __inline__ void
+store_hent(struct hostent *hent)
+{
+ hent=hent; // avoid warning
+}
+
+/* Send the query to the server and read the response back. Return -1
+ if it fails, otherwise put the response back in msg and return the
+ length of the response. */
+static int
+send_recv(char * msg, int len, int msglen)
+{
+ struct dns_header *dns_hdr;
+ int finished = false;
+ int read = 0;
+
+ dns_hdr = (struct dns_header *) msg;
+
+ do {
+ int len_togo = len;
+ struct timeval timeout;
+ struct sockaddr_in local_addr, from_addr;
+
+ memset((char *)&local_addr, 0, sizeof(local_addr));
+ local_addr.sin_family = AF_INET;
+ local_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ local_addr.sin_port = htons(get_port++);
+
+ if (__udp_sendto(msg, len_togo, &server, &local_addr) < 0)
+ return -1;
+
+ memset((char *)&from_addr, 0, sizeof(from_addr));
+
+ timeout.tv_sec = CYGNUM_REDBOOT_NETWORKING_DNS_TIMEOUT;
+ timeout.tv_usec = 0;
+
+ read = __udp_recvfrom(msg, len, &from_addr, &local_addr, &timeout);
+ if (read < 0)
+ return -1;
+
+ /* Reply to an old query. Ignore it */
+ if (ntohs(dns_hdr->id) != (id-1)) {
+ continue;
+ }
+ finished = true;
+ } while (!finished);
+
+ return read;
+}
+
+void
+set_dns(char* new_ip)
+{
+ in_addr_t dns_ip;
+
+ memset(&server.sin_addr, 0, sizeof(server.sin_addr));
+ if (!inet_aton(new_ip, &dns_ip)) {
+ diag_printf("Bad DNS server address: %s\n", new_ip);
+ } else {
+ memcpy(&server.sin_addr, &dns_ip, sizeof(dns_ip));
+ /* server config is valid */
+ s = 0;
+ }
+}
+
+void
+show_dns(void)
+{
+ diag_printf("\nDNS server IP: %s, DNS domain name: %s",
+ inet_ntoa((in_addr_t *)&server.sin_addr),
+ domainname);
+ if (0 == server.sin_addr.s_addr) {
+ s = -1;
+ }
+}
+
+/* Initialise the resolver. Open a socket and bind it to the address
+ of the server. return -1 if something goes wrong, otherwise 0 */
+int
+redboot_dns_res_init(void)
+{
+#ifdef CYGPKG_REDBOOT_NETWORKING_DNS_FCONFIG_DOMAIN
+ char *dns_domain = NULL;
+#endif
+ memset((char *)&server, 0, sizeof(server));
+ server.sin_len = sizeof(server);
+ server.sin_family = AF_INET;
+ server.sin_port = htons(DOMAIN_PORT);
+ cyg_drv_mutex_init(&dns_mutex);
+
+ /* Set the default DNS domain first, so that it can be overwritten
+ latter */
+#ifdef CYGPKG_REDBOOT_NETWORKING_DNS_DEFAULT_DOMAIN
+ setdomainname(__Xstr(CYGPKG_REDBOOT_NETWORKING_DNS_DEFAULT_DOMAIN),
+ strlen(__Xstr(CYGPKG_REDBOOT_NETWORKING_DNS_DEFAULT_DOMAIN)));
+#endif
+ /* Set the domain name from flash so that DHCP can later
+ overwrite it. */
+#ifdef CYGPKG_REDBOOT_NETWORKING_DNS_FCONFIG_DOMAIN
+ flash_get_config("dns_domain", &dns_domain, CONFIG_STRING);
+ if(dns_domain != NULL && dns_domain[0] != '\0')
+ setdomainname(dns_domain, strlen(dns_domain));
+#endif
+
+ /* If we got a DNS server address from the DHCP/BOOTP, then use
+ that address */
+ if ( __bootp_dns_set ) {
+ memcpy(&server.sin_addr, &__bootp_dns_addr,
+ sizeof(__bootp_dns_addr) );
+
+#ifdef CYGPKG_REDBOOT_NETWORKING_DNS_DHCP_DOMAIN
+ if(__bootp_dns_domain_set)
+ setdomainname(__bootp_dns_domain, strlen(__bootp_dns_domain));
+#endif
+ /* server config is valid */
+ s = 0;
+ }
+ else {
+#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
+ {
+ ip_addr_t dns_ip;
+
+ flash_get_config("dns_ip", &dns_ip, CONFIG_IP);
+ if (dns_ip[0] == 0 && dns_ip[1] == 0 &&
+ dns_ip[2] == 0 && dns_ip[3] == 0)
+ return -1;
+ memcpy(&server.sin_addr, &dns_ip, sizeof(dns_ip));
+ /* server config is valid */
+ s = 0;
+ }
+#else
+ // Use static configuration. If CYGPKG_REDBOOT_NETWORKING_DNS_IP
+ // is valid s will set set as a side effect.
+ set_dns(__Xstr(CYGPKG_REDBOOT_NETWORKING_DNS_IP));
+#endif
+ }
+
+ return 0;
+}
+
+/* Include the DNS client implementation code */
+#include <cyg/ns/dns/dns_impl.inl>
diff --git a/ecos/packages/redboot/current/src/net/enet.c b/ecos/packages/redboot/current/src/net/enet.c
new file mode 100644
index 0000000..5d31421
--- /dev/null
+++ b/ecos/packages/redboot/current/src/net/enet.c
@@ -0,0 +1,247 @@
+//==========================================================================
+//
+// net/enet.c
+//
+// Stand-alone ethernet [link-layer] support for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+#include <net/net.h>
+#include <cyg/io/eth/eth_drv.h> // Logical driver interfaces
+
+//#define ENET_STATS 1
+
+#ifdef ENET_STATS
+static int num_ip = 0;
+static int num_arp = 0;
+#ifdef NET_SUPPORT_RARP
+static int num_rarp = 0;
+#endif
+static int num_received = 0;
+static int num_transmitted = 0;
+#endif
+
+//
+// Support for user handlers of additional ethernet packets (nonIP)
+//
+
+#define NUM_EXTRA_HANDLERS 4
+static struct {
+ int type;
+ pkt_handler_t handler;
+} eth_handlers[NUM_EXTRA_HANDLERS];
+
+pkt_handler_t
+__eth_install_listener(int eth_type, pkt_handler_t handler)
+{
+ int i, empty;
+ pkt_handler_t old;
+
+ if (eth_type > 0x800 || handler != (pkt_handler_t)0) {
+ empty = -1;
+ for (i = 0; i < NUM_EXTRA_HANDLERS; i++) {
+ if (eth_handlers[i].type == eth_type) {
+ // Replace existing handler
+ old = eth_handlers[i].handler;
+ eth_handlers[i].handler = handler;
+ return old;
+ }
+ if (eth_handlers[i].type == 0) {
+ empty = i;
+ }
+ }
+ if (empty >= 0) {
+ // Found a free slot
+ eth_handlers[empty].type = eth_type;
+ eth_handlers[empty].handler = handler;
+ return (pkt_handler_t)0;
+ }
+ }
+ diag_printf("** Warning: can't install listener for ethernet type 0x%02x\n", eth_type);
+ return (pkt_handler_t)0;
+}
+
+void
+__eth_remove_listener(int eth_type)
+{
+ int i;
+
+ for (i = 0; i < NUM_EXTRA_HANDLERS; i++) {
+ if (eth_handlers[i].type == eth_type) {
+ eth_handlers[i].type = 0;
+ }
+ }
+}
+
+/*
+ * Non-blocking poll of ethernet link. Process packets until no more
+ * are available.
+ */
+void
+__enet_poll(void)
+{
+ pktbuf_t *pkt;
+ eth_header_t eth_hdr;
+ int i, type;
+#ifdef DEBUG_PKT_EXHAUSTION
+ static bool was_exhausted = false;
+#endif
+
+ while (true) {
+ /*
+ * Try to get a free pktbuf and return if none
+ * are available.
+ */
+ if ((pkt = __pktbuf_alloc(ETH_MAX_PKTLEN)) == NULL) {
+#ifdef DEBUG_PKT_EXHAUSTION
+ if (!was_exhausted) {
+ int old = start_console(); // Force output to standard port
+ diag_printf("__enet_poll: no more buffers\n");
+ __pktbuf_dump();
+ was_exhausted = true;
+ end_console(old);
+ }
+#endif
+ return;
+ }
+#ifdef DEBUG_PKT_EXHAUSTION
+ was_exhausted = false; // Report the next time we're out of buffers
+#endif
+
+ if ((pkt->pkt_bytes = eth_drv_read((char *)&eth_hdr, (char *)pkt->buf,
+ ETH_MAX_PKTLEN)) > 0) {
+#ifdef ENET_STATS
+ ++num_received;
+#endif
+ switch (type = ntohs(eth_hdr.type)) {
+
+ case ETH_TYPE_IP:
+#ifdef ENET_STATS
+ ++num_ip;
+#endif
+ pkt->ip_hdr = (ip_header_t *)pkt->buf;
+ __ip_handler(pkt, &eth_hdr.source);
+ break;
+
+ case ETH_TYPE_ARP:
+#ifdef ENET_STATS
+ ++num_arp;
+#endif
+ pkt->arp_hdr = (arp_header_t *)pkt->buf;
+ __arp_handler(pkt);
+ break;
+
+#ifdef NET_SUPPORT_RARP
+ case ETH_TYPE_RARP:
+#ifdef ENET_STATS
+ ++num_rarp;
+#endif
+ pkt->arp_hdr = (arp_header_t *)pkt->buf;
+ __rarp_handler(pkt);
+ break;
+#endif
+
+ default:
+ if (type > 0x800) {
+ for (i = 0; i < NUM_EXTRA_HANDLERS; i++) {
+ if (eth_handlers[i].type == type) {
+ (eth_handlers[i].handler)(pkt, &eth_hdr);
+ }
+ }
+ }
+ __pktbuf_free(pkt);
+ break;
+ }
+ } else {
+ __pktbuf_free(pkt);
+ break;
+ }
+ }
+}
+
+
+
+/*
+ * Send an ethernet packet.
+ */
+void
+__enet_send(pktbuf_t *pkt, enet_addr_t *dest, int eth_type)
+{
+ eth_header_t eth_hdr;
+
+ // Set up ethernet header
+ memcpy(&eth_hdr.destination, dest, sizeof(enet_addr_t));
+ memcpy(&eth_hdr.source, __local_enet_addr, sizeof(enet_addr_t));
+ eth_hdr.type = htons(eth_type);
+
+ eth_drv_write((char *)&eth_hdr, (char *)pkt->buf, pkt->pkt_bytes);
+#ifdef ENET_STATS
+ ++num_transmitted;
+#endif
+}
+
+#ifdef __LITTLE_ENDIAN__
+
+unsigned long
+ntohl(unsigned long x)
+{
+ return (((x & 0x000000FF) << 24) |
+ ((x & 0x0000FF00) << 8) |
+ ((x & 0x00FF0000) >> 8) |
+ ((x & 0xFF000000) >> 24));
+}
+
+unsigned short
+ntohs(unsigned short x)
+{
+ return (((x & 0x00FF) << 8) |
+ ((x & 0xFF00) >> 8));
+}
+
+#endif
diff --git a/ecos/packages/redboot/current/src/net/http_client.c b/ecos/packages/redboot/current/src/net/http_client.c
new file mode 100644
index 0000000..615a726
--- /dev/null
+++ b/ecos/packages/redboot/current/src/net/http_client.c
@@ -0,0 +1,258 @@
+//==========================================================================
+//
+// net/http_client.c
+//
+// Stand-alone HTTP support for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2002-05-22
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+// HTTP client support
+
+#include <redboot.h> // have_net
+#include <net/net.h>
+#include <net/http.h>
+
+// So we remember which ports have been used
+static int get_port = 7800;
+
+static struct _stream{
+ bool open;
+ int avail, actual_len, pos, filelen;
+ char data[4096];
+ char *bufp;
+ tcp_socket_t sock;
+} http_stream;
+
+static __inline__ int
+min(int a, int b)
+{
+ if (a < b)
+ return a;
+ else
+ return b;
+}
+
+int
+http_stream_open(connection_info_t *info, int *err)
+{
+ int res;
+ struct _stream *s = &http_stream;
+
+ if (!info->server->sin_port)
+ info->server->sin_port = 80; // HTTP port
+ if ((res = __tcp_open(&s->sock, info->server, get_port++, 5000, err)) < 0) {
+ *err = HTTP_OPEN;
+ return -1;
+ }
+ diag_sprintf(s->data, "GET %s HTTP/1.0\r\n\r\n", info->filename);
+ __tcp_write_block(&s->sock, s->data, strlen(s->data));
+ s->avail = 0;
+ s->open = true;
+ s->pos = 0;
+ return 0;
+}
+
+void
+http_stream_close(int *err)
+{
+ struct _stream *s = &http_stream;
+
+ if (s->open) {
+ __tcp_abort(&s->sock,1);
+ s->open = false;
+ }
+}
+
+int
+http_stream_read(char *buf,
+ int len,
+ int *err)
+{
+ struct _stream *s = &http_stream;
+ int total = 0;
+ int cnt, code;
+
+ if (!s->open) {
+ return -1; // Shouldn't happen, but...
+ }
+ while (len) {
+ while (s->avail == 0) {
+ // Need to wait for some data to arrive
+ __tcp_poll();
+ if (s->sock.state != _ESTABLISHED) {
+ if (s->sock.state == _CLOSE_WAIT) {
+ // This connection is breaking
+ if (s->sock.data_bytes == 0 && s->sock.rxcnt == 0) {
+ __tcp_close(&s->sock);
+ return total;
+ }
+ } else if (s->sock.state == _CLOSED) {
+ // The connection is gone
+ s->open = false;
+ return -1;
+ } else {
+ *err = HTTP_IO;
+ return -1;
+ }
+ }
+ s->actual_len = __tcp_read(&s->sock, s->data, sizeof(s->data));
+ if (s->actual_len > 0) {
+ s->bufp = s->data;
+ s->avail = s->actual_len;
+ if (s->pos == 0) {
+ // First data - need to scan HTTP response header
+ if (strncmp(s->bufp, "HTTP/", 5) == 0) {
+ // Should look like "HTTP/1.1 200 OK"
+ s->bufp += 5;
+ s->avail -= 5;
+ // Find first space
+ while ((s->avail > 0) && (*s->bufp != ' ')) {
+ s->bufp++;
+ s->avail--;
+ }
+ // Now the integer response
+ code = 0;
+ while ((s->avail > 0) && (*s->bufp == ' ')) {
+ s->bufp++;
+ s->avail--;
+ }
+ while ((s->avail > 0) && isdigit(*s->bufp)) {
+ code = (code * 10) + (*s->bufp - '0');
+ s->bufp++;
+ s->avail--;
+ }
+ // Make sure it says OK
+ while ((s->avail > 0) && (*s->bufp == ' ')) {
+ s->bufp++;
+ s->avail--;
+ }
+ if (strncmp(s->bufp, "OK", 2)) {
+ switch (code) {
+ case 400:
+ *err = HTTP_BADREQ;
+ break;
+ case 403:
+ *err = HTTP_FORBIDDEN;
+ break;
+ case 404:
+ *err = HTTP_NOFILE;
+ break;
+ default:
+ *err = HTTP_BADHDR;
+ break;
+ }
+ return -1;
+ }
+ // Find \r\n\r\n - end of HTTP preamble
+ while (s->avail >= 4) {
+ // This could be done faster, but not simpler
+ if (strncmp(s->bufp, "\r\n\r\n", 4) == 0) {
+ s->bufp += 4;
+ s->avail -= 4;
+#if 0 // DEBUG - show header
+ *(s->bufp-2) = '\0';
+ diag_printf(s->data);
+#endif
+ break;
+ }
+ s->avail--;
+ s->bufp++;
+ }
+ s->pos++;
+ } else {
+ // Unrecognized response
+ *err = HTTP_BADHDR;
+ return -1;
+ }
+ }
+ } else if (s->actual_len < 0) {
+ *err = HTTP_IO;
+ return -1;
+ }
+ }
+ cnt = min(len, s->avail);
+ memcpy(buf, s->bufp, cnt);
+ s->avail -= cnt;
+ s->bufp += cnt;
+ buf += cnt;
+ total += cnt;
+ len -= cnt;
+ }
+ return total;
+}
+
+char *
+http_error(int err)
+{
+ char *errmsg = "Unknown error";
+
+ switch (err) {
+ case HTTP_NOERR:
+ return "";
+ case HTTP_BADHDR:
+ return "Unrecognized HTTP response";
+ case HTTP_BADREQ:
+ return "Bad HTTP request (check file name)";
+ case HTTP_NOFILE:
+ return "No such file";
+ case HTTP_OPEN:
+ return "Can't connect to host";
+ case HTTP_IO:
+ return "I/O error";
+ case HTTP_FORBIDDEN:
+ return "Forbidden (check permissions)";
+ }
+ return errmsg;
+}
+
+//
+// RedBoot interface
+//
+GETC_IO_FUNCS(http_io, http_stream_open, http_stream_close,
+ 0, http_stream_read, http_error);
+RedBoot_load(http, http_io, true, true, 0);
diff --git a/ecos/packages/redboot/current/src/net/icmp.c b/ecos/packages/redboot/current/src/net/icmp.c
new file mode 100644
index 0000000..12cad17
--- /dev/null
+++ b/ecos/packages/redboot/current/src/net/icmp.c
@@ -0,0 +1,125 @@
+//==========================================================================
+//
+// net/icmp.c
+//
+// Stand-alone ICMP networking support for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <net/net.h>
+
+/*
+ * Handle ICMP packets.
+ */
+static void default_icmp_handler(pktbuf_t *pkt, ip_route_t *dest);
+
+static icmp_handler_t icmp_handler = default_icmp_handler;
+
+/*
+ * Install a user defined user_handler for incoming icmp packets.
+ * Returns zero if successful, -1 if the user_handler is already used.
+ */
+int
+__icmp_install_listener(icmp_handler_t user_handler)
+{
+ if (icmp_handler == user_handler) {
+ return -1;
+ }
+ icmp_handler = user_handler;
+ return 0;
+}
+
+
+/*
+ * Replace a user defined handler by the default handler.
+ */
+void
+__icmp_remove_listener(void)
+{
+ if (icmp_handler != default_icmp_handler) {
+ icmp_handler = default_icmp_handler;
+ }
+}
+
+/*
+ * ICMP entry point with an IP packet pkt and the destination dest a reply
+ * should be sent to.
+ */
+void
+__icmp_handler(pktbuf_t *pkt, ip_route_t *dest)
+{
+ (*icmp_handler)(pkt, dest);
+
+ BSPLOG(bsp_log("icmp: dest[%s] type[%d] seq[%d]\n",
+ inet_ntoa(pkt->ip_hdr->destination),
+ pkt->icmp_hdr->type,
+ pkt->icmp_hdr->seqnum));
+ __pktbuf_free(pkt);
+}
+
+
+/*
+ * The default ICMP handler only handles ICMP incoming echo request and
+ * outgoing echo reply.
+ */
+static void
+default_icmp_handler(pktbuf_t *pkt, ip_route_t *dest)
+{
+ word cksum;
+
+ if (pkt->icmp_hdr->type == ICMP_TYPE_ECHOREQUEST
+ && pkt->icmp_hdr->code == 0
+ && __sum((word *)pkt->icmp_hdr, pkt->pkt_bytes, 0) == 0) {
+
+ pkt->icmp_hdr->type = ICMP_TYPE_ECHOREPLY;
+ pkt->icmp_hdr->checksum = 0;
+ cksum = __sum((word *)pkt->icmp_hdr, pkt->pkt_bytes, 0);
+ pkt->icmp_hdr->checksum = htons(cksum);
+ __ip_send(pkt, IP_PROTO_ICMP, dest);
+ }
+}
diff --git a/ecos/packages/redboot/current/src/net/inet_addr.c b/ecos/packages/redboot/current/src/net/inet_addr.c
new file mode 100644
index 0000000..b84540c
--- /dev/null
+++ b/ecos/packages/redboot/current/src/net/inet_addr.c
@@ -0,0 +1,117 @@
+//==========================================================================
+//
+// net/inet_addr.c
+//
+// Stand-alone IP address parsing for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+#include <net/net.h>
+
+bool
+inet_aton(const char *s, in_addr_t *addr)
+{
+ int i, val, radix, digit;
+ unsigned long res = 0;
+ bool first;
+ char c;
+
+ for (i = 0; i < 4; i++) {
+ // Parse next digit string
+ first = true;
+ val = 0;
+ radix = 10;
+ while ((c = *s++) != '\0') {
+ if (first && (c == '0') && (_tolower(*s) == 'x')) {
+ radix = 16;
+ s++; // Skip over 0x
+ c = *s++;
+ }
+ first = false;
+ if (_is_hex(c) && ((digit = _from_hex(c)) < radix)) {
+ // Valid digit
+ val = (val * radix) + digit;
+ } else if (c == '.' && i < 3) { // all but last terminate by '.'
+ break;
+ } else {
+ return false;
+ }
+ }
+ // merge result
+#ifdef __LITTLE_ENDIAN__
+ res |= val << ((3-i)*8); // 24, 16, 8, 0
+#else
+ res = (res << 8) | val;
+#endif
+ if ('\0' == c) {
+ if (0 == i) { // first field found end of string
+ res = val; // no shifting, use it as the whole thing
+ break; // permit entering a single number
+ }
+ if (3 > i) // we found end of string before getting 4 fields
+ return false;
+ }
+ // after that we check that it was 0..255 only
+ if (val &~0xff) return false;
+ }
+ addr->s_addr = htonl(res);
+ return true;
+}
+
+// Assumes address is in network byte order
+char *
+inet_ntoa(in_addr_t *addr)
+{
+ static char str[32];
+ unsigned char *ap;
+
+ ap = (unsigned char *)addr;
+ diag_sprintf(str, "%d.%d.%d.%d", ap[0], ap[1], ap[2], ap[3]);
+ return str;
+}
diff --git a/ecos/packages/redboot/current/src/net/ip.c b/ecos/packages/redboot/current/src/net/ip.c
new file mode 100644
index 0000000..b63ba22
--- /dev/null
+++ b/ecos/packages/redboot/current/src/net/ip.c
@@ -0,0 +1,214 @@
+//==========================================================================
+//
+// net/ip.c
+//
+// Stand-alone IP networking support for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <net/net.h>
+
+#ifndef CYGDAT_REDBOOT_DEFAULT_IP_ADDR
+# define CYGDAT_REDBOOT_DEFAULT_IP_ADDR 0, 0, 0, 0
+#endif
+#ifndef CYGDAT_REDBOOT_DEFAULT_IP_ADDR_MASK
+# define CYGDAT_REDBOOT_DEFAULT_IP_ADDR_MASK 255, 255, 255, 0
+#endif
+#ifndef CYGDAT_REDBOOT_DEFAULT_GATEWAY_IP_ADDR
+# define CYGDAT_REDBOOT_DEFAULT_GATEWAY_IP_ADDR 0, 0, 0, 0
+#endif
+
+ip_addr_t __local_ip_addr = { CYGDAT_REDBOOT_DEFAULT_IP_ADDR };
+#ifdef CYGSEM_REDBOOT_NETWORKING_USE_GATEWAY
+ip_addr_t __local_ip_mask = { CYGDAT_REDBOOT_DEFAULT_IP_ADDR_MASK };
+ip_addr_t __local_ip_gate = { CYGDAT_REDBOOT_DEFAULT_GATEWAY_IP_ADDR };
+#endif
+
+static word ip_ident;
+
+#ifdef CYGSEM_REDBOOT_NETWORKING_USE_GATEWAY
+/*
+ * See if an address is on the local network
+ */
+int
+__ip_addr_local(ip_addr_t *addr)
+{
+ return !(
+ ((__local_ip_addr[0] ^ (*addr)[0]) & __local_ip_mask[0]) |
+ ((__local_ip_addr[1] ^ (*addr)[1]) & __local_ip_mask[1]) |
+ ((__local_ip_addr[2] ^ (*addr)[2]) & __local_ip_mask[2]) |
+ ((__local_ip_addr[3] ^ (*addr)[3]) & __local_ip_mask[3]));
+}
+#endif
+
+/*
+ * Match given IP address to our address.
+ * Check for broadcast matches as well.
+ */
+static int
+ip_addr_match(ip_addr_t addr)
+{
+ if (addr[0] == 255 && addr[1] == 255 && addr[2] == 255 && addr[3] == 255)
+ return 1;
+
+ if (!memcmp(addr, __local_ip_addr, sizeof(ip_addr_t)))
+ return 1;
+
+ /*
+ * Consider it an address match if we haven't gotten our IP address yet.
+ * Some DHCP servers will address IP packets to the assigned address
+ * instead of a IP broadcast address.
+ */
+ if (__local_ip_addr[0] == 0 && __local_ip_addr[1] == 0 &&
+ __local_ip_addr[2] == 0 && __local_ip_addr[3] == 0)
+ return 1;
+
+ return 0;
+}
+
+
+extern void __tcp_handler(pktbuf_t *, ip_route_t *);
+
+/*
+ * Handle IP packets coming from the polled ethernet interface.
+ */
+void
+__ip_handler(pktbuf_t *pkt, enet_addr_t *src_enet_addr)
+{
+ ip_header_t *ip = pkt->ip_hdr;
+ ip_route_t r;
+ int hdr_bytes;
+
+ /* first make sure its ours and has a good checksum. */
+ if (!ip_addr_match(ip->destination) ||
+ __sum((word *)ip, ip->hdr_len << 2, 0) != 0) {
+ __pktbuf_free(pkt);
+ return;
+ }
+
+ memcpy(r.ip_addr, ip->source, sizeof(ip_addr_t));
+ memcpy(r.enet_addr, src_enet_addr, sizeof(enet_addr_t));
+
+ hdr_bytes = ip->hdr_len << 2;
+ pkt->pkt_bytes = ntohs(ip->length) - hdr_bytes;
+
+ switch (ip->protocol) {
+
+#if NET_SUPPORT_ICMP
+ case IP_PROTO_ICMP:
+ pkt->icmp_hdr = (icmp_header_t *)(((char *)ip) + hdr_bytes);
+ __icmp_handler(pkt, &r);
+ break;
+#endif
+
+#if NET_SUPPORT_TCP
+ case IP_PROTO_TCP:
+ pkt->tcp_hdr = (tcp_header_t *)(((char *)ip) + hdr_bytes);
+ __tcp_handler(pkt, &r);
+ break;
+#endif
+
+#if NET_SUPPORT_UDP
+ case IP_PROTO_UDP:
+ pkt->udp_hdr = (udp_header_t *)(((char *)ip) + hdr_bytes);
+ __udp_handler(pkt, &r);
+ break;
+#endif
+
+ default:
+ __pktbuf_free(pkt);
+ break;
+ }
+}
+
+
+/*
+ * Send an IP packet.
+ *
+ * The IP data field should contain pkt->pkt_bytes of data.
+ * pkt->[udp|tcp|icmp]_hdr points to the IP data field. Any
+ * IP options are assumed to be already in place in the IP
+ * options field.
+ */
+int
+__ip_send(pktbuf_t *pkt, int protocol, ip_route_t *dest)
+{
+ ip_header_t *ip = pkt->ip_hdr;
+ int hdr_bytes;
+ unsigned short cksum;
+
+ /*
+ * Figure out header length. The use udp_hdr is
+ * somewhat arbitrary, but works because it is
+ * a union with other IP protocol headers.
+ */
+ hdr_bytes = (((char *)pkt->udp_hdr) - ((char *)ip));
+
+ pkt->pkt_bytes += hdr_bytes;
+
+ ip->version = 4;
+ ip->hdr_len = hdr_bytes >> 2;
+ ip->tos = 0;
+ ip->length = htons(pkt->pkt_bytes);
+ ip->ident = htons(ip_ident);
+ ip_ident++;
+ ip->fragment = 0;
+ ip->ttl = 255;
+ ip->ttl = 64;
+ ip->protocol = protocol;
+ ip->checksum = 0;
+ memcpy(ip->source, __local_ip_addr, sizeof(ip_addr_t));
+ memcpy(ip->destination, dest->ip_addr, sizeof(ip_addr_t));
+ cksum = __sum((word *)ip, hdr_bytes, 0);
+ ip->checksum = htons(cksum);
+
+ __enet_send(pkt, &dest->enet_addr, ETH_TYPE_IP);
+ return 0;
+}
+
+
diff --git a/ecos/packages/redboot/current/src/net/net_io.c b/ecos/packages/redboot/current/src/net/net_io.c
new file mode 100644
index 0000000..dc84c23
--- /dev/null
+++ b/ecos/packages/redboot/current/src/net/net_io.c
@@ -0,0 +1,950 @@
+//==========================================================================
+//
+// net/net_io.c
+//
+// Stand-alone network logical I/O support for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+#include <net/net.h>
+#include <cyg/hal/hal_misc.h> // Helper functions
+#include <cyg/hal/hal_if.h> // HAL I/O interfaces
+#include <cyg/hal/drv_api.h>
+#include <cyg/hal/hal_intr.h>
+#include <cyg/infra/cyg_ass.h> // assertion macros
+
+#ifndef CYGSEM_REDBOOT_DEFAULT_NO_BOOTP
+#define CYGSEM_REDBOOT_DEFAULT_NO_BOOTP 0
+#endif
+
+#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
+#include <flash_config.h>
+
+RedBoot_config_option("GDB connection port",
+ gdb_port,
+ ALWAYS_ENABLED, true,
+ CONFIG_INT,
+ CYGNUM_REDBOOT_NETWORKING_TCP_PORT
+ );
+RedBoot_config_option("Network debug at boot time",
+ net_debug,
+ ALWAYS_ENABLED, true,
+ CONFIG_BOOL,
+ false
+ );
+#if defined(CYGHWR_NET_DRIVERS) && (CYGHWR_NET_DRIVERS > 1)
+RedBoot_config_option("Default network device",
+ net_device,
+ ALWAYS_ENABLED, true,
+ CONFIG_NETPORT,
+ CYGDAT_REDBOOT_DEFAULT_NETWORK_DEVICE
+ );
+#endif
+// Note: the following options are related. If 'bootp' is false, then
+// the other values are used in the configuration. Because of the way
+// that configuration tables are generated, they should have names which
+// are related. The configuration options will show up lexicographically
+// ordered, thus the peculiar naming. In this case, the 'use' option is
+// negated (if false, the others apply) which makes the names even more
+// confusing.
+
+#ifdef CYGPKG_REDBOOT_NETWORKING_BOOTP
+RedBoot_config_option("Use BOOTP for network configuration",
+ bootp,
+ ALWAYS_ENABLED, true,
+ CONFIG_BOOL,
+ !CYGSEM_REDBOOT_DEFAULT_NO_BOOTP
+ );
+#endif
+RedBoot_config_option("Local IP address",
+ bootp_my_ip,
+ "bootp", false,
+ CONFIG_IP,
+ 0
+ );
+#ifdef CYGSEM_REDBOOT_NETWORKING_USE_GATEWAY
+RedBoot_config_option("Local IP address mask",
+ bootp_my_ip_mask,
+ "bootp", false,
+ CONFIG_IP,
+ 0
+ );
+RedBoot_config_option("Gateway IP address",
+ bootp_my_gateway_ip,
+ "bootp", false,
+ CONFIG_IP,
+ 0
+ );
+#endif
+RedBoot_config_option("Default server IP address",
+ bootp_server_ip,
+ ALWAYS_ENABLED, true,
+ CONFIG_IP,
+ 0
+ );
+
+// Note: the following options are related too.
+RedBoot_config_option("Force console for special debug messages",
+ info_console_force,
+ ALWAYS_ENABLED, true,
+ CONFIG_BOOL,
+ false
+ );
+RedBoot_config_option("Console number for special debug messages",
+ info_console_number,
+ "info_console_force", true,
+ CONFIG_INT,
+ 0
+ );
+#endif
+
+#define TCP_CHANNEL CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS
+
+#ifdef DEBUG_TCP
+int show_tcp = 0;
+#endif
+
+static tcp_socket_t tcp_sock;
+static int state;
+static int _timeout = 500;
+static int orig_console, orig_debug;
+
+static int in_buflen = 0;
+static unsigned char in_buf[64];
+static unsigned char *in_bufp;
+static int out_buflen = 0;
+static unsigned char out_buf[1024];
+static unsigned char *out_bufp;
+static bool flush_output_lines = false;
+
+// Functions in this module
+static void net_io_flush(void);
+static void net_io_revert_console(void);
+static void net_io_putc(void*, cyg_uint8);
+
+// Special characters used by Telnet - must be interpretted here
+#define TELNET_IAC 0xFF // Interpret as command (escape)
+#define TELNET_IP 0xF4 // Interrupt process
+#define TELNET_WILL 0xFB // I Will do XXX
+#define TELNET_WONT 0xFC // I Won't do XXX
+#define TELNET_DO 0xFD // Will you XXX
+#define TELNET_DONT 0xFE // Don't you XXX
+#define TELNET_TM 0x06 // Time marker (special DO/WONT after IP)
+
+static cyg_bool
+_net_io_getc_nonblock(void* __ch_data, cyg_uint8* ch)
+{
+ if (in_buflen == 0) {
+ __tcp_poll();
+ if (tcp_sock.state == _CLOSE_WAIT) {
+ // This connection is breaking
+ if (tcp_sock.data_bytes == 0 && tcp_sock.rxcnt == 0) {
+ __tcp_close(&tcp_sock);
+ return false;
+ }
+ }
+ if (tcp_sock.state == _CLOSED) {
+ // The connection is gone
+ net_io_revert_console();
+ *ch = '\n';
+ return true;
+ }
+ in_buflen = __tcp_read(&tcp_sock, in_buf, sizeof(in_buf));
+ in_bufp = in_buf;
+#ifdef DEBUG_TCP
+ if (show_tcp && (in_buflen > 0)) {
+ int old_console;
+ old_console = start_console();
+ diag_printf("%s:%d\n", __FUNCTION__, __LINE__);
+ diag_dump_buf(in_buf, in_buflen);
+ end_console(old_console);
+ }
+#endif // DEBUG_TCP
+ }
+ if (in_buflen) {
+ *ch = *in_bufp++;
+ in_buflen--;
+ return true;
+ } else {
+ return false;
+ }
+}
+
+static cyg_bool
+net_io_getc_nonblock(void* __ch_data, cyg_uint8* ch)
+{
+ cyg_uint8 esc;
+
+ if (!_net_io_getc_nonblock(__ch_data, ch))
+ return false;
+
+ if (gdb_active || *ch != TELNET_IAC)
+ return true;
+
+ // Telnet escape - need to read/handle more
+ while (!_net_io_getc_nonblock(__ch_data, &esc)) ;
+
+ switch (esc) {
+ case TELNET_IAC:
+ // The other special case - escaped escape
+ return true;
+ case TELNET_IP:
+ // Special case for ^C == Interrupt Process
+ *ch = 0x03;
+ // Just in case the other end needs synchronizing
+ net_io_putc(__ch_data, TELNET_IAC);
+ net_io_putc(__ch_data, TELNET_WONT);
+ net_io_putc(__ch_data, TELNET_TM);
+ net_io_flush();
+ return true;
+ case TELNET_DO:
+ // Telnet DO option
+ while (!_net_io_getc_nonblock(__ch_data, &esc)) ;
+ // Respond with WONT option
+ net_io_putc(__ch_data, TELNET_IAC);
+ net_io_putc(__ch_data, TELNET_WONT);
+ net_io_putc(__ch_data, esc);
+ return false; // Ignore this whole thing!
+ case TELNET_WILL:
+ // Telnet WILL option
+ while (!_net_io_getc_nonblock(__ch_data, &esc)) ;
+ // Respond with DONT option
+ net_io_putc(__ch_data, TELNET_IAC);
+ net_io_putc(__ch_data, TELNET_DONT);
+ net_io_putc(__ch_data, esc);
+ return false; // Ignore this whole thing!
+ default:
+ return false;
+ }
+}
+
+static cyg_uint8
+net_io_getc(void* __ch_data)
+{
+ cyg_uint8 ch;
+ int idle_timeout = 10; // 10ms
+
+ CYGARC_HAL_SAVE_GP();
+ while (true) {
+ if (net_io_getc_nonblock(__ch_data, &ch)) break;
+ if (--idle_timeout == 0) {
+ net_io_flush();
+ idle_timeout = 10;
+ }
+ }
+ CYGARC_HAL_RESTORE_GP();
+ return ch;
+}
+
+static void
+net_io_flush(void)
+{
+ int n;
+ char *bp = out_buf;
+
+#ifdef DEBUG_TCP
+ if (show_tcp) {
+ int old_console;
+ old_console = start_console();
+ diag_printf("%s.%d\n", __FUNCTION__, __LINE__);
+ diag_dump_buf(out_buf, out_buflen);
+ end_console(old_console);
+ }
+#endif // SHOW_TCP
+ n = __tcp_write_block(&tcp_sock, bp, out_buflen);
+ if (n < 0) {
+ // The connection is gone!
+ net_io_revert_console();
+ } else {
+ out_buflen -= n;
+ bp += n;
+ }
+ out_bufp = out_buf; out_buflen = 0;
+ // Check interrupt flag
+ if (CYGACC_CALL_IF_CONSOLE_INTERRUPT_FLAG()) {
+ CYGACC_CALL_IF_CONSOLE_INTERRUPT_FLAG_SET(0);
+ cyg_hal_user_break(0);
+ }
+}
+
+static void
+net_io_putc(void* __ch_data, cyg_uint8 c)
+{
+ static bool have_dollar, have_hash;
+ static int hash_count;
+
+ CYGARC_HAL_SAVE_GP();
+ *out_bufp++ = c;
+ if (c == '$') have_dollar = true;
+ if (have_dollar && (c == '#')) {
+ have_hash = true;
+ hash_count = 0;
+ }
+ if ((++out_buflen == sizeof(out_buf)) ||
+ (flush_output_lines && c == '\n') ||
+ (have_hash && (++hash_count == 3))) {
+ net_io_flush();
+ have_dollar = false;
+ }
+ CYGARC_HAL_RESTORE_GP();
+}
+
+static void
+net_io_write(void* __ch_data, const cyg_uint8* __buf, cyg_uint32 __len)
+{
+ int old_console;
+
+ old_console = start_console();
+ diag_printf("%s.%d\n", __FUNCTION__, __LINE__);
+ end_console(old_console);
+#if 0
+ CYGARC_HAL_SAVE_GP();
+
+ while(__len-- > 0)
+ net_io_putc(__ch_data, *__buf++);
+
+ CYGARC_HAL_RESTORE_GP();
+#endif
+}
+
+static void
+net_io_read(void* __ch_data, cyg_uint8* __buf, cyg_uint32 __len)
+{
+ int old_console;
+
+ old_console = start_console();
+ diag_printf("%s.%d\n", __FUNCTION__, __LINE__);
+ end_console(old_console);
+#if 0
+ CYGARC_HAL_SAVE_GP();
+
+ while(__len-- > 0)
+ *__buf++ = net_io_getc(__ch_data);
+
+ CYGARC_HAL_RESTORE_GP();
+#endif
+}
+
+static cyg_bool
+net_io_getc_timeout(void* __ch_data, cyg_uint8* ch)
+{
+ int delay_count;
+ cyg_bool res;
+
+ CYGARC_HAL_SAVE_GP();
+ net_io_flush(); // Make sure any output has been sent
+ delay_count = _timeout;
+
+ for(;;) {
+ res = net_io_getc_nonblock(__ch_data, ch);
+ if (res || 0 == delay_count--)
+ break;
+ }
+
+ CYGARC_HAL_RESTORE_GP();
+
+ return res;
+}
+
+static int
+net_io_control(void *__ch_data, __comm_control_cmd_t __func, ...)
+{
+ static int vector = 0;
+ int ret = 0;
+ static int irq_state = 0;
+
+ CYGARC_HAL_SAVE_GP();
+
+ switch (__func) {
+ case __COMMCTL_IRQ_ENABLE:
+ irq_state = 1;
+ if (vector == 0) {
+ vector = eth_drv_int_vector();
+ }
+ HAL_INTERRUPT_UNMASK(vector);
+ break;
+ case __COMMCTL_IRQ_DISABLE:
+ ret = irq_state;
+ irq_state = 0;
+ if (vector == 0) {
+ vector = eth_drv_int_vector();
+ }
+ HAL_INTERRUPT_MASK(vector);
+ break;
+ case __COMMCTL_DBG_ISR_VECTOR:
+ ret = vector;
+ break;
+ case __COMMCTL_SET_TIMEOUT:
+ {
+ va_list ap;
+
+ va_start(ap, __func);
+
+ ret = _timeout;
+ _timeout = va_arg(ap, cyg_uint32);
+
+ va_end(ap);
+ break;
+ }
+ case __COMMCTL_FLUSH_OUTPUT:
+ net_io_flush();
+ break;
+ case __COMMCTL_ENABLE_LINE_FLUSH:
+ flush_output_lines = true;
+ break;
+ case __COMMCTL_DISABLE_LINE_FLUSH:
+ flush_output_lines = false;
+ break;
+ default:
+ break;
+ }
+ CYGARC_HAL_RESTORE_GP();
+ return ret;
+}
+
+static int
+net_io_isr(void *__ch_data, int* __ctrlc,
+ CYG_ADDRWORD __vector, CYG_ADDRWORD __data)
+{
+ char ch;
+
+ CYGARC_HAL_SAVE_GP();
+ *__ctrlc = 0;
+ if (net_io_getc_nonblock(__ch_data, &ch)) {
+ if (ch == 0x03) {
+ *__ctrlc = 1;
+ }
+ }
+ CYGARC_HAL_RESTORE_GP();
+ return CYG_ISR_HANDLED;
+}
+
+// TEMP
+
+int
+start_console(void)
+{
+ int cur_console =
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
+
+#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
+ int i = 0;
+ if ( flash_get_config( "info_console_force", &i, CONFIG_BOOL) )
+ if ( i )
+ if ( ! flash_get_config( "info_console_number", &i, CONFIG_INT) )
+ i = 0; // the default, if that call failed.
+ if ( i )
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(i);
+ else
+#endif
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(0);
+
+ return cur_console;
+}
+
+void
+end_console(int old_console)
+{
+ // Restore original console
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(old_console);
+}
+// TEMP
+
+static void
+net_io_revert_console(void)
+{
+#ifdef CYGPKG_REDBOOT_ANY_CONSOLE
+ console_selected = false;
+#endif
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(orig_console);
+ CYGACC_CALL_IF_SET_DEBUG_COMM(orig_debug);
+ console_echo = true;
+}
+
+static void
+net_io_assume_console(void)
+{
+#ifdef CYGPKG_REDBOOT_ANY_CONSOLE
+ console_selected = true;
+#endif
+ console_echo = false;
+ orig_console = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(TCP_CHANNEL);
+ orig_debug = CYGACC_CALL_IF_SET_DEBUG_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
+ CYGACC_CALL_IF_SET_DEBUG_COMM(TCP_CHANNEL);
+}
+
+static void
+net_io_init(void)
+{
+ static int init = 0;
+ if (!init) {
+ hal_virtual_comm_table_t* comm;
+ int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
+
+ // Setup procs in the vector table
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(TCP_CHANNEL);
+ comm = CYGACC_CALL_IF_CONSOLE_PROCS();
+ //CYGACC_COMM_IF_CH_DATA_SET(*comm, chan);
+ CYGACC_COMM_IF_WRITE_SET(*comm, net_io_write);
+ CYGACC_COMM_IF_READ_SET(*comm, net_io_read);
+ CYGACC_COMM_IF_PUTC_SET(*comm, net_io_putc);
+ CYGACC_COMM_IF_GETC_SET(*comm, net_io_getc);
+ CYGACC_COMM_IF_CONTROL_SET(*comm, net_io_control);
+ CYGACC_COMM_IF_DBG_ISR_SET(*comm, net_io_isr);
+ CYGACC_COMM_IF_GETC_TIMEOUT_SET(*comm, net_io_getc_timeout);
+
+ // Disable interrupts via this interface to set static
+ // state into correct state.
+ net_io_control( comm, __COMMCTL_IRQ_DISABLE );
+
+ // Restore original console
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
+
+ init = 1;
+ gdb_active = false;
+ }
+ __tcp_listen(&tcp_sock, gdb_port);
+ state = tcp_sock.state;
+#ifdef DEBUG_TCP
+ diag_printf("show tcp = %p\n", (void *)&show_tcp);
+#endif
+}
+
+// Check for incoming TCP debug connection
+void
+net_io_test(bool is_idle)
+{
+ if (!is_idle) return; // Only care about idle case
+ if (!have_net) return;
+ __tcp_poll();
+ if (state != tcp_sock.state) {
+ // Something has changed
+ if (tcp_sock.state == _ESTABLISHED) {
+ // A new connection has arrived
+ net_io_assume_console();
+ in_bufp = in_buf; in_buflen = 1; *in_bufp = '\r';
+ out_bufp = out_buf; out_buflen = 0;
+ }
+ if (tcp_sock.state == _CLOSED) {
+ net_io_init(); // Get ready for another connection
+ }
+ }
+ state = tcp_sock.state;
+}
+
+// This schedules the 'net_io_test()' function to be run by RedBoot's
+// main command loop when idle (i.e. when no input arrives after some
+// period of time).
+RedBoot_idle(net_io_test, RedBoot_IDLE_NETIO);
+
+//
+// Network initialization
+//
+#include <cyg/io/eth/eth_drv.h>
+#include <cyg/io/eth/netdev.h>
+#include <cyg/hal/hal_tables.h>
+
+// Define table boundaries
+CYG_HAL_TABLE_BEGIN( __NETDEVTAB__, netdev );
+CYG_HAL_TABLE_END( __NETDEVTAB_END__, netdev );
+
+RedBoot_init(net_init, RedBoot_INIT_NET);
+
+static void
+show_addrs(void)
+{
+ diag_printf("IP: %s", inet_ntoa((in_addr_t *)&__local_ip_addr));
+#ifdef CYGSEM_REDBOOT_NETWORKING_USE_GATEWAY
+ diag_printf("/%s", inet_ntoa((in_addr_t *)&__local_ip_mask));
+ diag_printf(", Gateway: %s\n", inet_ntoa((in_addr_t *)&__local_ip_gate));
+#else
+ diag_printf(", ");
+#endif
+ diag_printf("Default server: %s", inet_ntoa(&my_bootp_info.bp_siaddr));
+#ifdef CYGPKG_REDBOOT_NETWORKING_DNS
+ show_dns();
+#endif
+ diag_printf("\n");
+}
+
+#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
+static void
+flash_get_IP(char *id, ip_addr_t *val)
+{
+ ip_addr_t my_ip;
+ int i;
+
+ if (flash_get_config(id, &my_ip, CONFIG_IP)) {
+ if (my_ip[0] != 0 || my_ip[1] != 0 ||
+ my_ip[2] != 0 || my_ip[3] != 0) {
+ // 'id' is set to something so let it override any static IP
+ for (i=0; i<4; i++)
+ (*val)[i] = my_ip[i];
+ }
+ }
+}
+#endif
+
+static cyg_netdevtab_entry_t *
+net_devtab_entry(unsigned index)
+{
+ cyg_netdevtab_entry_t *t = &__NETDEVTAB__[index];
+
+ if (t < &__NETDEVTAB__[0] || t >= &__NETDEVTAB_END__)
+ return NULL;
+
+ return t;
+}
+
+const char *
+net_devname(unsigned index)
+{
+ cyg_netdevtab_entry_t *t = net_devtab_entry(index);
+ if (t)
+ return t->name;
+ return NULL;
+}
+
+int
+net_devindex(char *name)
+{
+ const char *devname;
+ int index;
+
+ for (index = 0; (devname = net_devname(index)) != NULL; index++)
+ if (!strcmp(name, devname))
+ return index;
+ return -1;
+}
+
+static void
+show_eth_info(void)
+{
+ diag_printf("Ethernet %s: MAC address %02x:%02x:%02x:%02x:%02x:%02x\n",
+ __local_enet_sc->dev_name,
+ __local_enet_addr[0],
+ __local_enet_addr[1],
+ __local_enet_addr[2],
+ __local_enet_addr[3],
+ __local_enet_addr[4],
+ __local_enet_addr[5]);
+}
+
+void
+net_init(void)
+{
+ cyg_netdevtab_entry_t *t;
+ unsigned index;
+ struct eth_drv_sc *primary_net = (struct eth_drv_sc *)0;
+#if defined(CYGHWR_NET_DRIVERS) && (CYGHWR_NET_DRIVERS > 1)
+ char *default_devname = CYGDAT_REDBOOT_DEFAULT_NETWORK_DEVICE;
+ int default_index;
+#endif
+#ifdef CYGDAT_REDBOOT_DEFAULT_BOOTP_SERVER_IP_ADDR
+ char ip_addr[16];
+#endif
+
+ // Set defaults as appropriate
+#if defined(CYGPKG_REDBOOT_NETWORKING_BOOTP) && !CYGSEM_REDBOOT_DEFAULT_NO_BOOTP
+ use_bootp = true;
+#else
+ use_bootp = false;
+#endif
+#ifdef CYGDBG_REDBOOT_NET_DEBUG
+ net_debug = true;
+#else
+ net_debug = false;
+#endif
+ gdb_port = CYGNUM_REDBOOT_NETWORKING_TCP_PORT;
+#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
+ // Fetch values from saved config data, if available
+#if defined(CYGHWR_NET_DRIVERS) && (CYGHWR_NET_DRIVERS > 1)
+ flash_get_config("net_device", &default_devname, CONFIG_NETPORT);
+#endif
+ flash_get_config("net_debug", &net_debug, CONFIG_BOOL);
+ flash_get_config("gdb_port", &gdb_port, CONFIG_INT);
+#ifdef CYGPKG_REDBOOT_NETWORKING_BOOTP
+ flash_get_config("bootp", &use_bootp, CONFIG_BOOL);
+#endif
+ if (!use_bootp) {
+ flash_get_IP("bootp_my_ip", &__local_ip_addr);
+#ifdef CYGSEM_REDBOOT_NETWORKING_USE_GATEWAY
+ flash_get_IP("bootp_my_ip_mask", &__local_ip_mask);
+ flash_get_IP("bootp_my_gateway_ip", &__local_ip_gate);
+#endif
+ }
+#endif
+# ifdef CYGDBG_IO_ETH_DRIVERS_DEBUG
+ // Don't override if the user has deliberately set something more
+ // verbose.
+ if (0 == cyg_io_eth_net_debug)
+ cyg_io_eth_net_debug = net_debug;
+# endif
+ have_net = false;
+ // Make sure the recv buffers are set up
+ eth_drv_buffers_init();
+ __pktbuf_init();
+
+ // Initialize network device(s).
+#if defined(CYGHWR_NET_DRIVERS) && (CYGHWR_NET_DRIVERS > 1)
+ default_index = net_devindex(default_devname);
+ if (default_index < 0)
+ default_index = 0;
+#ifdef CYGSEM_REDBOOT_NETWORK_INIT_ONE_DEVICE
+ if ((t = net_devtab_entry(default_index)) != NULL && t->init(t)) {
+ t->status = CYG_NETDEVTAB_STATUS_AVAIL;
+ primary_net = __local_enet_sc;
+ } else
+#endif
+#endif // (CYGHWR_NET_DRIVERS) && (CYGHWR_NET_DRIVERS > 1)
+ for (index = 0; (t = net_devtab_entry(index)) != NULL; index++) {
+#ifdef CYGSEM_REDBOOT_NETWORK_INIT_ONE_DEVICE
+ if (index == default_index)
+ continue;
+#endif
+ if (t->init(t)) {
+ t->status = CYG_NETDEVTAB_STATUS_AVAIL;
+ if (primary_net == (struct eth_drv_sc *)0) {
+ primary_net = __local_enet_sc;
+ }
+#if defined(CYGHWR_NET_DRIVERS) && (CYGHWR_NET_DRIVERS > 1)
+# ifdef CYGSEM_REDBOOT_NETWORK_INIT_ONE_DEVICE
+ break;
+# else
+ if (index == default_index) {
+ primary_net = __local_enet_sc;
+ }
+# endif // CYGSEM_REDBOOT_NETWORK_INIT_ONE_DEVICE
+#endif
+ }
+ }
+ __local_enet_sc = primary_net;
+
+ if (!__local_enet_sc) {
+ diag_printf("No network interfaces found\n");
+ return;
+ }
+ // Initialize the network [if present]
+#ifdef CYGPKG_REDBOOT_NETWORKING_BOOTP
+ if (use_bootp) {
+ if (__bootp_find_local_ip(&my_bootp_info) == 0) {
+ have_net = true;
+ } else {
+ // Is it an unset address, or has it been set to a static addr
+ if (__local_ip_addr[0] == 0 && __local_ip_addr[1] == 0 &&
+ __local_ip_addr[2] == 0 && __local_ip_addr[3] == 0) {
+ show_eth_info();
+ diag_printf("Can't get BOOTP info for device!\n");
+ } else {
+ diag_printf("Can't get BOOTP info, using default IP address\n");
+ have_net = true;
+ }
+ }
+ }
+#endif
+ if (!use_bootp) {
+ if (__local_ip_addr[0] == 0 && __local_ip_addr[1] == 0 &&
+ __local_ip_addr[2] == 0 && __local_ip_addr[3] == 0) {
+ show_eth_info();
+ diag_printf("No IP info for device!\n");
+ } else {
+ enet_addr_t enet_addr;
+ have_net = true; // Assume values in FLASH were OK
+ // Tell the world that we are using this fixed IP address
+ if (__arp_request((ip_addr_t *)__local_ip_addr, &enet_addr, 1) >= 0) {
+ diag_printf("Warning: IP address %s in use\n", inet_ntoa((in_addr_t *)&__local_ip_addr));
+ }
+ }
+ }
+ if (have_net) {
+ show_eth_info();
+#ifdef CYGDAT_REDBOOT_DEFAULT_BOOTP_SERVER_IP_ADDR
+ diag_sprintf(ip_addr, "%d.%d.%d.%d",
+ CYGDAT_REDBOOT_DEFAULT_BOOTP_SERVER_IP_ADDR);
+ inet_aton(ip_addr, &my_bootp_info.bp_siaddr);
+#endif
+#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
+ flash_get_IP("bootp_server_ip", (ip_addr_t *)&my_bootp_info.bp_siaddr);
+#endif
+#ifdef CYGPKG_REDBOOT_NETWORKING_DNS
+ redboot_dns_res_init();
+#endif
+ show_addrs();
+ net_io_init();
+ }
+}
+
+static char usage[] = ""
+#ifdef CYGPKG_REDBOOT_NETWORKING_BOOTP
+ " [-b]"
+#endif
+ " [-l <local_ip_address>[/<mask_len>]] [-h <server_address>]"
+#ifdef CYGPKG_REDBOOT_NETWORKING_DNS
+ " [-d <dns_server_address>]"
+#ifdef CYGPKG_REDBOOT_NETWORKING_DNS_FCONFIG_DOMAIN
+ " [-D <dns_domain_name>]"
+#endif
+#endif
+ ;
+
+// Exported CLI function
+static void do_ip_addr(int argc, char *argv[]);
+RedBoot_cmd("ip_address",
+ "Set/change IP addresses",
+ usage,
+ do_ip_addr
+ );
+
+void
+do_ip_addr(int argc, char *argv[])
+{
+ struct option_info opts[5];
+ char *ip_addr, *host_addr;
+ bool ip_addr_set, host_addr_set;
+#ifdef CYGPKG_REDBOOT_NETWORKING_BOOTP
+ bool do_bootp = false;
+#endif
+ struct sockaddr_in host;
+#ifdef CYGPKG_REDBOOT_NETWORKING_DNS
+ char *dns_addr;
+ bool dns_addr_set;
+#ifdef CYGPKG_REDBOOT_NETWORKING_DNS_FCONFIG_DOMAIN
+ char *dns_domain;
+ bool dns_domain_set;
+#endif
+#endif
+ int num_opts;
+
+ if (!have_net) {
+ diag_printf("Sorry, networking is not available.\n");
+ return;
+ }
+
+ init_opts(&opts[0], 'l', true, OPTION_ARG_TYPE_STR,
+ (void *)&ip_addr, (bool *)&ip_addr_set, "local IP address");
+ init_opts(&opts[1], 'h', true, OPTION_ARG_TYPE_STR,
+ (void *)&host_addr, (bool *)&host_addr_set, "default server address");
+ num_opts = 2;
+#ifdef CYGPKG_REDBOOT_NETWORKING_BOOTP
+ init_opts(&opts[2], 'b', false, OPTION_ARG_TYPE_FLG,
+ &do_bootp, 0, "use BOOTP");
+ num_opts++;
+#endif
+#ifdef CYGPKG_REDBOOT_NETWORKING_DNS
+ init_opts(&opts[num_opts], 'd', true, OPTION_ARG_TYPE_STR,
+ (void *)&dns_addr, (bool *)&dns_addr_set, "DNS server address");
+ num_opts++;
+#ifdef CYGPKG_REDBOOT_NETWORKING_DNS_FCONFIG_DOMAIN
+ init_opts(&opts[num_opts], 'D', true, OPTION_ARG_TYPE_STR,
+ (void *)&dns_domain, (bool *)&dns_domain_set, "DNS domain");
+ num_opts++;
+#endif
+#endif
+ CYG_ASSERT(num_opts <= NUM_ELEMS(opts), "Too many options");
+
+ if (!scan_opts(argc, argv, 1, opts, num_opts, 0, 0, "")) {
+ return;
+ }
+#ifdef CYGPKG_REDBOOT_NETWORKING_BOOTP
+ if (do_bootp) {
+ if (__bootp_find_local_ip(&my_bootp_info) != 0) {
+ diag_printf("Failed to get BOOTP address\n");
+ }
+ }
+#endif
+ if (ip_addr_set) {
+#ifdef CYGSEM_REDBOOT_NETWORKING_USE_GATEWAY
+ char *slash_pos;
+ /* see if the (optional) mask length was given */
+ if( (slash_pos = strchr(ip_addr, '/')) ) {
+ unsigned long mask, mask_len;
+ *slash_pos = '\0';
+ slash_pos++;
+ if( !parse_num(slash_pos, &mask_len, 0, 0) ||
+ mask_len == 0 || mask_len > 32 ) {
+ diag_printf("Invalid mask length: %s\n", slash_pos);
+ return;
+ }
+ mask = htonl((0xffffffff << (32-mask_len))&0xffffffff);
+ memcpy(&__local_ip_mask, &mask, 4);
+ }
+#endif
+ if (!_gethostbyname(ip_addr, (in_addr_t *)&host)) {
+ diag_printf("Invalid local IP address: %s\n", ip_addr);
+ return;
+ }
+ // Of course, each address goes in its own place :-)
+ memcpy(&__local_ip_addr, &host.sin_addr, sizeof(host.sin_addr));
+ }
+ if (host_addr_set) {
+ if (!_gethostbyname(host_addr, (in_addr_t *)&host)) {
+ diag_printf("Invalid server address: %s\n", host_addr);
+ return;
+ }
+ my_bootp_info.bp_siaddr = host.sin_addr;
+ }
+#ifdef CYGPKG_REDBOOT_NETWORKING_DNS
+ if (dns_addr_set) {
+ set_dns(dns_addr);
+ }
+#ifdef CYGPKG_REDBOOT_NETWORKING_DNS_FCONFIG_DOMAIN
+ if (dns_domain_set) {
+ setdomainname(dns_domain, strlen(dns_domain));
+ }
+#endif
+#endif
+ show_addrs();
+ if (!have_net) {
+ have_net = true;
+ net_io_init();
+ }
+}
+
+// EOF net_io.c
diff --git a/ecos/packages/redboot/current/src/net/ping.c b/ecos/packages/redboot/current/src/net/ping.c
new file mode 100644
index 0000000..38b13e3
--- /dev/null
+++ b/ecos/packages/redboot/current/src/net/ping.c
@@ -0,0 +1,246 @@
+//==========================================================================
+//
+// ping.c
+//
+// Network utility - ping
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2001-01-22
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+#include <net/net.h>
+
+#ifndef CYGPKG_REDBOOT_NETWORKING
+#error CYGPKG_REDBOOT_NETWORKING required!
+#else
+
+static void do_ping(int argc, char *argv[]);
+RedBoot_cmd("ping",
+ "Network connectivity test",
+ "[-v] [-n <count>] [-l <length>] [-t <timeout>] [-r <rate>]\n"
+ " [-i <IP_addr>] -h <IP_addr>",
+ do_ping
+ );
+
+static bool icmp_received;
+static icmp_header_t hold_hdr;
+
+static void
+handle_icmp(pktbuf_t *pkt, ip_route_t *src_route)
+{
+ icmp_header_t *icmp;
+ unsigned short cksum;
+
+ icmp = pkt->icmp_hdr;
+ if (icmp->type == ICMP_TYPE_ECHOREQUEST
+ && icmp->code == 0
+ && __sum((word *)icmp, pkt->pkt_bytes, 0) == 0) {
+
+ icmp->type = ICMP_TYPE_ECHOREPLY;
+ icmp->checksum = 0;
+ cksum = __sum((word *)icmp, pkt->pkt_bytes, 0);
+ icmp->checksum = htons(cksum);
+ __ip_send(pkt, IP_PROTO_ICMP, src_route);
+ } else if (icmp->type == ICMP_TYPE_ECHOREPLY) {
+ memcpy(&hold_hdr, icmp, sizeof(*icmp));
+ icmp_received = true;
+ }
+}
+
+static void
+do_ping(int argc, char *argv[])
+{
+ struct option_info opts[7];
+ long count, timeout, length, rate, start_time, end_time, timer, received, tries;
+ char *local_ip_addr, *host_ip_addr;
+ bool local_ip_addr_set, host_ip_addr_set, count_set,
+ timeout_set, length_set, rate_set, verbose;
+ struct sockaddr_in local_addr, host_addr;
+ ip_addr_t hold_addr;
+ icmp_header_t *icmp;
+ pktbuf_t *pkt;
+ ip_header_t *ip;
+ unsigned short cksum;
+ ip_route_t dest_ip;
+
+ init_opts(&opts[0], 'n', true, OPTION_ARG_TYPE_NUM,
+ (void *)&count, (bool *)&count_set, "<count> - number of packets to test");
+ init_opts(&opts[1], 't', true, OPTION_ARG_TYPE_NUM,
+ (void *)&timeout, (bool *)&timeout_set, "<timeout> - max #ms per packet [rount trip]");
+ init_opts(&opts[2], 'i', true, OPTION_ARG_TYPE_STR,
+ (void *)&local_ip_addr, (bool *)&local_ip_addr_set, "local IP address");
+ init_opts(&opts[3], 'h', true, OPTION_ARG_TYPE_STR,
+ (void *)&host_ip_addr, (bool *)&host_ip_addr_set, "host name or IP address");
+ init_opts(&opts[4], 'l', true, OPTION_ARG_TYPE_NUM,
+ (void *)&length, (bool *)&length_set, "<length> - size of payload");
+ init_opts(&opts[5], 'v', false, OPTION_ARG_TYPE_FLG,
+ (void *)&verbose, (bool *)0, "verbose operation");
+ init_opts(&opts[6], 'r', true, OPTION_ARG_TYPE_NUM,
+ (void *)&rate, (bool *)&rate_set, "<rate> - time between packets");
+ if (!scan_opts(argc, argv, 1, opts, 7, (void **)0, 0, "")) {
+ diag_printf("PING - Invalid option specified\n");
+ return;
+ }
+ // Set defaults; this has to be done _after_ the scan, since it will
+ // have destroyed all values not explicitly set.
+ if (local_ip_addr_set) {
+ if (!_gethostbyname(local_ip_addr, (in_addr_t *)&local_addr)) {
+ diag_printf("PING - Invalid local name: %s\n", local_ip_addr);
+ return;
+ }
+ } else {
+ memcpy((in_addr_t *)&local_addr, __local_ip_addr, sizeof(__local_ip_addr));
+ }
+ if (host_ip_addr_set) {
+ if (!_gethostbyname(host_ip_addr, (in_addr_t *)&host_addr)) {
+ diag_printf("PING - Invalid host name: %s\n", host_ip_addr);
+ return;
+ }
+ if (__arp_lookup((ip_addr_t *)&host_addr.sin_addr, &dest_ip) < 0) {
+ diag_printf("PING: Cannot reach server '%s' (%s)\n",
+ host_ip_addr, inet_ntoa((in_addr_t *)&host_addr));
+ return;
+ }
+ } else {
+ diag_printf("PING - host name or IP address required\n");
+ return;
+ }
+#define DEFAULT_LENGTH 64
+#define DEFAULT_COUNT 10
+#define DEFAULT_TIMEOUT 1000
+#define DEFAULT_RATE 1000
+ if (!rate_set) {
+ rate = DEFAULT_RATE;
+ }
+ if (!length_set) {
+ length = DEFAULT_LENGTH;
+ }
+ if ((length < 64) || (length > 1400)) {
+ diag_printf("Invalid length specified: %ld\n", length);
+ return;
+ }
+ if (!count_set) {
+ count = DEFAULT_COUNT;
+ }
+ if (!timeout_set) {
+ timeout = DEFAULT_TIMEOUT;
+ }
+ // Note: two prints here because 'inet_ntoa' returns a static pointer
+ diag_printf("Network PING - from %s",
+ inet_ntoa((in_addr_t *)&local_addr));
+ diag_printf(" to %s\n",
+ inet_ntoa((in_addr_t *)&host_addr));
+ received = 0;
+ __icmp_install_listener(handle_icmp);
+ // Save default "local" address
+ memcpy(hold_addr, __local_ip_addr, sizeof(hold_addr));
+ for (tries = 0; tries < count; tries++) {
+ // The network stack uses the global variable '__local_ip_addr'
+ memcpy(__local_ip_addr, &local_addr, sizeof(__local_ip_addr));
+ // Build 'ping' request
+ if ((pkt = __pktbuf_alloc(ETH_MAX_PKTLEN)) == NULL) {
+ // Give up if no packets - something is wrong
+ break;
+ }
+
+ icmp = pkt->icmp_hdr;
+ ip = pkt->ip_hdr;
+ pkt->pkt_bytes = length + sizeof(icmp_header_t);
+
+ icmp->type = ICMP_TYPE_ECHOREQUEST;
+ icmp->code = 0;
+ icmp->checksum = 0;
+ icmp->seqnum = htons(tries+1);
+ cksum = __sum((word *)icmp, pkt->pkt_bytes, 0);
+ icmp->checksum = htons(cksum);
+
+ memcpy(ip->source, (in_addr_t *)&local_addr, sizeof(ip_addr_t));
+ memcpy(ip->destination, (in_addr_t *)&host_addr, sizeof(ip_addr_t));
+ ip->protocol = IP_PROTO_ICMP;
+ ip->length = htons(pkt->pkt_bytes);
+
+ __ip_send(pkt, IP_PROTO_ICMP, &dest_ip);
+ __pktbuf_free(pkt);
+
+ start_time = MS_TICKS();
+ timer = start_time + timeout;
+ icmp_received = false;
+ while (!icmp_received && (MS_TICKS_DELAY() < timer)) {
+ if (_rb_break(1)) {
+ goto abort;
+ }
+ MS_TICKS_DELAY();
+ __enet_poll();
+ }
+ end_time = MS_TICKS();
+
+ timer = MS_TICKS() + rate;
+ while (MS_TICKS_DELAY() < timer) {
+ if (_rb_break(1)) {
+ goto abort;
+ }
+ MS_TICKS_DELAY();
+ __enet_poll();
+ }
+
+ if (icmp_received) {
+ received++;
+ if (verbose) {
+ diag_printf(" seq: %d, time: %ld (ticks)\n",
+ ntohs(hold_hdr.seqnum), end_time-start_time);
+ }
+ }
+ }
+ abort:
+ __icmp_remove_listener();
+ // Clean up
+ memcpy(__local_ip_addr, &hold_addr, sizeof(__local_ip_addr));
+ // Report
+ diag_printf("PING - received %ld of %ld expected\n", received, count);
+}
+
+#endif //CYGPKG_REDBOOT_NETWORKING
diff --git a/ecos/packages/redboot/current/src/net/pktbuf.c b/ecos/packages/redboot/current/src/net/pktbuf.c
new file mode 100644
index 0000000..0c02bd4
--- /dev/null
+++ b/ecos/packages/redboot/current/src/net/pktbuf.c
@@ -0,0 +1,166 @@
+//==========================================================================
+//
+// net/pktbuf.c
+//
+// Stand-alone network packet support for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+#include <net/net.h>
+
+#define MAX_PKTBUF CYGNUM_REDBOOT_NETWORKING_MAX_PKTBUF
+
+#define BUFF_STATS 1
+
+#if BUFF_STATS
+int max_alloc = 0;
+int num_alloc = 0;
+int num_free = 0;
+#endif
+
+static pktbuf_t pktbuf_list[MAX_PKTBUF];
+static word bufdata[MAX_PKTBUF][ETH_MAX_PKTLEN/2 + 1];
+static pktbuf_t *free_list;
+
+
+/*
+ * Initialize the free list.
+ */
+void
+__pktbuf_init(void)
+{
+ int i;
+ word *p;
+ static int init = 0;
+
+ if (init) return;
+ init = 1;
+
+ for (i = 0; i < MAX_PKTBUF; i++) {
+ p = bufdata[i];
+ if ((((unsigned long)p) & 2) != 0)
+ ++p;
+ pktbuf_list[i].buf = p;
+ pktbuf_list[i].bufsize = ETH_MAX_PKTLEN;
+ pktbuf_list[i].next = free_list;
+ free_list = &pktbuf_list[i];
+ }
+}
+
+void
+__pktbuf_dump(void)
+{
+ int i;
+ for (i = 0; i < MAX_PKTBUF; i++) {
+ diag_printf("Buf[%d]/%p: buf: %p, len: %d/%d, next: %p\n",
+ i,
+ (void*)&pktbuf_list[i],
+ (void*)pktbuf_list[i].buf,
+ pktbuf_list[i].bufsize,
+ pktbuf_list[i].pkt_bytes,
+ (void*)pktbuf_list[i].next);
+ }
+ diag_printf("Free list = %p\n", (void*)free_list);
+}
+
+/*
+ * simple pktbuf allocation
+ */
+pktbuf_t *
+__pktbuf_alloc(int nbytes)
+{
+ pktbuf_t *p = free_list;
+
+ if (p) {
+ free_list = p->next;
+ p->ip_hdr = (ip_header_t *)p->buf;
+ p->tcp_hdr = (tcp_header_t *)(p->ip_hdr + 1);
+ p->pkt_bytes = 0;
+#if BUFF_STATS
+ ++num_alloc;
+ if ((num_alloc - num_free) > max_alloc)
+ max_alloc = num_alloc - num_free;
+#endif
+ }
+ return p;
+}
+
+
+/*
+ * free a pktbuf.
+ */
+void
+__pktbuf_free(pktbuf_t *pkt)
+{
+#if BUFF_STATS
+ --num_alloc;
+#endif
+#ifdef BSP_LOG
+ {
+ int i;
+ word *p;
+
+ for (i = 0; i < MAX_PKTBUF; i++) {
+ p = bufdata[i];
+ if ((((unsigned long)p) & 2) == 0)
+ ++p;
+ if (p == (word *)pkt)
+ break;
+ }
+ if (i < MAX_PKTBUF) {
+ BSPLOG(bsp_log("__pktbuf_free: bad pkt[%x].\n", pkt));
+ BSPLOG(while(1));
+ }
+ }
+#endif
+ pkt->next = free_list;
+ free_list = pkt;
+}
+
+
diff --git a/ecos/packages/redboot/current/src/net/tcp.c b/ecos/packages/redboot/current/src/net/tcp.c
new file mode 100644
index 0000000..b1757bc
--- /dev/null
+++ b/ecos/packages/redboot/current/src/net/tcp.c
@@ -0,0 +1,937 @@
+//==========================================================================
+//
+// net/tcp.c
+//
+// Stand-alone TCP networking support for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <net/net.h>
+#include <cyg/infra/diag.h>
+#include <cyg/hal/hal_if.h>
+
+#define MAX_TCP_SEGMENT (ETH_MAX_PKTLEN - (sizeof(eth_header_t) + sizeof(ip_header_t)))
+#define MAX_TCP_DATA (MAX_TCP_SEGMENT - sizeof(tcp_header_t))
+
+
+/* sequence number comparison macros */
+#define SEQ_LT(a,b) ((int)((a)-(b)) < 0)
+#define SEQ_LE(a,b) ((int)((a)-(b)) <= 0)
+#define SEQ_GT(a,b) ((int)((a)-(b)) > 0)
+#define SEQ_GE(a,b) ((int)((a)-(b)) >= 0)
+
+/* Set a timer which will send an RST and abort a connection. */
+static timer_t abort_timer;
+
+static void do_retrans(void *p);
+static void do_close(void *p);
+
+#ifdef BSP_LOG
+static char *
+flags_to_str(octet f)
+{
+ static char str[7], *p;
+
+ p = str;
+
+ if (f & TCP_FLAG_FIN)
+ *p++ = 'F';
+ if (f & TCP_FLAG_SYN)
+ *p++ = 'S';
+ if (f & TCP_FLAG_RST)
+ *p++ = 'R';
+ if (f & TCP_FLAG_PSH)
+ *p++ = 'P';
+ if (f & TCP_FLAG_ACK)
+ *p++ = 'A';
+ if (f & TCP_FLAG_URG)
+ *p++ = 'U';
+ *p = '\0';
+ return str;
+}
+#endif
+
+/*
+ * A major assumption is that only a very small number of sockets will
+ * active, so a simple linear search of those sockets is acceptible.
+ */
+static tcp_socket_t *tcp_list;
+
+/*
+ * Format and send an outgoing segment.
+ */
+static void
+tcp_send(tcp_socket_t *s, int flags, int resend)
+{
+ tcp_header_t *tcp;
+ ip_header_t *ip;
+ pktbuf_t *pkt = &s->pkt;
+ unsigned short cksum;
+ dword tcp_magic;
+ int tcp_magic_size = sizeof(tcp_magic);
+
+ ip = pkt->ip_hdr;
+ tcp = pkt->tcp_hdr;
+
+ if (flags & TCP_FLAG_SYN) {
+ /* If SYN, assume no data and send MSS option in tcp header */
+ pkt->pkt_bytes = sizeof(tcp_header_t) + 4;
+ tcp->hdr_len = 6;
+ tcp_magic = htonl(0x02040000 | MAX_TCP_DATA);
+ memcpy((unsigned char *)(tcp+1), &tcp_magic, tcp_magic_size);
+ s->data_bytes = 0;
+ } else {
+ pkt->pkt_bytes = s->data_bytes + sizeof(tcp_header_t);
+ tcp->hdr_len = 5;
+ }
+
+ /* tcp header */
+ tcp->reserved = 0;
+ tcp->seqnum = htonl(s->seq);
+ tcp->acknum = htonl(s->ack);
+ tcp->checksum = 0;
+
+ if (!resend) {
+ tcp->src_port = htons(s->our_port);
+ tcp->dest_port = htons(s->his_port);
+ tcp->flags = flags;
+ /* always set PUSH flag if sending data */
+ if (s->data_bytes)
+ tcp->flags |= TCP_FLAG_PSH;
+ tcp->window = htons(MAX_TCP_DATA);
+ tcp->urgent = 0;
+
+ /* fill in some pseudo-header fields */
+ memcpy(ip->source, __local_ip_addr, sizeof(ip_addr_t));
+ memcpy(ip->destination, s->his_addr.ip_addr, sizeof(ip_addr_t));
+ ip->protocol = IP_PROTO_TCP;
+ }
+
+ /* another pseudo-header field */
+ ip->length = htons(pkt->pkt_bytes);
+
+ /* compute tcp checksum */
+ cksum = __sum((word *)tcp, pkt->pkt_bytes, __pseudo_sum(ip));
+ tcp->checksum = htons(cksum);
+
+ __ip_send(pkt, IP_PROTO_TCP, &s->his_addr);
+
+ // HACK! If this delay is not present, then if the target system sends
+ // back data (not just an ACK), then somehow we miss it :-(
+ CYGACC_CALL_IF_DELAY_US(2*1000);
+
+ BSPLOG(bsp_log("tcp_send: state[%d] flags[%s] ack[%x] data[%d].\n",
+ s->state, flags_to_str(tcp->flags), s->ack, s->data_bytes));
+
+ if (s->state == _TIME_WAIT) {
+ // If 'reuse' is set on socket, close after 1 second, otherwise 2 minutes
+ __timer_set(&s->timer, s->reuse ? 1000 : 120000, do_close, s);
+ }
+ else if ((tcp->flags & (TCP_FLAG_FIN | TCP_FLAG_SYN)) || s->data_bytes)
+ __timer_set(&s->timer, 1000, do_retrans, s);
+}
+
+static pktbuf_t ack_pkt;
+static word ack_buf[ETH_MIN_PKTLEN/sizeof(word)];
+
+/*
+ * Send an ack.
+ */
+static void
+send_ack(tcp_socket_t *s)
+{
+ tcp_header_t *tcp;
+ ip_header_t *ip;
+ unsigned short cksum;
+
+ ack_pkt.buf = ack_buf;
+ ack_pkt.bufsize = sizeof(ack_buf);
+ ack_pkt.ip_hdr = ip = (ip_header_t *)ack_buf;
+ ack_pkt.tcp_hdr = tcp = (tcp_header_t *)(ip + 1);
+ ack_pkt.pkt_bytes = sizeof(tcp_header_t);
+
+ /* tcp header */
+ tcp->hdr_len = 5;
+ tcp->reserved = 0;
+ tcp->seqnum = htonl(s->seq);
+ tcp->acknum = htonl(s->ack);
+ tcp->checksum = 0;
+
+ tcp->src_port = htons(s->our_port);
+ tcp->dest_port = htons(s->his_port);
+ tcp->flags = TCP_FLAG_ACK;
+
+ tcp->window = htons(MAX_TCP_DATA);
+ tcp->urgent = 0;
+
+ /* fill in some pseudo-header fields */
+ memcpy(ip->source, __local_ip_addr, sizeof(ip_addr_t));
+ memcpy(ip->destination, s->his_addr.ip_addr, sizeof(ip_addr_t));
+ ip->protocol = IP_PROTO_TCP;
+
+ /* another pseudo-header field */
+ ip->length = htons(sizeof(tcp_header_t));
+
+ /* compute tcp checksum */
+ cksum = __sum((word *)tcp, sizeof(*tcp), __pseudo_sum(ip));
+ tcp->checksum = htons(cksum);
+
+ __ip_send(&ack_pkt, IP_PROTO_TCP, &s->his_addr);
+}
+
+
+/*
+ * Send a reset for a bogus incoming segment.
+ */
+static void
+send_reset(pktbuf_t *pkt, ip_route_t *r)
+{
+ ip_header_t *ip = pkt->ip_hdr;
+ tcp_header_t *tcp = pkt->tcp_hdr;
+ dword seq, ack;
+ word src, dest;
+ word cksum;
+
+ seq = ntohl(tcp->acknum);
+ ack = ntohl(tcp->seqnum);
+ src = ntohs(tcp->dest_port);
+ dest = ntohs(tcp->src_port);
+
+ tcp = (tcp_header_t *)(ip + 1);
+ pkt->pkt_bytes = sizeof(tcp_header_t);
+
+ /* tcp header */
+ tcp->hdr_len = 5;
+ tcp->reserved = 0;
+ tcp->seqnum = htonl(seq);
+ tcp->acknum = htonl(ack);
+ tcp->window = htons(1024);
+ tcp->urgent = 0;
+ tcp->checksum = 0;
+ tcp->src_port = htons(src);
+ tcp->dest_port = htons(dest);
+ tcp->flags = TCP_FLAG_RST | TCP_FLAG_ACK;
+
+ /* fill in some pseudo-header fields */
+ memcpy(ip->source, __local_ip_addr, sizeof(ip_addr_t));
+ memcpy(ip->destination, r->ip_addr, sizeof(ip_addr_t));
+ ip->protocol = IP_PROTO_TCP;
+ ip->length = htons(pkt->pkt_bytes);
+
+ /* compute tcp checksum */
+ cksum = __sum((word *)tcp, pkt->pkt_bytes, __pseudo_sum(ip));
+ tcp->checksum = htons(cksum);
+
+ __ip_send(pkt, IP_PROTO_TCP, r);
+}
+
+
+
+/*
+ * Remove given socket from socket list.
+ */
+static void
+unlink_socket(tcp_socket_t *s)
+{
+ tcp_socket_t *prev, *tp;
+
+ for (prev = NULL, tp = tcp_list; tp; prev = tp, tp = tp->next)
+ if (tp == s) {
+ BSPLOG(bsp_log("unlink tcp socket.\n"));
+ if (prev)
+ prev->next = s->next;
+ else
+ tcp_list = s->next;
+ }
+}
+
+/*
+ * Retransmit last packet.
+ */
+static void
+do_retrans(void *p)
+{
+ BSPLOG(bsp_log("tcp do_retrans.\n"));
+ tcp_send((tcp_socket_t *)p, 0, 1);
+}
+
+
+static void
+do_close(void *p)
+{
+ BSPLOG(bsp_log("tcp do_close.\n"));
+ /* close connection */
+ ((tcp_socket_t *)p)->state = _CLOSED;
+ unlink_socket(p);
+}
+
+
+static void
+free_rxlist(tcp_socket_t *s)
+{
+ pktbuf_t *p;
+
+ BSPLOG(bsp_log("tcp free_rxlist.\n"));
+
+ while ((p = s->rxlist) != NULL) {
+ s->rxlist = p->next;
+ __pktbuf_free(p);
+ }
+}
+
+
+/*
+ * Handle a conection reset.
+ */
+static void
+do_reset(tcp_socket_t *s)
+{
+ /* close connection */
+ s->state = _CLOSED;
+ __timer_cancel(&s->timer);
+ free_rxlist(s);
+ unlink_socket(s);
+}
+
+
+/*
+ * Extract data from incoming tcp segment.
+ * Returns true if packet is queued on rxlist, false otherwise.
+ */
+static int
+handle_data(tcp_socket_t *s, pktbuf_t *pkt)
+{
+ tcp_header_t *tcp = pkt->tcp_hdr;
+ unsigned int diff, seq;
+ int data_len;
+ char *data_ptr;
+ pktbuf_t *p;
+
+ data_len = pkt->pkt_bytes - (tcp->hdr_len << 2);
+ data_ptr = ((char *)tcp) + (tcp->hdr_len << 2);
+
+ seq = ntohl(tcp->seqnum);
+
+ BSPLOG(bsp_log("tcp data: seq[%x] len[%d].\n", seq, data_len));
+
+ if (SEQ_LE(seq, s->ack)) {
+ /*
+ * Figure difference between which byte we're expecting and which byte
+ * is sent first. Adjust data length and data pointer accordingly.
+ */
+ diff = s->ack - seq;
+ data_len -= diff;
+ data_ptr += diff;
+
+ if (data_len > 0) {
+ /* queue the new data */
+ s->ack += data_len;
+ pkt->next = NULL;
+ if ((p = s->rxlist) != NULL) {
+ while (p->next)
+ p = p->next;
+ p->next = pkt;
+ BSPLOG(bsp_log("tcp data: Add pkt[%x] len[%d].\n",
+ pkt, data_len));
+ } else {
+ s->rxlist = pkt;
+ s->rxcnt = data_len;
+ s->rxptr = data_ptr;
+ BSPLOG(bsp_log("tcp data: pkt[%x] len[%d].\n",
+ pkt, data_len));
+ }
+ return 1;
+ }
+ }
+ return 0;
+}
+
+
+static void
+handle_ack(tcp_socket_t *s, pktbuf_t *pkt)
+{
+ tcp_header_t *tcp = pkt->tcp_hdr;
+ dword ack;
+ int advance;
+ char *dp;
+
+ /* process ack value in packet */
+ ack = ntohl(tcp->acknum);
+
+ BSPLOG(bsp_log("Rcvd tcp ACK %x\n", ack));
+
+ if (SEQ_GT(ack, s->seq)) {
+ __timer_cancel(&s->timer);
+ advance = ack - s->seq;
+ if (advance > s->data_bytes)
+ advance = s->data_bytes;
+
+ BSPLOG(bsp_log("seq advance %d", advance));
+
+ if (advance > 0) {
+ s->seq += advance;
+ s->data_bytes -= advance;
+ if (s->data_bytes) {
+ /* other end ack'd only part of the pkt */
+ BSPLOG(bsp_log(" %d bytes left", s->data_bytes));
+ dp = (char *)(s->pkt.tcp_hdr + 1);
+ memcpy(dp, dp + advance, s->data_bytes);
+ }
+ }
+ }
+ BSPLOG(bsp_log("\n"));
+}
+
+
+/*
+ * Handle incoming TCP packets.
+ */
+void
+__tcp_handler(pktbuf_t *pkt, ip_route_t *r)
+{
+ tcp_header_t *tcp = pkt->tcp_hdr;
+ ip_header_t *ip = pkt->ip_hdr;
+ tcp_socket_t *prev,*s;
+ dword ack;
+ int queued = 0;
+
+ /* set length for pseudo sum calculation */
+ ip->length = htons(pkt->pkt_bytes);
+
+ if (__sum((word *)tcp, pkt->pkt_bytes, __pseudo_sum(ip)) == 0) {
+ for (prev = NULL, s = tcp_list; s; prev = s, s = s->next) {
+ if (s->our_port == ntohs(tcp->dest_port)) {
+ if (s->his_port == 0)
+ break;
+ if (s->his_port == ntohs(tcp->src_port) &&
+ !memcmp(r->ip_addr, s->his_addr.ip_addr, sizeof(ip_addr_t)))
+ break;
+ }
+ }
+
+ if (s) {
+ /* found the socket this packet belongs to */
+
+ /* refresh his ethernet address */
+ memcpy(s->his_addr.enet_addr, r->enet_addr, sizeof(enet_addr_t));
+
+ if (s->state != _SYN_RCVD && tcp->flags & TCP_FLAG_RST) {
+ BSPLOG(bsp_log("TCP_FLAG_RST rcvd\n"));
+ do_reset(s);
+ __pktbuf_free(pkt);
+ return;
+ }
+
+ switch (s->state) {
+
+ case _SYN_SENT:
+ /* active open not supported */
+ if (tcp->flags != (TCP_FLAG_SYN | TCP_FLAG_ACK)) {
+ do_reset(s);
+ __pktbuf_free(pkt);
+ return;
+ }
+ s->state = _ESTABLISHED;
+ s->ack = ntohl(tcp->seqnum) + 1;
+ s->seq = ntohl(tcp->acknum);
+ __timer_cancel(&s->timer);
+ send_ack(s);
+ break;
+
+ case _LISTEN:
+ if (tcp->flags & TCP_FLAG_SYN) {
+ s->state = _SYN_RCVD;
+ s->ack = ntohl(tcp->seqnum) + 1;
+ s->his_port = ntohs(tcp->src_port);
+ memcpy(s->his_addr.ip_addr, r->ip_addr, sizeof(ip_addr_t));
+ s->data_bytes = 0;
+
+ BSPLOG(bsp_log("SYN from %d.%d.%d.%d:%d (seq %x)\n",
+ s->his_addr.ip_addr[0],s->his_addr.ip_addr[1],
+ s->his_addr.ip_addr[2],s->his_addr.ip_addr[3],
+ s->his_port, ntohl(tcp->seqnum)));
+
+ tcp_send(s, TCP_FLAG_SYN | TCP_FLAG_ACK, 0);
+ }
+ else
+ send_reset(pkt, r);
+ break;
+
+ case _SYN_RCVD:
+ BSPLOG(bsp_log("_SYN_RCVD timer cancel.\n"));
+ __timer_cancel(&s->timer);
+
+ /* go back to _LISTEN state if reset */
+ if (tcp->flags & TCP_FLAG_RST) {
+ s->state = _LISTEN;
+
+ BSPLOG(bsp_log("_SYN_RCVD --> _LISTEN\n"));
+
+ } else if (tcp->flags & TCP_FLAG_SYN) {
+ /* apparently our SYN/ACK was lost? */
+ tcp_send(s, 0, 1);
+
+ BSPLOG(bsp_log("retransmitting SYN/ACK\n"));
+
+ } else if ((tcp->flags & TCP_FLAG_ACK) &&
+ ntohl(tcp->acknum) == (s->seq + 1)) {
+ /* we've established the connection */
+ s->state = _ESTABLISHED;
+ s->seq++;
+
+ BSPLOG(bsp_log("ACK received - connection established\n"));
+ }
+ break;
+
+ case _ESTABLISHED:
+ case _CLOSE_WAIT:
+ ack = s->ack; /* save original ack */
+ if (tcp->flags & TCP_FLAG_ACK)
+ handle_ack(s, pkt);
+
+ queued = handle_data(s, pkt);
+
+ if ((tcp->flags & TCP_FLAG_FIN) &&
+ ntohl(tcp->seqnum) == s->ack) {
+
+ BSPLOG(bsp_log("FIN received - going to _CLOSE_WAIT\n"));
+
+ s->ack++;
+ s->state = _CLOSE_WAIT;
+ }
+ /*
+ * Send an ack if neccessary.
+ */
+ if (s->ack != ack || pkt->pkt_bytes > (tcp->hdr_len << 2))
+ send_ack(s);
+ break;
+
+ case _LAST_ACK:
+ if (tcp->flags & TCP_FLAG_ACK) {
+ handle_ack(s, pkt);
+ if (ntohl(tcp->acknum) == (s->seq + 1)) {
+ BSPLOG(bsp_log("_LAST_ACK --> _CLOSED\n"));
+ s->state = _CLOSED;
+ unlink_socket(s);
+ }
+ }
+ break;
+
+ case _FIN_WAIT_1:
+ if (tcp->flags & TCP_FLAG_ACK) {
+ handle_ack(s, pkt);
+ if (ntohl(tcp->acknum) == (s->seq + 1)) {
+ /* got ACK for FIN packet */
+ s->seq++;
+ if (tcp->flags & TCP_FLAG_FIN) {
+ BSPLOG(bsp_log("_FIN_WAIT_1 --> _TIME_WAIT\n"));
+ s->ack++;
+ s->state = _TIME_WAIT;
+ send_ack(s);
+ } else {
+ s->state = _FIN_WAIT_2;
+ BSPLOG(bsp_log("_FIN_WAIT_1 --> _FIN_WAIT_2\n"));
+ }
+ break; /* All done for now */
+ }
+ }
+ /* At this point, no ACK for FIN has been seen, so check for
+ simultaneous close */
+ if (tcp->flags & TCP_FLAG_FIN) {
+ BSPLOG(bsp_log("_FIN_WAIT_1 --> _CLOSING\n"));
+ __timer_cancel(&s->timer);
+ s->ack++;
+ s->state = _CLOSING;
+ /* FIN is resent so the timeout and retry for this packet
+ will also take care of timeout and resend of the
+ previously sent FIN (which got us to FIN_WAIT_1). While
+ not technically correct, resending FIN only causes a
+ duplicate FIN (same sequence number) which should be
+ ignored by the other end. */
+ tcp_send(s, TCP_FLAG_FIN | TCP_FLAG_ACK, 0);
+ }
+ break;
+
+ case _FIN_WAIT_2:
+ queued = handle_data(s, pkt);
+ if (tcp->flags & TCP_FLAG_FIN) {
+ BSPLOG(bsp_log("_FIN_WAIT_2 --> _TIME_WAIT\n"));
+ s->ack++;
+ s->state = _TIME_WAIT;
+ send_ack(s);
+ }
+ break;
+
+ case _CLOSING:
+ if (tcp->flags & TCP_FLAG_ACK) {
+ handle_ack(s, pkt);
+ if (ntohl(tcp->acknum) == (s->seq + 1)) {
+ /* got ACK for FIN packet */
+ BSPLOG(bsp_log("_CLOSING --> _TIME_WAIT\n"));
+ __timer_cancel(&s->timer);
+ s->state = _TIME_WAIT;
+ }
+ }
+ break;
+
+ case _TIME_WAIT:
+ BSPLOG(bsp_log("_TIME_WAIT resend.\n"));
+ if (tcp->flags & TCP_FLAG_FIN)
+ tcp_send(s, 0, 1); /* just resend ack */
+ break;
+ }
+ } else {
+ BSPLOG(bsp_log("Unexpected segment from: %d.%d.%d.%d:%d\n",
+ r->ip_addr[0], r->ip_addr[1], r->ip_addr[3],
+ r->ip_addr[4], ntohs(tcp->src_port)));
+ send_reset(pkt, r);
+ }
+ }
+ if (!queued)
+ __pktbuf_free(pkt);
+}
+
+
+void
+__tcp_poll(void)
+{
+ __enet_poll();
+ __timer_poll();
+}
+
+
+int
+__tcp_listen(tcp_socket_t *s, word port)
+{
+ BSPLOG(bsp_log("tcp_listen: s[%p] port[%x]\n", s, port));
+
+ memset(s, 0, sizeof(tcp_socket_t));
+ s->state = _LISTEN;
+ s->our_port = port;
+ s->pkt.buf = (word *)s->pktbuf;
+ s->pkt.bufsize = ETH_MAX_PKTLEN;
+ s->pkt.ip_hdr = (ip_header_t *)s->pkt.buf;
+ s->pkt.tcp_hdr = (tcp_header_t *)(s->pkt.ip_hdr + 1);
+
+ s->next = tcp_list;
+
+#if 0
+ /* limit to one open socket at a time */
+ if (s->next) {
+ BSPLOG(bsp_log("tcp_listen: recursion error\n"));
+ BSPLOG(while(1));
+ }
+#endif
+
+ tcp_list = s;
+
+ return 0;
+}
+
+/*
+ * SO_REUSEADDR, no 2MSL.
+ */
+void
+__tcp_so_reuseaddr(tcp_socket_t *s)
+{
+// BSPLOG(bsp_log("__tcp_so_reuseaddr.\n"));
+ s->reuse = 0x01;
+}
+
+/*
+ * Block while waiting for all data to be transmitted.
+ */
+void
+__tcp_drain(tcp_socket_t *s)
+{
+// BSPLOG(bsp_log("__tcp_drain.\n"));
+ while (s->state != _CLOSED && s->data_bytes)
+ __tcp_poll();
+// BSPLOG(bsp_log("__tcp_drain done.\n"));
+}
+
+
+/*
+ * Close the tcp connection.
+ */
+static void
+do_abort(void *s)
+{
+ BSPLOG(bsp_log("do_abort: send RST\n"));
+ tcp_send((tcp_socket_t *)s, TCP_FLAG_ACK | TCP_FLAG_RST, 0);
+ __timer_cancel(&abort_timer);
+ ((tcp_socket_t *)s)->state = _CLOSED;
+ free_rxlist((tcp_socket_t *)s);
+ unlink_socket((tcp_socket_t *)s);
+}
+
+/*
+ * Abort a TCP connection, waiting for the connection to be closed, so
+ * it is save to reuse the tcp_socket_t structure.
+ */
+
+void
+__tcp_abort(tcp_socket_t *s, unsigned long delay)
+{
+ int timeout = 1000;
+
+ __timer_set(&abort_timer, delay, do_abort, s);
+
+ while (s->state != _CLOSED) {
+ if (--timeout <= 0) {
+ diag_printf("TCP close - connection failed to close\n");
+ return;
+ }
+
+ MS_TICKS_DELAY();
+ __tcp_poll();
+ }
+}
+
+/*
+ * Close the tcp connection.
+ */
+void
+__tcp_close(tcp_socket_t *s)
+{
+ __tcp_drain(s);
+ if (s->state == _ESTABLISHED || s->state == _SYN_RCVD) {
+ BSPLOG(bsp_log("__tcp_close: going to _FIN_WAIT_1\n"));
+ s->state = _FIN_WAIT_1;
+ tcp_send(s, TCP_FLAG_ACK | TCP_FLAG_FIN, 0);
+ } else if (s->state == _CLOSE_WAIT) {
+
+ BSPLOG(bsp_log("__tcp_close: going to _LAST_ACK\n"));
+
+ s->state = _LAST_ACK;
+ tcp_send(s, TCP_FLAG_ACK | TCP_FLAG_FIN, 0);
+ }
+ free_rxlist(s);
+}
+
+
+/*
+ * Wait for connection to be fully closed.
+ */
+void
+__tcp_close_wait(tcp_socket_t *s)
+{
+ BSPLOG(bsp_log("__tcp_close_wait.\n"));
+ while (s->state != _CLOSED)
+ __tcp_poll();
+ BSPLOG(bsp_log("__tcp_close_wait done.\n"));
+}
+
+
+/*
+ * Read up to 'len' bytes without blocking.
+ */
+int
+__tcp_read(tcp_socket_t *s, char *buf, int len)
+{
+ int nread;
+ pktbuf_t *pkt;
+ tcp_header_t *tcp;
+
+ if (len <= 0 || s->rxcnt == 0)
+ return 0;
+
+ if (s->state != _ESTABLISHED && s->rxcnt == 0)
+ return -1;
+
+ nread = 0;
+ while (len) {
+ if (len < s->rxcnt) {
+ memcpy(buf, s->rxptr, len);
+ BSPLOG(bsp_log("tcp_read: read %d bytes.\n", len));
+ s->rxptr += len;
+ s->rxcnt -= len;
+ nread += len;
+
+ BSPLOG(bsp_log("tcp_read: %d bytes left in rxlist head.\n",
+ s->rxcnt));
+
+ break;
+ } else {
+ memcpy(buf, s->rxptr, s->rxcnt);
+ BSPLOG(bsp_log("tcp_read: read %d bytes. pkt[%x] freed.\n",
+ s->rxcnt, s->rxlist));
+ nread += s->rxcnt;
+ buf += s->rxcnt;
+ len -= s->rxcnt;
+
+ /* setup for next packet in list */
+ pkt = s->rxlist;
+ s->rxlist = pkt->next;
+ __pktbuf_free(pkt);
+
+ if ((pkt = s->rxlist) != NULL) {
+ tcp = pkt->tcp_hdr;
+ s->rxcnt = pkt->pkt_bytes - (tcp->hdr_len << 2);
+ s->rxptr = ((char *)tcp) + (tcp->hdr_len << 2);
+
+ BSPLOG(bsp_log("tcp_read: next pkt[%x] has %d bytes.\n",
+ s->rxlist, s->rxcnt));
+ } else {
+
+ BSPLOG(bsp_log("tcp_read: no more data.\n"));
+
+ s->rxcnt = 0;
+ break;
+ }
+ }
+ }
+ return nread;
+}
+
+
+/*
+ * Write up to 'len' bytes without blocking
+ */
+int
+__tcp_write(tcp_socket_t *s, char *buf, int len)
+{
+ tcp_header_t *tcp = s->pkt.tcp_hdr;
+
+ if (len <= 0)
+ return 0;
+
+ if (s->state != _ESTABLISHED && s->state != _CLOSE_WAIT)
+ return -1;
+
+ if (s->data_bytes)
+ return 0;
+
+ if (len > MAX_TCP_DATA)
+ len = MAX_TCP_DATA;
+
+ memcpy(tcp + 1, buf, len);
+ s->data_bytes = len;
+
+ tcp_send(s, TCP_FLAG_ACK, 0);
+
+ return len;
+}
+
+/*
+ * Write 'len' bytes from 'buf', blocking until sent.
+ * If connection collapses, return -1
+ */
+int
+__tcp_write_block(tcp_socket_t *s, char *buf, int len)
+{
+ int total = 0;
+ int n;
+
+ while (len) {
+ if (s->state == _CLOSE_WAIT) {
+ // This connection is tring to close
+ // This connection is breaking
+ if (s->data_bytes == 0 && s->rxcnt == 0)
+ __tcp_close(s);
+ }
+ if (s->state == _CLOSED) {
+ // The connection is gone!
+ return -1;
+ }
+ n = __tcp_write(s, buf, len);
+ if (n > 0) {
+ len -= n;
+ buf += n;
+ total += n;
+ }
+ __tcp_poll();
+ }
+ __tcp_drain(s);
+ return total;
+}
+
+/*
+ * Establish a new [outgoing] connection, with a timeout.
+ */
+int
+__tcp_open(tcp_socket_t *s, struct sockaddr_in *host,
+ word port, int timeout, int *err)
+{
+ // Fill in socket details
+ memset(s, 0, sizeof(tcp_socket_t));
+ s->state = _SYN_SENT;
+ s->our_port = port;
+ s->his_port = host->sin_port;
+ s->pkt.buf = (word *)s->pktbuf;
+ s->pkt.bufsize = ETH_MAX_PKTLEN;
+ s->pkt.ip_hdr = (ip_header_t *)s->pkt.buf;
+ s->pkt.tcp_hdr = (tcp_header_t *)(s->pkt.ip_hdr + 1);
+ s->seq = (port << 16) | 0xDE77;
+ s->ack = 0;
+ if (__arp_lookup((ip_addr_t *)&host->sin_addr, &s->his_addr) < 0) {
+ diag_printf("%s: Can't find address of server\n", __FUNCTION__);
+ return -1;
+ }
+ s->next = tcp_list;
+ tcp_list = s;
+
+ // Send off the SYN packet to open the connection
+ tcp_send(s, TCP_FLAG_SYN, 0);
+ // Wait for connection to establish
+ while (s->state != _ESTABLISHED) {
+ if (s->state == _CLOSED) {
+ diag_printf("TCP open - host closed connection\n");
+ return -1;
+ }
+ if (--timeout <= 0) {
+ diag_printf("TCP open - connection timed out\n");
+ return -1;
+ }
+ MS_TICKS_DELAY();
+ __tcp_poll();
+ }
+ return 0;
+}
+
+
diff --git a/ecos/packages/redboot/current/src/net/tftp_client.c b/ecos/packages/redboot/current/src/net/tftp_client.c
new file mode 100644
index 0000000..c85d9bf
--- /dev/null
+++ b/ecos/packages/redboot/current/src/net/tftp_client.c
@@ -0,0 +1,316 @@
+//==========================================================================
+//
+// net/tftp_client.c
+//
+// Stand-alone TFTP support for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+// TFTP client support
+
+#include <redboot.h> // have_net
+#include <net/net.h>
+#include <net/tftp.h>
+#include <net/tftp_support.h>
+
+// So we remember which ports have been used
+static int get_port = 7700;
+
+static struct {
+ bool open;
+ int total_timeouts, packets_received;
+ unsigned long last_good_block;
+ int avail, actual_len;
+ struct sockaddr_in local_addr, from_addr;
+ char data[SEGSIZE+sizeof(struct tftphdr)];
+ char *bufp;
+} tftp_stream;
+
+int
+tftp_stream_open(connection_info_t *info,
+ int *err)
+{
+ struct tftphdr *hdr = (struct tftphdr *)tftp_stream.data;
+ char *cp, *fp;
+ char test_buf;
+
+ if (!have_net || tftp_stream.open) {
+ *err = TFTP_INVALID; // Already open
+ return -1;
+ }
+
+ // Create initial request
+ hdr->th_opcode = htons(RRQ); // Read file
+ cp = (char *)&hdr->th_stuff;
+ fp = info->filename;
+ while (*fp) *cp++ = *fp++;
+ *cp++ = '\0';
+ // Since this is used for downloading data, OCTET (binary) is the
+ // only mode that makes sense.
+ fp = "OCTET";
+ while (*fp) *cp++ = *fp++;
+ *cp++ = '\0';
+
+ memset((char *)&tftp_stream.local_addr, 0, sizeof(tftp_stream.local_addr));
+ tftp_stream.local_addr.sin_family = AF_INET;
+ tftp_stream.local_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ tftp_stream.local_addr.sin_port = htons(get_port++);
+
+ if (info->server->sin_port == 0) {
+ info->server->sin_port = htons(TFTP_PORT);
+ } else {
+ info->server->sin_port = htons(info->server->sin_port);
+ }
+
+ // Send request - note: RFC 1350 (TFTP rev 2) indicates that this should be
+ // only as long as required to hold the request, with the nul terminator.
+ // Some servers silently go to lunch if the request is not the correct size.
+ if (__udp_sendto(tftp_stream.data, cp-(char *)hdr,
+ info->server, &tftp_stream.local_addr) < 0) {
+ // Problem sending request
+ *err = TFTP_NETERR;
+ return -1;
+ }
+
+ tftp_stream.open = true;
+ tftp_stream.avail = 0;
+ tftp_stream.actual_len = -1;
+ tftp_stream.last_good_block = 0;
+ tftp_stream.total_timeouts = 0;
+ tftp_stream.from_addr.sin_port = 0;
+ tftp_stream.packets_received = 0;
+
+ // Try and read the first byte [block] since no errors are
+ // reported until then.
+ if (tftp_stream_read(&test_buf, 1, err) == 1) {
+ // Back up [rewind] over this datum
+ tftp_stream.bufp--;
+ tftp_stream.avail++;
+ return 0; // Open and first read successful
+ } else {
+ tftp_stream.open = false;
+ return -1; // Couldn't read
+ }
+}
+
+static int
+tftp_ack(int *err)
+{
+ struct tftphdr *hdr = (struct tftphdr *)tftp_stream.data;
+ // ACK last packet so server can shut down
+ if (tftp_stream.packets_received > 0) {
+ hdr->th_opcode = htons(ACK);
+ hdr->th_block = htons((cyg_uint16)tftp_stream.last_good_block & 0xFFFF);
+ if (__udp_sendto(tftp_stream.data, 4 /* FIXME */,
+ &tftp_stream.from_addr, &tftp_stream.local_addr) < 0) {
+ // Problem sending ACK
+ *err = TFTP_NETERR;
+ return -1;
+ }
+ }
+ return 0;
+}
+
+static int
+tftp_error_ack(int *err, short code, char *msg)
+{
+ struct tftphdr *hdr = (struct tftphdr *)tftp_stream.data;
+
+ if (strlen(msg) > (SEGSIZE-1)) {
+ *(msg + SEGSIZE) = 0;
+ }
+
+ if (tftp_stream.packets_received > 0) {
+ hdr->th_opcode = htons(ERROR);
+ hdr->th_code = code;
+ strcpy((char *)&hdr->th_data, msg);
+ if (__udp_sendto(tftp_stream.data, (5 + strlen(msg)),
+ &tftp_stream.from_addr, &tftp_stream.local_addr) < 0) {
+ // Problem sending ACK
+ *err = TFTP_NETERR;
+ return -1;
+ }
+ }
+ return 0;
+}
+
+void
+tftp_stream_close(int *err)
+{
+ if (tftp_stream.open == true) {
+ tftp_ack(err);
+ tftp_stream.open = false;
+ }
+}
+
+void
+tftp_stream_terminate(bool abort,
+ int (*getc)(void))
+{
+ int err;
+
+ if (abort)
+ tftp_error_ack(&err, EUNDEF, "redboot tftp_stream_terminate");
+ else
+ tftp_ack(&err);
+
+ tftp_stream.open = false;
+}
+
+int
+tftp_stream_read(char *buf,
+ int len,
+ int *err)
+{
+ int total_bytes = 0;
+ int size, recv_len, data_len;
+ struct timeval timeout;
+ struct tftphdr *hdr = (struct tftphdr *)tftp_stream.data;
+
+ while (total_bytes < len) {
+ // Move any bytes which we've already read/buffered
+ if (tftp_stream.avail > 0) {
+ size = tftp_stream.avail;
+ if (size > (len - total_bytes)) size = len - total_bytes;
+ memcpy(buf, tftp_stream.bufp, size);
+ buf += size;
+ tftp_stream.bufp += size;
+ tftp_stream.avail -= size;
+ total_bytes += size;
+ } else {
+ if (tftp_ack(err) < 0) {
+ return -1;
+ }
+ if ((tftp_stream.actual_len >= 0) && (tftp_stream.actual_len < SEGSIZE)) {
+ // Out of data
+ break;
+ }
+ timeout.tv_sec = (tftp_stream.last_good_block == 0) ? 10*TFTP_TIMEOUT_PERIOD : TFTP_TIMEOUT_PERIOD;
+ timeout.tv_usec = 0;
+ recv_len = sizeof(tftp_stream.data);
+ if ((data_len = __udp_recvfrom(&tftp_stream.data[0], recv_len, &tftp_stream.from_addr,
+ &tftp_stream.local_addr, &timeout)) < 0) {
+ // No data, try again
+ diag_printf("TFTP timed out %d/%d\n", tftp_stream.total_timeouts+1, TFTP_TIMEOUT_MAX);
+ if ((++tftp_stream.total_timeouts > TFTP_TIMEOUT_MAX) ||
+ (tftp_stream.last_good_block == 0)) {
+ // Timeout - no data received
+ *err = TFTP_TIMEOUT;
+ return -1;
+ }
+ // Send out the ACK for the last block - maybe server will retry
+ if (tftp_ack(err) < 0) {
+ return -1;
+ }
+ } else {
+ tftp_stream.packets_received++;
+ if (ntohs(hdr->th_opcode) == DATA) {
+ if (ntohs(hdr->th_block) == (cyg_uint16)((tftp_stream.last_good_block+1) & 0xFFFF)) {
+ // Consume this data
+ data_len -= 4; /* Sizeof TFTP header */
+ tftp_stream.avail = tftp_stream.actual_len = data_len;
+ tftp_stream.bufp = hdr->th_data;
+ tftp_stream.last_good_block++;
+ }
+ } else {
+ if (ntohs(hdr->th_opcode) == ERROR) {
+ *err = ntohs(hdr->th_code);
+ return -1;
+ } else {
+ // What kind of packet is this?
+ *err = TFTP_PROTOCOL;
+ return -1;
+ }
+ }
+ }
+ }
+ }
+ return total_bytes;
+}
+
+char *
+tftp_error(int err)
+{
+ char *errmsg = "Unknown error";
+
+ switch (err) {
+ case TFTP_ENOTFOUND:
+ return "file not found";
+ case TFTP_EACCESS:
+ return "access violation";
+ case TFTP_ENOSPACE:
+ return "disk full or allocation exceeded";
+ case TFTP_EBADOP:
+ return "illegal TFTP operation";
+ case TFTP_EBADID:
+ return "unknown transfer ID";
+ case TFTP_EEXISTS:
+ return "file already exists";
+ case TFTP_ENOUSER:
+ return "no such user";
+ case TFTP_TIMEOUT:
+ return "operation timed out";
+ case TFTP_NETERR:
+ return "some sort of network error";
+ case TFTP_INVALID:
+ return "invalid parameter";
+ case TFTP_PROTOCOL:
+ return "protocol violation";
+ case TFTP_TOOLARGE:
+ return "file is larger than buffer";
+ }
+ return errmsg;
+}
+
+//
+// RedBoot interface
+//
+GETC_IO_FUNCS(tftp_io, tftp_stream_open, tftp_stream_close,
+ tftp_stream_terminate, tftp_stream_read, tftp_error);
+RedBoot_load(tftp, tftp_io, true, true, 0);
+
diff --git a/ecos/packages/redboot/current/src/net/timers.c b/ecos/packages/redboot/current/src/net/timers.c
new file mode 100644
index 0000000..fff0bd8
--- /dev/null
+++ b/ecos/packages/redboot/current/src/net/timers.c
@@ -0,0 +1,134 @@
+//==========================================================================
+//
+// net/timers.c
+//
+// Stand-alone networking support for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <net/net.h>
+
+static timer_t *tmr_list;
+
+
+/*
+ * Set a timer. Caller is responsible for providing the timer_t struct.
+ */
+void
+__timer_set(timer_t *t, unsigned long delay,
+ tmr_handler_t handler, void *user_data)
+{
+ timer_t *p;
+
+ t->delay = delay;
+ t->start = MS_TICKS();
+ t->handler = handler;
+ t->user_data = user_data;
+
+ for (p = tmr_list; p; p = p->next)
+ if (p == t) {
+ return;
+ }
+
+ t->next = tmr_list;
+ tmr_list = t;
+}
+
+
+/*
+ * Remove a given timer from timer list.
+ */
+void
+__timer_cancel(timer_t *t)
+{
+ timer_t *prev, *p;
+
+ for (prev = NULL, p = tmr_list; p; prev = p, p = p->next)
+ if (p == t) {
+ if (prev)
+ prev->next = p->next;
+ else
+ tmr_list = p->next;
+ return;
+ }
+}
+
+
+/*
+ * Poll timer list for timer expirations.
+ */
+void
+__timer_poll(void)
+{
+ timer_t *prev, *t;
+
+ prev = NULL;
+ t = tmr_list;
+ while (t) {
+ if ((MS_TICKS_DELAY() - t->start) >= t->delay) {
+
+ /* remove it before calling handler */
+ if (prev)
+ prev->next = t->next;
+ else
+ tmr_list = t->next;
+ /* now, call the handler */
+ t->handler(t->user_data);
+
+ /*
+ * handler may be time consuming, so start
+ * from beginning of list.
+ */
+ prev = NULL;
+ t = tmr_list;
+ } else {
+ prev = t;
+ t = t->next;
+ }
+ }
+}
diff --git a/ecos/packages/redboot/current/src/net/udp.c b/ecos/packages/redboot/current/src/net/udp.c
new file mode 100644
index 0000000..6148d88
--- /dev/null
+++ b/ecos/packages/redboot/current/src/net/udp.c
@@ -0,0 +1,266 @@
+//==========================================================================
+//
+// net/udp.c
+//
+// Stand-alone UDP networking support for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+#include <net/net.h>
+
+#ifdef UDP_STATS
+static int udp_rx_total;
+static int udp_rx_handled;
+static int udp_rx_cksum;
+static int udp_rx_dropped;
+#endif
+
+#define MAX_UDP_DATA (ETH_MAX_PKTLEN - (ETH_HDR_SIZE + \
+ sizeof(ip_header_t) + \
+ sizeof(udp_header_t)))
+
+/*
+ * A major assumption is that only a very small number of sockets will
+ * active, so a simple linear search of those sockets is acceptible.
+ */
+static udp_socket_t *udp_list;
+
+
+/*
+ * Install a handler for incoming udp packets.
+ * Caller provides the udp_socket_t structure.
+ * Returns zero if successful, -1 if socket is already used.
+ */
+int
+__udp_install_listener(udp_socket_t *s, word port, udp_handler_t handler)
+{
+ udp_socket_t *p;
+
+ /*
+ * Make sure we only have one handler per port.
+ */
+ for (p = udp_list; p; p = p->next)
+ if (p->our_port == port)
+ return -1;
+
+ s->our_port = htons(port);
+ s->handler = handler;
+ s->next = udp_list;
+ udp_list = s;
+
+ return 0;
+}
+
+
+/*
+ * Remove the handler for the given socket.
+ */
+void
+__udp_remove_listener(word port)
+{
+ udp_socket_t *prev, *s;
+
+ for (prev = NULL, s = udp_list; s; prev = s, s = s->next)
+ if (s->our_port == htons(port)) {
+ if (prev)
+ prev->next = s->next;
+ else
+ udp_list = s->next;
+ }
+}
+
+
+/*
+ * Handle incoming UDP packets.
+ */
+void
+__udp_handler(pktbuf_t *pkt, ip_route_t *r)
+{
+ udp_header_t *udp = pkt->udp_hdr;
+ ip_header_t *ip = pkt->ip_hdr;
+ udp_socket_t *s;
+
+ if (udp->checksum == 0xffff)
+ udp->checksum = 0;
+
+ /* copy length for pseudo sum calculation */
+ ip->length = udp->length;
+
+ if (__sum((word *)udp, ntohs(udp->length), __pseudo_sum(ip)) == 0) {
+ for (s = udp_list; s; s = s->next) {
+ if (s->our_port == udp->dest_port) {
+ (*s->handler)(s, ((char *)udp) + sizeof(udp_header_t),
+ ntohs(udp->length) - sizeof(udp_header_t),
+ r, ntohs(udp->src_port));
+ __pktbuf_free(pkt);
+ return;
+ }
+ }
+ }
+ __pktbuf_free(pkt);
+}
+
+
+/*
+ * Send a UDP packet.
+ */
+int
+__udp_send(char *buf, int len, ip_route_t *dest_ip,
+ word dest_port, word src_port)
+{
+ pktbuf_t *pkt;
+ udp_header_t *udp;
+ ip_header_t *ip;
+ unsigned short cksum;
+ int ret;
+
+ /* dumb */
+ if (len > MAX_UDP_DATA)
+ return -1;
+
+ /* just drop it if can't get a buffer */
+ if ((pkt = __pktbuf_alloc(ETH_MAX_PKTLEN)) == NULL)
+ return -1;
+
+ udp = pkt->udp_hdr;
+ ip = pkt->ip_hdr;
+
+ pkt->pkt_bytes = len + sizeof(udp_header_t);
+
+ udp->src_port = htons(src_port);
+ udp->dest_port = htons(dest_port);
+ udp->length = htons(pkt->pkt_bytes);
+ udp->checksum = 0;
+
+ memcpy(((char *)udp) + sizeof(udp_header_t), buf, len);
+
+ /* fill in some pseudo-header fields */
+ memcpy(ip->source, __local_ip_addr, sizeof(ip_addr_t));
+ memcpy(ip->destination, dest_ip->ip_addr, sizeof(ip_addr_t));
+ ip->protocol = IP_PROTO_UDP;
+ ip->length = udp->length;
+
+ cksum = __sum((word *)udp, pkt->pkt_bytes, __pseudo_sum(ip));
+ udp->checksum = htons(cksum);
+
+ ret = __ip_send(pkt, IP_PROTO_UDP, dest_ip);
+ __pktbuf_free(pkt);
+ return ret;
+}
+
+int
+__udp_sendto(char *data, int len, struct sockaddr_in *server,
+ struct sockaddr_in *local)
+{
+ ip_route_t rt;
+
+ if (__arp_lookup((ip_addr_t *)&server->sin_addr, &rt) < 0) {
+ diag_printf("%s: Can't find address of server\n", __FUNCTION__);
+ return -1;
+ } else {
+ __udp_send(data, len, &rt, ntohs(server->sin_port), ntohs(local->sin_port));
+ return 0;
+ }
+}
+
+static char *recvfrom_buf;
+static int recvfrom_len;
+static struct sockaddr_in *recvfrom_server;
+
+static void
+__udp_recvfrom_handler(udp_socket_t *skt, char *buf, int len,
+ ip_route_t *src_route, word src_port)
+{
+ if (recvfrom_server == NULL || recvfrom_buf == NULL)
+ return;
+
+ if (recvfrom_server->sin_port && recvfrom_server->sin_port != htons(src_port))
+ return;
+
+ // Move data to waiting buffer
+ recvfrom_len = len;
+ memcpy(recvfrom_buf, buf, len);
+ if (recvfrom_server) {
+ recvfrom_server->sin_port = htons(src_port);
+ memcpy(&recvfrom_server->sin_addr, &src_route->ip_addr, sizeof(src_route->ip_addr));
+ recvfrom_buf = (char *)0; // Tell reader we got a packet
+ } else {
+ diag_printf("udp_recvfrom - dropped packet of %d bytes\n", len);
+ }
+}
+
+int
+__udp_recvfrom(char *data, int len, struct sockaddr_in *server,
+ struct sockaddr_in *local, struct timeval *timo)
+{
+ int res, my_port, total_ms;
+ udp_socket_t skt;
+ unsigned long start;
+
+ my_port = ntohs(local->sin_port);
+ if (__udp_install_listener(&skt, my_port, __udp_recvfrom_handler) < 0) {
+ return -1;
+ }
+ recvfrom_buf = data;
+ recvfrom_len = len;
+ recvfrom_server = server;
+ total_ms = (timo->tv_sec * 1000) + (timo->tv_usec / 1000);
+ start = MS_TICKS();
+ res = -1;
+ do {
+ __enet_poll(); // Handle the hardware
+ if (!recvfrom_buf) {
+ // Data have arrived
+ res = recvfrom_len;
+ break;
+ }
+ } while ((MS_TICKS_DELAY() - start) < total_ms);
+ __udp_remove_listener(my_port);
+ return res;
+}
diff --git a/ecos/packages/redboot/current/src/parse.c b/ecos/packages/redboot/current/src/parse.c
new file mode 100644
index 0000000..e4c858c
--- /dev/null
+++ b/ecos/packages/redboot/current/src/parse.c
@@ -0,0 +1,492 @@
+//==========================================================================
+//
+// parse.c
+//
+// RedBoot command line parsing routine
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas, eCosCentric
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+#include <cyg/hal/hal_arch.h>
+#include <cyg/hal/hal_intr.h>
+#include <cyg/hal/hal_cache.h>
+#include CYGHWR_MEMORY_LAYOUT_H
+#include <cyg/hal/hal_tables.h>
+
+// Define table boundaries
+extern struct cmd __RedBoot_CMD_TAB__[], __RedBoot_CMD_TAB_END__;
+
+//
+// Scan through an input line and break it into "arguments". These
+// are space delimited strings. Return a structure which points to
+// the strings, similar to a Unix program. Multiple commands in the line
+// are separated by ; similar to sh. If we find a semi we stop processing the
+// line, terminate the current command with a null and return the start
+// of the next command in *line. parse() can then be called again to
+// process the next command on the line.
+// Note: original input is destroyed by replacing the delimiters with
+// null ('\0') characters for ease of use.
+//
+struct cmd *
+parse(char **line, int *argc, char **argv)
+{
+ char *cp = *line;
+ char *pp;
+ int indx = 0;
+ int semi = 0;
+
+ while (*cp) {
+ // Skip leading spaces
+ while (*cp && *cp == ' ') cp++;
+ if (!*cp) {
+ break; // Line ended with a string of spaces
+ }
+ if (*cp == ';') {
+ *cp = '\0';
+ semi=1;
+ break;
+ }
+ if (indx < MAX_ARGV) {
+ argv[indx++] = cp;
+ } else {
+ diag_printf("Too many arguments - stopped at: '%s'\n", cp);
+ }
+ while (*cp) {
+ if (*cp == ' ') {
+ *cp++ = '\0';
+ break;
+ } else if (*cp == ';') {
+ break;
+ } else if (*cp == '"') {
+ // Swallow quote, scan till following one
+ if (argv[indx-1] == cp) {
+ argv[indx-1] = ++cp;
+ }
+ pp = cp;
+ while (*cp && *cp != '"') {
+ if (*cp == '\\') {
+ // Skip over escape - allows for escaped '"'
+ cp++;
+ }
+ // Move string to swallow escapes
+ *pp++ = *cp++;
+ }
+ if (!*cp) {
+ diag_printf("Unbalanced string!\n");
+ } else {
+ if (pp != cp) *pp = '\0';
+ *cp++ = '\0';
+ break;
+ }
+ } else {
+ cp++;
+ }
+ }
+ }
+ if (semi) {
+ *line = cp + 1;
+ } else {
+ *line = cp;
+ }
+ *argc = indx;
+ return cmd_search(__RedBoot_CMD_TAB__, &__RedBoot_CMD_TAB_END__, argv[0]);
+}
+
+//
+// Search through a list of commands
+//
+struct cmd *
+cmd_search(struct cmd *tab, struct cmd *tabend, char *arg)
+{
+ int cmd_len;
+ struct cmd *cmd, *cmd2;
+ // Search command table
+ cmd_len = strlen(arg);
+ cmd = tab;
+ while (cmd != tabend) {
+ if (strncasecmp(arg, cmd->str, cmd_len) == 0) {
+ if (strlen(cmd->str) > cmd_len) {
+ // Check for ambiguous commands here
+ // Note: If there are commands which are not length-unique
+ // then this check will be invalid. E.g. "du" and "dump"
+ bool first = true;
+ cmd2 = tab;
+ while (cmd2 != tabend) {
+ if ((cmd != cmd2) &&
+ (strncasecmp(arg, cmd2->str, cmd_len) == 0)) {
+ if (first) {
+ diag_printf("Ambiguous command '%s', choices are: %s",
+ arg, cmd->str);
+ first = false;
+ }
+ diag_printf(" %s", cmd2->str);
+ }
+ cmd2++;
+ }
+ if (!first) {
+ // At least one ambiguity found - fail the lookup
+ diag_printf("\n");
+ return (struct cmd *)0;
+ }
+ }
+ return cmd;
+ }
+ cmd++;
+ }
+ return (struct cmd *)0;
+}
+
+void
+cmd_usage(struct cmd *tab, struct cmd *tabend, char *prefix)
+{
+ struct cmd *cmd;
+
+ diag_printf("Usage:\n");
+ for (cmd = tab; cmd != tabend; cmd++) {
+ diag_printf(" %s%s %s\n", prefix, cmd->str, cmd->usage);
+ }
+}
+
+//
+// Handle illegal memory accesses (and other abort conditions)
+//
+static hal_jmp_buf error_jmpbuf;
+static cyg_bool redboot_exec_call = false;
+#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
+__externC void* volatile __mem_fault_handler;
+
+static void error_handler(void)
+{
+ hal_longjmp(error_jmpbuf, 1);
+}
+#endif
+
+// Routine to allow code to invoke RedBoot commands. This is useful
+// during initialization and in platform specific code.
+//
+// Call it like this:
+//
+// result = redboot_exec( "load", "-m", "file", "foo", 0 );
+//
+// Note the terminating zero. The result will be zero if the command
+// succeeded, and <0 if something went wrong.
+
+#define ARGV_MAX 20
+int redboot_exec( char *command, ... )
+{
+ int argc;
+ char *argv[ARGV_MAX+1];
+ va_list ap;
+ struct cmd *cmd;
+ int result = 0;
+
+ va_start(ap, command);
+
+ argv[0] = command;
+ for( argc = 1; argc < ARGV_MAX; argc++ )
+ {
+ char *arg = va_arg(ap, char *);
+ if( arg == 0 )
+ break;
+ argv[argc] = arg;
+ }
+ argv[argc] = NULL;
+
+ if(( cmd = cmd_search(__RedBoot_CMD_TAB__, &__RedBoot_CMD_TAB_END__, command) ))
+ {
+ // Try to handle aborts - messy because of the stack unwinding...
+#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
+ __mem_fault_handler = error_handler;
+#endif
+ redboot_exec_call = true;
+ if (hal_setjmp(error_jmpbuf))
+ result = -1;
+ else
+ (cmd->fun)(argc, argv);
+
+ redboot_exec_call = false;
+#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
+ __mem_fault_handler = 0;
+#endif
+ }
+ else
+ result = -1;
+
+ va_end(ap);
+
+ return result;
+}
+
+externC void err_printf( const char *fmt, ... )
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+
+ diag_vprintf( fmt, ap );
+
+ va_end(ap);
+
+ // If we are not in redboot_exec() just return as usual. If we are
+ // inside a call to redboot_exec(), longjump out to terminate the command.
+
+ if( redboot_exec_call )
+ {
+ diag_printf("err_printf: aborting command\n");
+ hal_longjmp(error_jmpbuf, 1);
+ }
+}
+
+
+// Option processing
+
+// Initialize option table entry (required because these entries
+// may have dynamic contents, thus cannot be statically initialized)
+//
+void
+init_opts(struct option_info *opts, char flag, bool takes_arg,
+ int arg_type, void *arg, bool *arg_set, char *name)
+{
+ opts->flag = flag;
+ opts->takes_arg = takes_arg;
+ opts->arg_type = arg_type,
+ opts->arg = arg;
+ opts->arg_set = arg_set;
+ opts->name = name;
+}
+
+//
+// Scan command line arguments (argc/argv), processing options, etc.
+//
+bool
+scan_opts(int argc, char *argv[], int first,
+ struct option_info *opts, int num_opts,
+ void *def_arg, int def_arg_type, char *def_descr)
+{
+ bool ret = true;
+ bool flag_ok;
+ bool def_arg_set = false;
+ int i, j;
+ char c, *s;
+ struct option_info *opt;
+
+ if (def_arg && (def_arg_type == OPTION_ARG_TYPE_STR)) {
+ *(char **)def_arg = (char *)0;
+ }
+ opt = opts;
+ for (j = 0; j < num_opts; j++, opt++) {
+ if (opt->arg_set) {
+ *opt->arg_set = false;
+ }
+ if (!opt->takes_arg) {
+ switch (opt->arg_type) {
+ case OPTION_ARG_TYPE_NUM:
+ *(int *)opt->arg = 0;
+ break;
+ case OPTION_ARG_TYPE_FLG:
+ *(bool *)opt->arg = false;
+ break;
+ }
+ }
+ }
+ for (i = first; i < argc; i++) {
+ if (argv[i][0] == '-') {
+ c = argv[i][1];
+ flag_ok = false;
+ opt = opts;
+ for (j = 0; j < num_opts; j++, opt++) {
+ if (c == opt->flag) {
+ if (opt->arg_set && *opt->arg_set) {
+ diag_printf("** Error: %s already specified\n", opt->name);
+ ret = false;
+ }
+ if (opt->takes_arg) {
+ if (argv[i][2] == '=') {
+ s = &argv[i][3];
+ } else {
+ s = argv[i+1];
+ i++;
+ }
+ switch (opt->arg_type) {
+ case OPTION_ARG_TYPE_NUM:
+ if (!parse_num(s, (unsigned long *)opt->arg, 0, 0)) {
+ diag_printf("** Error: invalid number '%s' for %s\n",
+ s, opt->name);
+ ret = false;
+ }
+ break;
+ case OPTION_ARG_TYPE_STR:
+ *(char **)opt->arg = s;
+ break;
+ }
+ *opt->arg_set = true;
+ } else {
+ switch (opt->arg_type) {
+ case OPTION_ARG_TYPE_NUM:
+ *(int *)opt->arg = *(int *)opt->arg + 1;
+ break;
+ case OPTION_ARG_TYPE_FLG:
+ *(bool *)opt->arg = true;
+ break;
+ }
+ }
+ flag_ok = true;
+ break;
+ }
+ }
+ if (!flag_ok) {
+ diag_printf("** Error: invalid flag '%c'\n", c);
+ ret = false;
+ }
+ } else {
+ if (def_arg) {
+ if (def_arg_set) {
+ diag_printf("** Error: %s already specified\n", def_descr);
+ ret = false;
+ }
+ switch (def_arg_type) {
+ case OPTION_ARG_TYPE_NUM:
+ if (!parse_num(argv[i], (unsigned long *)def_arg, 0, 0)) {
+ diag_printf("** Error: invalid number '%s' for %s\n",
+ argv[i], def_descr);
+ ret = false;
+ }
+ break;
+ case OPTION_ARG_TYPE_STR:
+ *(char **)def_arg = argv[i];
+ break;
+ }
+ def_arg_set = true;
+ } else {
+ diag_printf("** Error: no default/non-flag arguments supported\n");
+ ret = false;
+ }
+ }
+ }
+ return ret;
+}
+
+//
+// Parse (scan) a number
+//
+bool
+parse_num(char *s, unsigned long *val, char **es, char *delim)
+{
+ bool first = true;
+ int radix = 10;
+ char c;
+ unsigned long result = 0;
+ int digit;
+
+ while (*s == ' ') s++;
+ while (*s) {
+ if (first && (s[0] == '0') && (_tolower(s[1]) == 'x')) {
+ radix = 16;
+ s += 2;
+ }
+ first = false;
+ c = *s++;
+ if (_is_hex(c) && ((digit = _from_hex(c)) < radix)) {
+ // Valid digit
+#ifdef CYGPKG_HAL_MIPS
+ // FIXME: tx49 compiler generates 0x2539018 for MUL which
+ // isn't any good.
+ if (16 == radix)
+ result = result << 4;
+ else
+ result = 10 * result;
+ result += digit;
+#else
+ result = (result * radix) + digit;
+#endif
+ } else {
+ if (delim != (char *)0) {
+ // See if this character is one of the delimiters
+ char *dp = delim;
+ while (*dp && (c != *dp)) dp++;
+ if (*dp) break; // Found a good delimiter
+ }
+ return false; // Malformatted number
+ }
+ }
+ *val = result;
+ if (es != (char **)0) {
+ *es = s;
+ }
+ return true;
+}
+
+bool
+parse_bool(char *s, bool *val)
+{
+ while (*s == ' ') s++;
+ if ((*s == 't') || (*s == 'T')) {
+ char *p = "rue";
+ char *P = "RUE";
+ // check for (partial) rest of the word and no extra including the
+ // terminating zero. "tru" will match; "truef" will not.
+ while ( *++s ) {
+ if ( *p != *s && *P != *s ) return false;
+ p++; P++;
+ }
+ *val = true;
+ } else
+ if ((*s == 'f') || (*s == 'F')) {
+ char *p = "alse";
+ char *P = "ALSE";
+ while ( *++s ) {
+ if ( *p != *s && *P != *s ) return false;
+ p++; P++;
+ }
+ *val = false;
+ } else {
+ return false;
+ }
+ return true;
+}
+
diff --git a/ecos/packages/redboot/current/src/syscall.c b/ecos/packages/redboot/current/src/syscall.c
new file mode 100644
index 0000000..bab64d8
--- /dev/null
+++ b/ecos/packages/redboot/current/src/syscall.c
@@ -0,0 +1,654 @@
+/*==========================================================================
+//
+// syscall.c
+//
+// Redboot syscall handling for GNUPro bsp support
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): msalter
+// Contributors: msalter
+// Date: 1999-02-20
+// Purpose: Temporary support for gnupro bsp
+//
+//####DESCRIPTIONEND####
+//
+//=========================================================================*/
+
+#include <redboot.h>
+#include <cyg/hal/hal_intr.h>
+#include <cyg/hal/drv_api.h>
+#include <cyg/hal/hal_stub.h>
+
+#ifdef CYGSEM_REDBOOT_BSP_SYSCALLS
+
+#define NEWLIB_EIO 5 /* I/O error */
+#define NEWLIB_ENOSYS 88 /* Syscall not supported */
+
+/*
+ * Clients of this BSP will need to have access to BSP functions and
+ * data structures. Because, the client and the BSP may not be linked
+ * together, a structure of vectors is used to gain this access. A
+ * pointer to this structure can be gotten via a syscall. This syscall
+ * is made automatically from within the crt0.o file.
+ */
+typedef struct {
+ int version; /* version number for future expansion */
+ const void **__ictrl_table;
+ void **__exc_table;
+ void *__dbg_vector;
+ void *__kill_vector;
+ void *__console_procs;
+ void *__debug_procs;
+ void (*__flush_dcache)(void *__p, int __nbytes);
+ void (*__flush_icache)(void *__p, int __nbytes);
+ void *__cpu_data;
+ void *__board_data;
+ void *__sysinfo;
+ int (*__set_debug_comm)(int __comm_id);
+ int (*__set_console_comm)(int __comm_id);
+ int (*__set_serial_baud)(int __comm_id, int baud);
+ void *__dbg_data;
+ void (*__reset)(void);
+ int __console_interrupt_flag;
+} __shared_t;
+
+static __shared_t __shared_data = { 2 };
+
+// this is used by newlib's mode_t so we should match it
+#ifdef __GNUC__
+#define _ST_INT32 __attribute__ ((__mode__ (__SI__)))
+#else
+#define _ST_INT32
+#endif
+typedef unsigned int newlib_mode_t _ST_INT32;
+typedef short newlib_dev_t;
+typedef unsigned short newlib_ino_t;
+typedef unsigned short newlib_nlink_t;
+typedef long newlib_off_t;
+typedef unsigned short newlib_uid_t;
+typedef unsigned short newlib_gid_t;
+typedef long newlib_time_t;
+typedef long newlib_long_t;
+
+struct newlib_stat
+{
+ newlib_dev_t st_dev;
+ newlib_ino_t st_ino;
+ newlib_mode_t st_mode;
+ newlib_nlink_t st_nlink;
+ newlib_uid_t st_uid;
+ newlib_gid_t st_gid;
+ newlib_dev_t st_rdev;
+ newlib_off_t st_size;
+ // We assume we've been compiled with the same flags as newlib here
+#if defined(__svr4__) && !defined(__PPC__) && !defined(__sun__)
+ newlib_time_t st_atime;
+ newlib_time_t st_mtime;
+ newlib_time_t st_ctime;
+#else
+ newlib_time_t st_atime;
+ newlib_long_t st_spare1;
+ newlib_time_t st_mtime;
+ newlib_long_t st_spare2;
+ newlib_time_t st_ctime;
+ newlib_long_t st_spare3;
+ newlib_long_t st_blksize;
+ newlib_long_t st_blocks;
+ newlib_long_t st_spare4[2];
+#endif
+};
+#define NEWLIB_S_IFCHR 0020000 // character special file
+
+static inline char __getc(void)
+{
+ char c;
+ hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
+
+ if (__chan)
+ c = CYGACC_COMM_IF_GETC(*__chan);
+ else {
+ __chan = CYGACC_CALL_IF_DEBUG_PROCS();
+ c = CYGACC_COMM_IF_GETC(*__chan);
+ }
+ return c;
+}
+
+static inline void __putc(char c)
+{
+ hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
+ if (__chan)
+ CYGACC_COMM_IF_PUTC(*__chan, c);
+ else {
+ __chan = CYGACC_CALL_IF_DEBUG_PROCS();
+ CYGACC_COMM_IF_PUTC(*__chan, c);
+ }
+}
+
+
+static inline void __flush(void)
+{
+ hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
+
+ if (__chan == NULL)
+ __chan = CYGACC_CALL_IF_DEBUG_PROCS();
+
+ CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_FLUSH_OUTPUT);
+}
+
+// Timer support
+
+static cyg_handle_t sys_timer_handle;
+static cyg_interrupt sys_timer_interrupt;
+static cyg_uint64 sys_timer_ticks = 0;
+
+#ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
+
+static unsigned int set_period = CYGNUM_HAL_RTC_PERIOD; // The default
+
+typedef void *callback_func( char *pc, char *sp );
+static callback_func *timer_callback = 0;
+
+#endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
+
+static void
+sys_timer_dsr(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data)
+{
+ // do nothing
+}
+
+
+static cyg_uint32
+sys_timer_isr(cyg_vector_t vector, cyg_addrword_t data)
+{
+ ++sys_timer_ticks;
+
+#ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
+ HAL_CLOCK_RESET(CYGNUM_HAL_INTERRUPT_RTC, set_period);
+#else
+ HAL_CLOCK_RESET(CYGNUM_HAL_INTERRUPT_RTC, CYGNUM_HAL_RTC_PERIOD);
+#endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
+
+ cyg_drv_interrupt_acknowledge(CYGNUM_HAL_INTERRUPT_RTC);
+
+#ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
+ if ( timer_callback ) {
+ char *intrpc = (char *)0;
+ char *intrsp = (char *)0;
+
+ // There may be a number of ways to get the PC and (optional) SP
+ // information out of the HAL. Hence this is conditioned. In some
+ // configurations, a register-set pointer is available as
+ // (invisible) argument 3 to this ISR call.
+
+#ifdef HAL_GET_PROFILE_INFO
+ HAL_GET_PROFILE_INFO( intrpc, intrsp );
+#endif // HAL_GET_PROFILE_INFO available
+
+ CYGARC_HAL_SAVE_GP();
+ timer_callback( intrpc, intrsp );
+ CYGARC_HAL_RESTORE_GP();
+ }
+#endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
+ return CYG_ISR_HANDLED;
+}
+
+
+static void sys_timer_init(void)
+{
+#ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
+ HAL_CLOCK_INITIALIZE(set_period);
+#else
+ HAL_CLOCK_INITIALIZE(CYGNUM_HAL_RTC_PERIOD);
+#endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
+
+ cyg_drv_interrupt_create(
+ CYGNUM_HAL_INTERRUPT_RTC,
+ 0, // Priority - unused
+ (CYG_ADDRWORD)0, // Data item passed to ISR & DSR
+ sys_timer_isr, // ISR
+ sys_timer_dsr, // DSR
+ &sys_timer_handle, // handle to intr obj
+ &sys_timer_interrupt ); // space for int obj
+
+ cyg_drv_interrupt_attach(sys_timer_handle);
+
+ cyg_drv_interrupt_unmask(CYGNUM_HAL_INTERRUPT_RTC);
+}
+
+
+//
+// read -- read bytes from the serial port. Ignore fd, since
+// we only have stdin.
+static int
+sys_read(int fd, char *buf, int nbytes)
+{
+ int i = 0;
+
+ for (i = 0; i < nbytes; i++) {
+ *(buf + i) = __getc();
+ if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
+ (*(buf + i + 1)) = 0;
+ break;
+ }
+ }
+ return (i);
+}
+
+
+//
+// write -- write bytes to the serial port. Ignore fd, since
+// stdout and stderr are the same. Since we have no filesystem,
+// open will only return an error.
+//
+static int
+sys_write(int fd, char *buf, int nbytes)
+{
+#define WBUFSIZE 256
+ int tosend;
+
+ tosend = nbytes;
+
+ while (tosend > 0) {
+ if (*buf == '\n')
+ __putc('\r');
+ __putc(*buf++);
+ tosend--;
+ }
+ __flush();
+
+ return (nbytes);
+}
+
+
+//
+// open -- open a file descriptor. We don't have a filesystem, so
+// we return an error.
+//
+static int
+sys_open (const char *buf, int flags, int mode)
+{
+ return (-NEWLIB_EIO);
+}
+
+//
+// close -- We don't need to do anything, but pretend we did.
+//
+static int
+sys_close(int fd)
+{
+ return (0);
+}
+
+
+//
+// lseek -- Since a serial port is non-seekable, we return an error.
+//
+static int
+sys_lseek(int fd, int offset, int whence)
+{
+ return (-NEWLIB_EIO);
+}
+
+
+#define NS_PER_TICK (CYGNUM_HAL_RTC_NUMERATOR/CYGNUM_HAL_RTC_DENOMINATOR)
+#define TICKS_PER_SEC (1000000000ULL / NS_PER_TICK)
+
+// This needs to match newlib HZ which is normally 60.
+#define HZ (60ULL)
+
+#ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
+static unsigned int set_freq = TICKS_PER_SEC; // The default
+#endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
+static int
+sys_times(unsigned long *p)
+{
+ static int inited = 0;
+
+ if (!inited) {
+ inited = 1;
+ sys_timer_init();
+ }
+
+ /* target clock runs at CLOCKS_PER_SEC. Convert to HZ */
+ if (p)
+#ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
+ *p = (sys_timer_ticks * HZ) / (cyg_uint64)set_freq;
+#else
+ *p = (sys_timer_ticks * HZ) / TICKS_PER_SEC;
+#endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
+
+ return 0;
+}
+
+#ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
+
+static void sys_profile_call_back( char *func, char **previous_call_back )
+{
+ if ( previous_call_back )
+ *previous_call_back = (char *)timer_callback;
+
+ timer_callback = (callback_func *)func;
+
+ // Ensure the timer is started
+ (void)sys_times( (unsigned long *)0 );
+}
+
+static void sys_profile_frequency( int freq, int *previous_freq )
+{
+// Requested HZ:
+// 0 => tell me the current value (no change, IMPLEMENTED HERE)
+// - 1 => tell me the slowest (no change)
+// - 2 => tell me the default (no change, IMPLEMENTED HERE)
+// -nnn => tell me what you would choose for nnn (no change)
+// MIN_INT => tell me the fastest (no change)
+//
+// 1 => tell me the slowest (sets the clock)
+// MAX_INT => tell me the fastest (sets the clock)
+
+ // Ensure the timer is started
+ (void)sys_times( (unsigned long *)0 );
+
+ if ( -2 == freq )
+ freq = TICKS_PER_SEC; // default value
+ else if ( 0 == freq )
+ freq = set_freq; // collect current value
+ else {
+ int do_set_freq = (freq > 0);
+ unsigned int period = CYGNUM_HAL_RTC_PERIOD;
+
+ if ( 0 == (freq ^ -freq) ) // Then it's MIN_INT in local size
+ freq++; // just so that it will negate correctly
+
+ // Then set the timer to that fast - or pass on the enquiry
+#ifdef HAL_CLOCK_REINITIALIZE
+ // Give the HAL enough info to do the division sum relative to
+ // the default setup, in period and TICKS_PER_SEC.
+ HAL_CLOCK_REINITIALIZE( freq, period, TICKS_PER_SEC );
+#else
+ freq = TICKS_PER_SEC; // the only choice
+#endif
+ if ( do_set_freq ) { // update the global variables
+ unsigned int orig = set_freq;
+ set_freq = freq;
+ set_period = period;
+ // We must "correct" sys_timer_ticks for the new scale factor.
+ sys_timer_ticks = sys_timer_ticks * set_freq / orig;
+ }
+ }
+
+ if ( previous_freq ) // Return the current value (new value)
+ *previous_freq = freq;
+}
+
+void sys_profile_reset( void )
+{
+ timer_callback = NULL;
+// Want to preserve the frequency between runs, for clever GDB users!
+// sys_profile_frequency( TICKS_PER_SEC, NULL );
+}
+
+#endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
+
+//
+// Generic syscall handler.
+//
+// Returns 0 if syscall number is not handled by this
+// module, 1 otherwise. This allows applications to
+// extend the syscall handler by using exception chaining.
+//
+CYG_ADDRWORD
+__do_syscall(CYG_ADDRWORD func, // syscall function number
+ CYG_ADDRWORD arg1, CYG_ADDRWORD arg2, // up to four args.
+ CYG_ADDRWORD arg3, CYG_ADDRWORD arg4,
+ CYG_ADDRWORD *retval, CYG_ADDRWORD *sig) // syscall return value
+{
+ int err = 0;
+ *sig = 0;
+
+ switch (func) {
+
+ case SYS_open:
+ {
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
+ __externC int cyg_hal_gdbfileio_open( const char *name, int flags,
+ int mode, int *sig );
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_open((const char *)arg1, (int)arg2, (int)arg3,
+ (int *)sig);
+ else
+#endif
+ err = sys_open((const char *)arg1, (int)arg2, (int)arg3);
+ break;
+ }
+ case SYS_read:
+ {
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
+ __externC int cyg_hal_gdbfileio_read( int fd, void *buf, size_t count,
+ int *sig );
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_read((int)arg1, (void *)arg2, (size_t)arg3,
+ (int *)sig);
+ else
+#endif
+ err = sys_read((int)arg1, (char *)arg2, (int)arg3);
+ break;
+ }
+ case SYS_write:
+ {
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
+ __externC int cyg_hal_gdbfileio_write( int fd, const void *buf,
+ size_t count, int *sig );
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_write((int)arg1, (const void *)arg2,
+ (size_t)arg3, (int *)sig);
+ else
+#endif
+ err = sys_write((int)arg1, (char *)arg2, (int)arg3);
+ break;
+ }
+ case SYS_close:
+ {
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
+ __externC int cyg_hal_gdbfileio_close( int fd, int *sig );
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_close((int)arg1, (int *)sig);
+ else
+#endif
+ err = sys_close((int)arg1);
+ break;
+ }
+ case SYS_lseek:
+ {
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
+ __externC int cyg_hal_gdbfileio_lseek( int fd, long offset,
+ int whence, int *sig );
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_lseek((int)arg1, (long)arg2, (int)arg3,
+ (int *)sig);
+ else
+#endif
+ err = sys_lseek((int)arg1, (int)arg2, (int)arg3);
+ break;
+ }
+ case SYS_stat:
+ {
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
+ __externC int cyg_hal_gdbfileio_stat( const char *pathname,
+ void *statbuf, int *sig );
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_stat((const char *)arg1, (void *)arg2,
+ (int *)sig);
+ else
+#endif
+ err = -NEWLIB_ENOSYS;
+ break;
+ }
+ case SYS_fstat:
+ {
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
+ __externC int cyg_hal_gdbfileio_fstat( int fd, void *statbuf,
+ int *sig );
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_fstat((int)arg1, (void *)arg2,
+ (int *)sig);
+ else
+#endif
+ {
+ struct newlib_stat *st = (struct newlib_stat *)arg2;
+ st->st_mode = NEWLIB_S_IFCHR;
+ st->st_blksize = 4096;
+ err = 0;
+ }
+ break;
+ }
+ case SYS_rename:
+ {
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
+ __externC int cyg_hal_gdbfileio_rename( const char *oldpath,
+ const char *newpath,
+ int *sig );
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_rename((const char *)arg1, (const char *)arg2,
+ (int *)sig);
+ else
+#endif
+ err = -NEWLIB_ENOSYS;
+ break;
+ }
+ case SYS_unlink:
+ {
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
+ __externC int cyg_hal_gdbfileio_unlink( const char *pathname,
+ int *sig );
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_unlink((const char *)arg1, (int *)sig);
+ else
+#endif
+ err = -NEWLIB_ENOSYS;
+ break;
+ }
+ case SYS_isatty:
+ {
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
+ __externC int cyg_hal_gdbfileio_isatty( int fd, int *sig );
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_isatty((int)arg1, (int *)sig);
+ else
+#endif
+ err = 1;
+ break;
+ }
+ case SYS_system:
+ {
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
+ __externC int cyg_hal_gdbfileio_system( const char *command,
+ int *sig );
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_system((const char *)arg1, (int *)sig);
+ else
+#endif
+ err = -1;
+ break;
+ }
+ case SYS_gettimeofday:
+ {
+#ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
+ __externC int cyg_hal_gdbfileio_gettimeofday( void *tv, void *tz,
+ int *sig );
+ if (gdb_active)
+ err = cyg_hal_gdbfileio_gettimeofday((void *)arg1, (void *)arg2,
+ (int *)sig);
+ else
+#endif
+ err = 0;
+ break;
+ }
+ case SYS_utime:
+ // FIXME. Some libglosses depend on this behavior.
+ err = sys_times((unsigned long *)arg1);
+ break;
+
+ case SYS_times:
+ err = sys_times((unsigned long *)arg1);
+ break;
+
+ case SYS_meminfo:
+ err = 1;
+ *(unsigned long *)arg1 = (unsigned long)(ram_end-ram_start);
+ *(unsigned long *)arg2 = (unsigned long)ram_end;
+ break;
+#ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
+ case SYS_timer_call_back:
+ sys_profile_call_back( (char *)arg1, (char **)arg2 );
+ break;
+
+ case SYS_timer_frequency:
+ sys_profile_frequency( (int)arg1, (unsigned int *)arg2 );
+ break;
+
+ case SYS_timer_reset:
+ sys_profile_reset();
+ break;
+
+#endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
+ case __GET_SHARED:
+ *(__shared_t **)arg1 = &__shared_data;
+ break;
+
+ case SYS_exit:
+ *sig = -1; // signal exit
+ err = arg1;
+
+ if (gdb_active) {
+#ifdef CYGOPT_REDBOOT_BSP_SYSCALLS_EXIT_WITHOUT_TRAP
+ __send_exit_status((int)arg1);
+#else
+ *sig = SIGTRAP;
+ err = func;
+#endif // CYGOPT_REDBOOT_BSP_SYSCALLS_EXIT_WITHOUT_TRAP
+ }
+ break;
+
+ default:
+ return 0;
+ }
+
+ *retval = err;
+ return 1;
+}
+
+#endif
diff --git a/ecos/packages/redboot/current/src/ticks.c b/ecos/packages/redboot/current/src/ticks.c
new file mode 100644
index 0000000..b325045
--- /dev/null
+++ b/ecos/packages/redboot/current/src/ticks.c
@@ -0,0 +1,75 @@
+//==========================================================================
+//
+// ticks.c
+//
+// Stand-alone timer support for RedBoot
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include "redboot.h"
+
+static unsigned long ticks = 0;
+static long elapsed = 0;
+
+unsigned long
+do_ms_tick(void)
+{
+ CYGACC_CALL_IF_DELAY_US(CYGDBG_REDBOOT_TICK_GRANULARITY);
+ elapsed += CYGDBG_REDBOOT_TICK_GRANULARITY;
+ if (elapsed >= 1000) {
+ elapsed = 0;
+ ticks++;
+ }
+ return ticks;
+}
+
+unsigned long
+get_ms_ticks(void)
+{
+ return ticks;
+}
diff --git a/ecos/packages/redboot/current/src/time_date.cxx b/ecos/packages/redboot/current/src/time_date.cxx
new file mode 100644
index 0000000..6a36611
--- /dev/null
+++ b/ecos/packages/redboot/current/src/time_date.cxx
@@ -0,0 +1,123 @@
+//==========================================================================
+//
+// time_date.cxx
+//
+// RedBoot time/date commands
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2003 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors:
+// Date: 2003-09-10
+// Description:
+//####DESCRIPTIONEND####
+// -------------------------------------------------------------------------
+
+#include <redboot.h>
+#include <pkgconf/hal.h>
+#include <pkgconf/wallclock.h>
+
+#include <cyg/infra/diag.h>
+#include <cyg/io/wallclock.hxx> // The WallClock API
+#include <cyg/io/wallclock/wallclock.inl> // Helper functions (avoids LIBC)
+
+RedBoot_cmd("date",
+ "Show/Set the time of day",
+ "[YYYY/MM/DD HH:MM:SS]",
+ do_time_date
+ );
+
+static bool
+verify(cyg_uint32 val, int min, int max, char *id)
+{
+ if (((int)val < min) || ((int)val > max)) {
+ diag_printf("%s is out of range - must be [%d..%d]\n", id, min, max);
+ return false;
+ }
+ return true;
+}
+
+void
+do_time_date(int argc, char *argv[])
+{
+ cyg_uint32 now = Cyg_WallClock::wallclock->get_current_time();
+ cyg_uint32 year, month, mday, hour, minute, second;
+ char *sp;
+ bool ok = true;
+
+ if (argc == 1) {
+ // Just show the current time/date
+ _simple_mkdate(now, &year, &month, &mday, &hour, &minute, &second);
+ diag_printf("%04d/%02d/%02d %02d:%02d:%02d\n",
+ year, month, mday, hour, minute, second);
+ } else if (argc == 3) {
+ sp = argv[1];
+ if (!parse_num(sp, (unsigned long *)&year, &sp, "/") ||
+ !parse_num(sp, (unsigned long *)&month, &sp, "/") ||
+ !parse_num(sp, (unsigned long *)&mday, &sp, "/")) {
+ ok = false;
+ }
+ sp = argv[2];
+ if (!parse_num(sp, (unsigned long *)&hour, &sp, ":") ||
+ !parse_num(sp, (unsigned long *)&minute, &sp, ":") ||
+ !parse_num(sp, (unsigned long *)&second, &sp, ":")) {
+ ok = false;
+ }
+ if (ok) {
+ // Verify values make some sense, then set the hardware
+ if (year < 100) year += 2000;
+ ok = ok && verify(year, 1970, 2034, "year");
+ ok = ok && verify(month, 1, 12, "month");
+ ok = ok && verify(mday, 1, 31, "day");
+ ok = ok && verify(hour, 0, 23, "hour");
+ ok = ok && verify(minute, 0, 59, "minute");
+ ok = ok && verify(second, 0, 59, "second");
+ if (ok) {
+ now = _simple_mktime(year, month, mday, hour, minute, second);
+ Cyg_WallClock::wallclock->set_current_time(now);
+ }
+ }
+ } else {
+ ok = false;
+ }
+ if (!ok) {
+ diag_printf("usage: date [YYYY/MM/DD HH:MM:SS]\n");
+ }
+
+}
+
+// -------------------------------------------------------------------------
+// EOF time_date.cxx
diff --git a/ecos/packages/redboot/current/src/version.c b/ecos/packages/redboot/current/src/version.c
new file mode 100644
index 0000000..244dd26
--- /dev/null
+++ b/ecos/packages/redboot/current/src/version.c
@@ -0,0 +1,96 @@
+//==========================================================================
+//
+// version.c
+//
+// RedBoot version "string"
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-12-13
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <pkgconf/redboot.h>
+#include <cyg/hal/hal_arch.h>
+
+//
+// These strings are used for informational purposes only. If the end
+// user wishes to replace them, simply redefine them in a platform specific
+// file, e.g. in a local file used to provide additional local RedBoot
+// customization. Examples of such are platforms which define a special
+// 'exec' command used to start a Linux kernel.
+//
+// CAUTION! Since this file is compiled using very special rules, it is not
+// possible to replace it with a local version contained in the "build" tree.
+// Replacing the information exported herein is accomplished via the techniques
+// outlined above.
+//
+
+// Do not change the following two lines at all. They are fiddled by release
+// scripts.
+#define _CERTIFICATE Non-certified
+//#define CYGDAT_REDBOOT_CUSTOM_VERSION current
+
+#if defined(CYGDAT_REDBOOT_CUSTOM_VERSION)
+#define _REDBOOT_VERSION CYGDAT_REDBOOT_CUSTOM_VERSION
+#elif defined(CYGPKG_REDBOOT_current)
+#define _REDBOOT_VERSION UNKNOWN
+#else
+#define _REDBOOT_VERSION CYGPKG_REDBOOT
+#endif
+
+#define __s(x) #x
+#define _s(x) __s(x)
+
+char RedBoot_version[] CYGBLD_ATTRIB_WEAK =
+ "\nRedBoot(tm) bootstrap and debug environment [" _s(CYG_HAL_STARTUP) "]"
+ "\n" _s(_CERTIFICATE) " release, version " _s(_REDBOOT_VERSION)
+ " - built " __TIME__ ", " __DATE__ "\n\n";
+
+// Override default GDB stubs 'info'
+// Note: this can still be a "weak" symbol since it will occur in the .o
+// file explicitly mentioned in the link command. User programs will
+// still be allowed to override it.
+char GDB_stubs_version[] CYGBLD_ATTRIB_WEAK =
+ "eCos GDB stubs [via RedBoot] - built " __DATE__ " / " __TIME__;
diff --git a/ecos/packages/redboot/current/src/xyzModem.c b/ecos/packages/redboot/current/src/xyzModem.c
new file mode 100644
index 0000000..d04a487
--- /dev/null
+++ b/ecos/packages/redboot/current/src/xyzModem.c
@@ -0,0 +1,595 @@
+//==========================================================================
+//
+// xyzModem.c
+//
+// RedBoot stream handler for xyzModem protocol
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas, tsmith, Yoshinori Sato
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+#include <xyzModem.h>
+
+// Assumption - run xyzModem protocol over the console port
+
+// Values magic to the protocol
+#define SOH '\x01'
+#define STX '\x02'
+#define EOT '\x04'
+#define ACK '\x06'
+#define BSP '\x08'
+#define NAK '\x15'
+#define CAN '\x18'
+#define EOF '\x1A' // ^Z for DOS officionados
+
+#define USE_YMODEM_LENGTH
+
+// Data & state local to the protocol
+static struct {
+ hal_virtual_comm_table_t* __chan;
+ unsigned char pkt[1024], *bufp;
+ unsigned char blk,cblk,crc1,crc2;
+ unsigned char next_blk; // Expected block
+ int len, mode, total_retries;
+ int total_SOH, total_STX, total_CAN;
+ bool crc_mode, at_eof, tx_ack;
+#ifdef USE_YMODEM_LENGTH
+ unsigned long file_length, read_length;
+#endif
+} xyz;
+
+#define xyzModem_CHAR_TIMEOUT 2000 // 2 seconds
+#define xyzModem_MAX_RETRIES 20
+#define xyzModem_MAX_RETRIES_WITH_CRC 10
+#define xyzModem_CAN_COUNT 3 // Wait for 3 CAN before quitting
+
+#ifdef DEBUG
+#ifndef USE_SPRINTF
+//
+// Note: this debug setup only works if the target platform has two serial ports
+// available so that the other one (currently only port 1) can be used for debug
+// messages.
+//
+static int
+zm_dprintf(char *fmt, ...)
+{
+ int cur_console;
+ va_list args;
+
+ va_start(args, fmt);
+ cur_console = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(1);
+ diag_vprintf(fmt, args);
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(cur_console);
+}
+
+static void
+zm_flush(void)
+{
+}
+
+#else
+//
+// Note: this debug setup works by storing the strings in a fixed buffer
+//
+static char *zm_out = (char *)0x00380000;
+static char *zm_out_start = (char *)0x00380000;
+
+static int
+zm_dprintf(char *fmt, ...)
+{
+ int len;
+ va_list args;
+
+ va_start(args, fmt);
+ len = diag_vsprintf(zm_out, fmt, args);
+ zm_out += len;
+ return len;
+}
+
+static void
+zm_flush(void)
+{
+ char *p = zm_out_start;
+ while (*p) mon_write_char(*p++);
+ zm_out = zm_out_start;
+}
+#endif
+
+static void
+zm_dump_buf(void *buf, int len)
+{
+ diag_vdump_buf_with_offset(zm_dprintf, buf, len, 0);
+}
+
+static unsigned char zm_buf[2048];
+static unsigned char *zm_bp;
+
+static void
+zm_new(void)
+{
+ zm_bp = zm_buf;
+}
+
+static void
+zm_save(unsigned char c)
+{
+ *zm_bp++ = c;
+}
+
+static void
+zm_dump(int line)
+{
+ zm_dprintf("Packet at line: %d\n", line);
+ zm_dump_buf(zm_buf, zm_bp-zm_buf);
+}
+
+#define ZM_DEBUG(x) x
+#else
+#define ZM_DEBUG(x)
+#endif
+
+// Wait for the line to go idle
+static void
+xyzModem_flush(void)
+{
+ int res;
+ unsigned char c;
+ while (true) {
+ res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &c);
+ if (!res) return;
+ }
+}
+
+static int
+xyzModem_get_hdr(void)
+{
+ unsigned char c;
+ int res;
+ bool hdr_found = false;
+ int i, can_total, hdr_chars;
+ unsigned short cksum;
+
+ ZM_DEBUG(zm_new());
+ // Find the start of a header
+ can_total = 0;
+ hdr_chars = 0;
+
+ if (xyz.tx_ack) {
+ CYGACC_COMM_IF_PUTC(*xyz.__chan, ACK);
+ xyz.tx_ack = false;
+ }
+ while (!hdr_found) {
+ res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &c);
+ ZM_DEBUG(zm_save(c));
+ if (res) {
+ hdr_chars++;
+ switch (c) {
+ case SOH:
+ xyz.total_SOH++;
+ case STX:
+ if (c == STX) xyz.total_STX++;
+ hdr_found = true;
+ break;
+ case CAN:
+ xyz.total_CAN++;
+ ZM_DEBUG(zm_dump(__LINE__));
+ if (++can_total == xyzModem_CAN_COUNT) {
+ return xyzModem_cancel;
+ } else {
+ // Wait for multiple CAN to avoid early quits
+ break;
+ }
+ case EOT:
+ // EOT only supported if no noise
+ if (hdr_chars == 1) {
+ CYGACC_COMM_IF_PUTC(*xyz.__chan, ACK);
+ ZM_DEBUG(zm_dprintf("ACK on EOT #%d\n", __LINE__));
+ ZM_DEBUG(zm_dump(__LINE__));
+ return xyzModem_eof;
+ }
+ default:
+ // Ignore, waiting for start of header
+ ;
+ }
+ } else {
+ // Data stream timed out
+ xyzModem_flush(); // Toss any current input
+ ZM_DEBUG(zm_dump(__LINE__));
+ CYGACC_CALL_IF_DELAY_US((cyg_int32)250000);
+ return xyzModem_timeout;
+ }
+ }
+
+ // Header found, now read the data
+ res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &xyz.blk);
+ ZM_DEBUG(zm_save(xyz.blk));
+ if (!res) {
+ ZM_DEBUG(zm_dump(__LINE__));
+ return xyzModem_timeout;
+ }
+ res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &xyz.cblk);
+ ZM_DEBUG(zm_save(xyz.cblk));
+ if (!res) {
+ ZM_DEBUG(zm_dump(__LINE__));
+ return xyzModem_timeout;
+ }
+ xyz.len = (c == SOH) ? 128 : 1024;
+ xyz.bufp = xyz.pkt;
+ for (i = 0; i < xyz.len; i++) {
+ res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &c);
+ ZM_DEBUG(zm_save(c));
+ if (res) {
+ xyz.pkt[i] = c;
+ } else {
+ ZM_DEBUG(zm_dump(__LINE__));
+ return xyzModem_timeout;
+ }
+ }
+ res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &xyz.crc1);
+ ZM_DEBUG(zm_save(xyz.crc1));
+ if (!res) {
+ ZM_DEBUG(zm_dump(__LINE__));
+ return xyzModem_timeout;
+ }
+ if (xyz.crc_mode) {
+ res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &xyz.crc2);
+ ZM_DEBUG(zm_save(xyz.crc2));
+ if (!res) {
+ ZM_DEBUG(zm_dump(__LINE__));
+ return xyzModem_timeout;
+ }
+ }
+ ZM_DEBUG(zm_dump(__LINE__));
+ // Validate the message
+ if ((xyz.blk ^ xyz.cblk) != 0x00FF) {
+ ZM_DEBUG(zm_dprintf("Framing error - blk: %x/%x/%x\n", xyz.blk, xyz.cblk, (xyz.blk ^ xyz.cblk)));
+ ZM_DEBUG(zm_dump_buf(xyz.pkt, xyz.len));
+ xyzModem_flush();
+ return xyzModem_frame;
+ }
+ // Verify checksum/CRC
+ if (xyz.crc_mode) {
+ cksum = cyg_crc16(xyz.pkt, xyz.len);
+ if (cksum != ((xyz.crc1 << 8) | xyz.crc2)) {
+ ZM_DEBUG(zm_dprintf("CRC error - recvd: %02x%02x, computed: %x\n",
+ xyz.crc1, xyz.crc2, cksum & 0xFFFF));
+ return xyzModem_cksum;
+ }
+ } else {
+ cksum = 0;
+ for (i = 0; i < xyz.len; i++) {
+ cksum += xyz.pkt[i];
+ }
+ if (xyz.crc1 != (cksum & 0xFF)) {
+ ZM_DEBUG(zm_dprintf("Checksum error - recvd: %x, computed: %x\n", xyz.crc1, cksum & 0xFF));
+ return xyzModem_cksum;
+ }
+ }
+ // If we get here, the message passes [structural] muster
+ return 0;
+}
+
+int
+xyzModem_stream_open(connection_info_t *info, int *err)
+{
+ int console_chan, stat=0;
+ int retries = xyzModem_MAX_RETRIES;
+ int crc_retries = xyzModem_MAX_RETRIES_WITH_CRC;
+
+// ZM_DEBUG(zm_out = zm_out_start);
+#ifdef xyzModem_zmodem
+ if (info->mode == xyzModem_zmodem) {
+ *err = xyzModem_noZmodem;
+ return -1;
+ }
+#endif
+
+ // Set up the I/O channel. Note: this allows for using a different port in the future
+ console_chan = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
+ if (info->chan >= 0) {
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(info->chan);
+ } else {
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(console_chan);
+ }
+ xyz.__chan = CYGACC_CALL_IF_CONSOLE_PROCS();
+ CYGACC_CALL_IF_SET_CONSOLE_COMM(console_chan);
+ CYGACC_COMM_IF_CONTROL(*xyz.__chan, __COMMCTL_SET_TIMEOUT, xyzModem_CHAR_TIMEOUT);
+ xyz.len = 0;
+ xyz.crc_mode = true;
+ xyz.at_eof = false;
+ xyz.tx_ack = false;
+ xyz.mode = info->mode;
+ xyz.total_retries = 0;
+ xyz.total_SOH = 0;
+ xyz.total_STX = 0;
+ xyz.total_CAN = 0;
+#ifdef USE_YMODEM_LENGTH
+ xyz.read_length = 0;
+ xyz.file_length = 0;
+#endif
+
+ CYGACC_COMM_IF_PUTC(*xyz.__chan, (xyz.crc_mode ? 'C' : NAK));
+
+ if (xyz.mode == xyzModem_xmodem) {
+ // X-modem doesn't have an information header - exit here
+ xyz.next_blk = 1;
+ return 0;
+ }
+
+ while (retries-- > 0) {
+ stat = xyzModem_get_hdr();
+ if (stat == 0) {
+ // Y-modem file information header
+ if (xyz.blk == 0) {
+#ifdef USE_YMODEM_LENGTH
+ // skip filename
+ while (*xyz.bufp++);
+ // get the length
+ parse_num((char*)xyz.bufp, &xyz.file_length, NULL, " ");
+#endif
+ // The rest of the file name data block quietly discarded
+ xyz.tx_ack = true;
+ }
+ xyz.next_blk = 1;
+ xyz.len = 0;
+ return 0;
+ } else
+ if (stat == xyzModem_timeout) {
+ if (--crc_retries <= 0) xyz.crc_mode = false;
+ CYGACC_CALL_IF_DELAY_US(5*100000); // Extra delay for startup
+ CYGACC_COMM_IF_PUTC(*xyz.__chan, (xyz.crc_mode ? 'C' : NAK));
+ xyz.total_retries++;
+ ZM_DEBUG(zm_dprintf("NAK (%d)\n", __LINE__));
+ }
+ if (stat == xyzModem_cancel) {
+ break;
+ }
+ }
+ *err = stat;
+ ZM_DEBUG(zm_flush());
+ return -1;
+}
+
+int
+xyzModem_stream_read(char *buf, int size, int *err)
+{
+ int stat, total, len;
+ int retries;
+
+ total = 0;
+ stat = xyzModem_cancel;
+ // Try and get 'size' bytes into the buffer
+ while (!xyz.at_eof && (size > 0)) {
+ if (xyz.len == 0) {
+ retries = xyzModem_MAX_RETRIES;
+ while (retries-- > 0) {
+ stat = xyzModem_get_hdr();
+ if (stat == 0) {
+ if (xyz.blk == xyz.next_blk) {
+ xyz.tx_ack = true;
+ ZM_DEBUG(zm_dprintf("ACK block %d (%d)\n", xyz.blk, __LINE__));
+ xyz.next_blk = (xyz.next_blk + 1) & 0xFF;
+
+#if defined(xyzModem_zmodem) || defined(USE_YMODEM_LENGTH)
+ if (xyz.mode == xyzModem_xmodem || xyz.file_length == 0) {
+#else
+ if (1) {
+#endif
+ // Data blocks can be padded with ^Z (EOF) characters
+ // This code tries to detect and remove them
+ if ((xyz.bufp[xyz.len-1] == EOF) &&
+ (xyz.bufp[xyz.len-2] == EOF) &&
+ (xyz.bufp[xyz.len-3] == EOF)) {
+ while (xyz.len && (xyz.bufp[xyz.len-1] == EOF)) {
+ xyz.len--;
+ }
+ }
+ }
+
+#ifdef USE_YMODEM_LENGTH
+ // See if accumulated length exceeds that of the file.
+ // If so, reduce size (i.e., cut out pad bytes)
+ // Only do this for Y-modem (and Z-modem should it ever
+ // be supported since it can fall back to Y-modem mode).
+ if (xyz.mode != xyzModem_xmodem && 0 != xyz.file_length) {
+ xyz.read_length += xyz.len;
+ if (xyz.read_length > xyz.file_length) {
+ xyz.len -= (xyz.read_length - xyz.file_length);
+ }
+ }
+#endif
+ break;
+ } else if (xyz.blk == ((xyz.next_blk - 1) & 0xFF)) {
+ // Just re-ACK this so sender will get on with it
+ CYGACC_COMM_IF_PUTC(*xyz.__chan, ACK);
+ continue; // Need new header
+ } else {
+ stat = xyzModem_sequence;
+ }
+ }
+ if (stat == xyzModem_cancel) {
+ break;
+ }
+ if (stat == xyzModem_eof) {
+ CYGACC_COMM_IF_PUTC(*xyz.__chan, ACK);
+ ZM_DEBUG(zm_dprintf("ACK (%d)\n", __LINE__));
+ if (xyz.mode == xyzModem_ymodem) {
+ CYGACC_COMM_IF_PUTC(*xyz.__chan, (xyz.crc_mode ? 'C' : NAK));
+ xyz.total_retries++;
+ ZM_DEBUG(zm_dprintf("Reading Final Header\n"));
+ stat = xyzModem_get_hdr();
+ CYGACC_COMM_IF_PUTC(*xyz.__chan, ACK);
+ ZM_DEBUG(zm_dprintf("FINAL ACK (%d)\n", __LINE__));
+ }
+ xyz.at_eof = true;
+ break;
+ }
+ CYGACC_COMM_IF_PUTC(*xyz.__chan, (xyz.crc_mode ? 'C' : NAK));
+ xyz.total_retries++;
+ ZM_DEBUG(zm_dprintf("NAK (%d)\n", __LINE__));
+ }
+ if (stat < 0) {
+ *err = stat;
+ xyz.len = -1;
+ return total;
+ }
+ }
+ // Don't "read" data from the EOF protocol package
+ if (!xyz.at_eof) {
+ len = xyz.len;
+ if (size < len) len = size;
+ memcpy(buf, xyz.bufp, len);
+ size -= len;
+ buf += len;
+ total += len;
+ xyz.len -= len;
+ xyz.bufp += len;
+ }
+ }
+ return total;
+}
+
+void
+xyzModem_stream_close(int *err)
+{
+ diag_printf("xyzModem - %s mode, %d(SOH)/%d(STX)/%d(CAN) packets, %d retries\n",
+ xyz.crc_mode ? "CRC" : "Cksum",
+ xyz.total_SOH, xyz.total_STX, xyz.total_CAN,
+ xyz.total_retries);
+// ZM_DEBUG(zm_flush());
+}
+
+// Need to be able to clean out the input buffer, so have to take the
+// getc
+void xyzModem_stream_terminate(bool abort, int (*getc)(void))
+{
+ int c;
+
+ if (abort) {
+ ZM_DEBUG(zm_dprintf("!!!! TRANSFER ABORT !!!!\n"));
+ switch (xyz.mode) {
+ case xyzModem_xmodem:
+ case xyzModem_ymodem:
+ // The X/YMODEM Spec seems to suggest that multiple CAN followed by an equal
+ // number of Backspaces is a friendly way to get the other end to abort.
+ CYGACC_COMM_IF_PUTC(*xyz.__chan,CAN);
+ CYGACC_COMM_IF_PUTC(*xyz.__chan,CAN);
+ CYGACC_COMM_IF_PUTC(*xyz.__chan,CAN);
+ CYGACC_COMM_IF_PUTC(*xyz.__chan,CAN);
+ CYGACC_COMM_IF_PUTC(*xyz.__chan,BSP);
+ CYGACC_COMM_IF_PUTC(*xyz.__chan,BSP);
+ CYGACC_COMM_IF_PUTC(*xyz.__chan,BSP);
+ CYGACC_COMM_IF_PUTC(*xyz.__chan,BSP);
+ // Now consume the rest of what's waiting on the line.
+ ZM_DEBUG(zm_dprintf("Flushing serial line.\n"));
+ xyzModem_flush();
+ xyz.at_eof = true;
+ break;
+#ifdef xyzModem_zmodem
+ case xyzModem_zmodem:
+ // Might support it some day I suppose.
+#endif
+ break;
+ }
+ } else {
+ ZM_DEBUG(zm_dprintf("Engaging cleanup mode...\n"));
+ // Consume any trailing crap left in the inbuffer from
+ // previous recieved blocks. Since very few files are an exact multiple
+ // of the transfer block size, there will almost always be some gunk here.
+ // If we don't eat it now, RedBoot will think the user typed it.
+ ZM_DEBUG(zm_dprintf("Trailing gunk:\n"));
+ while ((c = (*getc)()) > -1) ;
+ ZM_DEBUG(zm_dprintf("\n"));
+ // Make a small delay to give terminal programs like minicom
+ // time to get control again after their file transfer program
+ // exits.
+ CYGACC_CALL_IF_DELAY_US((cyg_int32)250000);
+ }
+}
+
+char *
+xyzModem_error(int err)
+{
+ switch (err) {
+ case xyzModem_access:
+ return "Can't access file";
+ break;
+ case xyzModem_noZmodem:
+ return "Sorry, zModem not available yet";
+ break;
+ case xyzModem_timeout:
+ return "Timed out";
+ break;
+ case xyzModem_eof:
+ return "End of file";
+ break;
+ case xyzModem_cancel:
+ return "Cancelled";
+ break;
+ case xyzModem_frame:
+ return "Invalid framing";
+ break;
+ case xyzModem_cksum:
+ return "CRC/checksum error";
+ break;
+ case xyzModem_sequence:
+ return "Block sequence error";
+ break;
+ default:
+ return "Unknown error";
+ break;
+ }
+}
+
+//
+// RedBoot interface
+//
+GETC_IO_FUNCS(xyzModem_io, xyzModem_stream_open, xyzModem_stream_close,
+ xyzModem_stream_terminate, xyzModem_stream_read, xyzModem_error);
+RedBoot_load(xmodem, xyzModem_io, false, false, xyzModem_xmodem);
+RedBoot_load(ymodem, xyzModem_io, false, false, xyzModem_ymodem);
diff --git a/ecos/packages/redboot/current/src/xyzModem.h b/ecos/packages/redboot/current/src/xyzModem.h
new file mode 100644
index 0000000..02a49c0
--- /dev/null
+++ b/ecos/packages/redboot/current/src/xyzModem.h
@@ -0,0 +1,82 @@
+//==========================================================================
+//
+// xyzModem.h
+//
+// RedBoot stream handler for xyzModem protocol
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//
+// eCos 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 or (at your option) any later
+// version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-07-14
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#ifndef _XYZMODEM_H_
+#define _XYZMODEM_H_
+
+#define xyzModem_xmodem 1
+#define xyzModem_ymodem 2
+// Don't define this until the protocol support is in place
+//#define xyzModem_zmodem 3
+
+#define xyzModem_access -1
+#define xyzModem_noZmodem -2
+#define xyzModem_timeout -3
+#define xyzModem_eof -4
+#define xyzModem_cancel -5
+#define xyzModem_frame -6
+#define xyzModem_cksum -7
+#define xyzModem_sequence -8
+
+#define xyzModem_close 1
+#define xyzModem_abort 2
+
+int xyzModem_stream_open(connection_info_t *info, int *err);
+void xyzModem_stream_close(int *err);
+void xyzModem_stream_terminate(int method, int (*getc)(void));
+int xyzModem_stream_read(char *buf, int size, int *err);
+char *xyzModem_error(int err);
+
+extern getc_io_funcs_t xyzModem_io;
+
+#endif // _XYZMODEM_H_