# HG changeset patch # User gthomas # Date 1046711396 0 # Node ID a2dfa8bf3c5790f8edc721f7f45002afa5daed16 # Parent 182dec50341713cee817a68d9b66c69d6722d5bc Export RedBoot FIS functions - from Knud Woehler diff --git a/packages/hal/common/current/ChangeLog b/packages/hal/common/current/ChangeLog --- a/packages/hal/common/current/ChangeLog +++ b/packages/hal/common/current/ChangeLog @@ -1,3 +1,9 @@ +2003-03-03 Knud Woehler + + * src/hal_if.c: + * include/hal_if.h: Add CYGNUM_CALL_IF_FLASH_FIS_OP. FIS read + via the virtual vector table. + 2003-02-24 Jonathan Larmour * cdl/hal.cdl: Fix doc links. diff --git a/packages/hal/common/current/include/hal_if.h b/packages/hal/common/current/include/hal_if.h --- a/packages/hal/common/current/include/hal_if.h +++ b/packages/hal/common/current/include/hal_if.h @@ -45,7 +45,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): jskov -// Contributors:jskov +// Contributors:jskov, woehler // Date: 2000-06-07 // Purpose: HAL RAM/ROM calling interface // Description: ROM/RAM calling interface table definitions. The layout is a @@ -366,8 +366,9 @@ static __inline__ _rt_ #define CYGNUM_CALL_IF_DBG_DATA 19 #define CYGNUM_CALL_IF_FLASH_CFG_OP 20 #define CYGNUM_CALL_IF_MONITOR_RETURN 21 +#define CYGNUM_CALL_IF_FLASH_FIS_OP 22 -#define CYGNUM_CALL_IF_LAST_ENTRY CYGNUM_CALL_IF_MONITOR_RETURN +#define CYGNUM_CALL_IF_LAST_ENTRY CYGNUM_CALL_IF_FLASH_FIS_OP #define CYGNUM_CALL_IF_INSTALL_BPT_FN 35 @@ -426,6 +427,8 @@ typedef cyg_bool (__call_if_flash_cfg_op void *__val, int __type); typedef char *__call_if_monitor_version_t; typedef void (__call_if_monitor_return_t)(int status); +typedef cyg_bool (__call_if_flash_fis_op_fn_t)(int __oper, char *__name, + void *__val); #ifndef CYGACC_CALL_IF_DEFINED @@ -496,6 +499,26 @@ static __inline__ _rt_ _EXIT_MONITOR(); \ } +#define __call_VV3(_n_,_tt_,_rt_,_t1_,_t2_,_t3_) \ +static __inline__ _rt_ \ +__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_, _t3_ _p3_) \ +{ \ + _rt_ res; \ + _ENTER_MONITOR(); \ + res = ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_,_p3_); \ + _EXIT_MONITOR(); \ + return res; \ +} + +#define __call_voidVV3(_n_,_tt_,_rt_,_t1_,_t2_,_t3_) \ +static __inline__ _rt_ \ +__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_, _t3_ _p3_) \ +{ \ + _ENTER_MONITOR(); \ + ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_,_p3_); \ + _EXIT_MONITOR(); \ +} + #define __call_VV4(_n_,_tt_,_rt_,_t1_,_t2_,_t3_,_t4_) \ static __inline__ _rt_ \ __call_vv_##_n_(_t1_ _p1_, _t2_ _p2_, _t3_ _p3_, _t4_ _p4_) \ @@ -627,6 +650,14 @@ static __inline__ _rt_ #define CYGACC_CALL_IF_MONITOR_RETURN_SET(_x_) \ hal_virtual_vector_table[CYGNUM_CALL_IF_MONITOR_RETURN]=(CYG_ADDRWORD)(_x_) +#define CYGACC_CALL_IF_FLASH_FIS_OP(_o_,_k_,_d_) \ + CYGACC_CALL_VV3(__call_if_flash_fis_op_fn_t*, CYGNUM_CALL_IF_FLASH_FIS_OP, (_o_),(_k_),(_d_)) +__call_VV3(CYGNUM_CALL_IF_FLASH_FIS_OP, __call_if_flash_fis_op_fn_t, cyg_bool, int, char *, void *) +#define CYGACC_CALL_IF_FLASH_FIS_OP_SET(_x_) \ + hal_virtual_vector_table[CYGNUM_CALL_IF_FLASH_FIS_OP]=(CYG_ADDRWORD)(_x_) +#define CYGNUM_CALL_IF_FLASH_FIS_GET_FLASH_BASE (0) +#define CYGNUM_CALL_IF_FLASH_FIS_GET_SIZE (1) + // These need to be kept uptodate with the (unadorned) masters // in RedBoot's flash_config.h: #define CYGNUM_FLASH_CFG_OP_CONFIG_EMPTY 0 diff --git a/packages/hal/common/current/src/hal_if.c b/packages/hal/common/current/src/hal_if.c --- a/packages/hal/common/current/src/hal_if.c +++ b/packages/hal/common/current/src/hal_if.c @@ -42,7 +42,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): jskov -// Contributors:jskov +// Contributors:jskov, woehler // Date: 2000-06-07 // //####DESCRIPTIONEND#### @@ -75,6 +75,9 @@ #include #include #endif +#ifdef CYGOPT_REDBOOT_FIS +#include +#endif #endif //-------------------------------------------------------------------------- @@ -112,6 +115,39 @@ flash_config_op( int op, char * key, voi } #endif +#ifdef CYGOPT_REDBOOT_FIS + +static __call_if_flash_fis_op_fn_t flash_fis_op; + +static cyg_bool +flash_fis_op( int op, char *name, void *val) +{ + cyg_bool res = false; + struct fis_image_desc *fis; + int num; + + CYGARC_HAL_SAVE_GP(); + fis = fis_lookup(name, &num); + if(fis != NULL) + { + switch ( op ) { + case CYGNUM_CALL_IF_FLASH_FIS_GET_FLASH_BASE: + *(CYG_ADDRESS *)val = fis->flash_base; + res = true; + break; + case CYGNUM_CALL_IF_FLASH_FIS_GET_SIZE: + *(unsigned long *)val = fis->size; + res = true; + break; + default: + break; + } + } + CYGARC_HAL_RESTORE_GP(); + return res; +} +#endif + //---------------------------- // Delay uS #ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_DELAY_US @@ -891,6 +927,10 @@ hal_if_init(void) CYGACC_CALL_IF_FLASH_CFG_OP_SET(flash_config_op); #endif +#ifdef CYGOPT_REDBOOT_FIS + CYGACC_CALL_IF_FLASH_FIS_OP_SET(flash_fis_op); +#endif + // Data entries not currently supported in eCos #ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_DATA CYGACC_CALL_IF_DBG_DATA_SET(0); @@ -971,3 +1011,4 @@ hal_if_init(void) plf_if_init(); #endif } + diff --git a/packages/io/flash/current/ChangeLog b/packages/io/flash/current/ChangeLog --- a/packages/io/flash/current/ChangeLog +++ b/packages/io/flash/current/ChangeLog @@ -1,3 +1,10 @@ +2003-03-03 Knud Woehler + + * src/flashiodev.c: + * cdl/io_flash.cdl: Add CYGNUM_IO_FLASH_BLOCK_CFG_FIS_1 / + CYGNUM_IO_FLASH_BLOCK_CFG_STATIC_1. Initialize the block device + from the FIS table. + 2003-02-24 Jonathan Larmour * cdl/io_flash.cdl: Remove irrelevant doc link - default to top diff --git a/packages/io/flash/current/cdl/io_flash.cdl b/packages/io/flash/current/cdl/io_flash.cdl --- a/packages/io/flash/current/cdl/io_flash.cdl +++ b/packages/io/flash/current/cdl/io_flash.cdl @@ -42,7 +42,7 @@ # # Author(s): gthomas # Original data: gthomas -# Contributors: +# Contributors: woehler # Date: 2000-07-06 # #####DESCRIPTIONEND#### @@ -133,26 +133,54 @@ cdl_package CYGPKG_IO_FLASH { API ( cyg_io_read() etc. )" cdl_component CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_1 { - display "Name of flash device 1 block device" - flavor data - default_value { "\"/dev/flash1\"" } + display "Name of flash device 1 block device" + flavor data + default_value { "\"/dev/flash1\"" } + + cdl_interface CYGINT_IO_FLASH_BLOCK_CFG_1 { + requires 1 == CYGINT_IO_FLASH_BLOCK_CFG_1 + no_define + } - cdl_option CYGNUM_IO_FLASH_BLOCK_OFFSET_1 { - display "Start offset from flash base" - flavor data - default_value 0x100000 - description " - This gives the offset from the base of flash which this - block device corresponds to." - } - cdl_option CYGNUM_IO_FLASH_BLOCK_LENGTH_1 { - display "Length" - flavor data - default_value 0x100000 - description " - This gives the length of the region of flash given over - to this block device." - } + cdl_component CYGNUM_IO_FLASH_BLOCK_CFG_STATIC_1 { + display "Static configuration" + default_value 1 + implements CYGINT_IO_FLASH_BLOCK_CFG_1 + description " + This configures the flash device 1 block device + with static base and length" + + cdl_option CYGNUM_IO_FLASH_BLOCK_OFFSET_1 { + display "Start offset from flash base" + flavor data + default_value 0x100000 + description " + This gives the offset from the base of flash which this + block device corresponds to." + } + cdl_option CYGNUM_IO_FLASH_BLOCK_LENGTH_1 { + display "Length" + flavor data + default_value 0x100000 + description " + This gives the length of the region of flash given over + to this block device." + } + } + cdl_component CYGNUM_IO_FLASH_BLOCK_CFG_FIS_1 { + display "Configuration from FIS" + default_value 0 + implements CYGINT_IO_FLASH_BLOCK_CFG_1 + description " + This configures the flash device 1 block device + from Redboot FIS" + + cdl_component CYGDAT_IO_FLASH_BLOCK_FIS_NAME_1 { + display "Name of FIS entry" + flavor data + default_value { "\"jffs2\"" } + } + } } } } diff --git a/packages/io/flash/current/src/flashiodev.c b/packages/io/flash/current/src/flashiodev.c --- a/packages/io/flash/current/src/flashiodev.c +++ b/packages/io/flash/current/src/flashiodev.c @@ -41,7 +41,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): jlarmour -// Contributors: +// Contributors: woehler // Date: 2002-01-16 // Purpose: // Description: @@ -59,22 +59,53 @@ #include #include #include // memcpy +#include #define MIN(x,y) ((x)<(y) ? (x) : (y)) // 1 per devtab entry, so only 1 for now -static char flashiodev_workspaces[1][FLASH_MIN_WORKSPACE]; +//static char flashiodev_workspaces[1][FLASH_MIN_WORKSPACE]; + +struct flashiodev_priv_t{ + char workspace[FLASH_MIN_WORKSPACE]; + char *start; + char *end; +}; + +static struct flashiodev_priv_t flashiodev_priv[1]; static int dummy_printf( const char *fmt, ... ) {return 0;} static bool flashiodev_init( struct cyg_devtab_entry *tab ) { - char *ws = (char *)tab->priv; + struct flashiodev_priv_t *dev = (struct flashiodev_priv_t *)tab->priv; + char *ws = dev->workspace; int stat = flash_init( ws, FLASH_MIN_WORKSPACE, &dummy_printf ); + if ( stat == 0 ) + { +#ifdef CYGNUM_IO_FLASH_BLOCK_CFG_FIS_1 + CYG_ADDRESS flash_base; + unsigned long size; - if ( stat == 0 ) + if(!CYGACC_CALL_IF_FLASH_FIS_OP(CYGNUM_CALL_IF_FLASH_FIS_GET_FLASH_BASE, + CYGDAT_IO_FLASH_BLOCK_FIS_NAME_1, + &flash_base)) + return false; + if(!CYGACC_CALL_IF_FLASH_FIS_OP(CYGNUM_CALL_IF_FLASH_FIS_GET_SIZE, + CYGDAT_IO_FLASH_BLOCK_FIS_NAME_1, + &size)) + return false; + + dev->start = (char *)flash_base; + dev->end = (char *)flash_base + size; +#else + dev->start = (char *)flash_info.start + CYGNUM_IO_FLASH_BLOCK_OFFSET_1; + dev->end = (char *)flash_info.start + CYGNUM_IO_FLASH_BLOCK_OFFSET_1 + + CYGNUM_IO_FLASH_BLOCK_LENGTH_1) +#endif return true; + } else return false; } // flashiodev_init() @@ -92,21 +123,21 @@ static Cyg_ErrNo flashiodev_bread( cyg_io_handle_t handle, void *buf, cyg_uint32 *len, cyg_uint32 pos) { - char *startpos = (char *)flash_info.start + pos + - CYGNUM_IO_FLASH_BLOCK_OFFSET_1; + struct cyg_devtab_entry *tab = (struct cyg_devtab_entry *)handle; + struct flashiodev_priv_t *dev = (struct flashiodev_priv_t *)tab->priv; + + char *startpos = dev->start + pos; #ifdef CYGPKG_INFRA_DEBUG // don't bother checking this all the time char *endpos = startpos + *len - 1; - char *flashend = MIN( (char *)flash_info.end, - ((char *)flash_info.start + CYGNUM_IO_FLASH_BLOCK_OFFSET_1 + - CYGNUM_IO_FLASH_BLOCK_LENGTH_1)); - if ( startpos < (char *)flash_info.start+CYGNUM_IO_FLASH_BLOCK_OFFSET_1 ) + char *flashend = MIN( (char *)flash_info.end, dev->end); + if ( startpos < dev->start ) return -EINVAL; if ( endpos > flashend ) return -EINVAL; #endif + memcpy( buf, startpos, *len ); - return ENOERR; } // flashiodev_bread() @@ -114,17 +145,17 @@ static Cyg_ErrNo flashiodev_bwrite( cyg_io_handle_t handle, const void *buf, cyg_uint32 *len, cyg_uint32 pos ) { + struct cyg_devtab_entry *tab = (struct cyg_devtab_entry *)handle; + struct flashiodev_priv_t *dev = (struct flashiodev_priv_t *)tab->priv; + Cyg_ErrNo err = ENOERR; void *erraddr; - - char *startpos = (char *)flash_info.start + pos + CYGNUM_IO_FLASH_BLOCK_OFFSET_1; + char *startpos = dev->start + pos; #ifdef CYGPKG_INFRA_DEBUG // don't bother checking this all the time char *endpos = startpos + *len - 1; - char *flashend = MIN( (char *)flash_info.end, - ((char *)flash_info.start + CYGNUM_IO_FLASH_BLOCK_OFFSET_1 + - CYGNUM_IO_FLASH_BLOCK_LENGTH_1)); - if ( startpos < (char *)flash_info.start + CYGNUM_IO_FLASH_BLOCK_OFFSET_1 ) + char *flashend = MIN( (char *)flash_info.end, dev->end); + if ( startpos < dev->start ) return -EINVAL; if ( endpos > flashend ) return -EINVAL; @@ -143,22 +174,22 @@ flashiodev_get_config( cyg_io_handle_t h void* buf, cyg_uint32* len) { + 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: { if ( *len != sizeof( cyg_io_flash_getconfig_erase_t ) ) return -EINVAL; { - cyg_io_flash_getconfig_erase_t *e = - (cyg_io_flash_getconfig_erase_t *)buf; - char *startpos = (char *)flash_info.start + e->offset + CYGNUM_IO_FLASH_BLOCK_OFFSET_1; + cyg_io_flash_getconfig_erase_t *e = (cyg_io_flash_getconfig_erase_t *)buf; + char *startpos = dev->start + e->offset; #ifdef CYGPKG_INFRA_DEBUG // don't bother checking this all the time char *endpos = startpos + e->len - 1; - char *flashend = MIN( (char *)flash_info.end, - ((char *)flash_info.start + CYGNUM_IO_FLASH_BLOCK_OFFSET_1 + - CYGNUM_IO_FLASH_BLOCK_LENGTH_1)); - if ( startpos < (char *)flash_info.start + CYGNUM_IO_FLASH_BLOCK_OFFSET_1 ) + char *flashend = MIN( (char *)flash_info.end, dev->end); + if ( startpos < dev->start ) return -EINVAL; if ( endpos > flashend ) return -EINVAL; @@ -176,7 +207,7 @@ flashiodev_get_config( cyg_io_handle_t h (cyg_io_flash_getconfig_devsize_t *)buf; //d->dev_size = flash_info.blocks * flash_info.block_size; - d->dev_size = CYGNUM_IO_FLASH_BLOCK_LENGTH_1; + d->dev_size = dev->end - dev->start; } return ENOERR; } @@ -185,12 +216,11 @@ flashiodev_get_config( cyg_io_handle_t h { cyg_io_flash_getconfig_blocksize_t *b = (cyg_io_flash_getconfig_blocksize_t *)buf; - char *startpos = (char *)flash_info.start + CYGNUM_IO_FLASH_BLOCK_OFFSET_1 + b->offset; #ifdef CYGPKG_INFRA_DEBUG // don't bother checking this all the time - char *flashend = MIN( (char *)flash_info.end, - ((char *)flash_info.start + CYGNUM_IO_FLASH_BLOCK_OFFSET_1 + - CYGNUM_IO_FLASH_BLOCK_LENGTH_1)); - if ( startpos < (char *)flash_info.start + CYGNUM_IO_FLASH_BLOCK_OFFSET_1 ) + char *startpos = dev->start + b->offset; + char *flashend = MIN( (char *)flash_info.end, dev->end); + + if ( startpos < dev->start ) return -EINVAL; if ( startpos > flashend ) return -EINVAL; @@ -199,7 +229,7 @@ flashiodev_get_config( cyg_io_handle_t h return -EINVAL; // offset unused for now - b->block_size = flash_info.block_size; + b->block_size = flash_info.block_size; return ENOERR; } @@ -215,6 +245,9 @@ flashiodev_set_config( cyg_io_handle_t h const void* buf, cyg_uint32* len) { + struct cyg_devtab_entry *tab = (struct cyg_devtab_entry *)handle; + struct flashiodev_priv_t *dev = (struct flashiodev_priv_t *)tab->priv; + switch (key) { default: return -EINVAL; @@ -240,6 +273,6 @@ BLOCK_DEVTAB_ENTRY( cyg_io_flashdev1, &cyg_io_flashdev1_ops, &flashiodev_init, 0, // No lookup required - &flashiodev_workspaces[0] ); + &flashiodev_priv[0] ); // EOF flashiodev.c diff --git a/packages/redboot/current/ChangeLog b/packages/redboot/current/ChangeLog --- a/packages/redboot/current/ChangeLog +++ b/packages/redboot/current/ChangeLog @@ -1,3 +1,12 @@ +2003-03-03 Gary Thomas + + * src/main.c (set_console_baud_rate): Avoid "unused" warning. + +2003-03-03 Knud Woehler + + * 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 * doc/redboot.sgml: De-vendorise a little. diff --git a/packages/redboot/current/src/flash.c b/packages/redboot/current/src/flash.c --- a/packages/redboot/current/src/flash.c +++ b/packages/redboot/current/src/flash.c @@ -1218,6 +1218,7 @@ do_flash_init(void) fis_addr = (void *)((CYG_ADDRESS)flash_start + (CYGNUM_REDBOOT_FIS_DIRECTORY_BLOCK*flash_block_size)); } + memcpy(fis_work_block, fis_addr, flash_block_size); #endif __flash_init = 1; } diff --git a/packages/redboot/current/src/main.c b/packages/redboot/current/src/main.c --- a/packages/redboot/current/src/main.c +++ b/packages/redboot/current/src/main.c @@ -522,7 +522,7 @@ set_comm_baud_rate(hal_virtual_comm_tabl int set_console_baud_rate(int rate) { - int ret; + 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);