mirror of
https://git.FreeBSD.org/ports.git
synced 2024-11-04 22:33:27 +00:00
161 lines
3.7 KiB
Plaintext
161 lines
3.7 KiB
Plaintext
diff -ur --unidirectional-new-file skipsrc-1.0.orig/skip/freebsd/skip_wrapper.c work.new/skip/freebsd/skip_wrapper.c
|
|
--- skipsrc-1.0.orig/skip/freebsd/skip_wrapper.c Fri Oct 25 13:12:43 1996
|
|
+++ work.new/skip/freebsd/skip_wrapper.c Tue Jan 25 16:22:40 2000
|
|
@@ -66,55 +66,113 @@
|
|
#include <skip_es.h>
|
|
#include <skip_if.h>
|
|
|
|
+#define SKIP_CDEV_MAJOR 142
|
|
+#define SKIP_NUM_MINOR 16
|
|
+static struct cdevsw skip_cdevsw = {
|
|
+ /* open */ skip_ifopen,
|
|
+ /* close */ skip_ifclose,
|
|
+ /* read */ skip_ifread,
|
|
+ /* write */ skip_ifwrite,
|
|
+ /* ioctl */ skip_ifioctl,
|
|
+#if __FreeBSD_version < 400011
|
|
+ /* stop */ nullstop,
|
|
+ /* reset */ noreset,
|
|
+ /* devtotty */ nodevtotty,
|
|
+#endif
|
|
+ /* poll */ skip_ifpoll,
|
|
+ /* mmap */ nommap,
|
|
+ /* strategy */ nostrategy,
|
|
+ /* name */ "skip",
|
|
+#if __FreeBSD_version < 400011
|
|
+ /* maj */ NULL
|
|
+#else
|
|
+ /* maj */ SKIP_CDEV_MAJOR,
|
|
+ /* dump */ nodump,
|
|
+ /* psize */ nopsize,
|
|
+ /* flags */ 0,
|
|
+ /* bmaj */ -1
|
|
+#endif
|
|
+};
|
|
|
|
-/*
|
|
- * SunOS 4.1.x loadable driver wrapper for the SKIP module
|
|
- */
|
|
-extern char skip_module_name[];
|
|
+#if __FreeBSD_version < 400011
|
|
+static struct cdevsw *old_dev;
|
|
+static u_long skip_major;
|
|
+static dev_t dev;
|
|
+#else
|
|
+static u_long skip_major = SKIP_CDEV_MAJOR;
|
|
+static dev_t devs[SKIP_NUM_MINOR];
|
|
+#endif
|
|
|
|
/*
|
|
- * Module linkage information for the kernel.
|
|
+ * Handle loading and unloading of the SKIP module.
|
|
*/
|
|
-extern int nulldev();
|
|
-
|
|
-struct cfdriver skipcd=
|
|
- { NULL, "skip", NULL, NULL, DV_DULL, 0 };
|
|
-
|
|
-struct cdevsw skipdevsw = {
|
|
- skip_ifopen, skip_ifclose, skip_ifread, skip_ifwrite, skip_ifioctl,
|
|
- NULL, NULL, NULL, skip_ifselect, NULL, NULL
|
|
-};
|
|
-
|
|
-MOD_DEV("skipmod", LM_DT_CHAR, -1, (void *)&skipdevsw)
|
|
-
|
|
-extern int skip_init(), skip_uninit();
|
|
-
|
|
-/*ARGSUSED*/
|
|
-int
|
|
-skipmod_load(struct lkm_table *lkmtp, int cmd)
|
|
+static int
|
|
+skip_mod_event(module_t mod, int event, void *data)
|
|
{
|
|
-
|
|
- int rc;
|
|
- rc = skip_init();
|
|
- if (rc != 0) {
|
|
- return (rc);
|
|
+ int error = 0;
|
|
+#if __FreeBSD_version >= 400011
|
|
+ int minor;
|
|
+#endif
|
|
+
|
|
+ switch (event) {
|
|
+ case MOD_LOAD:
|
|
+
|
|
+ /* Add character device */
|
|
+#if __FreeBSD_version < 400011
|
|
+ dev = (dev_t)-1;
|
|
+ if ((error = cdevsw_add(&dev, &skip_cdevsw, &old_dev)) != 0) {
|
|
+ log(LOG_ERR, "skip: can't add device\n");
|
|
+ break;
|
|
+ }
|
|
+ skip_major = major(dev);
|
|
+#else
|
|
+ devs[0] = make_dev(&skip_cdevsw, 0,
|
|
+ UID_ROOT, GID_WHEEL, 0644, "skip_key");
|
|
+ for (minor = 1; minor < SKIP_NUM_MINOR; minor++) {
|
|
+ devs[minor] = make_dev(&skip_cdevsw, minor,
|
|
+ UID_ROOT, GID_WHEEL, 0644, "skip%d", minor);
|
|
+ }
|
|
+#endif
|
|
+
|
|
+ /* Initialize SKIP itself */
|
|
+ if ((error = skip_init()) != 0) {
|
|
+ /* XXX should remove char device */
|
|
+ log(LOG_ERR, "skip: init failed\n");
|
|
+ break;
|
|
+ }
|
|
+ log(LOG_INFO, "skip: device major=%lu, driver loaded\n",
|
|
+ skip_major);
|
|
+ break;
|
|
+
|
|
+ case MOD_UNLOAD:
|
|
+
|
|
+ /* Uninitialize SKIP */
|
|
+ if ((error = skip_uninit()) != 0) {
|
|
+ log(LOG_INFO, "skip: uninit failed\n");
|
|
+ break;
|
|
+ }
|
|
+
|
|
+ /* Replace original device driver (if any) */
|
|
+#if __FreeBSD_version < 400011
|
|
+ dev = makedev(skip_major, 0);
|
|
+ (void) cdevsw_add(&dev, old_dev, NULL);
|
|
+#else
|
|
+ for (minor = 0; minor < SKIP_NUM_MINOR; minor++)
|
|
+ destroy_dev(devs[minor]);
|
|
+#endif
|
|
+ break;
|
|
+
|
|
+ default:
|
|
+ error = EOPNOTSUPP;
|
|
+ break;
|
|
}
|
|
- uprintf("skip: driver loaded\n");
|
|
- return (0);
|
|
+ return(error);
|
|
}
|
|
|
|
-skipmod_unload(struct lkm_table *lkmtp, int cmd)
|
|
-{
|
|
-
|
|
- int rc;
|
|
- rc = skip_uninit();
|
|
- if (rc == 0) {
|
|
- uprintf("skip: driver unloaded\n");
|
|
- }
|
|
- return (rc);
|
|
-}
|
|
+static moduledata_t skip_mod = {
|
|
+ "skip",
|
|
+ skip_mod_event,
|
|
+ NULL
|
|
+};
|
|
+DECLARE_MODULE(skip, skip_mod, SI_SUB_PROTO_END, SI_ORDER_MIDDLE);
|
|
|
|
-xxxinit(struct lkm_table *lkmtp, int cmd, int ver)
|
|
-{
|
|
- DISPATCH(lkmtp, cmd, ver, skipmod_load, skipmod_unload, nosys);
|
|
-}
|