Sun Microsystems Netra CP2500 User Manual
Page 70
56
Netra CP2500 Board Programming Guide • March 2007
case ’4’: /* lock flash PROM block */
/* on certain PROMs */
fprintf(stderr,
"Enter PROM block number[0, 56]> ");
scanf ("%d", &uflash_if.blk_num);
fprintf(stderr,
"Enter number of block> ");
scanf ("%d", &uflash_if.num_of_blks);
if (ioctl(fd, UIOCLBLK, &uflash_if) == -1)
goto getout;
break;
case ’3’: /* query flash PROM */
/* on certain PROMs */
fprintf(stderr,
"Enter PROM block number[0, 56]> ");
scanf ("%d", &uflash_if.blk_num);
fprintf(stderr,
"Enter number of block> ");
scanf ("%d", &uflash_if.num_of_blks);
if (ioctl(fd, UIOCQBLK, &uflash_if) == -1)
goto getout;
for (i = uflash_if.blk_num;
i < (uflash_if.blk_num+uflash_if.num_of_blks);
i++)
{
fprintf(stderr, "block[%d] status = %x\n",
i, uflash_if.info.blk_status[i] & 0x1);
}
break;
case ’2’: /* identify flash PROM */
if (ioctl(fd, UIOCIBLK, &uflash_if) == -1)
goto getout;
fprintf(stderr, "manufacturer id = 0x%x, device id =\
0x%x\n# of blks = %d, blk size = 0x%x\n",
uflash_if.info.mfr_id & 0xFF,
uflash_if.info.dev_id & 0xFF,
uflash_if.info.blk_num,
uflash_if.info.blk_size);
break;
CODE EXAMPLE 3-6
Sample User Flash Application Program (Continued)