changeset 2614:6cbecf3cc2e4

* 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. * 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. * 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. * include/net/net.h: Include redboot.h for tick functions. * 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.
author jlarmour
date Tue, 11 Nov 2008 04:32:10 +0000
parents e19a7a6154d0
children 7dad438fcaea
files packages/redboot/current/ChangeLog packages/redboot/current/include/fis.h packages/redboot/current/include/flash_config.h packages/redboot/current/include/net/net.h packages/redboot/current/include/redboot.h packages/redboot/current/src/fconfig.c packages/redboot/current/src/fs/e2fs.c packages/redboot/current/src/io.c packages/redboot/current/src/load.c packages/redboot/current/src/main.c packages/redboot/current/src/net/net_io.c packages/redboot/current/src/parse.c packages/redboot/current/src/xyzModem.c
diffstat 13 files changed, 148 insertions(+), 78 deletions(-) [+]
line wrap: on
line diff
--- a/packages/redboot/current/ChangeLog
+++ b/packages/redboot/current/ChangeLog
@@ -1,3 +1,27 @@
+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-08-28  Gary Thomas  <gary@mlbassoc.com>
 
 	* src/flash.c (do_flash_init): Memory allocation was slightly
@@ -192,6 +216,28 @@ 2005-08-17  David Vrabel  <dvrabel@arcom
 	* 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
