2007-02-23 19:19:53 +01:00
|
|
|
/***********************************************************
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
|
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#ifndef PRIVATES_H
|
|
|
|
#define PRIVATES_H 1
|
|
|
|
|
2010-04-27 02:22:21 +02:00
|
|
|
#include <X11/Xdefs.h>
|
|
|
|
#include <X11/Xosdefs.h>
|
|
|
|
#include <X11/Xfuncproto.h>
|
|
|
|
#include "misc.h"
|
2007-02-23 19:19:53 +01:00
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
* STUFF FOR PRIVATES
|
|
|
|
*****************************************************************/
|
|
|
|
|
2010-04-27 02:22:21 +02:00
|
|
|
typedef struct _Private PrivateRec, *PrivatePtr;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
/* XSELinux uses the same private keys for numerous objects */
|
|
|
|
PRIVATE_XSELINUX,
|
|
|
|
|
|
|
|
/* Otherwise, you get a private in just the requested structure
|
|
|
|
*/
|
|
|
|
/* These can have objects created before all of the keys are registered */
|
|
|
|
PRIVATE_SCREEN,
|
|
|
|
PRIVATE_EXTENSION,
|
|
|
|
PRIVATE_COLORMAP,
|
|
|
|
|
|
|
|
/* These cannot have any objects before all relevant keys are registered */
|
|
|
|
PRIVATE_DEVICE,
|
|
|
|
PRIVATE_CLIENT,
|
|
|
|
PRIVATE_PROPERTY,
|
|
|
|
PRIVATE_SELECTION,
|
|
|
|
PRIVATE_WINDOW,
|
|
|
|
PRIVATE_PIXMAP,
|
|
|
|
PRIVATE_GC,
|
|
|
|
PRIVATE_CURSOR,
|
|
|
|
PRIVATE_CURSOR_BITS,
|
|
|
|
|
|
|
|
/* extension privates */
|
|
|
|
PRIVATE_DBE_WINDOW,
|
|
|
|
PRIVATE_DAMAGE,
|
|
|
|
PRIVATE_GLYPH,
|
|
|
|
PRIVATE_GLYPHSET,
|
|
|
|
PRIVATE_PICTURE,
|
2010-06-29 01:10:13 +02:00
|
|
|
PRIVATE_SYNC_FENCE,
|
2010-04-27 02:22:21 +02:00
|
|
|
|
|
|
|
/* last private type */
|
|
|
|
PRIVATE_LAST,
|
|
|
|
} DevPrivateType;
|
|
|
|
|
|
|
|
typedef struct _DevPrivateKeyRec {
|
2010-05-01 04:38:38 +02:00
|
|
|
int offset;
|
|
|
|
int size;
|
|
|
|
Bool initialized;
|
2010-05-01 04:36:33 +02:00
|
|
|
Bool allocated;
|
2010-05-01 04:38:38 +02:00
|
|
|
DevPrivateType type;
|
|
|
|
struct _DevPrivateKeyRec *next;
|
2010-04-27 02:22:21 +02:00
|
|
|
} DevPrivateKeyRec, *DevPrivateKey;
|
2007-03-01 21:00:02 +01:00
|
|
|
|
2010-09-17 02:11:44 +02:00
|
|
|
typedef struct _DevScreenPrivateKeyRec {
|
|
|
|
DevPrivateKeyRec screenKey;
|
|
|
|
} DevScreenPrivateKeyRec, *DevScreenPrivateKey;
|
|
|
|
|
2007-02-23 19:19:53 +01:00
|
|
|
/*
|
2010-04-27 02:22:21 +02:00
|
|
|
* Let drivers know how to initialize private keys
|
2007-02-23 19:19:53 +01:00
|
|
|
*/
|
2010-04-27 02:22:21 +02:00
|
|
|
|
|
|
|
#define HAS_DEVPRIVATEKEYREC 1
|
|
|
|
#define HAS_DIXREGISTERPRIVATEKEY 1
|
2007-02-23 19:19:53 +01:00
|
|
|
|
|
|
|
/*
|
2010-04-27 02:22:21 +02:00
|
|
|
* Register a new private index for the private type.
|
2010-04-28 21:37:08 +02:00
|
|
|
*
|
2010-04-27 02:22:21 +02:00
|
|
|
* This initializes the specified key and optionally requests pre-allocated
|
|
|
|
* private space for your driver/module. If you request no extra space, you
|
|
|
|
* may set and get a single pointer value using this private key. Otherwise,
|
|
|
|
* you can get the address of the extra space and store whatever data you like
|
|
|
|
* there.
|
2010-04-28 21:37:08 +02:00
|
|
|
*
|
2010-07-23 08:57:02 +02:00
|
|
|
* You may call dixRegisterPrivateKey more than once on the same key, but the
|
2010-04-27 02:22:21 +02:00
|
|
|
* size and type must match or the server will abort.
|
2010-04-28 21:37:08 +02:00
|
|
|
*
|
2010-07-23 08:57:02 +02:00
|
|
|
* dixRegisterPrivateKey returns FALSE if it fails to allocate memory
|
2010-04-27 02:22:21 +02:00
|
|
|
* during its operation.
|
2007-02-23 19:19:53 +01:00
|
|
|
*/
|
2010-04-27 02:22:21 +02:00
|
|
|
extern _X_EXPORT Bool
|
|
|
|
dixRegisterPrivateKey(DevPrivateKey key, DevPrivateType type, unsigned size);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check whether a private key has been registered
|
|
|
|
*/
|
|
|
|
static inline Bool
|
|
|
|
dixPrivateKeyRegistered(DevPrivateKey key)
|
|
|
|
{
|
2010-05-01 04:38:38 +02:00
|
|
|
return key->initialized;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the address of the private storage.
|
|
|
|
*
|
|
|
|
* For keys with pre-defined storage, this gets the base of that storage
|
|
|
|
* Otherwise, it returns the place where the private pointer is stored.
|
|
|
|
*/
|
|
|
|
static inline void *
|
|
|
|
dixGetPrivateAddr(PrivatePtr *privates, const DevPrivateKey key)
|
|
|
|
{
|
|
|
|
assert(key->initialized);
|
|
|
|
return (char *) (*privates) + key->offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fetch a private pointer stored in the object
|
|
|
|
*
|
|
|
|
* Returns the pointer stored with dixSetPrivate.
|
|
|
|
* This must only be used with keys that have
|
|
|
|
* no pre-defined storage
|
|
|
|
*/
|
|
|
|
static inline void *
|
|
|
|
dixGetPrivate(PrivatePtr *privates, const DevPrivateKey key)
|
|
|
|
{
|
|
|
|
assert (key->size == 0);
|
|
|
|
return *(void **) dixGetPrivateAddr(privates, key);
|
2010-04-27 02:22:21 +02:00
|
|
|
}
|
2007-02-23 19:19:53 +01:00
|
|
|
|
|
|
|
/*
|
2010-04-27 02:22:21 +02:00
|
|
|
* Associate 'val' with 'key' in 'privates' so that later calls to
|
|
|
|
* dixLookupPrivate(privates, key) will return 'val'.
|
|
|
|
*/
|
2010-05-01 04:38:38 +02:00
|
|
|
static inline void
|
|
|
|
dixSetPrivate(PrivatePtr *privates, const DevPrivateKey key, pointer val)
|
|
|
|
{
|
|
|
|
assert (key->size == 0);
|
|
|
|
*(pointer *) dixGetPrivateAddr(privates, key) = val;
|
|
|
|
}
|
2010-04-27 02:22:21 +02:00
|
|
|
|
|
|
|
#include "dix.h"
|
|
|
|
#include "resource.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Lookup a pointer to the private record.
|
2010-04-28 21:37:08 +02:00
|
|
|
*
|
2010-04-27 02:22:21 +02:00
|
|
|
* For privates with defined storage, return the address of the
|
|
|
|
* storage. For privates without defined storage, return the pointer
|
|
|
|
* contents
|
2007-02-23 19:19:53 +01:00
|
|
|
*/
|
2010-05-01 04:38:38 +02:00
|
|
|
static inline pointer
|
|
|
|
dixLookupPrivate(PrivatePtr *privates, const DevPrivateKey key)
|
|
|
|
{
|
|
|
|
if (key->size)
|
|
|
|
return dixGetPrivateAddr(privates, key);
|
|
|
|
else
|
|
|
|
return dixGetPrivate(privates, key);
|
|
|
|
}
|
2007-03-01 21:00:02 +01:00
|
|
|
|
|
|
|
/*
|
2010-05-01 04:38:38 +02:00
|
|
|
* Look up the address of the pointer to the storage
|
2010-04-28 21:37:08 +02:00
|
|
|
*
|
2010-05-01 04:38:38 +02:00
|
|
|
* This returns the place where the private pointer is stored,
|
|
|
|
* which is only valid for privates without predefined storage.
|
2007-03-01 21:00:02 +01:00
|
|
|
*/
|
2010-05-01 04:38:38 +02:00
|
|
|
static inline pointer *
|
|
|
|
dixLookupPrivateAddr(PrivatePtr *privates, const DevPrivateKey key)
|
|
|
|
{
|
|
|
|
assert (key->size == 0);
|
2010-06-19 02:28:15 +02:00
|
|
|
return (pointer *)dixGetPrivateAddr(privates, key);
|
2010-05-01 04:38:38 +02:00
|
|
|
}
|
2007-03-01 21:00:02 +01:00
|
|
|
|
2010-09-17 02:11:44 +02:00
|
|
|
extern _X_EXPORT Bool
|
|
|
|
dixRegisterScreenPrivateKey(DevScreenPrivateKey key, ScreenPtr pScreen, DevPrivateType type, unsigned size);
|
|
|
|
|
|
|
|
extern _X_EXPORT DevPrivateKey
|
|
|
|
_dixGetScreenPrivateKey(const DevScreenPrivateKey key, ScreenPtr pScreen);
|
|
|
|
|
|
|
|
static inline void *
|
|
|
|
dixGetScreenPrivateAddr(PrivatePtr *privates, const DevScreenPrivateKey key, ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
return dixGetPrivateAddr(privates, _dixGetScreenPrivateKey(key, pScreen));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *
|
|
|
|
dixGetScreenPrivate(PrivatePtr *privates, const DevScreenPrivateKey key, ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
return dixGetPrivate(privates, _dixGetScreenPrivateKey(key, pScreen));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
dixSetScreenPrivate(PrivatePtr *privates, const DevScreenPrivateKey key, ScreenPtr pScreen, pointer val)
|
|
|
|
{
|
2011-05-21 04:24:34 +02:00
|
|
|
dixSetPrivate(privates, _dixGetScreenPrivateKey(key, pScreen), val);
|
2010-09-17 02:11:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline pointer
|
|
|
|
dixLookupScreenPrivate(PrivatePtr *privates, const DevScreenPrivateKey key, ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
return dixLookupPrivate(privates, _dixGetScreenPrivateKey(key, pScreen));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline pointer *
|
|
|
|
dixLookupScreenPrivateAddr(PrivatePtr *privates, const DevScreenPrivateKey key, ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
return dixLookupPrivateAddr(privates, _dixGetScreenPrivateKey(key, pScreen));
|
|
|
|
}
|
|
|
|
|
2007-03-01 21:00:02 +01:00
|
|
|
/*
|
2010-05-01 04:38:38 +02:00
|
|
|
* Allocates private data separately from main object.
|
|
|
|
*
|
|
|
|
* For objects created during server initialization, this allows those
|
|
|
|
* privates to be re-allocated as new private keys are registered.
|
|
|
|
*
|
|
|
|
* This includes screens, the serverClient, default colormaps and
|
|
|
|
* extensions entries.
|
2007-03-01 21:00:02 +01:00
|
|
|
*/
|
2010-05-01 04:38:38 +02:00
|
|
|
extern _X_EXPORT Bool
|
|
|
|
dixAllocatePrivates(PrivatePtr *privates, DevPrivateType type);
|
2007-02-23 19:19:53 +01:00
|
|
|
|
|
|
|
/*
|
2010-05-01 04:38:38 +02:00
|
|
|
* Frees separately allocated private data
|
2007-02-23 19:19:53 +01:00
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
extern _X_EXPORT void
|
2010-04-27 02:22:21 +02:00
|
|
|
dixFreePrivates(PrivatePtr privates, DevPrivateType type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize privates by zeroing them
|
|
|
|
*/
|
2010-05-01 04:38:38 +02:00
|
|
|
extern _X_EXPORT void
|
|
|
|
_dixInitPrivates(PrivatePtr *privates, void *addr, DevPrivateType type);
|
2010-04-27 02:22:21 +02:00
|
|
|
|
|
|
|
#define dixInitPrivates(o, v, type) _dixInitPrivates(&(o)->devPrivates, (v), type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clean up privates
|
|
|
|
*/
|
2010-05-01 04:38:38 +02:00
|
|
|
extern _X_EXPORT void
|
|
|
|
_dixFiniPrivates(PrivatePtr privates, DevPrivateType type);
|
2010-04-27 02:22:21 +02:00
|
|
|
|
|
|
|
#define dixFiniPrivates(o,t) _dixFiniPrivates((o)->devPrivates,t)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocates private data at object creation time. Required
|
2010-05-01 04:38:38 +02:00
|
|
|
* for almost all objects, except for the list described
|
|
|
|
* above for dixAllocatePrivates.
|
2010-04-27 02:22:21 +02:00
|
|
|
*/
|
2010-05-01 04:38:38 +02:00
|
|
|
extern _X_EXPORT void *
|
|
|
|
_dixAllocateObjectWithPrivates(unsigned size, unsigned clear, unsigned offset, DevPrivateType type);
|
2010-04-27 02:22:21 +02:00
|
|
|
|
|
|
|
#define dixAllocateObjectWithPrivates(t, type) (t *) _dixAllocateObjectWithPrivates(sizeof(t), sizeof(t), offsetof(t, devPrivates), type)
|
|
|
|
|
2010-05-01 04:38:38 +02:00
|
|
|
extern _X_EXPORT void
|
|
|
|
_dixFreeObjectWithPrivates(void *object, PrivatePtr privates, DevPrivateType type);
|
2010-04-27 02:22:21 +02:00
|
|
|
|
|
|
|
#define dixFreeObjectWithPrivates(o,t) _dixFreeObjectWithPrivates(o, (o)->devPrivates, t)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return size of privates for the specified type
|
|
|
|
*/
|
2010-05-01 04:38:38 +02:00
|
|
|
extern _X_EXPORT int
|
|
|
|
dixPrivatesSize(DevPrivateType type);
|
2010-04-27 02:22:21 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Dump out private stats to ErrorF
|
|
|
|
*/
|
2010-05-01 04:38:38 +02:00
|
|
|
extern void
|
2010-04-27 02:22:21 +02:00
|
|
|
dixPrivateUsage(void);
|
2007-02-23 19:19:53 +01:00
|
|
|
|
2007-03-01 21:00:02 +01:00
|
|
|
/*
|
2010-04-28 21:37:08 +02:00
|
|
|
* Resets the privates subsystem. dixResetPrivates is called from the main loop
|
|
|
|
* before each server generation. This function must only be called by main().
|
2007-03-01 21:00:02 +01:00
|
|
|
*/
|
2010-04-27 02:22:21 +02:00
|
|
|
extern _X_EXPORT void
|
2007-03-01 21:00:02 +01:00
|
|
|
dixResetPrivates(void);
|
2007-02-23 19:19:53 +01:00
|
|
|
|
2007-03-01 21:00:02 +01:00
|
|
|
/*
|
2007-03-08 18:13:36 +01:00
|
|
|
* Looks up the offset where the devPrivates field is located.
|
2010-05-01 04:38:38 +02:00
|
|
|
*
|
2010-05-15 23:52:39 +02:00
|
|
|
* Returns -1 if the specified resource has no dev privates.
|
|
|
|
* The position of the devPrivates field varies by structure
|
|
|
|
* and calling code might only know the resource type, not the
|
|
|
|
* structure definition.
|
2007-03-01 21:00:02 +01:00
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
extern _X_EXPORT int
|
2007-03-01 21:00:02 +01:00
|
|
|
dixLookupPrivateOffset(RESTYPE type);
|
2007-02-23 19:19:53 +01:00
|
|
|
|
2007-09-06 22:55:51 +02:00
|
|
|
/*
|
|
|
|
* Convenience macro for adding an offset to an object pointer
|
|
|
|
* when making a call to one of the devPrivates functions
|
|
|
|
*/
|
2010-04-27 02:22:21 +02:00
|
|
|
#define DEVPRIV_AT(ptr, offset) ((PrivatePtr *)((char *)(ptr) + offset))
|
2007-02-23 19:19:53 +01:00
|
|
|
|
|
|
|
#endif /* PRIVATES_H */
|