| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: module.h,v 1.41 2016/11/16 10:42:14 pgoyette Exp $ */ | | 1 | /* $NetBSD: module.h,v 1.41.14.1 2018/03/10 10:33:02 pgoyette Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -52,59 +52,62 @@ typedef enum modclass { | | | @@ -52,59 +52,62 @@ typedef enum modclass { |
52 | /* Module sources: where did it come from? */ | | 52 | /* Module sources: where did it come from? */ |
53 | typedef enum modsrc { | | 53 | typedef enum modsrc { |
54 | MODULE_SOURCE_KERNEL, | | 54 | MODULE_SOURCE_KERNEL, |
55 | MODULE_SOURCE_BOOT, | | 55 | MODULE_SOURCE_BOOT, |
56 | MODULE_SOURCE_FILESYS | | 56 | MODULE_SOURCE_FILESYS |
57 | } modsrc_t; | | 57 | } modsrc_t; |
58 | | | 58 | |
59 | /* Commands passed to module control routine. */ | | 59 | /* Commands passed to module control routine. */ |
60 | typedef enum modcmd { | | 60 | typedef enum modcmd { |
61 | MODULE_CMD_INIT, /* mandatory */ | | 61 | MODULE_CMD_INIT, /* mandatory */ |
62 | MODULE_CMD_FINI, /* mandatory */ | | 62 | MODULE_CMD_FINI, /* mandatory */ |
63 | MODULE_CMD_STAT, /* optional */ | | 63 | MODULE_CMD_STAT, /* optional */ |
64 | MODULE_CMD_AUTOUNLOAD, /* optional */ | | 64 | MODULE_CMD_AUTOUNLOAD, /* optional */ |
| | | 65 | MODULE_CMD_GETALIASES, /* optional */ |
65 | } modcmd_t; | | 66 | } modcmd_t; |
66 | | | 67 | |
67 | #ifdef _KERNEL | | 68 | #ifdef _KERNEL |
68 | | | 69 | |
69 | #include <sys/kernel.h> | | 70 | #include <sys/kernel.h> |
70 | #include <sys/mutex.h> | | 71 | #include <sys/mutex.h> |
71 | | | 72 | |
72 | #include <prop/proplib.h> | | 73 | #include <prop/proplib.h> |
73 | | | 74 | |
74 | /* Module header structure. */ | | 75 | /* Module header structure. */ |
75 | typedef struct modinfo { | | 76 | typedef struct modinfo { |
76 | u_int mi_version; | | 77 | u_int mi_version; |
77 | modclass_t mi_class; | | 78 | modclass_t mi_class; |
78 | int (*mi_modcmd)(modcmd_t, void *); | | 79 | int (*mi_modcmd)(modcmd_t, void *); |
79 | const char *mi_name; | | 80 | const char *mi_name; |
80 | const char *mi_required; | | 81 | const char *mi_required; |
| | | 82 | const char *mi_aliases; |
81 | } const modinfo_t; | | 83 | } const modinfo_t; |
82 | | | 84 | |
83 | /* Per module information, maintained by kern_module.c */ | | 85 | /* Per module information, maintained by kern_module.c */ |
84 | typedef struct module { | | 86 | typedef struct module { |
85 | u_int mod_refcnt; | | 87 | u_int mod_refcnt; |
86 | const modinfo_t *mod_info; | | 88 | const modinfo_t *mod_info; |
87 | struct kobj *mod_kobj; | | 89 | struct kobj *mod_kobj; |
88 | TAILQ_ENTRY(module) mod_chain; | | 90 | TAILQ_ENTRY(module) mod_chain; |
89 | struct module *mod_required[MAXMODDEPS]; | | 91 | struct module *mod_required[MAXMODDEPS]; |
90 | u_int mod_nrequired; | | 92 | u_int mod_nrequired; |
91 | modsrc_t mod_source; | | 93 | modsrc_t mod_source; |
92 | time_t mod_autotime; | | 94 | time_t mod_autotime; |
93 | void *mod_ctf; | | 95 | void *mod_ctf; |
94 | u_int mod_fbtentries; /* DTrace FBT entry count */ | | 96 | u_int mod_fbtentries; /* DTrace FBT entry count */ |
95 | int mod_flags; | | 97 | int mod_flags; |
96 | #define MODFLG_MUST_FORCE 0x01 | | 98 | #define MODFLG_MUST_FORCE 0x01 |
97 | #define MODFLG_AUTO_LOADED 0x02 | | 99 | #define MODFLG_AUTO_LOADED 0x02 |
| | | 100 | #define MODFLG_IS_ALIAS 0x04 /* only for export via modstat_t */ |
98 | | | 101 | |
99 | } module_t; | | 102 | } module_t; |
100 | | | 103 | |
101 | /* | | 104 | /* |
102 | * Per-module linkage. Loadable modules have a `link_set_modules' section | | 105 | * Per-module linkage. Loadable modules have a `link_set_modules' section |
103 | * containing only one entry, pointing to the module's modinfo_t record. | | 106 | * containing only one entry, pointing to the module's modinfo_t record. |
104 | * For the kernel, `link_set_modules' can contain multiple entries and | | 107 | * For the kernel, `link_set_modules' can contain multiple entries and |
105 | * records all modules built into the kernel at link time. | | 108 | * records all modules built into the kernel at link time. |
106 | * | | 109 | * |
107 | * Alternatively, in some environments rump kernels use | | 110 | * Alternatively, in some environments rump kernels use |
108 | * __attribute__((constructor)) due to link sets being | | 111 | * __attribute__((constructor)) due to link sets being |
109 | * difficult (impossible?) to implement (e.g. GNU gold, OS X, etc.) | | 112 | * difficult (impossible?) to implement (e.g. GNU gold, OS X, etc.) |
110 | * If we're cold (read: rump_init() has not been called), we lob the | | 113 | * If we're cold (read: rump_init() has not been called), we lob the |