Modules/UDI - Cleaned up source layout, implemented PCI IRQs
[tpg/acess2.git] / KernelLand / Modules / Interfaces / UDI / udi_lib / core / imc.c
1 /**
2  * \file imc.c
3  * \author John Hodge (thePowersGang)
4  */
5 #define DEBUG   1
6 #include <udi.h>
7 #include <acess.h>
8 #include <udi_internal.h>
9
10 // === EXPORTS ===
11 EXPORT(udi_channel_anchor);
12 EXPORT(udi_channel_spawn);
13 EXPORT(udi_channel_set_context);
14 EXPORT(udi_channel_op_abort);
15 EXPORT(udi_channel_close);
16 EXPORT(udi_channel_event_ind);
17 EXPORT(udi_channel_event_complete);
18
19 // === CODE ===
20 /**
21  */
22 void udi_channel_anchor(
23         udi_channel_anchor_call_t *callback, udi_cb_t *gcb,
24         udi_channel_t channel, udi_index_t ops_idx, void *channel_context
25         )
26 {
27         UNIMPLEMENTED();
28 }
29
30 /**
31  */
32 extern void udi_channel_spawn(
33         udi_channel_spawn_call_t *callback, udi_cb_t *gcb,
34         udi_channel_t channel, udi_index_t spawn_idx,
35         udi_index_t ops_idx, void *channel_context
36         )
37 {
38         LOG("gcb=%p,channel=%p", gcb, channel, spawn_idx, ops_idx, channel_context);
39         
40         // Search existing channel for a matching spawn_idx
41         udi_channel_t ret = UDI_CreateChannel_Linked(channel, spawn_idx);
42
43         // Bind local end of channel to ops_idx (with channel_context)
44         if( ops_idx != 0 )
45         {
46                 udi_index_t     region_idx;
47                 tUDI_DriverInstance     *inst = UDI_int_ChannelGetInstance(gcb, false, &region_idx);
48                 UDI_BindChannel(ret, false, inst, ops_idx, region_idx, channel_context, false,0);
49         }
50         else
51         {
52                 // leave unbound
53         }
54
55         callback(gcb, ret);
56 }
57
58 /**
59  * 
60  */
61 void udi_channel_set_context(
62         udi_channel_t target_channel, void *channel_context
63         )
64 {
65         LOG("target_channel=%p,channel_context=%p", target_channel, channel_context);
66         UDI_int_ChannelSetContext(target_channel, channel_context);
67 }
68
69 void udi_channel_op_abort(
70         udi_channel_t target_channel, udi_cb_t *orig_cb
71         )
72 {
73         udi_channel_event_cb_t cb;
74         cb.gcb.channel = target_channel;
75         cb.event = UDI_CHANNEL_CLOSED;
76         cb.params.orig_cb = orig_cb;
77         udi_channel_event_ind(&cb);
78 }
79
80 void udi_channel_close(udi_channel_t channel)
81 {
82         Warning("%s Unimplemented", __func__);
83 }
84
85 void udi_channel_event_ind(udi_channel_event_cb_t *cb)
86 {
87         LOG("cb=%p{...}", cb);
88         const struct {
89                 udi_channel_event_ind_op_t *channel_event_ind_op;
90         } *ops = UDI_int_ChannelPrepForCall( UDI_GCB(cb), NULL, 0 );
91         if(!ops) {
92                 Log_Warning("UDI", "udi_channel_event_ind on wrong channel type");
93                 return ;
94         }
95
96         // UDI_int_MakeDeferredCb( UDI_GCB(cb), ops->channel_event_ind_op );
97
98         UDI_int_ChannelReleaseFromCall( UDI_GCB(cb) );  
99         ops->channel_event_ind_op(cb);
100 }
101
102 void udi_channel_event_complete(udi_channel_event_cb_t *cb, udi_status_t status)
103 {
104         UNIMPLEMENTED();
105 }

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