aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/module.h
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2000-04-29 13:19:31 +0000
committerPeter Wemm <peter@FreeBSD.org>2000-04-29 13:19:31 +0000
commit54823af2565dc332ccd7f75ee16c4d13d3ceac0b (patch)
treed016e627e55254c6614f1a89e03e480119f0615f /sys/sys/module.h
parent18616dacbb251027e93797e1c8232b09f8582de4 (diff)
downloadsrc-54823af2565dc332ccd7f75ee16c4d13d3ceac0b.tar.gz
src-54823af2565dc332ccd7f75ee16c4d13d3ceac0b.zip
First round implementation of a fine grain enhanced module to module
version dependency system. This isn't quite finished, but it is at a useful stage to do a functional checkpoint. Highlights: - version and dependency metadata is gathered via linker sets, so things are handled the same for static kernels and code built to live in a kld. - The dependencies are at module level (versus at file level). - Dependencies determine kld symbol search order - this means that you cannot link against symbols in another file unless you depend on it. This is so that you cannot accidently unload the target out from underneath the ones referencing it. - It is flexible enough that we can put tags in #include files and macros so that we can get decent hooks for enforcing recompiles on incompatable ABI changes. eg: if we change struct proc, we could force a recompile for all kld's that reference the proc struct. - Tangled dependency references at boot time are sorted. Files are relocated once all their dependencies are already relocated. Caveats: - Loader support is incomplete, but has been worked on seperately. - Actual enforcement of the version number tags is not active yet - just the module dependencies are live. The actual structure of versioning hasn't been agreed on yet. (eg: major.minor, or whatever) - There is some backwards compatability for old modules without metadata but I'm not sure how good it is. This is based on work originally done by Boris Popov (bp@freebsd.org), but I'm not sure he'd recognize much of it now. Don't blame him. :-) Also, ideas have been borrowed from Mike Smith.
Notes
Notes: svn path=/head/; revision=59751
Diffstat (limited to 'sys/sys/module.h')
-rw-r--r--sys/sys/module.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/sys/sys/module.h b/sys/sys/module.h
index 800f45aa4195..e5f0547b56d8 100644
--- a/sys/sys/module.h
+++ b/sys/sys/module.h
@@ -29,6 +29,17 @@
#ifndef _SYS_MODULE_H_
#define _SYS_MODULE_H_
+/*
+ * Module metadata types
+ */
+#define MDT_DEPEND 1 /* argument is a module name */
+#define MDT_MODULE 2 /* module declaration */
+#define MDT_VERSION 3 /* module version(s) */
+
+#define MDT_STRUCT_VERSION 1 /* version of metadata structure */
+
+#define MDT_SETNAME "modmetadata_set"
+
typedef enum modeventtype {
MOD_LOAD,
MOD_UNLOAD,
@@ -60,12 +71,63 @@ typedef union modspecific {
u_long ulongval;
} modspecific_t;
+/*
+ * Module dependency declarartion
+ */
+struct mod_depend {
+ int md_ver_minimum;
+ int md_ver_preferred;
+ int md_ver_maximum;
+};
+
+/*
+ * Module version declaration
+ */
+struct mod_version {
+ int mv_version;
+};
+
+struct mod_metadata {
+ int md_version; /* structure version MDTV_* */
+ int md_type; /* type of entry MDT_* */
+ void *md_data; /* specific data */
+ char *md_cval; /* common string label */
+};
+
#ifdef _KERNEL
+#include <sys/linker_set.h>
+
+#define MODULE_METADATA(uniquifier, type, data, cval) \
+ static struct mod_metadata _mod_metadata ## uniquifier = { \
+ MDT_STRUCT_VERSION, \
+ type, \
+ data, \
+ cval \
+ }; \
+ DATA_SET(modmetadata_set, _mod_metadata ## uniquifier)
+
+#define MODULE_DEPEND(module, mdepend, vmin, vpref, vmax) \
+ static struct mod_depend _ ##module ## _depend_on_ ## mdepend = { \
+ vmin, \
+ vpref, \
+ vmax \
+ }; \
+ MODULE_METADATA(_md_ ##module ## _on_ ##mdepend, MDT_DEPEND, \
+ &_ ##module ## _depend_on_ ##mdepend, #mdepend)
+
#define DECLARE_MODULE(name, data, sub, order) \
+ MODULE_METADATA(_md_ ##name, MDT_MODULE, &data, #name); \
SYSINIT(name##module, sub, order, module_register_init, &data) \
struct __hack
+#define MODULE_VERSION(module, version) \
+ static struct mod_version _ ## module ## _version = { \
+ version \
+ }; \
+ MODULE_METADATA(_ ## module ## _version, MDT_VERSION, \
+ & _ ## module ## _version, #module)
+
void module_register_init(const void *data);
struct linker_file;
int module_register(const struct moduledata *data, struct linker_file *lf);