Sample User Flash Application Program
You can use the following program to test the user flash device and driver. This program also demonstrates how this device can be used.
CODE EXAMPLE 3-6 Sample User Flash Application Program
/*
*
*This application program demonstrates the user program
*interface to the User Flash PROM driver.
*
*One can read or write a number of bytes up to the size of
*the user PROM by means of pread() and pwrite() calls.
*All other functions of the PROM can be accessed by
*means of ioctl() calls such as:
*
*
*
*
*Please note that not all of the above ioctl calls are
*available for all flash PROMs. It is the user’s
*responsibility to find out the features of a given PROM.
*The type, block size, and number of blocks of the PROM
*are returned by "identify" ioctl().
*
*The pwrite() erases the block[s] and then does the
*writing.
*
*Use the following line to compile your custom application
*programs:
*make uflash_test
*/
#pragma ident "@(#)uflash_test.c 1.0 | 03/04/30 SMI" |
#include <stdio.h> #include <sys/signal.h> #include <stdio.h> #include <sys/time.h> #include <errno.h> #include <sys/types.h> #include <sys/fcntl.h> #include <sys/stream.h> #include "uflash_if.h" /*
*/
Chapter 3 User Flash 53