e173747e911630e43476255317417b5a28b04dde
[tpg/acess2.git] / KernelLand / Modules / Interfaces / UDI / channels.c
1 /*
2  * Acess2 UDI Layer
3  * - By John Hodge (thePowersGang)
4  */
5 #define DEBUG   0
6 #include <acess.h>
7 #include <udi.h>
8 #include "udi_internal.h"
9
10 struct sUDI_ChannelSide {
11         struct sUDI_Channel     *BackPtr;
12         const void      *Ops;
13         void    *Context;
14 };
15
16 typedef struct sUDI_Channel
17 {
18         enum eUDI_MetaLang      MetaLang;
19         struct sUDI_ChannelSide  Side[2];
20 } tUDI_Channel;
21
22 // === CODE ===
23 udi_channel_t UDI_CreateChannel(enum eUDI_MetaLang metalang, udi_index_t meta_ops_num,
24         tUDI_DriverInstance *ThisEnd, udi_index_t ThisOpsIndex,
25         tUDI_DriverInstance *OtherEnd, udi_index_t OtherOpsIndex)
26 {
27         tUDI_Channel    *ret = NEW(tUDI_Channel,);
28         ret->MetaLang = metalang;
29         ret->Side[0].BackPtr = ret;
30 //      ret->Side[0].Ops = ThisEnd->Module->InitInfo->Op;
31         ret->Side[1].BackPtr = ret;
32         return (udi_channel_t)&ret->Side[0].BackPtr;
33 }
34
35 const void *UDI_int_ChannelPrepForCall(udi_cb_t *gcb, enum eUDI_MetaLang metalang)
36 {
37         tUDI_Channel *ch = *(tUDI_Channel**)(gcb->channel);
38         ASSERTCR(ch->MetaLang, ==, metalang, NULL);
39
40         struct sUDI_ChannelSide *newside = (gcb->channel == (udi_channel_t)&ch->Side[0].BackPtr ? &ch->Side[1] : &ch->Side[0]);
41
42 //      gcb->initiator_context = gcb->context;
43         gcb->channel = (udi_channel_t)&newside->BackPtr;
44         gcb->context = newside->Context;
45         return newside->Ops;
46 }
47

UCC git Repository :: git.ucc.asn.au