Mercurial > archived > louis > epitech > mq > rathaxes
comparison E1000_UpdateToScalarRef @ 106:976a4b87803f
Fix the resolution and the e1000 sample with the new scalar ref feature
author | David Pineau <dav.pineau@gmail.com> |
---|---|
date | Mon, 25 Mar 2013 01:17:56 +0100 |
parents | |
children | 7efe3212db3a |
comparison
equal
deleted
inserted
replaced
105:fb20f01ea997 | 106:976a4b87803f |
---|---|
1 # HG changeset patch | |
2 # Parent 9e6d855c6c477852924e13d354686f18d2036a0e | |
3 Update the e1000 sample with the new features | |
4 | |
5 diff --git a/rathaxes/samples/e1000/e1000.blt b/rathaxes/samples/e1000/e1000.blt | |
6 --- a/rathaxes/samples/e1000/e1000.blt | |
7 +++ b/rathaxes/samples/e1000/e1000.blt | |
8 @@ -87,7 +87,7 @@ | |
9 decl data_types() | |
10 { | |
11 unsigned int size; | |
12 - ${e1000::RxDescriptor} *base; | |
13 + ${e1000::RxDescriptor.ref} base; | |
14 dma_addr_t dma_base; | |
15 ${Socket::SKBuff} skbuffs[${config.rx_ring_size}]; | |
16 } | |
17 @@ -124,7 +124,7 @@ | |
18 { | |
19 unsigned int size; | |
20 /* XXX: can't use ${e1000::TxDescriptor} here: */ | |
21 - ${e1000::TxDescriptor} *base; /* rename to descs */ | |
22 + ${e1000::TxDescriptor.ref} base; /* rename to descs */ | |
23 dma_addr_t dma_base; | |
24 ${Socket::SKBuff} skbuffs[${config.tx_ring_size}]; | |
25 unsigned short head; | |
26 @@ -133,20 +133,20 @@ | |
27 | |
28 chunk LKM::prototypes() | |
29 { | |
30 - static void rtx_e1000_tx_ring_clean(${e1000::TxRing} *); | |
31 - static unsigned int rtx_e1000_tx_ring_descriptors_remaining(${e1000::TxRing} *); | |
32 - static int rtx_e1000_tx_ring_tso_cksum_offload(${e1000::TxRing} *, ${Socket::SKBuff} *); | |
33 - static void rtx_e1000_tx_ring_put(${e1000::TxRing} *, ${Socket::SKBuff} *); | |
34 + static void rtx_e1000_tx_ring_clean(${e1000::TxRing.ref}); | |
35 + static unsigned int rtx_e1000_tx_ring_descriptors_remaining(${e1000::TxRing.ref}); | |
36 + static int rtx_e1000_tx_ring_tso_cksum_offload(${e1000::TxRing.ref}, ${Socket::SKBuff.ref}); | |
37 + static void rtx_e1000_tx_ring_put(${e1000::TxRing.ref}, ${Socket::SKBuff.ref}); | |
38 /* FIXME: See issue #54 */ | |
39 - static void rtx_e1000_tx_ring_start_xmit(${e1000::TxRing} *, /*const*/ ${e1000::Context} *); | |
40 + static void rtx_e1000_tx_ring_start_xmit(${e1000::TxRing.ref}, /*const*/ ${e1000::Context.ref}); | |
41 } | |
42 | |
43 chunk LKM::code() | |
44 { | |
45 - static void rtx_e1000_tx_ring_clean(${e1000::TxRing} *self) | |
46 + static void rtx_e1000_tx_ring_clean(${e1000::TxRing.ref} self) | |
47 { | |
48 - ${e1000::TxDescriptor} *tx_desc; | |
49 - bool done; | |
50 + ${e1000::TxDescriptor.ref} tx_desc; | |
51 + bool done; | |
52 | |
53 for (; self->head != self->tail; self->head++) | |
54 { | |
55 @@ -159,7 +159,7 @@ | |
56 pr_info("%s: tx_ring_clean: moving head to %d/%d", ${config.name}, self->head, ${config.tx_ring_size}); | |
57 } | |
58 | |
59 - static unsigned int rtx_e1000_tx_ring_descriptors_remaining(${e1000::TxRing} *self) | |
60 + static unsigned int rtx_e1000_tx_ring_descriptors_remaining(${e1000::TxRing.ref} self) | |
61 { | |
62 if (self->tail == self->head) /* ring is empty */ | |
63 return 256; /* XXX: ${config.tx_ring_size}; */ | |
64 @@ -169,19 +169,17 @@ | |
65 return self->head - self->tail; | |
66 } | |
67 | |
68 - static int rtx_e1000_tx_ring_tso_cksum_offload(${e1000::TxRing} *self, ${Socket::SKBuff} *skb) | |
69 + static int rtx_e1000_tx_ring_tso_cksum_offload(${e1000::TxRing.ref} self, ${Socket::SKBuff.ref} skb) | |
70 { | |
71 /* XXX We can't use ${skb} here because it's a pointer */ | |
72 - ${Socket::AbstractSKBuff} *k_skb = skb->skbuff; | |
73 - ${cast local.k_skb as Socket::AbstractSKBuff}; | |
74 + ${Socket::AbstractSKBuff.ref} k_skb = skb->skbuff; | |
75 return skb_is_gso(${local.k_skb.k_sk_buff}) || ${local.k_skb.k_sk_buff}->ip_summed == CHECKSUM_PARTIAL; | |
76 } | |
77 | |
78 - static void rtx_e1000_tx_ring_put(${e1000::TxRing} *self, ${Socket::SKBuff} *skb) | |
79 + static void rtx_e1000_tx_ring_put(${e1000::TxRing.ref} self, ${Socket::SKBuff.ref} skb) | |
80 { | |
81 /* XXX We can't use ${skb} here because it's a pointer */ | |
82 - ${Socket::AbstractSKBuff} *k_skb = skb->skbuff; | |
83 - ${cast local.k_skb as Socket::AbstractSKBuff}; | |
84 + ${Socket::AbstractSKBuff.ref} k_skb = skb->skbuff; | |
85 WARN_ON(!skb); | |
86 | |
87 /* | |
88 @@ -192,7 +190,7 @@ | |
89 * code shouldn't be aware of it and use something more | |
90 * abstract. | |
91 */ | |
92 - ${e1000::TxDescriptor} *tx_desc = &self->base[self->tail]; | |
93 + ${e1000::TxDescriptor.ref} tx_desc = &self->base[self->tail]; | |
94 tx_desc->lower.data = cpu_to_le32( | |
95 E1000_TXD_CMD_EOP | | |
96 E1000_TXD_CMD_IFCS | | |
97 @@ -205,7 +203,7 @@ | |
98 } | |
99 | |
100 /* FIXME: See issue #54 */ | |
101 - static void rtx_e1000_tx_ring_start_xmit(${e1000::TxRing} *self, /*const*/ ${e1000::Context} *hw_ctx) | |
102 + static void rtx_e1000_tx_ring_start_xmit(${e1000::TxRing.ref} self, /*const*/ ${e1000::Context.ref} hw_ctx) | |
103 { | |
104 pr_info("%s: start_xmit: moving tail to %d/%d", ${config.name}, self->tail, ${config.tx_ring_size}); | |
105 rtx_e1000_register_write32(hw_ctx, E1000_TDT, self->tail); | |
106 @@ -271,7 +269,7 @@ | |
107 Builtin::symbol ioaddr) | |
108 { | |
109 { | |
110 - ${e1000::Context} *hw_ctx = &${rtx_ether_ctx}->hw_ctx; | |
111 + ${e1000::Context.ref} hw_ctx = &${rtx_ether_ctx}->hw_ctx; | |
112 hw_ctx->bars = ${bars}; | |
113 hw_ctx->ioaddr = ${ioaddr}; | |
114 } | |
115 @@ -280,8 +278,9 @@ | |
116 chunk Ethernet::adapter_reset(Ethernet::Device rtx_ether_ctx) | |
117 { | |
118 { | |
119 - ${e1000::Context} *hw_ctx = &${rtx_ether_ctx}->hw_ctx; | |
120 - rtx_e1000_register_write32(hw_ctx, E1000_CTRL, E1000_CMD_RST); | |
121 + /* XXX Naming this variable 'hw_ctx' kicks the decl out of the generated code */ | |
122 + ${e1000::Context.ref} tmp_hw_ctx = &${rtx_ether_ctx}->hw_ctx; | |
123 + rtx_e1000_register_write32(tmp_hw_ctx, E1000_CTRL, E1000_CMD_RST); | |
124 udelay(10); | |
125 } | |
126 } | |
127 @@ -289,7 +288,7 @@ | |
128 chunk Ethernet::adapter_load_mac_address(Ethernet::Device rtx_ether_ctx) | |
129 { | |
130 { | |
131 - ${e1000::Context} *hw_ctx = &${rtx_ether_ctx}->hw_ctx; | |
132 + ${e1000::Context.ref} hw_ctx = &${rtx_ether_ctx}->hw_ctx; | |
133 /* Shamelessly borrowed from Minix */ | |
134 for (int i = 0; i < 3; ++i) | |
135 { | |
136 @@ -468,12 +467,12 @@ | |
137 { | |
138 chunk LKM::prototypes() | |
139 { | |
140 - static void rtx_e1000_print_status(${e1000::Context} *); | |
141 + static void rtx_e1000_print_status(${e1000::Context.ref}); | |
142 } | |
143 | |
144 chunk LKM::code() | |
145 { | |
146 - static void rtx_e1000_print_status(${e1000::Context} *hw_ctx) | |
147 + static void rtx_e1000_print_status(${e1000::Context.ref} hw_ctx) | |
148 { | |
149 unsigned int status = rtx_e1000_register_read32(hw_ctx, E1000_STATUS); | |
150 ${Log::info("card status:")}; | |
151 @@ -518,13 +517,13 @@ | |
152 chunk LKM::prototypes() | |
153 { | |
154 /* FIXME: See issue #54 */ | |
155 - static unsigned int rtx_e1000_register_read32(/*const*/ ${e1000::Context} *, unsigned int); | |
156 + static unsigned int rtx_e1000_register_read32(/*const*/ ${e1000::Context.ref}, unsigned int); | |
157 } | |
158 | |
159 chunk LKM::code() | |
160 { | |
161 /* FIXME: See issue #54 */ | |
162 - static unsigned int rtx_e1000_register_read32(/*const*/ ${e1000::Context} *ctx, unsigned int reg_offset) | |
163 + static unsigned int rtx_e1000_register_read32(/*const*/ ${e1000::Context.ref} ctx, unsigned int reg_offset) | |
164 { | |
165 return ioread32(ctx->ioaddr + reg_offset); | |
166 } | |
167 @@ -541,13 +540,13 @@ | |
168 chunk LKM::prototypes() | |
169 { | |
170 /* FIXME: See issue #54 */ | |
171 - static void rtx_e1000_register_write32(/*const*/ ${e1000::Context} *, unsigned int, unsigned int); | |
172 + static void rtx_e1000_register_write32(/*const*/ ${e1000::Context.ref}, unsigned int, unsigned int); | |
173 } | |
174 | |
175 chunk LKM::code() | |
176 { | |
177 /* FIXME: See issue #54 */ | |
178 - static void rtx_e1000_register_write32(/*const*/ ${e1000::Context} *ctx, unsigned int reg_offset, unsigned int value) | |
179 + static void rtx_e1000_register_write32(/*const*/ ${e1000::Context.ref} ctx, unsigned int reg_offset, unsigned int value) | |
180 { | |
181 iowrite32(value, ctx->ioaddr + reg_offset); | |
182 } | |
183 @@ -564,13 +563,13 @@ | |
184 chunk LKM::prototypes() | |
185 { | |
186 /* FIXME: See issue #54 */ | |
187 - static void rtx_e1000_register_set32(/*const*/ ${e1000::Context} *, unsigned int, unsigned int); | |
188 + static void rtx_e1000_register_set32(/*const*/ ${e1000::Context.ref}, unsigned int, unsigned int); | |
189 } | |
190 | |
191 chunk LKM::code() | |
192 { | |
193 /* FIXME: See issue #54 */ | |
194 - static void rtx_e1000_register_set32(/*const*/ ${e1000::Context} *ctx, unsigned int reg_offset, unsigned int value) | |
195 + static void rtx_e1000_register_set32(/*const*/ ${e1000::Context.ref} ctx, unsigned int reg_offset, unsigned int value) | |
196 { | |
197 iowrite32(rtx_e1000_register_read32(ctx, reg_offset) | value, ctx->ioaddr + reg_offset); | |
198 } | |
199 @@ -587,13 +586,13 @@ | |
200 chunk LKM::prototypes() | |
201 { | |
202 /* FIXME: See issue #54 */ | |
203 - static void rtx_e1000_register_unset32(/*const*/ ${e1000::Context} *, unsigned int, unsigned int); | |
204 + static void rtx_e1000_register_unset32(/*const*/ ${e1000::Context.ref}, unsigned int, unsigned int); | |
205 } | |
206 | |
207 chunk LKM::code() | |
208 { | |
209 /* FIXME: See issue #54 */ | |
210 - static void rtx_e1000_register_unset32(/*const*/ ${e1000::Context} *ctx, unsigned int reg_offset, unsigned int value) | |
211 + static void rtx_e1000_register_unset32(/*const*/ ${e1000::Context.ref} ctx, unsigned int reg_offset, unsigned int value) | |
212 { | |
213 iowrite32(rtx_e1000_register_read32(ctx, reg_offset) & ~value, ctx->ioaddr + reg_offset); | |
214 } | |
215 @@ -644,7 +643,7 @@ | |
216 * e1000::Context? (but we would need to make it point back to | |
217 * the struct net_device) | |
218 */ | |
219 - ${e1000::Context} *hw_ctx; | |
220 + ${e1000::Context.ref} hw_ctx; | |
221 hw_ctx = &${rtx_ether_ctx}->hw_ctx; | |
222 | |
223 /* | |
224 @@ -755,7 +754,7 @@ | |
225 */ | |
226 for (i = 0; i != ${config.rx_ring_size}; ++i) | |
227 { | |
228 - hw_ctx->rx_ring.skbuffs[i].skbuff = (${Socket::AbstractSKBuff}*)netdev_alloc_skb( | |
229 + hw_ctx->rx_ring.skbuffs[i].skbuff = (${Socket::AbstractSKBuff.ref})netdev_alloc_skb( | |
230 ${rtx_ether_ctx.net_device.k_net_dev}, /* XXX: .k_net_dev isn't expanded here */ | |
231 ${config.rx_buffer_len}); | |
232 if (!hw_ctx->rx_ring.skbuffs[i].skbuff) | |
233 @@ -894,8 +893,7 @@ | |
234 * XXX: Not generated if named "hw_ctx" (which is funny because | |
235 * it's used and works in the template right above this one): | |
236 */ | |
237 - ${e1000::Context} *hw_ctx_; | |
238 - ${cast local.hw_ctx_ as e1000::Context}; | |
239 + ${e1000::Context.ref} hw_ctx_; | |
240 hw_ctx_ = &${rtx_ether_ctx}->hw_ctx; | |
241 | |
242 /* | |
243 @@ -911,7 +909,7 @@ | |
244 ${config.rx_buffer_len}, | |
245 DMA_FROM_DEVICE); | |
246 /* XXX Go through the rtx types (Socket::SKBuff, AbstractSKBuff) */ | |
247 - dev_kfree_skb(hw_ctx_->rx_ring.skbuffs[i].skbuff); | |
248 + dev_kfree_skb((struct sk_buff*)hw_ctx_->rx_ring.skbuffs[i].skbuff); | |
249 } | |
250 dma_free_coherent(${rtx_ether_ctx.device}, hw_ctx_->rx_ring.size, | |
251 hw_ctx_->rx_ring.base, hw_ctx_->rx_ring.dma_base); | |
252 @@ -973,14 +971,14 @@ | |
253 */ | |
254 | |
255 ${Socket::SKBuff} skb; | |
256 - ${e1000::Context} *hw_ctx; | |
257 - ${e1000::TxRing} *tx_ring; | |
258 - ${Device::AbstractDevice} *devp; | |
259 + ${e1000::Context.ref} hw_ctx; | |
260 + ${e1000::TxRing.ref} tx_ring; | |
261 + ${Device::AbstractDevice.ref} devp; | |
262 | |
263 ${local.skb.init(kernel_skb)}; | |
264 hw_ctx = &${rtx_ether_ctx}->hw_ctx; | |
265 tx_ring = &hw_ctx->tx_ring; | |
266 - devp = (${Device::AbstractDevice}*)${rtx_ether_ctx.device}; | |
267 + devp = (${Device::AbstractDevice.ref})${rtx_ether_ctx.device}; | |
268 | |
269 ${Log::info("xmit: skbuff details:")}; | |
270 /* | |
271 diff --git a/rathaxes/samples/e1000/ethernet.blt b/rathaxes/samples/e1000/ethernet.blt | |
272 --- a/rathaxes/samples/e1000/ethernet.blt | |
273 +++ b/rathaxes/samples/e1000/ethernet.blt | |
274 @@ -61,7 +61,7 @@ | |
275 | |
276 method init(Builtin::symbol dev) | |
277 { | |
278 - ${self} = (${Ethernet::AbstractDevice} *)${dev}; | |
279 + ${self} = (${Ethernet::AbstractDevice.ref})${dev}; | |
280 } | |
281 | |
282 map | |
283 @@ -79,8 +79,8 @@ | |
284 * I think it's useless to use the ${PCI::AbstractDevice} "abstraction" | |
285 * here, since we already are in a Linux specific context. | |
286 */ | |
287 - ${PCI::AbstractDevice} *pci_dev; | |
288 - ${Ethernet::AbstractDevice} *net_dev; | |
289 + ${PCI::AbstractDevice.ref} pci_dev; | |
290 + ${Ethernet::AbstractDevice.ref} net_dev; | |
291 | |
292 /* | |
293 * In the long-term, this may disappear for a new concept allowing | |
294 @@ -144,14 +144,12 @@ | |
295 * XXX The casts are here because the compiler doesn't resolve | |
296 * "enclosed" type (e.g: local.var.enclosed) correctly. | |
297 */ | |
298 - ${Ethernet::AbstractDevice} *rtx_net_dev; | |
299 - ${cast local.rtx_net_dev as Ethernet::AbstractDevice}; | |
300 + ${Ethernet::AbstractDevice.ref} rtx_net_dev; | |
301 { /* XXX: I end up with a placeholder if I don't open a scope */ | |
302 ${local.rtx_net_dev.init(local.dev)}; | |
303 } | |
304 | |
305 - ${Ethernet::Device} *rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx}; | |
306 - ${cast local.rtx_ether_ctx as Ethernet::Device}; | |
307 + ${Ethernet::Device.ref} rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx}; | |
308 | |
309 int error; | |
310 { | |
311 @@ -189,10 +187,8 @@ | |
312 { | |
313 static int rtx_ethernet_xmit(struct sk_buff* kernel_skb, struct net_device *net_dev) | |
314 { | |
315 - ${Ethernet::Device} *rtx_ether_ctx = netdev_priv(net_dev); | |
316 - ${Socket::AbstractSKBuff} *rtx_skb = (${Socket::AbstractSKBuff}*) kernel_skb; | |
317 - ${cast local.rtx_skb as Socket::AbstractSKBuff}; | |
318 - ${cast local.rtx_ether_ctx as Ethernet::Device}; | |
319 + ${Ethernet::Device.ref} rtx_ether_ctx = netdev_priv(net_dev); | |
320 + ${Socket::AbstractSKBuff.ref} rtx_skb = (${Socket::AbstractSKBuff.ref}) kernel_skb; | |
321 | |
322 ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx, local.rtx_skb)}; | |
323 } | |
324 @@ -210,14 +206,12 @@ | |
325 { | |
326 static int rtx_ethernet_close(struct net_device *dev) | |
327 { | |
328 - ${Ethernet::AbstractDevice} *rtx_net_dev; | |
329 - ${cast local.rtx_net_dev as Ethernet::AbstractDevice}; | |
330 + ${Ethernet::AbstractDevice.ref} rtx_net_dev; | |
331 { /* XXX: I end up with a placeholder if I don't open a scope */ | |
332 ${local.rtx_net_dev.init(local.dev)}; | |
333 } | |
334 | |
335 - ${Ethernet::Device} *rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx}; | |
336 - ${cast local.rtx_ether_ctx as Ethernet::Device}; | |
337 + ${Ethernet::Device.ref} rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx}; | |
338 | |
339 /* TODO: change this pointcut into a pointcut/adapter/callback: */ | |
340 { | |
341 @@ -249,11 +243,9 @@ | |
342 { | |
343 static enum irqreturn rtx_ethernet_interrupt_handler(int irq, void *dev_id) | |
344 { | |
345 - ${Ethernet::AbstractDevice} *rtx_net_dev = dev_id; | |
346 - ${cast local.rtx_net_dev as Ethernet::AbstractDevice}; | |
347 + ${Ethernet::AbstractDevice.ref} rtx_net_dev = dev_id; | |
348 | |
349 - ${Ethernet::Device} *rtx_ether_ctx; | |
350 - ${cast local.rtx_ether_ctx as Ethernet::Device}; | |
351 + ${Ethernet::Device.ref} rtx_ether_ctx; | |
352 rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx}; | |
353 | |
354 ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx)}; | |
355 @@ -285,12 +277,11 @@ | |
356 */ | |
357 chunk PCI::pci_probe_hook(PCI::Device rtx_pci_dev) | |
358 { | |
359 - ${Ethernet::AbstractDevice} *rtx_net_dev; | |
360 - ${Ethernet::Device} *rtx_ether_ctx; | |
361 - ${cast local.rtx_net_dev as Ethernet::AbstractDevice}; | |
362 + ${Ethernet::AbstractDevice.ref} rtx_net_dev; | |
363 + ${Ethernet::Device.ref} rtx_ether_ctx; | |
364 | |
365 /* Cast the result back into our "transparent wrapper" type */ | |
366 - rtx_net_dev = (${Ethernet::AbstractDevice}*)alloc_etherdev(sizeof(*rtx_ether_ctx)); | |
367 + rtx_net_dev = (${Ethernet::AbstractDevice.ref})alloc_etherdev(sizeof(*rtx_ether_ctx)); | |
368 if (!rtx_net_dev) | |
369 { | |
370 ${Log::info("cannot allocate the ethernet device context")}; | |
371 @@ -317,8 +308,7 @@ | |
372 * type of rtx_pci_dev.pci_device to the type of | |
373 * rtx_pci_dev instead of the type of rtx_pci_dev.pci_device. | |
374 */ | |
375 - ${PCI::AbstractDevice} *workaround = ${rtx_pci_dev.pci_device}; | |
376 - ${cast local.workaround as PCI::AbstractDevice}; | |
377 + ${PCI::AbstractDevice.ref} workaround = ${rtx_pci_dev.pci_device}; | |
378 { /* XXX: I end up with a placeholder if I don't open a scope */ | |
379 ${local.rtx_ether_ctx.init(local.rtx_net_dev, local.workaround)}; | |
380 } | |
381 @@ -333,8 +323,7 @@ | |
382 */ | |
383 int bars = ${rtx_pci_dev.bars}; | |
384 unsigned char /* __iomem */ *ioaddr = ${rtx_pci_dev.ioaddr}; | |
385 - ${cast local.bars as Builtin::number}; | |
386 - ${cast local.rtx_ether_ctx as Ethernet::Device}; | |
387 + ${cast local.bars as Builtin::number.scalar}; | |
388 ${pointcut Ethernet::adapter_init_context(local.rtx_ether_ctx, | |
389 local.bars, | |
390 local.ioaddr)}; | |
391 @@ -359,12 +348,10 @@ | |
392 */ | |
393 chunk PCI::pci_remove_hook(PCI::Device rtx_pci_dev) | |
394 { | |
395 - ${Ethernet::Device} *rtx_ether_ctx = ${rtx_pci_dev.rtx_drv_context}; | |
396 - ${cast local.rtx_ether_ctx as Ethernet::Device}; /* XXX */ | |
397 + ${Ethernet::Device.ref} rtx_ether_ctx = ${rtx_pci_dev.rtx_drv_context}; | |
398 BUG_ON(!rtx_ether_ctx); | |
399 | |
400 - ${Ethernet::AbstractDevice} *rtx_net_dev = ${local.rtx_ether_ctx.net_device}; | |
401 - ${cast local.rtx_net_dev as Ethernet::AbstractDevice}; /* XXX */ | |
402 + ${Ethernet::AbstractDevice.ref} rtx_net_dev = ${local.rtx_ether_ctx.net_device}; | |
403 | |
404 unregister_netdev(${local.rtx_net_dev.k_net_dev}); | |
405 free_netdev(${local.rtx_net_dev.k_net_dev}); | |
406 diff --git a/rathaxes/samples/e1000/ethernet.rti b/rathaxes/samples/e1000/ethernet.rti | |
407 --- a/rathaxes/samples/e1000/ethernet.rti | |
408 +++ b/rathaxes/samples/e1000/ethernet.rti | |
409 @@ -41,9 +41,9 @@ | |
410 * I'd like to use better names here, but I'd like to understand the | |
411 * difference between the two first: | |
412 */ | |
413 - attribute Builtin::symbol.scalar perm_addr; | |
414 - attribute Builtin::symbol.scalar dev_addr; | |
415 - attribute Builtin::symbol.scalar irq; | |
416 + attribute Builtin::symbol.ref perm_addr; | |
417 + attribute Builtin::symbol.ref dev_addr; | |
418 + attribute Builtin::symbol.ref irq; | |
419 } | |
420 | |
421 required sequence open(Ethernet::Device) | |
422 diff --git a/rathaxes/samples/e1000/pci.blt b/rathaxes/samples/e1000/pci.blt | |
423 --- a/rathaxes/samples/e1000/pci.blt | |
424 +++ b/rathaxes/samples/e1000/pci.blt | |
425 @@ -32,7 +32,7 @@ | |
426 { | |
427 decl data_types() | |
428 { | |
429 - ${PCI::AbstractDevice} *pdev; | |
430 + ${PCI::AbstractDevice.ref} pdev; | |
431 int bars; | |
432 /* It could be an array at some point: */ | |
433 unsigned char /* __iomem */ *ioaddr; | |
434 @@ -41,17 +41,16 @@ | |
435 | |
436 chunk LKM::prototypes() | |
437 { | |
438 - static int rtx_pci_device_enable(${PCI::Device} *); | |
439 - static void rtx_pci_device_disable(${PCI::Device} *); | |
440 + static int rtx_pci_device_enable(${PCI::Device.ref}); | |
441 + static void rtx_pci_device_disable(${PCI::Device.ref}); | |
442 } | |
443 | |
444 chunk LKM::code() | |
445 { | |
446 - static int rtx_pci_device_enable(${PCI::Device} *self) | |
447 + static int rtx_pci_device_enable(${PCI::Device.ref} self) | |
448 { | |
449 int error; | |
450 - ${PCI::AbstractDevice} *enable_pdev = self->pdev; | |
451 - ${cast local.enable_pdev as PCI::AbstractDevice}; | |
452 + ${PCI::AbstractDevice.ref} enable_pdev = self->pdev; | |
453 error = pci_enable_device(${local.enable_pdev.k_pci_dev}); | |
454 if (error) | |
455 return error; | |
456 @@ -62,10 +61,9 @@ | |
457 return 0; | |
458 } | |
459 | |
460 - static void rtx_pci_device_disable(${PCI::Device} *self) | |
461 + static void rtx_pci_device_disable(${PCI::Device.ref} self) | |
462 { | |
463 - ${PCI::AbstractDevice} *disable_pdev = self->pdev; | |
464 - ${cast local.disable_pdev as PCI::AbstractDevice}; | |
465 + ${PCI::AbstractDevice.ref} disable_pdev = self->pdev; | |
466 if (self->ioaddr) | |
467 iounmap(self->ioaddr); | |
468 pci_release_selected_regions(${local.disable_pdev.k_pci_dev}, self->bars); | |
469 @@ -75,8 +73,7 @@ | |
470 | |
471 method init(PCI::AbstractDevice pdev) | |
472 { | |
473 - ${PCI::AbstractDevice} * workaround = (${PCI::AbstractDevice}*)pdev; | |
474 - ${cast local.workaround as PCI::AbstractDevice}; | |
475 + ${PCI::AbstractDevice.ref} workaround = (${PCI::AbstractDevice.ref})pdev; | |
476 ${self}->pdev = ${pdev}; | |
477 ${self}->bars = pci_select_bars(${local.workaround.k_pci_dev}, IORESOURCE_MEM); | |
478 ${self}->ioaddr = NULL; | |
479 @@ -95,8 +92,7 @@ | |
480 | |
481 method select_ioaddr(Builtin::number bar) | |
482 { | |
483 - ${PCI::AbstractDevice} *select_ioaddr_pdev = ${self}->pdev; | |
484 - ${cast local.select_ioaddr_pdev as PCI::AbstractDevice}; | |
485 + ${PCI::AbstractDevice.ref} select_ioaddr_pdev = ${self}->pdev; | |
486 ${self}->ioaddr = pci_ioremap_bar(${local.select_ioaddr_pdev.k_pci_dev}, ${bar}); | |
487 } | |
488 | |
489 @@ -131,9 +127,8 @@ | |
490 const struct pci_device_id *pdev_id) | |
491 { | |
492 int error; | |
493 - ${PCI::Device} *rtx_pci_dev; | |
494 - ${PCI::AbstractDevice} *rtx_pdev = (${PCI::AbstractDevice}*)pdev; | |
495 - ${cast local.rtx_pdev as PCI::AbstractDevice}; | |
496 + ${PCI::Device.ref} rtx_pci_dev; | |
497 + ${PCI::AbstractDevice.ref} rtx_pdev = (${PCI::AbstractDevice.ref})pdev; | |
498 | |
499 rtx_pci_dev = kmalloc(sizeof(*rtx_pci_dev), GFP_KERNEL); | |
500 if (!rtx_pci_dev) | |
501 @@ -173,12 +168,6 @@ | |
502 goto fail; | |
503 } | |
504 | |
505 - /* | |
506 - * XXX: We have to cast here because the compiler is | |
507 - * confused by the fact that rtx_pci_dev is a | |
508 - * pointer. | |
509 - */ | |
510 - ${cast local.rtx_pci_dev as PCI::Device}; | |
511 ${pointcut PCI::pci_probe_hook(local.rtx_pci_dev)}; | |
512 | |
513 return 0; | |
514 @@ -208,14 +197,11 @@ | |
515 { | |
516 static void rtx_pci_remove(struct pci_dev *pdev) | |
517 { | |
518 - ${PCI::AbstractDevice} *rtx_pdev = (${PCI::AbstractDevice}*)pdev; | |
519 - ${cast local.rtx_pdev as PCI::AbstractDevice}; | |
520 - ${PCI::Device} *rtx_pci_dev = ${rtx_pdev.rtx_pci_ctx}; | |
521 + ${PCI::AbstractDevice.ref} rtx_pdev = (${PCI::AbstractDevice.ref})pdev; | |
522 + ${PCI::Device.ref} rtx_pci_dev = ${rtx_pdev.rtx_pci_ctx}; | |
523 | |
524 BUG_ON(!rtx_pci_dev); | |
525 | |
526 - /* XXX: compiler confused by the pointer type. */ | |
527 - ${cast local.rtx_pci_dev as PCI::Device}; | |
528 ${pointcut PCI::pci_remove_hook(local.rtx_pci_dev)}; | |
529 | |
530 /* ${local.rtx_pci_dev.disable()}; */ | |
531 diff --git a/rathaxes/samples/e1000/socket.blt b/rathaxes/samples/e1000/socket.blt | |
532 --- a/rathaxes/samples/e1000/socket.blt | |
533 +++ b/rathaxes/samples/e1000/socket.blt | |
534 @@ -22,20 +22,20 @@ | |
535 { | |
536 decl data_types() | |
537 { | |
538 - ${Socket::AbstractSKBuff} *skbuff; | |
539 - dma_addr_t dma_handle; | |
540 + ${Socket::AbstractSKBuff.ref} skbuff; | |
541 + dma_addr_t dma_handle; | |
542 } | |
543 | |
544 chunk LKM::prototypes() | |
545 { | |
546 - static void rtx_socket_skbuff_dump_infos(${Socket::SKBuff} *); | |
547 - static int rtx_socket_skbuff_map(${Socket::SKBuff} *, struct device *, enum dma_data_direction); | |
548 - static void rtx_socket_skbuff_unmap_and_free(${Socket::SKBuff} *, struct device *, enum dma_data_direction); | |
549 + static void rtx_socket_skbuff_dump_infos(${Socket::SKBuff.ref}); | |
550 + static int rtx_socket_skbuff_map(${Socket::SKBuff.ref}, struct device *, enum dma_data_direction); | |
551 + static void rtx_socket_skbuff_unmap_and_free(${Socket::SKBuff.ref}, struct device *, enum dma_data_direction); | |
552 } | |
553 | |
554 chunk LKM::code() | |
555 { | |
556 - static void rtx_socket_skbuff_dump_infos(${Socket::SKBuff} *self) | |
557 + static void rtx_socket_skbuff_dump_infos(${Socket::SKBuff.ref} self) | |
558 { | |
559 WARN_ON(!self->skbuff); | |
560 | |
561 @@ -44,8 +44,7 @@ | |
562 * but Rathaxes doesn't support functions with a variable number of | |
563 * arguments yet. | |
564 */ | |
565 - ${Socket::AbstractSKBuff} *skb = self->skbuff; | |
566 - ${cast local.skb as Socket::AbstractSKBuff}; | |
567 + ${Socket::AbstractSKBuff.ref} skb = self->skbuff; | |
568 ${Ethernet::ProtocolId} ethernet_proto = { .id = be16_to_cpu(${local.skb.k_sk_buff}->protocol) }; | |
569 | |
570 static const char * const ip_summed_values[] = { | |
571 @@ -66,12 +65,11 @@ | |
572 ); | |
573 } | |
574 | |
575 - static int rtx_socket_skbuff_map(${Socket::SKBuff} *self, | |
576 + static int rtx_socket_skbuff_map(${Socket::SKBuff.ref} self, | |
577 struct device *dev, | |
578 enum dma_data_direction direction) | |
579 { | |
580 - ${Socket::AbstractSKBuff} *skb = self->skbuff; | |
581 - ${cast local.skb as Socket::AbstractSKBuff}; | |
582 + ${Socket::AbstractSKBuff.ref} skb = self->skbuff; | |
583 | |
584 WARN_ON(!${local.skb.k_sk_buff}); | |
585 WARN_ON(self->dma_handle); | |
586 @@ -90,12 +88,11 @@ | |
587 return 0; | |
588 } | |
589 | |
590 - static void rtx_socket_skbuff_unmap_and_free(${Socket::SKBuff} *self, | |
591 + static void rtx_socket_skbuff_unmap_and_free(${Socket::SKBuff.ref} self, | |
592 struct device *dev, | |
593 enum dma_data_direction direction) | |
594 { | |
595 - ${Socket::AbstractSKBuff} *skb = self->skbuff; | |
596 - ${cast local.skb as Socket::AbstractSKBuff}; | |
597 + ${Socket::AbstractSKBuff.ref} skb = self->skbuff; | |
598 | |
599 WARN_ON(!${local.skb.k_sk_buff}); | |
600 |