199767f8919635c4928607450d9e0abb932109ceToomas Soome/*-
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright (c) 1997 Doug Rabson
199767f8919635c4928607450d9e0abb932109ceToomas Soome * All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Redistribution and use in source and binary forms, with or without
199767f8919635c4928607450d9e0abb932109ceToomas Soome * modification, are permitted provided that the following conditions
199767f8919635c4928607450d9e0abb932109ceToomas Soome * are met:
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 1. Redistributions of source code must retain the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 2. Redistributions in binary form must reproduce the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer in the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * documentation and/or other materials provided with the distribution.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
199767f8919635c4928607450d9e0abb932109ceToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
199767f8919635c4928607450d9e0abb932109ceToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
199767f8919635c4928607450d9e0abb932109ceToomas Soome * SUCH DAMAGE.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * $FreeBSD$
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _SYS_MODULE_H_
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _SYS_MODULE_H_
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Module metadata types
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MDT_DEPEND 1 /* argument is a module name */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MDT_MODULE 2 /* module declaration */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MDT_VERSION 3 /* module version(s) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MDT_PNP_INFO 4 /* Plug and play hints record */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MDT_STRUCT_VERSION 1 /* version of metadata structure */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MDT_SETNAME "modmetadata_set"
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef enum modeventtype {
199767f8919635c4928607450d9e0abb932109ceToomas Soome MOD_LOAD,
199767f8919635c4928607450d9e0abb932109ceToomas Soome MOD_UNLOAD,
199767f8919635c4928607450d9e0abb932109ceToomas Soome MOD_SHUTDOWN,
199767f8919635c4928607450d9e0abb932109ceToomas Soome MOD_QUIESCE
199767f8919635c4928607450d9e0abb932109ceToomas Soome} modeventtype_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef struct module *module_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef int (*modeventhand_t)(module_t, int /* modeventtype_t */, void *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Struct for registering modules statically via SYSINIT.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef struct moduledata {
199767f8919635c4928607450d9e0abb932109ceToomas Soome const char *name; /* module name */
199767f8919635c4928607450d9e0abb932109ceToomas Soome modeventhand_t evhand; /* event handler */
199767f8919635c4928607450d9e0abb932109ceToomas Soome void *priv; /* extra data */
199767f8919635c4928607450d9e0abb932109ceToomas Soome} moduledata_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * A module can use this to report module specific data to the user via
199767f8919635c4928607450d9e0abb932109ceToomas Soome * kldstat(2).
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef union modspecific {
199767f8919635c4928607450d9e0abb932109ceToomas Soome int intval;
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int uintval;
199767f8919635c4928607450d9e0abb932109ceToomas Soome long longval;
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_long ulongval;
199767f8919635c4928607450d9e0abb932109ceToomas Soome} modspecific_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Module dependency declaration
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct mod_depend {
199767f8919635c4928607450d9e0abb932109ceToomas Soome int md_ver_minimum;
199767f8919635c4928607450d9e0abb932109ceToomas Soome int md_ver_preferred;
199767f8919635c4928607450d9e0abb932109ceToomas Soome int md_ver_maximum;
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Module version declaration
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct mod_version {
199767f8919635c4928607450d9e0abb932109ceToomas Soome int mv_version;
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct mod_metadata {
199767f8919635c4928607450d9e0abb932109ceToomas Soome int md_version; /* structure version MDTV_* */
199767f8919635c4928607450d9e0abb932109ceToomas Soome int md_type; /* type of entry MDT_* */
199767f8919635c4928607450d9e0abb932109ceToomas Soome const void *md_data; /* specific data */
199767f8919635c4928607450d9e0abb932109ceToomas Soome const char *md_cval; /* common string label */
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct mod_pnp_match_info
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome const char *descr; /* Description of the table */
199767f8919635c4928607450d9e0abb932109ceToomas Soome const char *bus; /* Name of the bus for this table */
199767f8919635c4928607450d9e0abb932109ceToomas Soome const void *table; /* Pointer to pnp table */
199767f8919635c4928607450d9e0abb932109ceToomas Soome int entry_len; /* Length of each entry in the table (may be */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* longer than descr describes). */
199767f8919635c4928607450d9e0abb932109ceToomas Soome int num_entry; /* Number of entries in the table */
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef _KERNEL
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/linker_set.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MODULE_METADATA(uniquifier, type, data, cval) \
199767f8919635c4928607450d9e0abb932109ceToomas Soome static struct mod_metadata _mod_metadata##uniquifier = { \
199767f8919635c4928607450d9e0abb932109ceToomas Soome MDT_STRUCT_VERSION, \
199767f8919635c4928607450d9e0abb932109ceToomas Soome type, \
199767f8919635c4928607450d9e0abb932109ceToomas Soome data, \
199767f8919635c4928607450d9e0abb932109ceToomas Soome cval \
199767f8919635c4928607450d9e0abb932109ceToomas Soome }; \
199767f8919635c4928607450d9e0abb932109ceToomas Soome DATA_SET(modmetadata_set, _mod_metadata##uniquifier)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MODULE_DEPEND(module, mdepend, vmin, vpref, vmax) \
199767f8919635c4928607450d9e0abb932109ceToomas Soome static struct mod_depend _##module##_depend_on_##mdepend \
199767f8919635c4928607450d9e0abb932109ceToomas Soome __section(".data") = { \
199767f8919635c4928607450d9e0abb932109ceToomas Soome vmin, \
199767f8919635c4928607450d9e0abb932109ceToomas Soome vpref, \
199767f8919635c4928607450d9e0abb932109ceToomas Soome vmax \
199767f8919635c4928607450d9e0abb932109ceToomas Soome }; \
199767f8919635c4928607450d9e0abb932109ceToomas Soome MODULE_METADATA(_md_##module##_on_##mdepend, MDT_DEPEND, \
199767f8919635c4928607450d9e0abb932109ceToomas Soome &_##module##_depend_on_##mdepend, #mdepend)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Every kernel has a 'kernel' module with the version set to
199767f8919635c4928607450d9e0abb932109ceToomas Soome * __FreeBSD_version. We embed a MODULE_DEPEND() inside every module
199767f8919635c4928607450d9e0abb932109ceToomas Soome * that depends on the 'kernel' module. It uses the current value of
199767f8919635c4928607450d9e0abb932109ceToomas Soome * __FreeBSD_version as the minimum and preferred versions. For the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * maximum version it rounds the version up to the end of its branch
199767f8919635c4928607450d9e0abb932109ceToomas Soome * (i.e. M99999 for M.x). This allows a module built on M.x to work
199767f8919635c4928607450d9e0abb932109ceToomas Soome * on M.y systems where y >= x, but fail on M.z systems where z < x.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MODULE_KERNEL_MAXVER (roundup(__FreeBSD_version, 100000) - 1)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DECLARE_MODULE_WITH_MAXVER(name, data, sub, order, maxver) \
199767f8919635c4928607450d9e0abb932109ceToomas Soome MODULE_DEPEND(name, kernel, __FreeBSD_version, \
199767f8919635c4928607450d9e0abb932109ceToomas Soome __FreeBSD_version, maxver); \
199767f8919635c4928607450d9e0abb932109ceToomas Soome MODULE_METADATA(_md_##name, MDT_MODULE, &data, #name); \
199767f8919635c4928607450d9e0abb932109ceToomas Soome SYSINIT(name##module, sub, order, module_register_init, &data); \
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct __hack
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DECLARE_MODULE(name, data, sub, order) \
199767f8919635c4928607450d9e0abb932109ceToomas Soome DECLARE_MODULE_WITH_MAXVER(name, data, sub, order, MODULE_KERNEL_MAXVER)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The module declared with DECLARE_MODULE_TIED can only be loaded
199767f8919635c4928607450d9e0abb932109ceToomas Soome * into the kernel with exactly the same __FreeBSD_version.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Use it for modules that use kernel interfaces that are not stable
199767f8919635c4928607450d9e0abb932109ceToomas Soome * even on STABLE/X branches.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DECLARE_MODULE_TIED(name, data, sub, order) \
199767f8919635c4928607450d9e0abb932109ceToomas Soome DECLARE_MODULE_WITH_MAXVER(name, data, sub, order, __FreeBSD_version)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MODULE_VERSION(module, version) \
199767f8919635c4928607450d9e0abb932109ceToomas Soome static struct mod_version _##module##_version \
199767f8919635c4928607450d9e0abb932109ceToomas Soome __section(".data") = { \
199767f8919635c4928607450d9e0abb932109ceToomas Soome version \
199767f8919635c4928607450d9e0abb932109ceToomas Soome }; \
199767f8919635c4928607450d9e0abb932109ceToomas Soome MODULE_METADATA(_##module##_version, MDT_VERSION, \
199767f8919635c4928607450d9e0abb932109ceToomas Soome &_##module##_version, #module)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/**
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Generic macros to create pnp info hints that modules may export
199767f8919635c4928607450d9e0abb932109ceToomas Soome * to allow external tools to parse their intenral device tables
199767f8919635c4928607450d9e0abb932109ceToomas Soome * to make an informed guess about what driver(s) to load.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MODULE_PNP_INFO(d, b, unique, t, l, n) \
199767f8919635c4928607450d9e0abb932109ceToomas Soome static const struct mod_pnp_match_info _module_pnp_##b##_##unique = { \
199767f8919635c4928607450d9e0abb932109ceToomas Soome .descr = d, \
199767f8919635c4928607450d9e0abb932109ceToomas Soome .bus = #b, \
199767f8919635c4928607450d9e0abb932109ceToomas Soome .table = t, \
199767f8919635c4928607450d9e0abb932109ceToomas Soome .entry_len = l, \
199767f8919635c4928607450d9e0abb932109ceToomas Soome .num_entry = n \
199767f8919635c4928607450d9e0abb932109ceToomas Soome }; \
199767f8919635c4928607450d9e0abb932109ceToomas Soome MODULE_METADATA(_md_##b##_pnpinfo_##unique, MDT_PNP_INFO, \
199767f8919635c4928607450d9e0abb932109ceToomas Soome &_module_pnp_##b##_##unique, #b);
199767f8919635c4928607450d9e0abb932109ceToomas Soome/**
199767f8919635c4928607450d9e0abb932109ceToomas Soome * descr is a string that describes each entry in the table. The general
199767f8919635c4928607450d9e0abb932109ceToomas Soome * form is (TYPE:pnp_name[/pnp_name];)*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * where TYPE is one of the following:
199767f8919635c4928607450d9e0abb932109ceToomas Soome * U8 uint8_t element
199767f8919635c4928607450d9e0abb932109ceToomas Soome * V8 like U8 and 0xff means match any
199767f8919635c4928607450d9e0abb932109ceToomas Soome * G16 uint16_t element, any value >= matches
199767f8919635c4928607450d9e0abb932109ceToomas Soome * L16 uint16_t element, any value <= matches
199767f8919635c4928607450d9e0abb932109ceToomas Soome * M16 uint16_t element, mask of which of the following fields to use.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * U16 uint16_t element
199767f8919635c4928607450d9e0abb932109ceToomas Soome * V16 like U16 and 0xffff means match any
199767f8919635c4928607450d9e0abb932109ceToomas Soome * U32 uint32_t element
199767f8919635c4928607450d9e0abb932109ceToomas Soome * V32 like U32 and 0xffffffff means match any
199767f8919635c4928607450d9e0abb932109ceToomas Soome * W32 Two 16-bit values with first pnp_name in LSW and second in MSW.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Z pointer to a string to match exactly
199767f8919635c4928607450d9e0abb932109ceToomas Soome * D like Z, but is the string passed to device_set_descr()
199767f8919635c4928607450d9e0abb932109ceToomas Soome * P A pointer that should be ignored
199767f8919635c4928607450d9e0abb932109ceToomas Soome * E EISA PNP Identifier (in binary, but bus publishes string)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * K Key for whole table. pnp_name=value. must be last, if present.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The pnp_name "#" is reserved for other fields that should be ignored.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomeextern struct sx modules_sx;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MOD_XLOCK sx_xlock(&modules_sx)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MOD_SLOCK sx_slock(&modules_sx)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MOD_XUNLOCK sx_xunlock(&modules_sx)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MOD_SUNLOCK sx_sunlock(&modules_sx)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MOD_LOCK_ASSERT sx_assert(&modules_sx, SX_LOCKED)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MOD_XLOCK_ASSERT sx_assert(&modules_sx, SX_XLOCKED)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct linker_file;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid module_register_init(const void *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint module_register(const struct moduledata *, struct linker_file *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomemodule_t module_lookupbyname(const char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomemodule_t module_lookupbyid(int);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint module_quiesce(module_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid module_reference(module_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid module_release(module_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint module_unload(module_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint module_getid(module_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soomemodule_t module_getfnext(module_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeconst char * module_getname(module_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid module_setspecific(module_t, modspecific_t *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct linker_file *module_file(module_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef MOD_DEBUG
199767f8919635c4928607450d9e0abb932109ceToomas Soomeextern int mod_debug;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MOD_DEBUG_REFS 1
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MOD_DPF(cat, args) do { \
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (mod_debug & MOD_DEBUG_##cat) \
199767f8919635c4928607450d9e0abb932109ceToomas Soome printf(args); \
199767f8919635c4928607450d9e0abb932109ceToomas Soome} while (0)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#else /* !MOD_DEBUG */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MOD_DPF(cat, args)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* _KERNEL */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MAXMODNAME 32
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct module_stat {
199767f8919635c4928607450d9e0abb932109ceToomas Soome int version; /* set to sizeof(struct module_stat) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome char name[MAXMODNAME];
199767f8919635c4928607450d9e0abb932109ceToomas Soome int refs;
199767f8919635c4928607450d9e0abb932109ceToomas Soome int id;
199767f8919635c4928607450d9e0abb932109ceToomas Soome modspecific_t data;
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _KERNEL
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/cdefs.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome__BEGIN_DECLS
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint modnext(int _modid);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint modfnext(int _modid);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint modstat(int _modid, struct module_stat *_stat);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint modfind(const char *_name);
199767f8919635c4928607450d9e0abb932109ceToomas Soome__END_DECLS
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* !_SYS_MODULE_H_ */