1 /* $NetBSD: ml_ipl.c,v 1.5 2007/06/04 12:38:58 martti Exp $ */
4 * Copyright (C) 1993-2001 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
9 * 29/12/94 Added code from Marc Huber <huber@fzi.de> to allow it to allocate
10 * its own major char number! Way cool patch!
12 #include <sys/types.h>
17 #include <sys/syslog.h>
19 #include <sys/param.h>
20 #include <sys/errno.h>
22 #include <sys/vnode.h>
23 #include <sundev/mbvar.h>
24 #include <sun/autoconf.h>
25 #include <sun/vddrv.h>
26 #if defined(sun4c) || defined(sun4m)
27 #include <sun/openprom.h>
31 #define IPL_NAME "/dev/ipl"
34 extern int ipfattach(), iplopen(), iplclose(), iplioctl(), iplread();
35 extern int nulldev(), iplidentify(), errno
;
37 struct cdevsw ipldevsw
=
39 iplopen
, iplclose
, iplread
, nulldev
,
40 iplioctl
, nulldev
, nulldev
, nulldev
,
45 struct dev_ops ipl_ops
=
83 VDMAGIC_PSEUDO
, /* magic */
86 &ipl_ops
, /* dev_ops */
88 NULL
, /* struct mb_ctlr *mb_ctlr */
89 NULL
, /* struct mb_driver *mb_driver */
90 NULL
, /* struct mb_device *mb_device */
95 &ipldevsw
, /* cdevsw */
101 extern int vd_unuseddev();
102 extern struct cdevsw cdevsw
[];
105 xxxinit(fc
, vdp
, vdi
, vds
)
117 while (ipl_major
< nchrdev
&&
118 cdevsw
[ipl_major
].d_open
!= vd_unuseddev
)
120 if (ipl_major
== nchrdev
)
122 vd
.Drv_charmajor
= ipl_major
;
123 vdp
->vdd_vdtab
= (struct vdlinkage
*)&vd
;
124 return ipl_attach(vdi
);
126 return unload(vdp
, vdi
);
136 static unload(vdp
, vdi
)
138 struct vdioctl_unload
*vdi
;
142 (void) vn_remove(IPL_NAME
, UIO_SYSSPACE
, FILE);
147 static int ipl_attach(vdi
)
148 struct vdioctl_load
*vdi
;
152 int error
= 0, fmode
= S_IFCHR
|0600;
154 (void) vn_remove(IPL_NAME
, UIO_SYSSPACE
, FILE);
156 vattr
.va_type
= MFTOVT(fmode
);
157 vattr
.va_mode
= (fmode
& 07777);
158 vattr
.va_rdev
= ipl_major
<<8;
160 error
= vn_create(IPL_NAME
, UIO_SYSSPACE
, &vattr
, EXCL
, 0, &vp
);