This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

support reverse endianess of fis and fconfig info


This is handy for platforms which are bi-endian. It allows the
same fis and fconfig info to be used regardless of runtime
endianess.

I also added a mechanism for HALs to intercept the flash_read
and flash_program operations in RedBoot. This was needed for
a platform that had to do some extra endianess processing due
to the way the flash bus is wired.

--Mark

Index: redboot/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/ChangeLog,v
retrieving revision 1.203
diff -u -p -5 -r1.203 ChangeLog
--- redboot/current/ChangeLog	31 Aug 2004 19:44:14 -0000	1.203
+++ redboot/current/ChangeLog	1 Sep 2004 21:17:34 -0000
@@ -1,5 +1,16 @@
+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.
 
Index: redboot/current/cdl/redboot.cdl
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/cdl/redboot.cdl,v
retrieving revision 1.65
diff -u -p -5 -r1.65 redboot.cdl
--- redboot/current/cdl/redboot.cdl	21 Aug 2004 12:43:32 -0000	1.65
+++ redboot/current/cdl/redboot.cdl	1 Sep 2004 21:17:34 -0000
@@ -572,10 +572,20 @@ cdl_package CYGPKG_REDBOOT {
               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 "
Index: redboot/current/include/redboot.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/include/redboot.h,v
retrieving revision 1.33
diff -u -p -5 -r1.33 redboot.h
--- redboot/current/include/redboot.h	31 May 2004 07:55:28 -0000	1.33
+++ redboot/current/include/redboot.h	1 Sep 2004 21:17:34 -0000
@@ -6,11 +6,11 @@
 //
 //==========================================================================
 //####ECOSGPLCOPYRIGHTBEGIN####
 // -------------------------------------------
 // This file is part of eCos, the Embedded Configurable Operating System.
-// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Red Hat, Inc.
 // Copyright (C) 2002, 2003, 2004 Gary Thomas
 //
 // 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.
@@ -58,10 +58,11 @@
 
 #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
@@ -479,6 +480,29 @@ isalnum(int c)
 #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_
Index: redboot/current/src/fconfig.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/fconfig.c,v
retrieving revision 1.9
diff -u -p -5 -r1.9 fconfig.c
--- redboot/current/src/fconfig.c	24 Feb 2004 14:15:15 -0000	1.9
+++ redboot/current/src/fconfig.c	1 Sep 2004 21:17:34 -0000
@@ -6,11 +6,11 @@
 //
 //==========================================================================
 //####ECOSGPLCOPYRIGHTBEGIN####
 // -------------------------------------------
 // This file is part of eCos, the Embedded Configurable Operating System.
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
 // Copyright (C) 2003 Gary Thomas
 //
 // 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.
@@ -52,16 +52,18 @@
 //####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);
@@ -189,10 +191,64 @@ extern struct config_option __CONFIG_opt
 #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;
+    unsigned 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(unsigned char *dp, char *title, int list_opt, char *newvalue )
 {
     char line[256], hold_line[256], *sp, *lp;
@@ -681,10 +737,32 @@ flash_lookup_alias(char *alias, char *al
     }
 }
 
 #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)
@@ -697,29 +775,30 @@ flash_write_config(bool prompt)
 #endif
 
     config->len = sizeof(struct _config);
     config->key1 = CONFIG_KEY1;  
     config->key2 = CONFIG_KEY2;
-    config->cksum = cyg_crc32((unsigned char *)config, sizeof(struct _config)-sizeof(config->cksum));
+    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
-        flash_read(fis_addr, fis_work_block, fisdir_size, (void **)&err_addr);
+        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
         flash_unlock((void *)cfg_base, cfg_size, (void **)&err_addr);
 #endif
         if ((stat = flash_erase(cfg_base, cfg_size, (void **)&err_addr)) != 0) {
             diag_printf("   initialization failed at %p: %s\n", err_addr, flash_errmsg(stat));
         } else {
-            if ((stat = flash_program(cfg_base, (void *)config, sizeof(struct _config), 
-                                      (void **)&err_addr)) != 0) {
+            conf_endian_fixup(config);
+            if ((stat = FLASH_PROGRAM(cfg_base, config, sizeof(struct _config), (void **)&err_addr)) != 0) {
                 diag_printf("Error writing config data at %p: %s\n", 
                             err_addr, flash_errmsg(stat));
             }
+            conf_endian_fixup(config);
         }
 #ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL
         // Insure [quietly] that the config data is locked after the update
         flash_lock((void *)cfg_base, cfg_size, (void **)&err_addr);
 #endif
@@ -826,17 +905,15 @@ flash_get_config(char *key, void *val, i
 #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) && ((cyg_crc32((unsigned char *)config, 
-               sizeof(struct _config)-sizeof(config->cksum)) != config->cksum) ||
+    if ( (config != readonly_config) && ((flash_crc(config) != config->cksum) ||
         (config->key1 != CONFIG_KEY1)|| (config->key2 != CONFIG_KEY2))) {
         save_config = config;
         config = readonly_config;
-        if ((cyg_crc32((unsigned char *)config, 
-                       sizeof(struct _config)-sizeof(config->cksum)) != config->cksum) ||
+        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;
         }
@@ -1074,19 +1151,19 @@ load_flash_config(void)
     } else {
         cfg_base = (void *)((CYG_ADDRESS)flash_start + 
            _rup(_rup((CYGNUM_REDBOOT_FLASH_CONFIG_BLOCK*flash_block_size), cfg_size), flash_block_size));
     }
 #endif
-    flash_read((void *)cfg_base, (void *)config, sizeof(struct _config), (void **)&err_addr);
+    FLASH_READ(cfg_base, 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 ((cyg_crc32((unsigned char *)config, 
-                   sizeof(struct _config)-sizeof(config->cksum)) != config->cksum) ||
+    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;
Index: redboot/current/src/flash.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/flash.c,v
retrieving revision 1.68
diff -u -p -5 -r1.68 flash.c
--- redboot/current/src/flash.c	31 Aug 2004 19:44:14 -0000	1.68
+++ redboot/current/src/flash.c	1 Sep 2004 21:17:34 -0000
@@ -6,11 +6,11 @@
 //
 //==========================================================================
 //####ECOSGPLCOPYRIGHTBEGIN####
 // -------------------------------------------
 // This file is part of eCos, the Embedded Configurable Operating System.
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
 // Copyright (C) 2003, 2004 Gary Thomas
 //
 // 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.
@@ -59,10 +59,11 @@
 #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)
 
@@ -189,18 +190,49 @@ _show_invalid_flash_address(CYG_ADDRESS 
     diag_printf("Invalid FLASH address %p: %s\n", (void *)flash_addr, flash_errmsg(stat));
     diag_printf("   valid range is %p-%p\n", (void *)flash_start, (void *)flash_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)
+{
+    void *err_addr;
+
+    FLASH_READ(fis_addr, fis_work_block, fisdir_size, (void **)&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;
-    void *err_addr;
 
-    flash_read(fis_addr, fis_work_block, fisdir_size, (void **)&err_addr);
+    fis_read_directory();
+
     img = (struct fis_image_desc *)fis_work_block;
     for (i = 0;  i < fisdir_size/sizeof(*img);  i++, img++) {
         if ((img->name[0] != (unsigned char)0xFF) && 
             (strcasecmp(name, img->name) == 0)) {
             if (num) *num = i;
@@ -214,30 +246,33 @@ void
 fis_update_directory(void)
 {
     int stat;
     void *err_addr;
 
+    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);
 #endif
 #ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL
     // Ensure [quietly] that the directory is unlocked before trying to update
     flash_unlock((void *)fis_addr, flash_block_size, (void **)&err_addr);
 #endif
     if ((stat = flash_erase(fis_addr, flash_block_size, (void **)&err_addr)) != 0) {
         diag_printf("Error erasing FIS directory at %p: %s\n", err_addr, flash_errmsg(stat));
     } else {
-        if ((stat = flash_program(fis_addr, fis_work_block, flash_block_size,
-                                  (void **)&err_addr)) != 0) {
+        if ((stat = FLASH_PROGRAM(fis_addr, fis_work_block,
+                                  flash_block_size, (void **)&err_addr)) != 0) {
             diag_printf("Error writing FIS directory at %p: %s\n", 
                         err_addr, flash_errmsg(stat));
         }
     }
 #ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL
     // Ensure [quietly] that the directory is locked after the update
     flash_lock((void *)fis_addr, flash_block_size, (void **)&err_addr);
 #endif
+    fis_endian_fixup(fis_work_block);
 }
 
 static void
 fis_init(int argc, char *argv[])
 {
@@ -448,11 +483,10 @@ 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];
-    void *err_addr;
     unsigned long last_addr, lowest_addr;
     bool image_found;
 
 #ifdef CYGHWR_REDBOOT_ARM_FLASH_SIB
     // FIXME: this is somewhat half-baked
@@ -471,11 +505,12 @@ fis_list(int argc, char *argv[])
     i = 1;
 #endif
     if (!scan_opts(argc, argv, 2, opts, i, 0, 0, "")) {
         return;
     }
-    flash_read(fis_addr, fis_work_block, fisdir_size, (void **)&err_addr);
+    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",
@@ -521,11 +556,10 @@ struct free_chunk {
 
 static int
 find_free(struct free_chunk *chunks)
 {
     CYG_ADDRESS *fis_ptr, *fis_end;
-    void *err_addr;
     struct fis_image_desc *img;
     int i, idx;
     int num_chunks = 1;
 
     // Do not search the area reserved for pre-RedBoot systems:
@@ -533,11 +567,11 @@ find_free(struct free_chunk *chunks)
                               CYGNUM_REDBOOT_FLASH_RESERVED_BASE + 
                               CYGBLD_REDBOOT_MIN_IMAGE_SIZE);
     fis_end = (CYG_ADDRESS *)flash_end;
     chunks[num_chunks-1].start = (CYG_ADDRESS)fis_ptr;
     chunks[num_chunks-1].end = (CYG_ADDRESS)fis_end;
-    flash_read(fis_addr, fis_work_block, fisdir_size, (void **)&err_addr);
+    fis_read_directory();
     img = (struct fis_image_desc *) fis_work_block;
     for (i = 0;  i < fisdir_size/sizeof(*img);  i++, img++) {
         if (img->name[0] != (unsigned char)0xFF) {
             // Figure out which chunk this is in and split it
             for (idx = 0;  idx < num_chunks;  idx++) {
@@ -726,11 +760,11 @@ fis_create(int argc, char *argv[])
     {
         fis_usage("invalid arguments");
         return;
     }
 
-    flash_read(fis_addr, fis_work_block, fisdir_size, (void **)&err_addr);
+    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) {
@@ -886,11 +920,11 @@ fis_create(int argc, char *argv[])
                 prog_ok = false;
             }
         }
         if (prog_ok) {
             // Now program it
-            if ((stat = flash_program((void *)flash_addr, (void *)mem_addr, img_size, (void **)&err_addr)) != 0) {
+            if ((stat = FLASH_PROGRAM((void *)flash_addr, (void *)mem_addr, img_size, (void **)&err_addr)) != 0) {
                 diag_printf("Can't program region at %p: %s\n", err_addr, flash_errmsg(stat));
                 prog_ok = false;
             }
         }
     }
@@ -1054,12 +1088,12 @@ fis_load(int argc, char *argv[])
 
         // Set load address/top
         load_address = mem_addr;
         load_address_end = (unsigned long)p->out_buf;
 
-    	// Reload fis directory
-        flash_read(fis_addr, fis_work_block, fisdir_size, (void **)&err_addr);
+        // Reload fis directory
+        fis_read_directory();
     } else // dangling block
 #endif
     {
         flash_read((void *)img->flash_base, (void *)mem_addr, img->data_length, (void **)&err_addr);
 
@@ -1154,11 +1188,11 @@ fis_write(int argc, char *argv[])
             prog_ok = false;
         }
     }
     if (prog_ok) {
         // Now program it
-        if ((stat = flash_program((void *)flash_addr, (void *)mem_addr, length, (void **)&err_addr)) != 0) {
+        if ((stat = FLASH_PROGRAM((void *)flash_addr, (void *)mem_addr, length, (void **)&err_addr)) != 0) {
             diag_printf("Can't program region at %p: %s\n", err_addr, flash_errmsg(stat));
             prog_ok = false;
         }
     }
 }
@@ -1225,11 +1259,11 @@ fis_lock(int argc, char *argv[])
 
     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 **)&name, OPTION_ARG_TYPE_STR, "image name"))
+    if (!scan_opts(argc, argv, 2, opts, 2, &name, OPTION_ARG_TYPE_STR, "image name"))
     {
         fis_usage("invalid arguments");
         return;
     }
 
@@ -1272,11 +1306,11 @@ fis_unlock(int argc, char *argv[])
 
     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 **)&name, OPTION_ARG_TYPE_STR, "image name"))
+    if (!scan_opts(argc, argv, 2, opts, 2, &name, OPTION_ARG_TYPE_STR, "image name"))
     {
         fis_usage("invalid arguments");
         return;
     }
 
@@ -1319,11 +1353,10 @@ _flash_info(void)
 
 bool
 do_flash_init(void)
 {
     int stat;
-    void *err_addr;
 
     if (!__flash_init) {
         __flash_init = 1;
         if ((stat = flash_init(diag_printf)) != 0) {
             diag_printf("FLASH: driver init failed: %s\n", flash_errmsg(stat));
@@ -1355,11 +1388,11 @@ do_flash_init(void)
         }
         if (((CYG_ADDRESS)fis_addr + fisdir_size - 1) > (CYG_ADDRESS)flash_end) {
             diag_printf("FIS directory doesn't fit\n");
             return false;
         }
-        flash_read(fis_addr, fis_work_block, fisdir_size, (void **)&err_addr);
+        fis_read_directory();
 #endif
     }
     return true;
 }
 
Index: redboot/current/src/main.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/main.c,v
retrieving revision 1.59
diff -u -p -5 -r1.59 main.c
--- redboot/current/src/main.c	31 May 2004 07:55:28 -0000	1.59
+++ redboot/current/src/main.c	1 Sep 2004 21:17:34 -0000
@@ -6,11 +6,11 @@
 //
 //==========================================================================
 //####ECOSGPLCOPYRIGHTBEGIN####
 // -------------------------------------------
 // This file is part of eCos, the Embedded Configurable Operating System.
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
 // Copyright (C) 2002, 2003, 2004 Gary Thomas
 //
 // 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.
@@ -176,11 +176,11 @@ do_version(int argc, char *argv[])
 
     diag_printf(version);
 #ifdef HAL_PLATFORM_CPU
     diag_printf("Platform: %s (%s) %s\n", HAL_PLATFORM_BOARD, HAL_PLATFORM_CPU, HAL_PLATFORM_EXTRA);
 #endif
-    diag_printf("Copyright (C) 2000, 2001, 2002, Red Hat, Inc.\n\n");
+    diag_printf("Copyright (C) 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.\n\n");
     diag_printf("RAM: %p-%p, ", (void*)ram_start, (void*)ram_end);
     diag_printf("[%p-%p]", mem_segments[0].start, mem_segments[0].end);
     diag_printf(" available\n");
 #if CYGBLD_REDBOOT_MAX_MEM_SEGMENTS > 1
     for (seg = 1;  seg < CYGBLD_REDBOOT_MAX_MEM_SEGMENTS;  seg++) {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]