97dd36d9d617e84b4339fbd281dcb0ca3de46027
[tpg/acess2.git] / KernelLand / Modules / Interfaces / UDI / udi_lib / physio / pio.c
1 /**
2  * \file udi_lib/physio/pio.c
3  * \author John Hodge (thePowersGang)
4  */
5 #define DEBUG   1
6 #include <udi.h>
7 #include <udi_physio.h>
8 #include <acess.h>
9 #include <udi_internal.h>
10
11 typedef void    _udi_pio_do_io_op_t(uint32_t child_ID, udi_ubit32_t regset_idx, udi_ubit32_t ofs, size_t len,
12         void *data, bool isOutput);
13
14 // === STRUCTURES ===
15 struct udi_pio_handle_s
16 {
17         tUDI_DriverInstance     *Inst;
18         udi_index_t     RegionIdx;
19         
20         _udi_pio_do_io_op_t     *IOFunc;
21         udi_ubit32_t    Offset;
22         udi_ubit32_t    Length;
23         
24         size_t  nTransOps;
25         udi_pio_trans_t *TransOps;
26         
27         udi_ubit16_t    PIOAttributes;
28         udi_ubit32_t    Pace;
29         udi_index_t     Domain;
30
31         // TODO: Cached labels
32 };
33
34 // === IMPORTS ===
35 extern _udi_pio_do_io_op_t      pci_pio_do_io;
36
37 // === EXPORTS ===
38 EXPORT(udi_pio_map);
39 EXPORT(udi_pio_unmap);
40 EXPORT(udi_pio_atmic_sizes);
41 EXPORT(udi_pio_abort_sequence);
42 EXPORT(udi_pio_trans);
43 EXPORT(udi_pio_probe);
44
45 // === CODE ===
46 void udi_pio_map(udi_pio_map_call_t *callback, udi_cb_t *gcb,
47         udi_ubit32_t regset_idx, udi_ubit32_t base_offset, udi_ubit32_t length,
48         udi_pio_trans_t *trans_list, udi_ubit16_t list_length,
49         udi_ubit16_t pio_attributes, udi_ubit32_t pace, udi_index_t serialization_domain)
50 {
51         LOG("gcb=%p,regset_idx=%i,base_offset=0x%x,length=0x%x,trans_list=%p,list_length=%i,...",
52                 gcb, regset_idx, base_offset, length, trans_list, list_length);
53         char bus_type[16];
54         udi_instance_attr_type_t        type;
55         type = udi_instance_attr_get_internal(gcb, "bus_type", 0, bus_type, sizeof(bus_type), NULL);
56         if(type != UDI_ATTR_STRING) {
57                 Log_Warning("UDI", "No/invalid bus_type attribute");
58                 callback(gcb, UDI_NULL_PIO_HANDLE);
59                 return ;
60         }
61
62
63         _udi_pio_do_io_op_t     *io_op;
64         if( strcmp(bus_type, "pci") == 0 ) {
65                 // Ask PCI binding
66                 io_op = pci_pio_do_io;
67         }
68         else {
69                 // Oops, unknown
70                 callback(gcb, UDI_NULL_PIO_HANDLE);
71                 return ;
72         }
73
74         udi_pio_handle_t ret = malloc( sizeof(struct udi_pio_handle_s) );
75         ret->Inst = UDI_int_ChannelGetInstance(gcb, false, &ret->RegionIdx);
76         ret->IOFunc = io_op;
77         ret->Offset = base_offset;
78         ret->Length = length;
79         ret->TransOps = trans_list;
80         // TODO: Pre-scan to get labels
81         ret->nTransOps = list_length;
82         ret->PIOAttributes = pio_attributes;
83         ret->Pace = pace;
84         // TODO: Validate serialization_domain
85         ret->Domain = serialization_domain;
86         
87         callback(gcb, ret);
88 }
89
90 void udi_pio_unmap(udi_pio_handle_t pio_handle)
91 {
92         UNIMPLEMENTED();
93 }
94
95 udi_ubit32_t udi_pio_atmic_sizes(udi_pio_handle_t pio_handle)
96 {
97         UNIMPLEMENTED();
98         return 0;
99 }
100
101 void udi_pio_abort_sequence(udi_pio_handle_t pio_handle, udi_size_t scratch_requirement)
102 {
103         UNIMPLEMENTED();
104 }
105
106 void udi_pio_trans(udi_pio_trans_call_t *callback, udi_cb_t *gcb,
107         udi_pio_handle_t pio_handle, udi_index_t start_label,
108         udi_buf_t *buf, void *mem_ptr)
109 {
110         UNIMPLEMENTED();
111 }
112
113 void udi_pio_probe(udi_pio_probe_call_t *callback, udi_cb_t *gcb,
114         udi_pio_handle_t pio_handle, void *mem_ptr, udi_ubit32_t pio_offset,
115         udi_ubit8_t tran_size, udi_ubit8_t direction)
116 {
117         UNIMPLEMENTED();
118 }
119

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