The following code fragments are a first attempt at providing access to CF information. The alt_avalon_cf_get_config stub is filled out and eCos cleaned and rebuilt.
// fill out stub in altera_avalon_cf.c
// Altera Avalon compact flash driver
alt_avalon_cf_get_config(disk_channel *chan,
cyg_uint32 key,
const void *xbuf, //cyg_disk_info_t;
cyg_uint32 *len)
{
cyg_disk_info_t *info = chan->info; // info is a pointer
cyg_disk_info_t *buf = (cyg_disk_info_t *) xbuf;
cyg_disk_identify_t *ident = &chan->info->ident;
Cyg_ErrNo res = ENOERR;
D("alt_avalon_cf_get_config\n");
if (!chan->init)
return -EINVAL;
if (*len < sizeof(cyg_disk_info_t))
return -EINVAL;
*buf = *info;
*len = sizeof(cyg_disk_info_t);
//D((" serial = '%s'\n", ident->serial));
//D((" firmware rev = '%s'\n", ident->firmware_rev));
D(" model num = '%s'\n", ident->model_num);
D(" block_size = %d\n", info->block_size);
D(" blocks_num = %d\n", info->blocks_num);
return res;
}
Here is a code fragment to access the info. In this case
the block size, number of blocks and CF model string.
//------------------------------------------------------
// code to access CF info
// use API call 'cyg_io_get_config'
// information on the CF card
cyg_disk_info_t cf_info;
char cf_model[20];
// later on...
{ // get CF card info
cyg_io_handle_t cf_handle;
void *xbuf = (void *)&cf_info; //cyg_disk_info_t
Cyg_ErrNo error;
cyg_uint32 len = sizeof(cyg_disk_info_t);
error = cyg_io_lookup("/dev/cfa/1", &cf_handle);
if(error!=0) printf("lookup error:%i\n",error);
else
{
error = cyg_io_get_config(cf_handle,0,xbuf,&len); //
printf("cf get_config error: %i %i\n",error,-EINVAL); // should get -EINVAL
//cf_info_ptr = *(cyg_disk_info_t *)xbuf;
// get useful info
block_size = cf_info.block_size;
blocks_num = cf_info.blocks_num;
strncpy(cf_model,cf_info.ident.model_num,16);
printf("block size:%i num_blocks:%i %s\n"
,cf_info.block_size,cf_info.blocks_num,cf_model);
}
Looks like I get to answer my own questions.