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