diff options
| author | pgoyette <pgoyette@NetBSD.org> | 2019-02-03 08:02:24 +0000 |
|---|---|---|
| committer | pgoyette <pgoyette@NetBSD.org> | 2019-02-03 08:02:24 +0000 |
| commit | 5e3f9e6095afc1847e1f17ceaff08b8f6dc390e5 (patch) | |
| tree | bc60a62796bd6e08efca8762a56f70521c42b7c0 /sys/dev/raidframe | |
| parent | 005cb03434d044d7e2838cd337b4285a61b495a7 (diff) | |
Don't include the raidframe compat code in the main raid module, the
compat code lives in their own compat_raid_xx modules, which will now
be autoloaded if needed.
While here, extract the compat_netbsd32_raid code into its own module,
too.
Welcome to 8.99.34
Diffstat (limited to 'sys/dev/raidframe')
| -rw-r--r-- | sys/dev/raidframe/rf_compat32.c | 38 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_compat50.c | 6 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_compat50_mod.h | 5 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_compat80.c | 6 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_compat80_mod.h | 5 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_netbsdkintf.c | 39 |
6 files changed, 61 insertions, 38 deletions
diff --git a/sys/dev/raidframe/rf_compat32.c b/sys/dev/raidframe/rf_compat32.c index b1c1ff7546d..e52e52989ff 100644 --- a/sys/dev/raidframe/rf_compat32.c +++ b/sys/dev/raidframe/rf_compat32.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_compat32.c,v 1.1 2018/01/18 00:32:49 mrg Exp $ */ +/* $NetBSD: rf_compat32.c,v 1.2 2019/02/03 08:02:24 pgoyette Exp $ */ /* * Copyright (c) 2017 Matthew R. Green @@ -31,6 +31,8 @@ #include <sys/types.h> #include <sys/param.h> #include <sys/systm.h> +#include <sys/module.h> +#include <sys/compat_stub.h> #include <dev/raidframe/raidframeio.h> #include <dev/raidframe/raidframevar.h> @@ -113,3 +115,37 @@ rf_config_netbsd32(void *data, RF_Config_t *k_cfg) RF_Free(cfg32, sizeof(RF_Config_t32)); return rv; } + +static void +raidframe_netbsd32_init(void) +{ + + MODULE_SET_HOOK(raidframe_netbsd32_config_hook, "raid32", + rf_config_netbsd32); +} + +static void +raidframe_netbsd32_fini(void) +{ + + MODULE_UNSET_HOOK(raidframe_netbsd32_config_hook); +} + +MODULE(MODULE_CLASS_EXEC, compat_netbsd32_raid, "raid,compat_netbsd32"); + +static int +compat_netbsd32_raid_modcmd(modcmd_t cmd, void *arg) +{ + + switch (cmd) { + case MODULE_CMD_INIT: + raidframe_netbsd32_init(); + return 0; + case MODULE_CMD_FINI: + raidframe_netbsd32_fini(); + return 0; + default: + return ENOTTY; + } +} + diff --git a/sys/dev/raidframe/rf_compat50.c b/sys/dev/raidframe/rf_compat50.c index dc38fc496f5..da993194328 100644 --- a/sys/dev/raidframe/rf_compat50.c +++ b/sys/dev/raidframe/rf_compat50.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_compat50.c,v 1.6 2019/01/31 12:31:50 christos Exp $ */ +/* $NetBSD: rf_compat50.c,v 1.7 2019/02/03 08:02:24 pgoyette Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -240,14 +240,14 @@ raidframe_ioctl_50(u_long cmd, int initted, RF_Raid_t *raidPtr, int unit, return EPASSTHROUGH; } -void +static void raidframe_50_init(void) { MODULE_SET_HOOK(raidframe_ioctl_50_hook, "raid50", raidframe_ioctl_50); } -void +static void raidframe_50_fini(void) { diff --git a/sys/dev/raidframe/rf_compat50_mod.h b/sys/dev/raidframe/rf_compat50_mod.h index 090cf224c3b..5a5c9336a69 100644 --- a/sys/dev/raidframe/rf_compat50_mod.h +++ b/sys/dev/raidframe/rf_compat50_mod.h @@ -1,4 +1,4 @@ -/* $NetBSD: rf_compat50_mod.h,v 1.3 2019/01/31 12:31:50 christos Exp $ */ +/* $NetBSD: rf_compat50_mod.h,v 1.4 2019/02/03 08:02:24 pgoyette Exp $ */ /*- @@ -33,9 +33,6 @@ #ifndef _RF_COMPAT50_MOD_H_ #define _RF_COMPAT50_MOD_H_ -void raidframe_50_fini(void); -void raidframe_50_init(void); - int raidframe_ioctl_50(u_long, int, RF_Raid_t *, int, void *, RF_Config_t **); #endif /* _RF_COMPAT50_MOD_H_ */ diff --git a/sys/dev/raidframe/rf_compat80.c b/sys/dev/raidframe/rf_compat80.c index b7fad134f94..aeaec3d437e 100644 --- a/sys/dev/raidframe/rf_compat80.c +++ b/sys/dev/raidframe/rf_compat80.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_compat80.c,v 1.7 2019/01/31 12:31:50 christos Exp $ */ +/* $NetBSD: rf_compat80.c,v 1.8 2019/02/03 08:02:24 pgoyette Exp $ */ /* * Copyright (c) 2017 Matthew R. Green @@ -265,14 +265,14 @@ raidframe_ioctl_80(u_long cmd, int initted, RF_Raid_t *raidPtr, int unit, return EPASSTHROUGH; } -void +static void raidframe_80_init(void) { MODULE_SET_HOOK(raidframe_ioctl_80_hook, "raid80", raidframe_ioctl_80); } -void +static void raidframe_80_fini(void) { diff --git a/sys/dev/raidframe/rf_compat80_mod.h b/sys/dev/raidframe/rf_compat80_mod.h index 853fbf5b383..5a6d60dfef6 100644 --- a/sys/dev/raidframe/rf_compat80_mod.h +++ b/sys/dev/raidframe/rf_compat80_mod.h @@ -1,4 +1,4 @@ -/* $NetBSD: rf_compat80_mod.h,v 1.3 2019/01/31 12:31:50 christos Exp $ */ +/* $NetBSD: rf_compat80_mod.h,v 1.4 2019/02/03 08:02:24 pgoyette Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -38,7 +38,4 @@ struct RF_Config_s; int raidframe_ioctl_80(u_long, int, struct RF_Raid_s *, int, void *, struct RF_Config_s **); -void raidframe_80_init(void); -void raidframe_80_fini(void); - #endif /* _RF_COMPAT80_MOD_H_ */ diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c index 115041204ff..135828b737d 100644 --- a/sys/dev/raidframe/rf_netbsdkintf.c +++ b/sys/dev/raidframe/rf_netbsdkintf.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_netbsdkintf.c,v 1.360 2019/01/29 09:28:50 pgoyette Exp $ */ +/* $NetBSD: rf_netbsdkintf.c,v 1.361 2019/02/03 08:02:24 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc. @@ -101,11 +101,9 @@ ***********************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.360 2019/01/29 09:28:50 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.361 2019/02/03 08:02:24 pgoyette Exp $"); #ifdef _KERNEL_OPT -#include "opt_compat_netbsd.h" -#include "opt_compat_netbsd32.h" #include "opt_raid_autoconfig.h" #endif @@ -150,11 +148,12 @@ __KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.360 2019/01/29 09:28:50 pgoyett #include "rf_parityscan.h" #include "rf_threadstuff.h" -#include "rf_compat50.h" - #include "rf_compat80.h" -#ifdef COMPAT_NETBSD32 +#ifdef _LP64 +#ifndef COMPAT_NETBSD32 +#define COMPAT_NETBSD32 +#endif #include "rf_compat32.h" #endif @@ -1113,11 +1112,9 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) case RAIDFRAME_PARITYMAP_GET_DISABLE: case RAIDFRAME_PARITYMAP_SET_DISABLE: case RAIDFRAME_PARITYMAP_SET_PARAMS: -#ifdef COMPAT_NETBSD32 #ifdef _LP64 case RAIDFRAME_GET_INFO32: #endif -#endif if ((rs->sc_flags & RAIDF_INITED) == 0) return (ENXIO); } @@ -1132,6 +1129,7 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) * * If compat code returns EAGAIN, we need to finish via config * * Otherwise the cmd has been handled and we just return */ + module_autoload("compat_raid_50", MODULE_CLASS_EXEC); MODULE_CALL_HOOK(raidframe_ioctl_50_hook, (cmd, (rs->sc_flags & RAIDF_INITED),raidPtr, unit, data, &k_cfg), enosys(), retcode); @@ -1142,6 +1140,7 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) else if (retcode != EPASSTHROUGH) return retcode; + module_autoload("compat_raid_80", MODULE_CLASS_EXEC); MODULE_CALL_HOOK(raidframe_ioctl_80_hook, (cmd, (rs->sc_flags & RAIDF_INITED),raidPtr, unit, data, &k_cfg), enosys(), retcode); @@ -1163,11 +1162,9 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) /* configure the system */ case RAIDFRAME_CONFIGURE: -#ifdef COMPAT_NETBSD32 #ifdef _LP64 case RAIDFRAME_CONFIGURE32: #endif -#endif if (raidPtr->valid) { /* There is a valid RAID set running on this unit! */ @@ -1182,14 +1179,13 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) if (k_cfg == NULL) { return (ENOMEM); } -#ifdef COMPAT_NETBSD32 #ifdef _LP64 if (cmd == RAIDFRAME_CONFIGURE32 && (l->l_proc->p_flag & PK_32) != 0) - retcode = rf_config_netbsd32(data, k_cfg); + MODULE_CALL_HOOK(raidframe_netbsd32_config_hook, + (data, k_cfg), enosys(), retcode); else #endif -#endif { u_cfg = *((RF_Config_t **) data); retcode = copyin(u_cfg, k_cfg, sizeof(RF_Config_t)); @@ -1321,7 +1317,7 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) printf("raid%d: Num Columns: %d\n", raidid, clabel->num_columns); printf("raid%d: Clean: %d\n", raidid, clabel->clean); printf("raid%d: Status: %d\n", raidid, clabel->status); -#endif +#endif /* DEBUG */ clabel->row = 0; column = clabel->column; @@ -1337,7 +1333,7 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) clabel, sizeof(*clabel)); raidflush_component_label(raidPtr, column); return (0); -#endif +#endif /* 0 */ case RAIDFRAME_INIT_LABELS: clabel = (RF_ComponentLabel_t *) data; @@ -1491,24 +1487,21 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) return(retcode); case RAIDFRAME_GET_INFO: -#ifdef COMPAT_NETBSD32 #ifdef _LP64 case RAIDFRAME_GET_INFO32: -#endif -#endif +#endif /* LP64 */ RF_Malloc(d_cfg, sizeof(RF_DeviceConfig_t), (RF_DeviceConfig_t *)); if (d_cfg == NULL) return (ENOMEM); retcode = rf_get_info(raidPtr, d_cfg); if (retcode == 0) { -#ifdef COMPAT_NETBSD32 #ifdef _LP64 - if (cmd == RAIDFRAME_GET_INFO32) + if (raidframe_netbsd32_config_hook.hooked && + cmd == RAIDFRAME_GET_INFO32) ucfgp = NETBSD32PTR64(*(netbsd32_pointer_t *)data); else -#endif -#endif +#endif /* _LP64 */ ucfgp = *(RF_DeviceConfig_t **)data; retcode = copyout(d_cfg, ucfgp, sizeof(RF_DeviceConfig_t)); } |
