beautypg.com

Sun Microsystems Netra CP2500 User Manual

Page 68

background image

54

Netra CP2500 Board Programming Guide • March 2007

#if 1

#define PROM_SIZE 0x700000 /* 7 MBytes */

#endif

static char *help[14] = {

"0 -- read user flash PROM",

"1 -- write user flash PROM",

"2 -- identify user flash PROM",

"3 -- query blocks",

"4 -- lock blocks",

"5 -- clear all locks",

"6 -- erase blocks",

"q -- quit",

"?/h -- display this menu",

""

};

/*char get_cmd(); */

static char

get_cmd()

{

char buf[10];

gets(buf);

return (buf[0]);

}

/*

* Main

*/

main(int argc, char *argv[])

{

int n_byte; /* returned from pread/pwrite */

int size, offset, pat;

int fd0, h, i;

int fd, prom_id;

uflash_if_t uflash_if;

caddr_t r_buf, w_buf;

char *devname0 = "/dev/uflash0";

char c;

r_buf = (caddr_t)malloc(PROM_SIZE);

w_buf = (caddr_t)malloc(PROM_SIZE);

/*

* Open the user flash PROM.

*/

CODE EXAMPLE 3-6

Sample User Flash Application Program (Continued)