Chapter 2
Flash Device Driver
17
Example Flash Application Program
You can use the following program to test the flash device driver. This program
demonstrates how the device can be used.
CODE
EXAMPLE
2-6
Flash Application Program
/*
*
* This application program demonstrates the user program
* interface to the 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:
* -) identify the chip,
* -) query block,
* -) lock block/unlock block,
* -) erase block
* 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"
/*
*/