This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
flashiodev changes for jffs2 from redboot
- From: Andrew Lunn <andrew at lunn dot ch>
- To: eCos Patches <ecos-patches at ecos dot sourceware dot org>
- Date: Thu, 12 Aug 2004 20:58:41 +0200
- Subject: flashiodev changes for jffs2 from redboot
Hi Folks
I just committed this to the flashv2 branch.
Andrew
Index: io/flash/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/flash/current/ChangeLog,v
retrieving revision 1.38.2.2
diff -u -r1.38.2.2 ChangeLog
--- io/flash/current/ChangeLog 6 Aug 2004 11:18:33 -0000 1.38.2.2
+++ io/flash/current/ChangeLog 12 Aug 2004 18:57:05 -0000
@@ -1,3 +1,13 @@
+2004-08-09 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * src/flashiodev.c (flashiodev_lookup): Moved most of the
+ flashiodev_init into this new function. This fixed the ordering
+ issue with redboot startup. When doing a FIS name lookup in
+ flashiodev_init, redboot was not yet initialized so lookup
+ failed. Moving this into flashiodev_lookup solves this problem.
+ Its now possible for redboot to mount the jffs2 filesystem with
+ -d /dev/flash1.
+
2004-08-06 Andrew Lunn <andrew.lunn@ascom.ch>
* src/flashiodev.c: Fix typo in macro and configuration options
Index: io/flash/current/src/flashiodev.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/flash/current/src/flashiodev.c,v
retrieving revision 1.8.2.2
diff -u -r1.8.2.2 flashiodev.c
--- io/flash/current/src/flashiodev.c 6 Aug 2004 11:18:33 -0000 1.8.2.2
+++ io/flash/current/src/flashiodev.c 12 Aug 2004 18:57:05 -0000
@@ -80,55 +80,61 @@
static bool
flashiodev_init( struct cyg_devtab_entry *tab )
{
- struct flashiodev_priv_t *dev = (struct flashiodev_priv_t *)tab->priv;
+ int stat = cyg_flash_init( &dummy_printf );
+
+ return (stat == CYG_FLASH_ERR_OK);
+} // flashiodev_init()
+
+static Cyg_ErrNo
+flashiodev_lookup(struct cyg_devtab_entry **tab,
+ struct cyg_devtab_entry *sub_tab,
+ const char *name)
+{
+ struct flashiodev_priv_t *dev = (struct flashiodev_priv_t *)(*tab)->priv;
cyg_flash_info_t info;
cyg_uint32 i;
+ int stat;
- int stat = cyg_flash_init( &dummy_printf );
- if ( stat == 0 ) {
- if (dev->use_fis) {
- CYG_ADDRESS flash_base;
- unsigned long size;
+ if (dev->use_fis) {
+ CYG_ADDRESS flash_base;
+ unsigned long size;
- if(!CYGACC_CALL_IF_FLASH_FIS_OP(CYGNUM_CALL_IF_FLASH_FIS_GET_FLASH_BASE,
- dev->fis_name,
- &flash_base))
- return false;
- if(!CYGACC_CALL_IF_FLASH_FIS_OP(CYGNUM_CALL_IF_FLASH_FIS_GET_SIZE,
- dev->fis_name,
- &size))
- return false;
-
- dev->start = flash_base;
- dev->end = flash_base + size;
- }
- if (dev->use_offset) {
- // dev->start the contain the offset to the beginning of the block
- // dev->end is the length of the block
- cyg_flashaddr_t start, end;
- cyg_flash_get_limits(&start, &end);
- dev->start = dev->start + start;
- dev->end = dev->start + dev->end;
- }
- if (dev->use_absolute) {
- // dev->start is the absolute address of the start
- // dev->end is the length;
- dev->end = dev->start + dev->end;
- }
-
- stat = cyg_flash_get_info_addr(dev->start, &info);
- if (stat != CYG_FLASH_ERR_OK) {
- return false;
- }
- dev->block_size = 0;
- for (i=0; i < info.num_block_infos; i++){
- dev->block_size = MAX(dev->block_size, info.block_info[i].block_size);
+ if(!CYGACC_CALL_IF_FLASH_FIS_OP(CYGNUM_CALL_IF_FLASH_FIS_GET_FLASH_BASE,
+ dev->fis_name,
+ &flash_base))
+ return ENODEV;
+ if(!CYGACC_CALL_IF_FLASH_FIS_OP(CYGNUM_CALL_IF_FLASH_FIS_GET_SIZE,
+ dev->fis_name,
+ &size))
+ return ENODEV;
+ dev->start = flash_base;
+ dev->end = flash_base + size;
+ }
+ if (dev->use_offset) {
+ // dev->start the contain the offset to the beginning of the block
+ // dev->end is the length of the block
+ cyg_flashaddr_t start, end;
+ cyg_flash_get_limits(&start, &end);
+ dev->start = dev->start + start;
+ dev->end = dev->start + dev->end;
+ }
+ if (dev->use_absolute) {
+ // dev->start is the absolute address of the start
+ // dev->end is the length;
+ dev->end = dev->start + dev->end;
+ }
+
+ stat = cyg_flash_get_info_addr(dev->start, &info);
+ if (stat != CYG_FLASH_ERR_OK) {
+ return ENODEV;
}
-
- return true;
- } else
- return false;
-} // flashiodev_init()
+ dev->block_size = 0;
+ for (i=0; i < info.num_block_infos; i++){
+ dev->block_size = MAX(dev->block_size, info.block_info[i].block_size);
+ }
+
+ return ENOERR;
+} // flashiodev_lookup()
static Cyg_ErrNo
flashiodev_bread( cyg_io_handle_t handle, void *buf, cyg_uint32 *len,
@@ -136,11 +142,10 @@
{
struct cyg_devtab_entry *tab = (struct cyg_devtab_entry *)handle;
struct flashiodev_priv_t *dev = (struct flashiodev_priv_t *)tab->priv;
-
+
cyg_flashaddr_t startpos = dev->start + pos;
Cyg_ErrNo err;
-
#ifdef CYGPKG_INFRA_DEBUG // don't bother checking this all the time
cyg_flashaddr_t endpos = startpos + *len - 1;
if ( startpos < dev->start )
@@ -188,7 +193,7 @@
{
struct cyg_devtab_entry *tab = (struct cyg_devtab_entry *)handle;
struct flashiodev_priv_t *dev = (struct flashiodev_priv_t *)tab->priv;
-
+
switch (key) {
case CYG_IO_GET_CONFIG_FLASH_ERASE:
{
@@ -216,7 +221,7 @@
{
cyg_io_flash_getconfig_devsize_t *d =
(cyg_io_flash_getconfig_devsize_t *)buf;
-
+
d->dev_size = dev->end - dev->start;
}
return ENOERR;
@@ -342,7 +347,7 @@
0,
&cyg_io_flashdev1_ops,
&flashiodev_init,
- 0, // No lookup required
+ &flashiodev_lookup,
&priv1 );
@@ -386,7 +391,7 @@
0,
&cyg_io_flashdev1_ops,
&flashiodev_init,
- 0, // No lookup required
+ &flashiodev_lookup,
&priv2 );
#endif