Write Example Program - Sun Microsystems Netra CP2500 Programming Manual

For the solaris operating system
Table of Contents

Advertisement

Read Action on User Flash Device (Continued)
CODE EXAMPLE 3-3
printf("number of blocks = 0x%p", ufif0.info.blk_num);
printf("block size = 0x%p"
}
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();
}

Write Example Program

CODE EXAMPLE 3-4
Write Action on User Flash Device
CODE EXAMPLE 3-4
/*
* uflash_write.c
* An example that shows how to write user flash
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <uflash_if.h>
char *uflash0 = "/dev/uflash0";
ufif0.info.blk_size);
contains the Write Action on the user flash device.
Chapter 3 User Flash
49

Advertisement

Table of Contents
loading

Table of Contents