1 | /* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Module.h,v 1.37 2003/08/24 17:36:54 dawes Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
|
---|
5 | *
|
---|
6 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
7 | * copy of this software and associated documentation files (the "Software"),
|
---|
8 | * to deal in the Software without restriction, including without limitation
|
---|
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
10 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
11 | * Software is furnished to do so, subject to the following conditions:
|
---|
12 | *
|
---|
13 | * The above copyright notice and this permission notice shall be included in
|
---|
14 | * all copies or substantial portions of the Software.
|
---|
15 | *
|
---|
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
---|
20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
---|
21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
22 | * OTHER DEALINGS IN THE SOFTWARE.
|
---|
23 | *
|
---|
24 | * Except as contained in this notice, the name of the copyright holder(s)
|
---|
25 | * and author(s) shall not be used in advertising or otherwise to promote
|
---|
26 | * the sale, use or other dealings in this Software without prior written
|
---|
27 | * authorization from the copyright holder(s) and author(s).
|
---|
28 | */
|
---|
29 |
|
---|
30 | /*
|
---|
31 | * This file contains the parts of the loader interface that are visible
|
---|
32 | * to modules. This is the only loader-related header that modules should
|
---|
33 | * include.
|
---|
34 | *
|
---|
35 | * It should include a bare minimum of other headers.
|
---|
36 | *
|
---|
37 | * Longer term, the module/loader code should probably live directly under
|
---|
38 | * Xserver/.
|
---|
39 | *
|
---|
40 | * XXX This file arguably belongs in xfree86/loader/.
|
---|
41 | */
|
---|
42 |
|
---|
43 | #ifndef _XF86MODULE_H
|
---|
44 | #define _XF86MODULE_H
|
---|
45 |
|
---|
46 | #include "misc.h"
|
---|
47 | #include "xf86Version.h"
|
---|
48 | #ifndef NULL
|
---|
49 | #define NULL ((void *)0)
|
---|
50 | #endif
|
---|
51 |
|
---|
52 | typedef enum {
|
---|
53 | LD_RESOLV_IFDONE = 0, /* only check if no more
|
---|
54 | delays pending */
|
---|
55 | LD_RESOLV_NOW = 1, /* finish one delay step */
|
---|
56 | LD_RESOLV_FORCE = 2 /* force checking... */
|
---|
57 | } LoaderResolveOptions;
|
---|
58 |
|
---|
59 | #define DEFAULT_LIST ((char *)-1)
|
---|
60 |
|
---|
61 | /* This indicates a special module that doesn't have the usual entry point */
|
---|
62 | #define EXTERN_MODULE ((pointer)-1)
|
---|
63 |
|
---|
64 | /* Built-in ABI classes. These definitions must not be changed. */
|
---|
65 | #define ABI_CLASS_NONE NULL
|
---|
66 | #define ABI_CLASS_ANSIC "X.Org ANSI C Emulation"
|
---|
67 | #define ABI_CLASS_VIDEODRV "X.Org Video Driver"
|
---|
68 | #define ABI_CLASS_XINPUT "X.Org XInput driver"
|
---|
69 | #define ABI_CLASS_EXTENSION "X.Org Server Extension"
|
---|
70 | #define ABI_CLASS_FONT "X.Org Font Renderer"
|
---|
71 |
|
---|
72 | #define ABI_MINOR_MASK 0x0000FFFF
|
---|
73 | #define ABI_MAJOR_MASK 0xFFFF0000
|
---|
74 | #define GET_ABI_MINOR(v) ((v) & ABI_MINOR_MASK)
|
---|
75 | #define GET_ABI_MAJOR(v) (((v) & ABI_MAJOR_MASK) >> 16)
|
---|
76 | #define SET_ABI_VERSION(maj, min) \
|
---|
77 | ((((maj) << 16) & ABI_MAJOR_MASK) | ((min) & ABI_MINOR_MASK))
|
---|
78 |
|
---|
79 | /*
|
---|
80 | * ABI versions. Each version has a major and minor revision. Modules
|
---|
81 | * using lower minor revisions must work with servers of a higher minor
|
---|
82 | * revision. There is no compatibility between different major revisions.
|
---|
83 | * Whenever the ABI_ANSIC_VERSION is changed, the others must also be
|
---|
84 | * changed. The minor revision mask is 0x0000FFFF and the major revision
|
---|
85 | * mask is 0xFFFF0000.
|
---|
86 | */
|
---|
87 | #define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 2)
|
---|
88 | #define ABI_VIDEODRV_VERSION SET_ABI_VERSION(0, 8)
|
---|
89 | #define ABI_XINPUT_VERSION SET_ABI_VERSION(0, 5)
|
---|
90 | #define ABI_EXTENSION_VERSION SET_ABI_VERSION(0, 2)
|
---|
91 | #define ABI_FONT_VERSION SET_ABI_VERSION(0, 4)
|
---|
92 |
|
---|
93 | #define MODINFOSTRING1 0xef23fdc5
|
---|
94 | #define MODINFOSTRING2 0x10dc023a
|
---|
95 |
|
---|
96 | #ifndef MODULEVENDORSTRING
|
---|
97 | #ifndef __OS2ELF__
|
---|
98 | #define MODULEVENDORSTRING "X.Org Foundation"
|
---|
99 | #else
|
---|
100 | #define MODULEVENDORSTRING "X.Org Foundation - OS2"
|
---|
101 | #endif
|
---|
102 | #endif
|
---|
103 |
|
---|
104 | /* Error return codes for errmaj. New codes must only be added at the end. */
|
---|
105 | typedef enum {
|
---|
106 | LDR_NOERROR = 0,
|
---|
107 | LDR_NOMEM, /* memory allocation failed */
|
---|
108 | LDR_NOENT, /* Module file does not exist */
|
---|
109 | LDR_NOSUBENT, /* pre-requsite file to be sub-loaded does not exist */
|
---|
110 | LDR_NOSPACE, /* internal module array full */
|
---|
111 | LDR_NOMODOPEN, /* module file could not be opened (check errmin) */
|
---|
112 | LDR_UNKTYPE, /* file is not a recognized module type */
|
---|
113 | LDR_NOLOAD, /* type specific loader failed */
|
---|
114 | LDR_ONCEONLY, /* Module should only be loaded once (not an error) */
|
---|
115 | LDR_NOPORTOPEN, /* could not open port (check errmin) */
|
---|
116 | LDR_NOHARDWARE, /* could not query/initialize the hardware device */
|
---|
117 | LDR_MISMATCH, /* the module didn't match the spec'd requirments */
|
---|
118 | LDR_BADUSAGE, /* LoadModule is called with bad arguments */
|
---|
119 | LDR_INVALID, /* The module doesn't have a valid ModuleData object */
|
---|
120 | LDR_BADOS, /* The module doesn't support the OS */
|
---|
121 | LDR_MODSPECIFIC /* A module-specific error in the SetupProc */
|
---|
122 | } LoaderErrorCode;
|
---|
123 |
|
---|
124 | /*
|
---|
125 | * Some common module classes. The moduleclass can be used to identify
|
---|
126 | * that modules loaded are of the correct type. This is a finer
|
---|
127 | * classification than the ABI classes even though the default set of
|
---|
128 | * classes have the same names. For example, not all modules that require
|
---|
129 | * the video driver ABI are themselves video drivers.
|
---|
130 | */
|
---|
131 | #define MOD_CLASS_NONE NULL
|
---|
132 | #define MOD_CLASS_VIDEODRV "X.Org Video Driver"
|
---|
133 | #define MOD_CLASS_XINPUT "X.Org XInput Driver"
|
---|
134 | #define MOD_CLASS_FONT "X.Org Font Renderer"
|
---|
135 | #define MOD_CLASS_EXTENSION "X.Org Server Extension"
|
---|
136 |
|
---|
137 | /* This structure is expected to be returned by the initfunc */
|
---|
138 | typedef struct {
|
---|
139 | const char * modname; /* name of module, e.g. "foo" */
|
---|
140 | const char * vendor; /* vendor specific string */
|
---|
141 | CARD32 _modinfo1_; /* constant MODINFOSTRING1/2 to find */
|
---|
142 | CARD32 _modinfo2_; /* infoarea with a binary editor or sign tool */
|
---|
143 | CARD32 xf86version; /* contains XF86_VERSION_CURRENT */
|
---|
144 | CARD8 majorversion; /* module-specific major version */
|
---|
145 | CARD8 minorversion; /* module-specific minor version */
|
---|
146 | CARD16 patchlevel; /* module-specific patch level */
|
---|
147 | const char * abiclass; /* ABI class that the module uses */
|
---|
148 | CARD32 abiversion; /* ABI version */
|
---|
149 | const char * moduleclass; /* module class description */
|
---|
150 | CARD32 checksum[4]; /* contains a digital signature of the */
|
---|
151 | /* version info structure */
|
---|
152 | } XF86ModuleVersionInfo;
|
---|
153 |
|
---|
154 | /*
|
---|
155 | * This structure can be used to callers of LoadModule and LoadSubModule to
|
---|
156 | * specify version and/or ABI requirements.
|
---|
157 | */
|
---|
158 | typedef struct {
|
---|
159 | CARD8 majorversion; /* module-specific major version */
|
---|
160 | CARD8 minorversion; /* moudle-specific minor version */
|
---|
161 | CARD16 patchlevel; /* module-specific patch level */
|
---|
162 | const char * abiclass; /* ABI class that the module uses */
|
---|
163 | CARD32 abiversion; /* ABI version */
|
---|
164 | const char * moduleclass; /* module class */
|
---|
165 | } XF86ModReqInfo;
|
---|
166 |
|
---|
167 | /* values to indicate unspecified fields in XF86ModReqInfo. */
|
---|
168 | #define MAJOR_UNSPEC 0xFF
|
---|
169 | #define MINOR_UNSPEC 0xFF
|
---|
170 | #define PATCH_UNSPEC 0xFFFF
|
---|
171 | #define ABI_VERS_UNSPEC 0xFFFFFFFF
|
---|
172 |
|
---|
173 | #define MODULE_VERSION_NUMERIC(maj, min, patch) \
|
---|
174 | ((((maj) & 0xFF) << 24) | (((min) & 0xFF) << 16) | (patch & 0xFFFF))
|
---|
175 | #define GET_MODULE_MAJOR_VERSION(vers) (((vers) >> 24) & 0xFF)
|
---|
176 | #define GET_MODULE_MINOR_VERSION(vers) (((vers) >> 16) & 0xFF)
|
---|
177 | #define GET_MODULE_PATCHLEVEL(vers) ((vers) & 0xFFFF)
|
---|
178 |
|
---|
179 | #define INITARGS void
|
---|
180 |
|
---|
181 | typedef void (*InitExtension)(INITARGS);
|
---|
182 |
|
---|
183 | typedef struct {
|
---|
184 | InitExtension initFunc;
|
---|
185 | const char * name;
|
---|
186 | Bool *disablePtr;
|
---|
187 | InitExtension setupFunc;
|
---|
188 | const char ** initDependencies;
|
---|
189 | } ExtensionModule;
|
---|
190 |
|
---|
191 | extern ExtensionModule *ExtensionModuleList;
|
---|
192 |
|
---|
193 | /* Prototypes for Loader functions that are exported to modules */
|
---|
194 | #ifndef IN_LOADER
|
---|
195 | /* Prototypes with opaque pointers for use by modules */
|
---|
196 | pointer LoadSubModule(pointer, const char *, const char **,
|
---|
197 | const char **, pointer, const XF86ModReqInfo *,
|
---|
198 | int *, int *);
|
---|
199 | void UnloadSubModule(pointer);
|
---|
200 | void LoadFont(pointer);
|
---|
201 | void UnloadModule (pointer);
|
---|
202 | #endif
|
---|
203 | pointer LoaderSymbol(const char *);
|
---|
204 | char **LoaderListDirs(const char **, const char **);
|
---|
205 | void LoaderFreeDirList(char **);
|
---|
206 | void LoaderErrorMsg(const char *, const char *, int, int);
|
---|
207 | void LoadExtension(ExtensionModule *, Bool);
|
---|
208 | void LoaderRefSymLists(const char **, ...);
|
---|
209 | void LoaderRefSymbols(const char *, ...);
|
---|
210 | void LoaderReqSymLists(const char **, ...);
|
---|
211 | void LoaderReqSymbols(const char *, ...);
|
---|
212 | int LoaderCheckUnresolved(int);
|
---|
213 | void LoaderGetOS(const char **name, int *major, int *minor, int *teeny);
|
---|
214 |
|
---|
215 | typedef pointer (*ModuleSetupProc)(pointer, pointer, int *, int *);
|
---|
216 | typedef void (*ModuleTearDownProc)(pointer);
|
---|
217 | #define MODULESETUPPROTO(func) pointer func(pointer, pointer, int*, int*)
|
---|
218 | #define MODULETEARDOWNPROTO(func) void func(pointer)
|
---|
219 |
|
---|
220 | typedef struct {
|
---|
221 | XF86ModuleVersionInfo * vers;
|
---|
222 | ModuleSetupProc setup;
|
---|
223 | ModuleTearDownProc teardown;
|
---|
224 | } XF86ModuleData;
|
---|
225 |
|
---|
226 | #endif /* _XF86STR_H */
|
---|