From 7250e7ecab292ac5debd1e11bed31e3fda034baa Mon Sep 17 00:00:00 2001 From: Courtney Goeltzenleuchter Date: Tue, 10 Feb 2015 18:40:14 -0700 Subject: icd: add loader magic word to verify ICD is compatible We wanted a more explicit way to determine if the driver ICD being loaded is providing compatible objects. To do that we check for a magic dword value at the beginning of the object. Non-compliant ICDs will assert in the loader or the loader's dispatch functions if an object does not have the correct value. Dispatch checks are debug only. --- include/xglIcd.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 include/xglIcd.h (limited to 'include') diff --git a/include/xglIcd.h b/include/xglIcd.h new file mode 100644 index 00000000..3efffe6d --- /dev/null +++ b/include/xglIcd.h @@ -0,0 +1,32 @@ +#ifndef XGLICD_H +#define XGLICD_H + +#include +#include +#include "xglPlatform.h" + +/* + * The ICD must reserve space for a pointer for the loader's dispatch + * table, at the start of . + * The ICD must initialize this variable using the SET_LOADER_MAGIC_VALUE macro. + */ + +#define ICD_LOADER_MAGIC 0x01CDC0DE + +typedef union _XGL_LOADER_DATA { + uint32_t loaderMagic; + void *loaderData; +} XGL_LOADER_DATA; + +STATIC_INLINE void set_loader_magic_value(void *pNewObject) { + XGL_LOADER_DATA *loader_info = (XGL_LOADER_DATA *) pNewObject; + loader_info->loaderMagic = ICD_LOADER_MAGIC; +} + +STATIC_INLINE bool valid_loader_magic_value(void *pNewObject) { + const XGL_LOADER_DATA *loader_info = (XGL_LOADER_DATA *) pNewObject; + return loader_info->loaderMagic == ICD_LOADER_MAGIC; +} + +#endif // XGLICD_H + -- cgit v1.2.3