12
Netra CP3010 Board Programming Guide
• January
2006
}
/* get uflash sizes */
if (ioctl(ufd0, UIOCIBLK, &ufif0) == -1 ) {
perror("ioctl(ufd0, UIOCIBLK): ");
exit(1);
}
if (ufd0) {
printf("%s: \n", uflash0);
printf("manfacturer id = 0x%p\n", ufif0.info.mfr_id);
printf("device id = 0x%p\n", ufif0.info.dev_id);
printf("number of blocks = 0x%p", ufif0.info.blk_num);
printf("block size = 0x%p" ufif0.info.blk_size);
}
static int
uflash_uninit() {
if (ufd0)
close(ufd0);
cleanup:
if (buf0)
free(buf0);
}
static int
uflash_read() {
/* read block 0 of user flash */
if (pread(ufd0, buf0, ufif0.info.blk_size, 0) != ufif0.info.blk_size)
perror("uflash0:read");
return(0);
}
main() {
int ret;
module = argv[0];
ret = uflash_init();
if (!ret)
uflash_read();
uflash_uninit();
}
CODE
EXAMPLE
2-3
Read Action on Flash Device
(Continued)