aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/module.h
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2015-12-11 05:27:53 +0000
committerWarner Losh <imp@FreeBSD.org>2015-12-11 05:27:53 +0000
commitda82615ae25bd0f5c88b665eab0f92cf3514836a (patch)
tree8d671688bd1ce11b1ab51c8a2f74d0caba501123 /sys/sys/module.h
parent9cc0609146c89e0d813f94feb58052f9cbbcea8a (diff)
downloadsrc-da82615ae25bd0f5c88b665eab0f92cf3514836a.tar.gz
src-da82615ae25bd0f5c88b665eab0f92cf3514836a.zip
Create the MDT_PNP_INFO metadata record to communicate PNP info about
modules. External agents may use this data to automatically load those modules. Differential Review: https://reviews.freebsd.org/D3461
Notes
Notes: svn path=/head/; revision=292077
Diffstat (limited to 'sys/sys/module.h')
-rw-r--r--sys/sys/module.h49
1 files changed, 48 insertions, 1 deletions
diff --git a/sys/sys/module.h b/sys/sys/module.h
index 4582bf927cb1..e8e08d42c147 100644
--- a/sys/sys/module.h
+++ b/sys/sys/module.h
@@ -89,10 +89,19 @@ struct mod_version {
struct mod_metadata {
int md_version; /* structure version MDTV_* */
int md_type; /* type of entry MDT_* */
- void *md_data; /* specific data */
+ const void *md_data; /* specific data */
const char *md_cval; /* common string label */
};
+struct mod_pnp_match_info
+{
+ const char *descr; /* Description of the table */
+ const char *bus; /* Name of the bus for this table */
+ const void *table; /* Pointer to pnp table */
+ int entry_len; /* Length of each entry in the table (may be */
+ /* logner than descr descriebs). */
+ int num_entry; /* Number of entries in the table */
+};
#ifdef _KERNEL
#include <sys/linker_set.h>
@@ -155,6 +164,44 @@ struct mod_metadata {
MODULE_METADATA(_##module##_version, MDT_VERSION, \
&_##module##_version, #module)
+/**
+ * Generic macros to create pnp info hints that modules may export
+ * to allow external tools to parse their intenral device tables
+ * to make an informed guess about what driver(s) to load.
+ */
+#define MODULE_PNP_INFO(d, b, unique, t, l, n) \
+ static const struct mod_pnp_match_info _module_pnp_##b##_##unique = { \
+ .descr = d, \
+ .bus = #b, \
+ .table = t, \
+ .entry_len = l, \
+ .num_entry = n \
+ }; \
+ MODULE_METADATA(_md_##b##_pnpinfo_##unique, MDT_PNP_INFO, \
+ &_module_pnp_##b##_##unique, #b);
+/**
+ * descr is a string that describes each entry in the table. The general
+ * form is (TYPE:pnp_name[/pnp_name];)*
+ * where TYPE is one of the following:
+ * U8 uint8_t element
+ * V8 like U8 and 0xff means match any
+ * G16 uint16_t element, any value >= matches
+ * L16 uint16_t element, any value <= matches
+ * M16 uint16_t element, mask of which of the following fields to use.
+ * U16 uint16_t element
+ * V16 like U16 and 0xffff means match any
+ * U32 uint32_t element
+ * V32 like U32 and 0xffffffff means match any
+ * W32 Two 16-bit values with first pnp_name in LSW and second in MSW.
+ * Z pointer to a string to match exactly
+ * D like Z, but is the string passed to device_set_descr()
+ * P A pointer that should be ignored
+ * E EISA PNP Identifier (in binary, but bus publishes string)
+ * K Key for whole table. pnp_name=value. must be last, if present.
+ *
+ * The pnp_name "#" is reserved for other fields that should be ignored.
+ */
+
extern struct sx modules_sx;
#define MOD_XLOCK sx_xlock(&modules_sx)