Mercurial > archived > louis > epitech > mq > rathaxes
comparison rathaxes_samples_e1000_add_a_dma_abstraction.patch @ 117:f3c7e9b0c5cf
WIP on the DMA API
author | Louis Opter <louis@lse.epita.fr> |
---|---|
date | Thu, 25 Jul 2013 16:45:13 -0700 |
parents | 5a663f8f0e54 |
children | ad21d8a182ad |
comparison
equal
deleted
inserted
replaced
116:2a7126613c70 | 117:f3c7e9b0c5cf |
---|---|
1 # HG changeset patch | 1 # HG changeset patch |
2 # Parent af7a1f8589d632497e2f2574570f5153cae59b91 | 2 # Parent 61470dc5e775a696da551b5227663bf2659f8f4b |
3 e1000: start a DMA allocation/mapping abstraction | 3 e1000: start a DMA allocation/mapping abstraction |
4 | 4 |
5 It currently matches a lot the Linux DMA API but it should be usable by | 5 It currently matches a lot the Linux DMA API but it should be usable by |
6 other OSes too. The Linux DMA API is described at the end of the chapter | 6 other OSes too. The Linux DMA API is described at the end of the chapter |
7 15 in the LDD3. | 7 15 in the LDD3. |
33 ethernet.blt) | 33 ethernet.blt) |
34 diff --git a/rathaxes/samples/e1000/dma.blt b/rathaxes/samples/e1000/dma.blt | 34 diff --git a/rathaxes/samples/e1000/dma.blt b/rathaxes/samples/e1000/dma.blt |
35 new file mode 100644 | 35 new file mode 100644 |
36 --- /dev/null | 36 --- /dev/null |
37 +++ b/rathaxes/samples/e1000/dma.blt | 37 +++ b/rathaxes/samples/e1000/dma.blt |
38 @@ -0,0 +1,89 @@ | 38 @@ -0,0 +1,103 @@ |
39 +with DMA, Builtin, LKM, Device | 39 +with DMA, Builtin, LKM, Device |
40 +{ | 40 +{ |
41 + template type DMA::AbstractDMAHandle() | 41 + template type DMA::AbstractDMAHandle() |
42 + { | 42 + { |
43 + chunk LKM::includes() | 43 + chunk LKM::includes() |
50 + dma_addr_t data; | 50 + dma_addr_t data; |
51 + } | 51 + } |
52 + | 52 + |
53 + map | 53 + map |
54 + { | 54 + { |
55 + k_dma_handle: ((dma_addr_t)${self}); | 55 + k_dma_handle: (dma_addr_t)(${self}); |
56 + } | |
57 + } | |
58 + | |
59 + template type DMA::DMAHandle() | |
60 + { | |
61 + decl data_types() | |
62 + { | |
63 + ${DMA::AbstractDMAHandle} data; | |
64 + } | |
65 + | |
66 + map | |
67 + { | |
68 + /* XXX: we should use ${DMA::AbstractDMAHandle} here: */ | |
69 + dma_handle: (dma_addr_t)(${self}); | |
56 + } | 70 + } |
57 + } | 71 + } |
58 + | 72 + |
59 + template type DMA::AbstractDMADirection() | 73 + template type DMA::AbstractDMADirection() |
60 + { | 74 + { |
63 + enum dma_data_direction data; | 77 + enum dma_data_direction data; |
64 + } | 78 + } |
65 + | 79 + |
66 + map | 80 + map |
67 + { | 81 + { |
68 + k_dma_direction: ((enum dma_data_direction)${self}); | 82 + k_dma_direction: (enum dma_data_direction)(${self}); |
69 + } | 83 + } |
70 + } | 84 + } |
71 + | 85 + |
72 + template type DMA::DMADirection() | 86 + template type DMA::DMADirection() |
73 + { | 87 + { |
79 + } | 93 + } |
80 + | 94 + |
81 + map | 95 + map |
82 + { | 96 + { |
83 + /* XXX: we should use ${DMA::AbstractDMADirection} here: */ | 97 + /* XXX: we should use ${DMA::AbstractDMADirection} here: */ |
84 + dma_direction: ((enum dma_data_direction)${self}); | 98 + dma_direction: (enum dma_data_direction)(${self}); |
85 + } | 99 + } |
86 + } | 100 + } |
87 + | 101 + |
88 + template sequence map(Device::AbstractDevice dev, Builtin::symbol buf, Builtin::number size, DMA::DMADirection dir) | 102 + template sequence map(Device::AbstractDevice dev, Builtin::symbol buf, Builtin::number size, DMA::DMADirection dir) |
89 + { | 103 + { |
90 + chunk ::CALL() | 104 + chunk ::CALL() |
91 + { | 105 + { |
92 + ((${DMA::DMA::AbstractDMAHandle})dma_map_single(${dev.k_device}, ${buf}, ${size}, ${dir.dma_direction})); | 106 + ((${DMA::DMAHandle})dma_map_single(${dev.k_device}, ${buf}, ${size}, ${dir.dma_direction})); |
93 + } | 107 + } |
94 + } | 108 + } |
95 + | 109 + |
96 + template sequence unmap(Device::AbstractDevice dev, DMA::AbstractDMAHandle handle, Builtin::number size, DMA::DMADirection dir) | 110 + template sequence unmap(Device::AbstractDevice dev, DMA::AbstractDMAHandle handle, Builtin::number size, DMA::DMADirection dir) |
97 + { | 111 + { |
127 +} | 141 +} |
128 diff --git a/rathaxes/samples/e1000/dma.rti b/rathaxes/samples/e1000/dma.rti | 142 diff --git a/rathaxes/samples/e1000/dma.rti b/rathaxes/samples/e1000/dma.rti |
129 new file mode 100644 | 143 new file mode 100644 |
130 --- /dev/null | 144 --- /dev/null |
131 +++ b/rathaxes/samples/e1000/dma.rti | 145 +++ b/rathaxes/samples/e1000/dma.rti |
132 @@ -0,0 +1,48 @@ | 146 @@ -0,0 +1,54 @@ |
133 +interface DMA : Builtin, LKM, Device | 147 +interface DMA : Builtin, LKM, Device |
134 +{ | 148 +{ |
135 + provided type AbstractDMAHandle | 149 + provided type AbstractDMAHandle |
136 + { | 150 + { |
137 + chunk LKM::includes(); | 151 + chunk LKM::includes(); |
138 + decl data_types(); | 152 + decl data_types(); |
139 + attribute Builtin::symbol.scalar k_dma_handle; | 153 + attribute Builtin::symbol.scalar k_dma_handle; |
140 + } | 154 + } |
141 + | 155 + |
156 + provided type DMAHandle | |
157 + { | |
158 + decl data_types(); | |
159 + attribute AbstractDMAHandle.scalar dma_handle; | |
160 + } | |
161 + | |
142 + provided type AbstractDMADirection | 162 + provided type AbstractDMADirection |
143 + { | 163 + { |
144 + decl data_types(); | 164 + decl data_types(); |
145 + attribute Builtin::symbol.scalar k_dma_direction; | 165 + attribute Builtin::symbol.scalar k_dma_direction; |
146 + } | 166 + } |