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)
75 struct marshalled_bus_bind_ack *info = (void*)Call;
76 ((udi_bus_bind_ack_op_t*)Call->Handler)(
77 UDI_MCB(Call->cb, udi_bus_bind_cb_t),
78 info->dma_constraints,
79 info->preferred_endianness,
84 void udi_bus_bind_ack(
85 udi_bus_bind_cb_t *cb,
86 udi_dma_constraints_t dma_constraints,
87 udi_ubit8_t preferred_endianness,
91 LOG("cb=%p{...}, dma_constraints=%p, preferred_endianness=%i,status=%i",
92 cb, dma_constraints, preferred_endianness, status);
93 PREP_OPS(udi_bus_device_ops_t, &cMetaLang_BusBridge, UDI_BUS_DEVICE_OPS_NUM)
95 struct marshalled_bus_bind_ack *call = NEW(struct marshalled_bus_bind_ack,);
96 call->Call.Unmarshal = _unmarshal_bus_bind_ack;
97 call->Call.cb = UDI_GCB(cb);
98 call->Call.Handler = (udi_op_t*)ops->bus_bind_ack_op;
99 call->dma_constraints = dma_constraints;
100 call->preferred_endianness = preferred_endianness;
101 call->status = status;
102 UDI_int_AddDeferred(&call->Call);