2 * Copyright (C) 1993-1998 by Darren Reed.
4 * Redistribution and use in source and binary forms are permitted
5 * provided that this notice is preserved and due credit is given
6 * to the original author and the contributors. The author accepts no
7 * responsibility and is not changed in any way.
9 * I hate legaleese, don't you ?
12 * 29/12/94 Added code from Marc Huber <huber@fzi.de> to allow it to allocate
13 * its own major char number! Way cool patch!
15 #include <sys/types.h>
20 #include <sys/syslog.h>
22 #include <sys/param.h>
23 #include <sys/errno.h>
25 #include <sys/vnode.h>
26 #include <sundev/mbvar.h>
27 #include <sun/autoconf.h>
28 #include <sun/vddrv.h>
29 #if defined(sun4c) || defined(sun4m)
30 #include <sun/openprom.h>
34 #define IPL_NAME "/dev/ipl"
37 extern int iplattach(), iplopen(), iplclose(), iplioctl(), iplread();
38 extern int nulldev(), iplidentify(), errno;
40 struct cdevsw ipldevsw =
42 iplopen, iplclose, iplread, nulldev,
43 iplioctl, nulldev, nulldev, nulldev,
48 struct dev_ops ipl_ops =
86 VDMAGIC_PSEUDO, /* magic */
89 &ipl_ops, /* dev_ops */
91 NULL, /* struct mb_ctlr *mb_ctlr */
92 NULL, /* struct mb_driver *mb_driver */
93 NULL, /* struct mb_device *mb_device */
98 &ipldevsw, /* cdevsw */
104 extern int vd_unuseddev();
105 extern struct cdevsw cdevsw[];
108 xxxinit(fc, vdp, vdi, vds)
120 while (ipl_major < nchrdev &&
121 cdevsw[ipl_major].d_open != vd_unuseddev)
123 if (ipl_major == nchrdev)
125 vd.Drv_charmajor = ipl_major;
126 vdp->vdd_vdtab = (struct vdlinkage *)&vd;
127 return ipl_attach(vdi);
129 return unload(vdp, vdi);
139 static unload(vdp, vdi)
141 struct vdioctl_unload *vdi;
145 (void) vn_remove(IPL_NAME, UIO_SYSSPACE, FILE);
150 static int ipl_attach(vdi)
151 struct vdioctl_load *vdi;
155 int error = 0, fmode = S_IFCHR|0600;
157 (void) vn_remove(IPL_NAME, UIO_SYSSPACE, FILE);
159 vattr.va_type = MFTOVT(fmode);
160 vattr.va_mode = (fmode & 07777);
161 vattr.va_rdev = ipl_major<<8;
163 error = vn_create(IPL_NAME, UIO_SYSSPACE, &vattr, EXCL, 0, &vp);