3 * - By John Hodge (thePowersGang)
5 * udi_lib/physio/meta_bus.c
6 * - Bus Bridge Metalanguage
11 #include <udi_physio.h>
12 #include "../../udi_internal.h"
15 udi_layout_t cMetaLang_BusBridge_IntrAttachCbLayout[] = {
18 UDI_DL_ORIGIN_T, // TODO: handle
21 tUDI_MetaLang cMetaLang_BusBridge = {
27 {sizeof(udi_bus_bind_cb_t), NULL}, // Defined, but is just a gcb
28 {sizeof(udi_intr_attach_cb_t), NULL},
29 {sizeof(udi_intr_detach_cb_t), NULL},
30 {sizeof(udi_intr_event_cb_t), NULL}
35 EXPORT(udi_bus_unbind_req);
36 EXPORT(udi_bus_unbind_ack);
37 EXPORT(udi_bus_bind_req);
38 EXPORT(udi_bus_bind_ack);
40 #define PREP_OPS(type,ml,num) const type *ops = UDI_int_ChannelPrepForCall(UDI_GCB(cb), ml, num); \
41 if(!ops) { Log_Warning("UDI", "%s on wrong channel type", __func__); return ; }
43 #define PREP_OPS_DEVICE const udi_bus_device_ops_t *ops = UDI_int_ChannelPrepForCall( UDI_GCB(cb), &cMetaLang_BusBridge, UDI_BUS_DEVICE_OPS_NUM ); \
44 if(!ops) { Log_Warning("UDI", "%s on wrong channel type", __func__); return ; }
47 void udi_bus_unbind_req(udi_bus_bind_cb_t *cb)
51 void udi_bus_unbind_ack(udi_bus_bind_cb_t *cb)
56 void udi_bus_bind_req(udi_bus_bind_cb_t *cb)
58 LOG("cb=%p{...}", cb);
59 PREP_OPS(udi_bus_bridge_ops_t, &cMetaLang_BusBridge, UDI_BUS_BRIDGE_OPS_NUM)
61 UDI_int_MakeDeferredCb( UDI_GCB(cb), (udi_op_t*)ops->bus_bind_req_op );
64 struct marshalled_bus_bind_ack
66 tUDI_DeferredCall Call;
67 udi_dma_constraints_t dma_constraints;
68 udi_ubit8_t preferred_endianness;
72 static void _unmarshal_bus_bind_ack(tUDI_DeferredCall *Call)
74 struct marshalled_bus_bind_ack *info = (void*)Call;
75 ((udi_bus_bind_ack_op_t*)Call->Handler)(
76 UDI_MCB(Call->cb, udi_bus_bind_cb_t),
77 info->dma_constraints,
78 info->preferred_endianness,
83 void udi_bus_bind_ack(
84 udi_bus_bind_cb_t *cb,
85 udi_dma_constraints_t dma_constraints,
86 udi_ubit8_t preferred_endianness,
90 LOG("cb=%p{...}, dma_constraints=%p, preferred_endianness=%i,status=%i",
91 cb, dma_constraints, preferred_endianness, status);
92 PREP_OPS(udi_bus_device_ops_t, &cMetaLang_BusBridge, UDI_BUS_DEVICE_OPS_NUM)
94 struct marshalled_bus_bind_ack *call = NEW(struct marshalled_bus_bind_ack,);
95 call->Call.Unmarshal = _unmarshal_bus_bind_ack;
96 call->Call.cb = UDI_GCB(cb);
97 call->Call.Handler = (udi_op_t*)ops->bus_bind_ack_op;
98 call->dma_constraints = dma_constraints;
99 call->preferred_endianness = preferred_endianness;
100 call->status = status;
101 UDI_int_AddDeferred(&call->Call);