--- a/packages/redboot/current/include/fis.h
+++ b/packages/redboot/current/include/fis.h
@@ -87,7 +87,7 @@ struct fis_valid_info
 struct fis_image_desc {
     union
     {
-    unsigned char name[16];      // Null terminated name
+        char name[16];      // Null terminated name
         #ifdef CYGOPT_REDBOOT_REDUNDANT_FIS
            struct fis_valid_info valid_info;
         #endif
--- a/packages/redboot/current/include/flash_config.h
+++ b/packages/redboot/current/include/flash_config.h
@@ -9,6 +9,7 @@
 // -------------------------------------------
 // This file is part of eCos, the Embedded Configurable Operating System.
 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
+// Copyright (C) 2008 eCosCentric Limited.
 //
 // 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
@@ -102,7 +103,7 @@ bool flash_add_config(struct config_opti
 struct _config {
     unsigned long len;
     unsigned long key1;
-    unsigned char config_data[MAX_CONFIG_DATA-(4*4)];
+    char config_data[MAX_CONFIG_DATA-(4*4)];
     unsigned long key2;
     unsigned long cksum;
 };
--- a/packages/redboot/current/include/net/net.h
+++ b/packages/redboot/current/include/net/net.h
@@ -10,6 +10,7 @@
 // This file is part of eCos, the Embedded Configurable Operating System.
 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
 // Copyright (C) 2002, 2003 Gary Thomas
+// Copyright (C) 2004, 2005 eCosCentric Limited
 //
 // 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
@@ -71,11 +72,6 @@ extern int cyg_io_eth_net_debug;
 # endif
 #endif
 
-extern unsigned long do_ms_tick(void);
-extern unsigned long get_ms_ticks(void);
-#define MS_TICKS() get_ms_ticks()
-#define MS_TICKS_DELAY() do_ms_tick()
-
 /* #define NET_SUPPORT_RARP  1 */
 #define NET_SUPPORT_ICMP 1
 #define NET_SUPPORT_UDP  1
@@ -645,4 +641,7 @@ extern int net_devindex(char *name);
 #define BSPLOG(x)
 #endif
 
+// Need tick functions
+#include <redboot.h>
+
 #endif // _NET_H_
--- a/packages/redboot/current/include/redboot.h
+++ b/packages/redboot/current/include/redboot.h
@@ -115,7 +115,7 @@ EXTERN bool net_debug;
 #endif
 
 #ifdef CYGFUN_REDBOOT_BOOT_SCRIPT
-EXTERN unsigned char *script;
+EXTERN char *script;
 EXTERN int script_timeout;
 #ifdef CYGSEM_REDBOOT_VARIABLE_BAUD_RATE
 EXTERN int console_baud_rate;
@@ -135,8 +135,8 @@ 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(char c);
-externC bool mon_read_char_with_timeout(char *c);
+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, ...);
@@ -160,6 +160,14 @@ externC bool _rb_break(int timeout);
 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);
@@ -318,7 +326,7 @@ externC bool scan_opts(int argc, char *a
 
 externC int redboot_exec( char *command, ... );
 
-externC void err_printf( char *fmt, ... );
+externC void err_printf( const char *fmt, ... );
 
 #ifdef CYGNUM_HAL_VIRTUAL_VECTOR_AUX_CHANNELS
 #define CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS \
--- a/packages/redboot/current/src/fconfig.c
+++ b/packages/redboot/current/src/fconfig.c
@@ -10,6 +10,7 @@
 // This file is part of eCos, the Embedded Configurable Operating System.
 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
 // Copyright (C) 2003 Gary Thomas
+// Copyright (C) 2005, 2008 eCosCentric Ltd.
 //
 // 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
@@ -106,7 +107,7 @@ int   cfg_size;   // Length of config da
 #endif // FLASH MEDIA
 
 // Prototypes for local functions
-static unsigned char *flash_lookup_config(char *key);
+static char *flash_lookup_config(char *key);
 
 static bool config_ok;
 
@@ -201,7 +202,7 @@ conf_endian_fixup(void *ptr)
 {
 #ifdef REDBOOT_FLASH_REVERSE_BYTEORDER
     struct _config *p = (struct _config *)ptr;
-    unsigned char *dp = p->config_data;
+    char *dp = p->config_data;
     void *val_ptr;
     int len;
     cyg_uint16 u16;
@@ -249,7 +250,7 @@ conf_endian_fixup(void *ptr)
 }
 
 static int
-get_config(unsigned char *dp, char *title, int list_opt, char *newvalue )
+get_config(char *dp, char *title, int list_opt, char *newvalue )
 {
     char line[256], hold_line[256], *sp, *lp;
     int ret;
@@ -317,7 +318,7 @@ get_config(unsigned char *dp, char *titl
         break;
     case CONFIG_SCRIPT:
         diag_printf("\n");
-        sp = lp = (unsigned char *)val_ptr;
+        sp = lp = (char *)val_ptr;
         while (*sp) {
             while (*lp != '\n') lp++;
             *lp = '\0';
@@ -432,7 +433,7 @@ get_config(unsigned char *dp, char *titl
 #endif
     case CONFIG_SCRIPT:
         // Assume it always changes
-        sp = (unsigned char *)val_ptr;
+        sp = (char *)val_ptr;
 	script_len = 0;
         diag_printf("Enter script, terminate with empty line\n");
         while (true) {
@@ -459,7 +460,7 @@ get_config(unsigned char *dp, char *titl
             diag_printf("Sorry, value is too long\n");
             return CONFIG_BAD;
         }
-        strcpy((unsigned char *)val_ptr, line);
+        strcpy((char *)val_ptr, line);
         break;
     }
     return CONFIG_CHANGED;
@@ -517,7 +518,7 @@ do_flash_config(int argc, char *argv[])
     bool fullnames;
     bool dumbterminal;
     int list_opt = 0;
-    unsigned char *dp;
+    char *dp;
     int len, ret;
     char *title;
     char *onlyone = NULL;
@@ -532,7 +533,7 @@ do_flash_config(int argc, char *argv[])
     }
 #endif
     memcpy(backup_config, config, sizeof(struct _config));
-    script = (unsigned char *)0;
+    script = NULL;
 
     init_opts(&opts[0], 'l', false, OPTION_ARG_TYPE_FLG, 
               (void *)&list_only, (bool *)0, "list configuration only");
@@ -696,7 +697,7 @@ flash_lookup_alias(char *alias, char *al
 {
     char name[80];
     char *val;
-    unsigned char * dp;
+    char * dp;
     void *val_ptr;
     int type;
     bool hold_bool_val;
@@ -774,9 +775,13 @@ flash_crc(struct _config *conf)
 void
 flash_write_config(bool prompt)
 {
-#if defined(CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA_FLASH)
+#if defined(CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA_FLASH) && !defined(CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG)
+# ifdef CYG_FLASH_ERR_OK // crude temporary hack to see if we're being used with flashv2
+    cyg_flashaddr_t err_addr;
+# else
+    void *err_addr;
+# endif
 #if !defined(CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG)
-    void *err_addr;
     int stat;
 #endif
 #endif
@@ -819,13 +824,13 @@ flash_write_config(bool prompt)
 //
 // Find the configuration entry for a particular key
 //
-static unsigned char *
+static char *
 flash_lookup_config(char *key)
 {
-    unsigned char *dp;
+    char *dp;
     int len;
 
-    if (!config_ok) return (unsigned char *)NULL;
+    if (!config_ok) return NULL;
 
     dp = &config->config_data[0];
     while (dp < &config->config_data[sizeof(config->config_data)]) {
@@ -837,7 +842,7 @@ flash_lookup_config(char *key)
         dp += len;
     }
 //    diag_printf("Can't find config data for '%s'\n", key);
-    return false;
+    return NULL;
 }
 
 //
@@ -846,7 +851,7 @@ flash_lookup_config(char *key)
 bool
 flash_next_key(char *key, int keylen, int *type, int *offset)
 {
-    unsigned char *dp;
+    char *dp;
     int len;
 
     if (!config_ok) return false;
@@ -867,7 +872,7 @@ flash_next_key(char *key, int keylen, in
 bool
 flash_get_config(char *key, void *val, int type)
 {
-    unsigned char *dp;
+    char *dp;
     void *val_ptr;
 #ifdef CYGSEM_REDBOOT_FLASH_CONFIG_READONLY_FALLBACK
     struct _config *save_config = 0;
@@ -876,7 +881,7 @@ flash_get_config(char *key, void *val, i
 
     if (!config_ok) return false;
 
-    if ((dp = flash_lookup_config(key)) != (unsigned char *)NULL) {
+    if ((dp = flash_lookup_config(key)) != NULL) {
         if (CONFIG_OBJECT_TYPE(dp) == type) {
             val_ptr = (void *)CONFIG_OBJECT_VALUE(dp);
             switch (type) {
@@ -941,12 +946,12 @@ flash_get_config(char *key, void *val, i
 bool
 flash_set_config(char *key, void *val, int type)
 {
-    unsigned char *dp;
+    char *dp;
     void *val_ptr;
 
     if (!config_ok) return false;
 
-    if ((dp = flash_lookup_config(key)) != (unsigned char *)NULL) {
+    if ((dp = flash_lookup_config(key)) != NULL) {
         if (CONFIG_OBJECT_TYPE(dp) == type) {
             val_ptr = (void *)CONFIG_OBJECT_VALUE(dp);
             switch (type) {
@@ -987,7 +992,7 @@ flash_set_config(char *key, void *val, i
 // Copy data into the config area
 //
 static void
-flash_config_insert_value(unsigned char *dp, struct config_option *opt)
+flash_config_insert_value(char *dp, struct config_option *opt)
 {
     switch (opt->type) {
         // Note: the data may be unaligned in the configuration data
@@ -1034,12 +1039,12 @@ flash_config_insert_value(unsigned char 
 bool
 flash_add_config(struct config_option *opt, bool update)
 {
-    unsigned char *dp, *kp;
+    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)) != (unsigned char *)NULL) {
+    if ((dp = flash_lookup_config(opt->key)) != NULL) {
         flash_config_insert_value(CONFIG_OBJECT_VALUE(dp), opt);
         if (update) {
             flash_write_config(true);
@@ -1126,7 +1131,7 @@ load_flash_config(void)
 #endif
 
     config_ok = false;
-    script = (unsigned char *)0;
+    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
--- a/packages/redboot/current/src/fs/e2fs.c
+++ b/packages/redboot/current/src/fs/e2fs.c
@@ -10,6 +10,7 @@
 // This file is part of eCos, the Embedded Configurable Operating System.
 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
 // Copyright (C) 2003 Gary Thomas <gary@mind.be>
+// Copyright (C) 2008 eCosCentric Limited.
 //
 // 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
@@ -160,13 +161,16 @@ static int
 e2fs_mount(partition_t *part, e2fs_desc_t *e2fs)
 {
     int sb_block = 1;
-    cyg_uint32  sb_buf[E2FS_MIN_BLOCK_SIZE/sizeof(cyg_uint32)];
-    struct e2fs_super_block *sb = (struct e2fs_super_block *)sb_buf;
+    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),
-			(cyg_uint32 *)sb, 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) {
--- a/packages/redboot/current/src/io.c
+++ b/packages/redboot/current/src/io.c
@@ -10,6 +10,7 @@
 // This file is part of eCos, the Embedded Configurable Operating System.
 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
 // Copyright (C) 2002, 2003, 2005 Gary Thomas
+// Copyright (C) 2004, 2008 eCosCentric Limited
 //
 // 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
@@ -119,7 +120,7 @@ do_channel(int argc, char *argv[])
 }
 
 void 
-mon_write_char(char c)
+mon_write_char(unsigned char c)
 {
     hal_virtual_comm_table_t *__chan;
 
@@ -148,7 +149,7 @@ mon_write_char(char c)
 }
 
 static void 
-mon_read_char(char *c)
+mon_read_char(unsigned char *c)
 {
     hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
     
@@ -165,7 +166,7 @@ static int _mon_timeout;
 #endif
 
 bool
-mon_read_char_with_timeout(char *c)
+mon_read_char_with_timeout(unsigned char *c)
 {
     bool res = false;
     hal_virtual_comm_table_t *__chan;
@@ -253,10 +254,10 @@ mon_set_read_char_timeout(int ms)
 bool
 _rb_break(int timeout)
 {
-    char c;
+    unsigned char c;
     mon_set_read_char_timeout(timeout);
     if (mon_read_char_with_timeout(&c)) {
-        if (c == 0x03) {  // Test for ^C
+        if (c == '\x03') {  // Test for ^C
             return true;
         }
     }
@@ -402,7 +403,7 @@ int
 #define CTRL(c) ((c)&0x1F)
 #ifdef CYGSEM_REDBOOT_CMD_LINE_ANSI_SEQUENCES
         // Special handling of ANSI keyboard sequences (arrows, etc)
-        if (c == 0x1B) {
+        if (c == '\x1B') {
             // Leadin for ANSI keyboard sequence
             ansi_state = 1;
             continue;
@@ -693,7 +694,7 @@ int
             }
 #endif
             if (console_echo) {
-                mon_write_char(c);
+                mon_write_char((unsigned char)c);
             }
             if (ip == eol) {
                 // Advance both pointers
--- a/packages/redboot/current/src/load.c
+++ b/packages/redboot/current/src/load.c
@@ -116,8 +116,8 @@ extern struct load_io_entry __RedBoot_LO
 struct {
     getc_io_funcs_t *io;
     int (*fun)(char *, int len, int *err);
-    unsigned char  buf[BUF_SIZE];
-    unsigned char *bufp;
+    char  buf[BUF_SIZE];
+    char *bufp;
     int   avail, len, err;
     int   verbose, decompress, tick;
 #ifdef CYGBLD_BUILD_REDBOOT_WITH_ZLIB
@@ -165,7 +165,7 @@ redboot_getc(void)
         }
     }
     getc_info.avail--;
-    return *getc_info.bufp++;
+    return ((int)*getc_info.bufp++) & 0x00FF;
 }
 
 #ifdef CYGBLD_BUILD_REDBOOT_WITH_ZLIB
@@ -310,7 +310,7 @@ load_elf_image(getc_t getc, unsigned lon
     unsigned long addr_offset = 0;
     unsigned long highest_address = 0;
     unsigned long lowest_address = 0xFFFFFFFF;
-    unsigned char *SHORT_DATA = "Short data reading ELF file\n";
+    const char SHORT_DATA[] = "Short data reading ELF file\n";
 
     // Read the header
     if (_read(getc, (unsigned char *)&ehdr, sizeof(ehdr)) != sizeof(ehdr)) {
--- a/packages/redboot/current/src/main.c
+++ b/packages/redboot/current/src/main.c
@@ -283,10 +283,10 @@ cyg_start(void)
 #endif
 #ifdef CYGMEM_SECTION_heap1
     workspace_start = (unsigned char *)CYGMEM_SECTION_heap1;
-    workspace_end = (unsigned char *)(CYGMEM_SECTION_heap1+CYGMEM_SECTION_heap1_SIZE);
+    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);
+    workspace_end = (unsigned char *)CYGMEM_REGION_ram+CYGMEM_REGION_ram_SIZE;
 #endif
 
     if ( ram_end < workspace_end ) {
@@ -337,11 +337,11 @@ cyg_start(void)
 # endif
     if (script) {
         // Give the guy a chance to abort any boot script
-        unsigned char *hold_script = 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 = (unsigned char *)0;
+        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);
@@ -354,7 +354,7 @@ cyg_start(void)
             script_timeout_ms -= CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT;
         }
         if (res == _GETS_CTRLC) {
-            script = (unsigned char *)0;  // Disable script
+            script = NULL;  // Disable script
         } else {
             script = hold_script;  // Re-enable script
         }
@@ -382,6 +382,8 @@ cyg_start(void)
 		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
@@ -393,12 +395,13 @@ cyg_start(void)
     
                 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((CYG_ADDRWORD)workspace_end,
+                HAL_THREAD_INIT_CONTEXT(gdb_stack_sp,
                                         breakpoint, trampoline,0);
 
                 // switch context to trampoline (get GDB stubs started)
-                HAL_THREAD_SWITCH_CONTEXT(&saved_context, &workspace_end);
+                HAL_THREAD_SWITCH_CONTEXT(&saved_context, &gdb_stack_sp);
 
                 gdb_active = false;
 
@@ -527,6 +530,7 @@ do_go(int argc, char *argv[])
     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
@@ -556,8 +560,8 @@ do_go(int argc, char *argv[])
     if (wait_time_set) {
         int script_timeout_ms = wait_time * 1000;
 #ifdef CYGSEM_REDBOOT_FLASH_CONFIG
-        unsigned char *hold_script = script;
-        script = (unsigned char *)0;
+        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);
@@ -599,12 +603,12 @@ do_go(int argc, char *argv[])
     }
     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((CYG_ADDRWORD)workspace_end, 
-                            entry, trampoline, 0);
+    HAL_THREAD_INIT_CONTEXT(trampoline_stack_sp, entry, trampoline, 0);
 
     // switch context to trampoline
-    HAL_THREAD_SWITCH_CONTEXT(&saved_context, &workspace_end);
+    HAL_THREAD_SWITCH_CONTEXT(&saved_context, &trampoline_stack_sp);
 
     // we get back here by way of return_to_redboot()
 
@@ -762,3 +766,5 @@ valid_address(unsigned char *addr)
     }
     return false;
 }
+
+/* EOF main.c */
--- a/packages/redboot/current/src/net/net_io.c
+++ b/packages/redboot/current/src/net/net_io.c
@@ -10,6 +10,7 @@
 // This file is part of eCos, the Embedded Configurable Operating System.
 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
 // Copyright (C) 2002, 2003, 2004 Gary Thomas
+// Copyright (C) 2004,2005 eCosCentric Limited
 //
 // 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
@@ -887,12 +888,11 @@ do_ip_addr(int argc, char *argv[])
         char *slash_pos;
         /* see if the (optional) mask length was given */
         if( (slash_pos = strchr(ip_addr, '/')) ) {
-            int mask_len;
-            unsigned long mask;
+            unsigned long mask, mask_len;
             *slash_pos = '\0';
             slash_pos++;
-            if( !parse_num(slash_pos, (unsigned long *)&mask_len, 0, 0) ||  
-                mask_len <= 0 || mask_len > 32 ) {
+            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;
             }
--- a/packages/redboot/current/src/parse.c
+++ b/packages/redboot/current/src/parse.c
@@ -261,7 +261,7 @@ int redboot_exec( char *command, ... )
     return result;
 }
 
-externC void err_printf( char *fmt, ... )
+externC void err_printf( const char *fmt, ... )
 {
     va_list ap;
     
--- a/packages/redboot/current/src/xyzModem.c
+++ b/packages/redboot/current/src/xyzModem.c
@@ -59,14 +59,14 @@
 // Assumption - run xyzModem protocol over the console port
 
 // Values magic to the protocol
-#define SOH 0x01
-#define STX 0x02
-#define EOT 0x04
-#define ACK 0x06
-#define BSP 0x08
-#define NAK 0x15
-#define CAN 0x18
-#define EOF 0x1A  // ^Z for DOS officionados
+#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
 
@@ -180,7 +180,7 @@ static void
 xyzModem_flush(void)
 {
     int res;
-    char c;
+    unsigned char c;
     while (true) {
         res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &c);
         if (!res) return;
@@ -190,7 +190,7 @@ xyzModem_flush(void)
 static int
 xyzModem_get_hdr(void)
 {
-    char c;
+    unsigned char c;
     int res;
     bool hdr_found = false;
     int i, can_total, hdr_chars;
@@ -288,7 +288,7 @@ xyzModem_get_hdr(void)
     }
     ZM_DEBUG(zm_dump(__LINE__));
     // Validate the message
-    if ((xyz.blk ^ xyz.cblk) != (unsigned char)0xFF) {
+    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();
@@ -372,7 +372,7 @@ xyzModem_stream_open(connection_info_t *
                 // skip filename
                 while (*xyz.bufp++);
                 // get the length
-                parse_num(xyz.bufp, &xyz.file_length, NULL, " ");
+                parse_num((char*)xyz.bufp, &xyz.file_length, NULL, " ");
 #endif
                 // The rest of the file name data block quietly discarded
                 xyz.tx_ack = true;