#include <udi_physio.h>
#include "../../udi_internal.h"
-// === GLOBALS ==
-udi_layout_t cMetaLang_BusBridge_IntrAttachCbLayout[] = {
- UDI_DL_STATUS_T,
- UDI_DL_UBIT8_T,
- UDI_DL_ORIGIN_T, // TODO: handle
- 0
-};
-tUDI_MetaLang cMetaLang_BusBridge = {
- "udi_bridge",
- // CB Types
- 5,
- {
- {0}, // 0: Empty
- {sizeof(udi_bus_bind_cb_t), NULL}, // Defined, but is just a gcb
- {sizeof(udi_intr_attach_cb_t), NULL},
- {sizeof(udi_intr_detach_cb_t), NULL},
- {sizeof(udi_intr_event_cb_t), NULL}
- }
-};
+#define USE_MEI 0
+
+#define udi_mei_info udi_meta_info__bridge
+
+extern tUDI_MetaLang cMetaLang_BusBridge;
+extern udi_mei_init_t udi_meta_info__bridge;
// === EXPORTS ===
-EXPORT(udi_bus_unbind_req);
-EXPORT(udi_bus_unbind_ack);
EXPORT(udi_bus_bind_req);
EXPORT(udi_bus_bind_ack);
+EXPORT(udi_bus_unbind_req);
+EXPORT(udi_bus_unbind_ack);
+EXPORT(udi_intr_attach_req);
+EXPORT(udi_intr_attach_ack);
+EXPORT(udi_intr_attach_ack_unused);
+EXPORT(udi_intr_detach_req);
+EXPORT(udi_intr_detach_ack);
+EXPORT(udi_intr_detach_ack_unused);
+EXPORT(udi_intr_event_ind);
+EXPORT(udi_intr_event_rdy);
#define PREP_OPS(type,ml,num) const type *ops = UDI_int_ChannelPrepForCall(UDI_GCB(cb), ml, num); \
if(!ops) { Log_Warning("UDI", "%s on wrong channel type", __func__); return ; }
if(!ops) { Log_Warning("UDI", "%s on wrong channel type", __func__); return ; }
// === CODE ===
+#if !USE_MEI
void udi_bus_unbind_req(udi_bus_bind_cb_t *cb)
{
UNIMPLEMENTED();
{
LOG("Call=%p", Call);
struct marshalled_bus_bind_ack *info = (void*)Call;
+ UDI_int_ChannelReleaseFromCall( Call->cb );
((udi_bus_bind_ack_op_t*)Call->Handler)(
UDI_MCB(Call->cb, udi_bus_bind_cb_t),
info->dma_constraints,
call->status = status;
UDI_int_AddDeferred(&call->Call);
}
+
+void udi_intr_attach_req(udi_intr_attach_cb_t *cb)
+{
+ LOG("cb=%p", cb);
+ PREP_OPS(udi_bus_bridge_ops_t, &cMetaLang_BusBridge, UDI_BUS_BRIDGE_OPS_NUM)
+ UDI_int_MakeDeferredCb( UDI_GCB(cb), (udi_op_t*)ops->intr_attach_req_op );
+}
+void udi_intr_attach_ack(udi_intr_attach_cb_t *cb, udi_status_t status)
+{
+ LOG("cb=%p,status=%i", cb, status);
+ PREP_OPS(udi_bus_device_ops_t, &cMetaLang_BusBridge, UDI_BUS_DEVICE_OPS_NUM)
+ UDI_int_MakeDeferredCbS( UDI_GCB(cb), (udi_op_t*)ops->intr_attach_ack_op, status );
+}
+
+void udi_intr_detach_req(udi_intr_detach_cb_t *cb)
+{
+ LOG("cb=%p", cb);
+ PREP_OPS(udi_bus_bridge_ops_t, &cMetaLang_BusBridge, UDI_BUS_BRIDGE_OPS_NUM)
+ UDI_int_MakeDeferredCb( UDI_GCB(cb), (udi_op_t*)ops->intr_detach_req_op );
+}
+void udi_intr_detach_ack(udi_intr_detach_cb_t *cb)
+{
+ LOG("cb=%p", cb);
+ PREP_OPS(udi_bus_device_ops_t, &cMetaLang_BusBridge, UDI_BUS_DEVICE_OPS_NUM)
+ UDI_int_MakeDeferredCb( UDI_GCB(cb), (udi_op_t*)ops->intr_detach_ack_op );
+}
+#endif
+
+void udi_intr_event_ind(udi_intr_event_cb_t *cb, udi_ubit8_t flags)
+{
+ LOG("cb=%p,flags=0x%x", cb, flags);
+ PREP_OPS(udi_intr_handler_ops_t, &cMetaLang_BusBridge, UDI_BUS_INTR_HANDLER_OPS_NUM)
+ UDI_int_MakeDeferredCbU8( UDI_GCB(cb), (udi_op_t*)ops->intr_event_ind_op, flags );
+}
+
+void udi_intr_event_rdy(udi_intr_event_cb_t *cb)
+{
+ LOG("cb=%p", cb);
+ PREP_OPS(udi_intr_dispatcher_ops_t, &cMetaLang_BusBridge, UDI_BUS_INTR_DISPATCH_OPS_NUM)
+ UDI_int_MakeDeferredCb( UDI_GCB(cb), (udi_op_t*)ops->intr_event_rdy_op );
+}
+
+void udi_intr_attach_ack_unused(udi_intr_attach_cb_t *intr_attach_cb, udi_status_t status)
+{
+ Log_Error("UDI", "Driver %s caused %s to be called",
+ UDI_int_ChannelGetInstance(UDI_GCB(intr_attach_cb), false, NULL)->Module->ModuleName,
+ __func__);
+}
+void udi_intr_detach_ack_unused(udi_intr_detach_cb_t *intr_detach_cb)
+{
+ Log_Error("UDI", "Driver %s caused %s to be called",
+ UDI_int_ChannelGetInstance(UDI_GCB(intr_detach_cb), false, NULL)->Module->ModuleName,
+ __func__);
+}
+
+#if USE_MEI
+UDI_MEI_STUBS(udi_bus_bind_ack, udi_bus_bind_cb_t, 3,
+ (dma_constraints, preferred_endianness, status ),
+ (udi_dma_constraints_t, udi_ubit8_t, udi_status_t),
+ (UDI_VA_POINTER, UDI_VA_UBIT8_T, UDI_VA_STATUS_T),
+ UDI_BUS_DEVICE_OPS_NUM, 1)
+UDI_MEI_STUBS(udi_bus_unbind_ack, udi_bus_bind_cb_t, 0,
+ (), (), (),
+ UDI_BUS_DEVICE_OPS_NUM, 2)
+UDI_MEI_STUBS(udi_intr_attach_ack, udi_intr_attach_cb_t, 1,
+ (status), (udi_status_t), (UDI_VA_STATUS_T),
+ UDI_BUS_DEVICE_OPS_NUM, 3)
+UDI_MEI_STUBS(udi_intr_detach_ack, udi_intr_detach_cb_t, 0,
+ (), (), (),
+ UDI_BUS_DEVICE_OPS_NUM, 4)
+
+UDI_MEI_STUBS(udi_bus_bind_req, udi_bus_bind_cb_t, 0,
+ (), (), (),
+ UDI_BUS_BRIDGE_OPS_NUM, 1)
+UDI_MEI_STUBS(udi_bus_unbind_req, udi_bus_bind_cb_t, 0,
+ (), (), (),
+ UDI_BUS_BRIDGE_OPS_NUM, 2)
+UDI_MEI_STUBS(udi_intr_attach_req, udi_intr_attach_cb_t, 0,
+ (), (), (),
+ UDI_BUS_BRIDGE_OPS_NUM, 3)
+UDI_MEI_STUBS(udi_intr_detach_req, udi_intr_detach_cb_t, 0,
+ (), (), (),
+ UDI_BUS_BRIDGE_OPS_NUM, 4)
+
+#endif
+
+// === GLOBALS ==
+udi_layout_t udi_meta_info__bridge__bus_bind_cb[] = {
+ UDI_DL_END
+};
+udi_layout_t udi_meta_info__bridge__intr_attach_cb[] = {
+ UDI_DL_STATUS_T,
+ UDI_DL_UBIT8_T,
+ UDI_DL_PIO_HANDLE_T,
+ UDI_DL_END
+};
+udi_layout_t udi_meta_info__bridge__intr_detach_cb[] = {
+ UDI_DL_INDEX_T,
+ UDI_DL_END
+};
+
+#if USE_MEI
+udi_layout_t _noargs_marshal[] = {
+ UDI_DL_END
+};
+udi_layout_t _bus_bind_ack_marshal[] = {
+ UDI_DL_DMA_CONSTRAINTS_T,
+ UDI_DL_UBIT8_T,
+ UDI_DL_STATUS_T,
+ UDI_DL_END
+};
+udi_layout_t _udi_intr_attach_ack_marshal[] = {
+ UDI_DL_STATUS_T,
+ UDI_DL_END
+};
+
+udi_mei_op_template_t udi_meta_info__bridge__bus_ops[] = {
+ {"udi_bus_bind_req", UDI_MEI_OPCAT_REQ, 0, UDI_BUS_BIND_CB_NUM, UDI_BUS_DEVICE_OPS_NUM,1, 0,0,
+ udi_bus_bind_req_direct, udi_bus_bind_req_backend, udi_meta_info__bridge__bus_bind_cb,
+ _noargs_marshal},
+ {"udi_bus_unbind_req", UDI_MEI_OPCAT_REQ, 0, UDI_BUS_BIND_CB_NUM, UDI_BUS_DEVICE_OPS_NUM,2, 0,0,
+ udi_bus_unbind_req_direct, udi_bus_unbind_req_backend, udi_meta_info__bridge__bus_bind_cb,
+ _noargs_marshal},
+ {"udi_intr_attach_req", UDI_MEI_OPCAT_REQ, 0, UDI_BUS_INTR_ATTACH_CB_NUM, UDI_BUS_DEVICE_OPS_NUM,3, 0,0,
+ udi_intr_attach_req_direct, udi_intr_attach_req_backend, udi_meta_info__bridge__intr_attach_cb,
+ _noargs_marshal},
+ {"udi_intr_detach_req", UDI_MEI_OPCAT_REQ, 0, UDI_BUS_INTR_DETACH_CB_NUM, UDI_BUS_DEVICE_OPS_NUM,4, 0,0,
+ udi_intr_detach_req_direct, udi_intr_detach_req_backend, udi_meta_info__bridge__intr_detach_cb,
+ _noargs_marshal},
+ {0}
+};
+udi_mei_op_template_t udi_meta_info__bridge__device_ops[] = {
+ {"udi_bus_bind_ack", UDI_MEI_OPCAT_ACK, 0, UDI_BUS_BIND_CB_NUM, 0,0, 0,0,
+ udi_bus_bind_ack_direct, udi_bus_bind_ack_backend, udi_meta_info__bridge__bus_bind_cb,
+ _bus_bind_ack_marshal},
+ {"udi_bus_unbind_ack", UDI_MEI_OPCAT_ACK, 0, UDI_BUS_BIND_CB_NUM, 0,0, 0,0,
+ udi_bus_unbind_ack_direct, udi_bus_unbind_ack_backend, udi_meta_info__bridge__bus_bind_cb,
+ _noargs_marshal},
+ {"udi_intr_attach_ack", UDI_MEI_OPCAT_ACK, 0, UDI_BUS_INTR_ATTACH_CB_NUM, 0,0, 0,0,
+ udi_intr_attach_ack_direct, udi_intr_attach_ack_backend, udi_meta_info__bridge__intr_attach_cb,
+ _udi_intr_attach_ack_marshal},
+ {"udi_intr_detach_ack", UDI_MEI_OPCAT_ACK, 0, UDI_BUS_INTR_DETACH_CB_NUM, 0,0, 0,0,
+ udi_intr_detach_ack_direct, udi_intr_detach_ack_backend, udi_meta_info__bridge__intr_detach_cb,
+ _noargs_marshal},
+ {0}
+};
+udi_mei_ops_vec_template_t udi_meta_info__bridge_ops[] = {
+ {UDI_BUS_BRIDGE_OPS_NUM, UDI_MEI_REL_EXTERNAL|UDI_MEI_REL_BIND, udi_meta_info__bridge__bus_ops},
+ {UDI_BUS_DEVICE_OPS_NUM, UDI_MEI_REL_EXTERNAL|UDI_MEI_REL_BIND, udi_meta_info__bridge__device_ops},
+ {0}
+};
+udi_mei_init_t udi_meta_info__bridge = {
+ udi_meta_info__bridge_ops,
+ NULL
+};
+#endif
+tUDI_MetaLang cMetaLang_BusBridge = {
+ "udi_bridge",
+ // CB Types
+ 5,
+ {
+ {0}, // 0: Empty
+ {sizeof(udi_bus_bind_cb_t), udi_meta_info__bridge__bus_bind_cb},
+ {sizeof(udi_intr_attach_cb_t), udi_meta_info__bridge__intr_attach_cb},
+ {sizeof(udi_intr_detach_cb_t), udi_meta_info__bridge__intr_detach_cb},
+ {sizeof(udi_intr_event_cb_t), NULL}
+ }
+};
typedef const struct udi_mei_init_s udi_mei_init_t;
typedef const struct udi_mei_ops_vec_template_s udi_mei_ops_vec_template_t;
-typedef const struct uid_mei_op_template_s uid_mei_op_template_t;
+typedef const struct uid_mei_op_template_s udi_mei_op_template_t;
typedef udi_ubit8_t udi_mei_enumeration_rank_func_t(udi_ubit32_t attr_device_match, void **attr_value_list);
typedef void udi_mei_direct_stub_t(udi_op_t *op, udi_cb_t *gcb, va_list arglist);
#define UDI_MEI_MAX_VISIBLE_SIZE 2000
#define UDI_MEI_MAX_MARSHAL_SIZE 4000
+
+extern void udi_mei_call(udi_cb_t *gcb, udi_mei_init_t *meta_info, udi_index_t meta_ops_num, udi_index_t vec_idx, ...);
+
#define _UDI_MEI_FIRST(lst, ...) lst
-#define _UDI_MEI_OTHER(lst, ...) __VA_ARGS__
+#define _UDI_MEI_OTHER(lst, ...) (__VA_ARGS__)
#define _UDI_MEI_VARG(type,name,vatype) \
type name = UDI_VA_ARG(arglist, type, vatype);
-#define _UDI_MEI_VARGS0()
-#define _UDI_MEI_VARGS1(args,argt,argva) \
- _UDI_MEI_VARG(_UDI_MEI_FIRST(argt), _UDI_MEI_FIRST(args),_UDI_MEI_FIRST(argva))
-#define _UDI_MEI_VARGS2(args,argt,argva) \
- _UDI_MEI_VARG(_UDI_MEI_FIRST(argt), _UDI_MEI_FIRST(args),_UDI_MEI_FIRST(argva)) \
- _UDI_MEI_VARGS1( _UDI_MEI_OTHER(argt), _UDI_MEI_OTHER(args), _UDI_MEI_OTHER(argva) )
+#define _UDI_MEI_VARGS0(argt,args,argva)
+#define _UDI_MEI_VARGS1(argt,args,argva) \
+ _UDI_MEI_VARG(_UDI_MEI_FIRST argt, _UDI_MEI_FIRST args, _UDI_MEI_FIRST argva)
+#define _UDI_MEI_VARGS2(argt,args,argva) \
+ _UDI_MEI_VARG(_UDI_MEI_FIRST argt, _UDI_MEI_FIRST args,_UDI_MEI_FIRST argva ) \
+ _UDI_MEI_VARGS1( _UDI_MEI_OTHER argt, _UDI_MEI_OTHER args, _UDI_MEI_OTHER argva )
+#define _UDI_MEI_VARGS3(argt,args,argva) \
+ _UDI_MEI_VARG(_UDI_MEI_FIRST argt, _UDI_MEI_FIRST args, _UDI_MEI_FIRST argva) \
+ _UDI_MEI_VARGS2( _UDI_MEI_OTHER argt, _UDI_MEI_OTHER args, _UDI_MEI_OTHER argva )
+
+#define _UDI_MEI_ARG_LIST0(t,a)
+#define _UDI_MEI_ARG_LIST1(t,a) , _UDI_MEI_FIRST t _UDI_MEI_FIRST a
+#define _UDI_MEI_ARG_LIST2(t,a) , _UDI_MEI_FIRST t _UDI_MEI_FIRST a \
+ _UDI_MEI_ARG_LIST1(_UDI_MEI_OTHER t, _UDI_MEI_OTHER a)
+#define _UDI_MEI_ARG_LIST3(t,a) , _UDI_MEI_FIRST t _UDI_MEI_FIRST a \
+ _UDI_MEI_ARG_LIST2(_UDI_MEI_OTHER t, _UDI_MEI_OTHER a)
+
+#define _UDI_ARG_LIST_0()
+#define _UDI_ARG_LIST_1(a) ,a
+#define _UDI_ARG_LIST_2(a,b) ,a,b
+#define _UDI_ARG_LIST_3(a,b,c) ,a,b,c
#define UDI_MEI_STUBS(op_name, cb_type, argc, args, arg_types, arg_va_list, meta_ops_num, vec_idx) \
- void op_name(cb_type *cb, _UDI_ARG_LIST_##argc args ) {\
- udi_mei_call(UDI_GCB(cb), &udi_mei_info, meta_ops_num, vec_idx, args);\
+ void op_name(cb_type *cb _UDI_MEI_ARG_LIST##argc(arg_types, args) ) {\
+ udi_mei_call(UDI_GCB(cb), &udi_mei_info, meta_ops_num, vec_idx _UDI_ARG_LIST_##argc args);\
}\
- void op_name##_direct(udi_op_t *op, udi_cb_t *gcb, va_lis arglist) {\
- _UDI_MEI_VARGS##argc(args ,## arg_types ,## arg_va_list)\
- (*(op_name##_op_t)op)(UDI_MCB(gcb, cb_type) ,## args);\
+ void op_name##_direct(udi_op_t *op, udi_cb_t *gcb, va_list arglist) {\
+ _UDI_MEI_VARGS##argc(arg_types, args, arg_va_list)\
+ (*(op_name##_op_t*)op)(UDI_MCB(gcb, cb_type) _UDI_ARG_LIST_##argc args);\
}\
void op_name##_backend(udi_op_t *op, udi_cb_t *gcb, void *marshal_space) {\
}