* Copyright (c) 1986 MICOM-Interlan, Inc., Boxborough Mass.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
"@(#) Copyright (c) 1986 MICOM-Interlan, Inc., Boxborough Mass.\n\
static char sccsid
[] = "@(#)npload.c 6.2 (Berkeley) 2/20/86";
char *devname
= "/dev/np00";
/* Pathname for device to be loaded */
/* Name of the image file to be loaded */
printf("usage: npload imagefile [device]\n");
/* Open the device to be loaded */
if((ed
= open(devname
,O_RDWR
)) == -1) {
(void) sprintf(fullpath
, "/dev/%s", devname
);
if((ed
= open(devname
,O_RDWR
)) == -1) {
"%s unable to open device %s errno = %d\n",
argv
[0], devname
, errno
);
/* Open the image file */
if((fd
= open(fname
,O_RDONLY
)) == -1) {
fprintf(stderr
,"%s: unable to open file %s errno = %d\n",
/* Reset the specified device */
if(ioctl(ed
,NPRESET
| IOC_VOID
,&stadd
) == -1) {
fprintf(stderr
,"unable to reset %s errno = %d\n",devname
,errno
);
/* Seek to address 400 on the device */
if(lseek(ed
,(long)0x400,0) == -1) {
fprintf(stderr
,"seek failed on %s errno = %d.\n",devname
,errno
);
/* Seek to address 400 on the image file */
if(lseek(fd
,(long)0x400,0) == -1) {
fprintf(stderr
,"seek failed on %s errno = %d.\n",fname
,errno
);
/* Read from the image file and write to the device */
while((nbyte
= read(fd
,ibuf
,1024)) > 0) {
if((ret
= write(ed
,ibuf
,nbyte
)) == -1) {
fprintf(stderr
,"Bad write to %s errno = %d\n",
/* Issue a begin execution command to the device */
if(ioctl(ed
,NPSTART
| IOC_VOID
,&stadd
) == -1) {
fprintf(stderr
,"Start error on %s errno = %d.\n",devname
,errno
);