Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/include/module/header.h need to be fixed.

0001 /*                    The Quest Operating System
0002  *  Copyright (C) 2005-2010  Richard West, Boston University
0003  *
0004  *  This program is free software: you can redistribute it and/or modify
0005  *  it under the terms of the GNU General Public License as published by
0006  *  the Free Software Foundation, either version 3 of the License, or
0007  *  (at your option) any later version.
0008  *
0009  *  This program is distributed in the hope that it will be useful,
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *  GNU General Public License for more details.
0013  *
0014  *  You should have received a copy of the GNU General Public License
0015  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0016  */
0017 
0018 #ifndef _MODULE_HEADER_H_
0019 #define _MODULE_HEADER_H_
0020 
0021 #include "util/stringify.h"
0022 
0023 struct module_ops {
0024   bool (*init) (void);
0025 };
0026 
0027 struct module {
0028   const char *name, *desc;
0029   const struct module_ops *ops;
0030   const u32 num_dependencies;
0031   const char **dependencies;
0032 };
0033 
0034 #define DEF_MODULE(n,d,o,...)                                           \
0035   static const char *_module_##n##_deps[] = __VA_ARGS__;                \
0036   static struct module _module_##n = {                                  \
0037     .name = __stringify(n),                                             \
0038     .desc = d,                                                          \
0039     .num_dependencies = sizeof (_module_##n##_deps) / sizeof (s8 *),    \
0040     .ops = o,                                                           \
0041     .dependencies = _module_##n##_deps                                  \
0042   };                                                                    \
0043   _MODULE_PTR_ATTR const struct module *_module_##n##_ptr = &_module_##n
0044 
0045 #define _MODULE_PTR_ATTR __attribute__((section(".module.ptrs"), unused))
0046 
0047 #endif
0048 
0049 /*
0050  * Local Variables:
0051  * indent-tabs-mode: nil
0052  * mode: C
0053  * c-file-style: "gnu"
0054  * c-basic-offset: 2
0055  * End:
0056  */
0057 
0058 /* vi: set et sw=2 sts=2: */