3 * - By John Hodge (thePowersGang)
6 * - Definitions for opaque structures
8 #ifndef _UDI_INTERNAL_H_
9 #define _UDI_INTERNAL_H_
13 #define NEW(type,extra) (type*)calloc(sizeof(type)extra,1)
14 #define NEW_wA(type,fld,cnt) NEW(type,+(sizeof(((type*)NULL)->fld[0])*cnt))
16 typedef struct sUDI_PropMessage tUDI_PropMessage;
17 typedef struct sUDI_PropRegion tUDI_PropRegion;
18 typedef struct sUDI_PropDevSpec tUDI_PropDevSpec;
20 typedef const struct sUDI_MetaLang tUDI_MetaLang;
22 typedef struct sUDI_MetaLangRef tUDI_MetaLangRef;
23 typedef struct sUDI_BindOps tUDI_BindOps;
25 typedef struct sUDI_DriverModule tUDI_DriverModule;
26 typedef struct sUDI_DriverInstance tUDI_DriverInstance;
27 typedef struct sUDI_DriverRegion tUDI_DriverRegion;
29 typedef struct sUDI_ChildBinding tUDI_ChildBinding;
31 struct sUDI_PropMessage
38 struct sUDI_PropRegion
40 udi_index_t RegionIdx;
42 UDI_REGIONTYPE_NORMAL,
46 UDI_REGIONBINDING_STATIC,
47 UDI_REGIONBINDING_DYNAMIC,
55 UDI_REGIONLATENCY_NONOVERRRUNABLE,
56 UDI_REGIONLATENCY_POWERFAIL,
57 UDI_REGIONLATENCY_OVERRUNNABLE,
58 UDI_REGIONLATENCY_RETRYABLE,
60 UDI_REGIONLATENCY_NONCTRITICAL,
62 udi_ubit32_t OverrunTime;
65 udi_index_t PriBindOps;
66 udi_index_t SecBindOps;
80 struct sUDI_MetaLangRef
83 const char *interface_name;
84 tUDI_MetaLang *metalang;
85 // TODO: pointer to metalanguage structure
91 udi_ubit8_t region_idx;
93 udi_ubit8_t bind_cb_idx;
96 struct sUDI_PropDevSpec
100 tUDI_MetaLang *Metalang;
102 udi_instance_attr_list_t Attribs[];
105 struct sUDI_DriverModule
107 tUDI_DriverModule *Next;
110 udi_init_t *InitInfo;
112 // Counts of arrays in InitInfo
116 const char *ModuleName;
118 tUDI_PropMessage *Messages; // Sorted list
121 tUDI_PropRegion *RegionTypes;
124 tUDI_MetaLangRef *MetaLangs;
127 tUDI_BindOps *Parents;
130 tUDI_BindOps *ChildBindOps;
133 tUDI_PropDevSpec **Devices;
138 struct sUDI_DriverInstance
140 struct sUDI_DriverInstance *Next;
141 tUDI_DriverModule *Module;
142 udi_channel_t ManagementChannel;
143 tUDI_DriverInstance *Parent;
144 tUDI_ChildBinding *ParentChildBinding;
146 int CurState; // Current MA state
148 tUDI_ChildBinding *FirstChild;
149 tUDI_DriverRegion *Regions[];
152 struct sUDI_DriverRegion
154 udi_init_context_t *InitContext;
157 struct sUDI_ChildBinding
159 tUDI_ChildBinding *Next;
161 udi_ubit32_t ChildID;
162 tUDI_MetaLang *Metalang;
163 tUDI_BindOps *BindOps;
166 tUDI_DriverInstance *BoundInstance;
169 udi_instance_attr_list_t Attribs[];
172 // --- Metalanguages ---
173 extern tUDI_MetaLang cMetaLang_Management;
175 // --- Index to pointer translation ---
176 extern udi_ops_init_t *UDI_int_GetOps(tUDI_DriverInstance *Inst, udi_index_t index);
177 extern tUDI_MetaLang *UDI_int_GetMetaLang(tUDI_DriverInstance *Inst, udi_index_t meta_idx);
180 extern udi_channel_t UDI_CreateChannel_Blank(tUDI_MetaLang *metalang);
181 extern udi_channel_t UDI_CreateChannel_Linked(udi_channel_t orig, udi_ubit8_t spawn_idx);
182 extern int UDI_BindChannel_Raw(udi_channel_t channel, bool other_side, tUDI_DriverInstance *inst, udi_index_t region_idx, udi_index_t meta_ops_num, void *context, const void *ops);
183 extern int UDI_BindChannel(udi_channel_t channel, bool other_side, tUDI_DriverInstance *inst, udi_index_t ops, udi_index_t region, void *context, bool is_child_bind, udi_ubit32_t child_ID);
184 extern tUDI_DriverInstance *UDI_int_ChannelGetInstance(udi_cb_t *gcb, bool other_side, udi_index_t *region_idx);
185 extern void UDI_int_ChannelSetContext(udi_channel_t channel, void *context);
186 extern const void *UDI_int_ChannelPrepForCall(udi_cb_t *gcb, tUDI_MetaLang *metalang, udi_index_t meta_ops_num);
187 extern void UDI_int_ChannelFlip(udi_cb_t *gcb);
188 extern void UDI_int_ChannelReleaseFromCall(udi_cb_t *gcb);
190 // --- Async Calls ---
191 typedef struct sUDI_DeferredCall tUDI_DeferredCall;
192 typedef void tUDI_DeferredUnmarshal(tUDI_DeferredCall *Call);
193 struct sUDI_DeferredCall
195 struct sUDI_DeferredCall *Next;
196 tUDI_DeferredUnmarshal *Unmarshal;
201 extern void UDI_int_DeferredThread(void *unused); // Worker started by main.c
202 extern void UDI_int_AddDeferred(tUDI_DeferredCall *Call);
203 extern void UDI_int_MakeDeferredCb(udi_cb_t *cb, udi_op_t *handler);
205 extern void UDI_int_MakeDeferredCbU8(udi_cb_t *cb, udi_op_t *handler, udi_ubit8_t arg1);
206 extern void UDI_int_MakeDeferredCbS(udi_cb_t *cb, udi_op_t *handler, udi_status_t status);
209 extern void *udi_cb_alloc_internal(tUDI_DriverInstance *Inst, udi_ubit8_t bind_cb_idx, udi_channel_t channel);
210 extern udi_cb_t *udi_cb_alloc_internal_v(tUDI_MetaLang *Meta, udi_index_t MetaCBNum, size_t inline_size, size_t scratch_size, udi_channel_t channel);
212 // --- Attribute Management ---
213 extern udi_instance_attr_type_t udi_instance_attr_get_internal(udi_cb_t *gcb, const char *attr_name, udi_ubit32_t child_ID, void *attr_value, udi_size_t attr_length, udi_size_t *actual_length);