Example #1
0
int
tape_open(struct open_file *f, ...)
{
	struct bootparam *bp;
	struct saioreq *si;
	int error, part;
	char *fname;		/* partition number, i.e. "1" */
	va_list ap;

	va_start(ap, f);
	fname = va_arg(ap, char *);
#ifdef DEBUG
	printf("tape_open: part=%s\n", fname);
#endif
	va_end(ap);

	/*
	 * Set the tape segment number to the one indicated
	 * by the single digit fname passed in above.
	 */
	if ((fname[0] < '0') && (fname[0] > '9')) {
		return ENOENT;
	}
	part = fname[0] - '0';

	/*
	 * Setup our part of the saioreq.
	 * (determines what gets opened)
	 */
	si = &tape_ioreq;
	memset(si, 0, sizeof(*si));

	bp = *romVectorPtr->bootParam;
	si->si_boottab = bp->bootDevice;
	si->si_ctlr = bp->ctlrNum;
	si->si_unit = bp->unitNum;
	si->si_boff = part; 	/* default = bp->partNum + 1; */

	error = prom_iopen(si);

#ifdef DEBUG
	printf("tape_open: prom_iopen returned 0x%x\n", error);
#endif

	if (!error)
		f->f_devdata = si;

	return (error);
}
Example #2
0
int
disk_open(struct open_file *f, ...)
{
	struct bootparam *bp;
	struct saioreq *si;
	int error;

#ifdef DEBUG_PROM
	char *devname;		/* Device part of file name (or NULL). */
	va_list ap;

	va_start(ap, f);
	devname = va_arg(ap, char *);
	if (debug)
		printf("disk_open: %s\n", devname);
	va_end(ap);
#endif

	si = &disk_ioreq;
	if (disk_opencount == 0) {
		/*
		 * Setup our part of the saioreq.
		 * (determines what gets opened)
		 */
		bp = *romVectorPtr->bootParam;
		si->si_boottab = bp->bootDevice;
		si->si_ctlr = bp->ctlrNum;
		si->si_unit = bp->unitNum;
		si->si_boff = bp->partNum;
		if ((error = prom_iopen(si)) != 0)
			return (error);
	}
	disk_opencount++;

	f->f_devdata = si;
	return 0;
}
Example #3
0
/*
 * Open the PROM device.
 * Return netif ptr on success.
 */
struct devdata *
netif_init(void *aux)
{
	struct devdata *dd = &netif_devdata;
	struct saioreq *si;
	struct bootparam *bp;
	int error;

	/*
	 * Setup our part of the saioreq.
	 * (determines what gets opened)
	 */
	si = &dd->dd_si;
	memset(si, 0, sizeof(*si));
	bp = *romVectorPtr->bootParam;
	si->si_boottab = bp->bootDevice;
	si->si_ctlr = bp->ctlrNum;
	si->si_unit = bp->unitNum;
	si->si_boff = bp->partNum;

#ifdef NETIF_DEBUG
	if (debug)
		printf("netif_init: calling prom_iopen\n");
#endif

	/*
	 * Note: Sun PROMs will do RARP on open, but does not tell
	 * you the IP address it gets, so it is just noise to us...
	 */
	if ((error = prom_iopen(si)) != 0) {
		printf("netif_init: prom_iopen, error=%d\n", error);
		return (NULL);
	}

	if (si->si_sif == NULL) {
		printf("netif_init: not a network device\n");
		prom_iclose(si);
		return (NULL);
	}

	/* Allocate the transmit/receive buffers. */
	if (dd->rbuf == NULL) {
		dd->rbuf_len = PKT_BUF_SIZE;
		dd->rbuf = dvma_alloc(dd->rbuf_len);
	}
	if (dd->tbuf == NULL) {
		dd->tbuf_len = PKT_BUF_SIZE;
		dd->tbuf = dvma_alloc(dd->tbuf_len);
	}
	if ((dd->rbuf == NULL) ||
	    (dd->tbuf == NULL))
		panic("netif_init: malloc failed");

#ifdef NETIF_DEBUG
	if (debug)
		printf("netif_init: rbuf=0x%x, tbuf=0x%x\n",
			   dd->rbuf, dd->tbuf);
#endif

	/* Record our ethernet address. */
	netif_getether(si->si_sif, dd->dd_myea);

	dd->dd_opens = 0;

	return(dd);
}