★ PROGRAMMER'S GUIDE ★ File system library#define BUF_SIZE 2048GfsHn gfs; / * File handle * / Sint32 fid; / * File identifier * / Sint32 nsct = 1; / * Number of sectors read * / Uint32 buf [BUF_SIZE / 4]; / * Read area * / gfs = GFS_Open (fid); / * File open * / GFS_Fread (gfs, nsct, buf, BUF_SIZE); / * Read nsct sector into buf * / GFS_Close (gfs); / * File close * /
#define BUF_SIZE 2048 * 2
GfsHn gfs; / * File handle * /
Sint32 nsct = 2; / * Number of sectors read * /
Sint32 stat; / * Server status * /
Uint32 buf [BUF_SIZE / 4]; / * Read area * /
gfs = GFS_Open (fid); / * File open * /
/ * Request function * /
GFS_NwFread (gfs, nsct, buf, BUF_SIZE); / * Read nsct sector into buf * /
/ * Immediate return * /
for (;;) {
/ * Server function * /
stat = GFS_NwExecOne (gfs); / * Perform read * /
if (stat == GFS_SVR_COMPLETED) {/ * Is reading completed? * /
break;
}
user (); / * Arbitrary user processing * /
}
GFS_Close (gfs); / * File close * /
/ * Number of sectors read from each file * / #define NSCT1 1 # define NSCT2 2 # define NSCT3 3 / * The size of the data storage area of each file (unit is bytes) * / # define BSIZE1 2048 * NSCT1 # define BSIZE2 2048 * NSCT2 # define BSIZE3 2048 * NSCT3Sint32 fid1, fid2, fid3; / * File identifier of each file * / GfsHn gfs1, gfs2, gfs3; / * File handle for each file * / Uint32 buf1 [BSIZE1 / 4]; / * Data storage area for each file * / Uint32 buf2 [BSIZE2 / 4]; Uint32 buf3 [BSIZE3 / 4]; GfsHn now_gfs; / * File handle being accessed * / Sint32 stat; / * Server status * / gfs1 = GFS_Open (fid1); / * File open * / gfs2 = GFS_Open (fid2); gfs3 = GFS_Open (fid3); GFS_NwFread (gfs1, NSCT1, buf1, BSIZE1); / * Start read operation * / GFS_NwFread (gfs2, NSCT2, buf2, BSIZE2); GFS_NwFread (gfs3, NSCT3, buf3, BSIZE3); for (;;) { stat = GFS_NwExecServer (& now_gfs); / * Perform read * / if (stat == GFS_SVR_COMPLETED) {/ * Do you have any work to do? * / break; } user (); / * Arbitrary user processing * / } GFS_Close (gfs1); GFS_Close (gfs2); GFS_Close (gfs3);
#define SECT_SIZE 2048 #define FILE_SECT 1000 #define FILE_SIZE (FILE_SECT * SECT_SIZE) #define RD_UNIT 10 Uint8 * rd_bp, * proc_bp; / * Read buffer and processing buffer * / Uint32 buf1 [RD_UNIT * SECT_SIZE / 4]; / * Data storage area 1 * / Uint32 buf2 [RD_UNIT * SECT_SIZE / 4]; / * Data storage area 2 * / GfsHn gfs; Sint32 i, stat, nbyte;gfs = GFS_Open (fid); GFS_NwCdRead (gfs, FILE_SECT); / * Read-ahead instruction to CD buffer * / GFS_SetTransPara (gfs, RD_UNIT); / * Extract maximum RD_UNIT sector at once * / for (i = 0; i <FILE_SECT / RD_UNIT; ++ i) { / * Read, set processing buffer * / if (i & 1) { rd_bp = buf1; proc_bp = buf2; } else { rd_bp = buf2; proc_bp = buf1; } / * Eject from CD buffer * / GFS_NwFread (gfs, RD_UNIT, rd_bp, RD_UNIT * SECT_SIZE); do { if (i & 0) { user_process (proc_bp); / * Processing for read data * / } else { user_process0 (); / * Processing before data is read * / } GFS_NwExecOne (gfs); GFS_NwGetStat (gfs, & stat, & nbyte); } While (nbyte <RD_UNIT * SECT_SIZE); }
★ PROGRAMMER'S GUIDE ★ File system library