Mercurial > archived > louis > epitech > mq > rathaxes
comparison rathaxes_correctly_use_chunk_and_template_sequences_parameters_in_e1000.patch @ 70:c22a9acf8cd7
wip on e1000 remove even more hardcoded arguments
author | Louis Opter <louis@lse.epitech.net> |
---|---|
date | Sat, 18 Feb 2012 20:07:34 +0100 |
parents | 8bb53638585b |
children | 3d37fa01b19c 6e9dcbd120c5 |
comparison
equal
deleted
inserted
replaced
69:8bb53638585b | 70:c22a9acf8cd7 |
---|---|
43 - rtx_ether_ctx->hw_ctx.bars = pci_select_bars(pdev, IORESOURCE_MEM); | 43 - rtx_ether_ctx->hw_ctx.bars = pci_select_bars(pdev, IORESOURCE_MEM); |
44 - if (pci_enable_device_mem(pdev)) | 44 - if (pci_enable_device_mem(pdev)) |
45 + /* | 45 + /* |
46 + * PCI init stuff: | 46 + * PCI init stuff: |
47 + * | 47 + * |
48 + * Some of that code should be moved in the PCI blts, also at some | 48 + * Some of that code should certainly be moved in the PCI/Ethernet |
49 + * point maybe we could do that completely automatically in the PCI | 49 + * blts, also at some point maybe we could do that completely |
50 + * blts. | 50 + * automatically in the PCI/Ethernet blts. |
51 + */ | 51 + */ |
52 + | 52 + |
53 + /* | 53 + /* |
54 + * We could have used an init function here but since we can't init | 54 + * We could have used an init function here but since we can't init |
55 + * all the fields at once (see, ioaddr) and cannot call a C | 55 + * all the fields at once (see, ioaddr) and cannot call a C |
148 + iounmap(${rtx_ether_ctx}->hw_ctx.ioaddr); | 148 + iounmap(${rtx_ether_ctx}->hw_ctx.ioaddr); |
149 + pci_release_selected_regions(${pdev}, ${rtx_ether_ctx}->hw_ctx.bars); | 149 + pci_release_selected_regions(${pdev}, ${rtx_ether_ctx}->hw_ctx.bars); |
150 } | 150 } |
151 | 151 |
152 chunk ::CALL | 152 chunk ::CALL |
153 @@ -215,7 +232,7 @@ | |
154 } | |
155 } | |
156 | |
157 - template sequence e1000::print_status() | |
158 + template sequence e1000::print_status(Ethernet::Device ctx) | |
159 { | |
160 chunk LKM::prototypes() | |
161 { | |
153 @@ -227,7 +244,7 @@ | 162 @@ -227,7 +244,7 @@ |
154 static void rtx_e1000_print_status(struct rtx_e1000_ctx *ctx) | 163 static void rtx_e1000_print_status(struct rtx_e1000_ctx *ctx) |
155 { | 164 { |
156 unsigned int status = rtx_e1000_register_read32(ctx, E1000_STATUS); | 165 unsigned int status = rtx_e1000_register_read32(ctx, E1000_STATUS); |
157 - pr_info("rtx_e1000 status: \n"); | 166 - pr_info("rtx_e1000 status: \n"); |
158 + pr_info("card status: \n"); | 167 + pr_info("card status: \n"); |
159 pr_info("\tRegister value: 0x%x\n", status); | 168 pr_info("\tRegister value: 0x%x\n", status); |
160 pr_info("\tMode: %s\n", (status & 1) ? "Full": "Half"); | 169 pr_info("\tMode: %s\n", (status & 1) ? "Full": "Half"); |
161 pr_info("\tLink: %s\n", (status & 2) ? "Up" : "Down"); | 170 pr_info("\tLink: %s\n", (status & 2) ? "Up" : "Down"); |
162 @@ -275,7 +292,7 @@ | 171 @@ -238,6 +255,7 @@ |
172 | |
173 chunk ::CALL | |
174 { | |
175 + rtx_e1000_print_status(&${ctx}->hw_ctx); | |
176 } | |
177 } | |
178 | |
179 @@ -275,7 +293,7 @@ | |
163 | 180 |
164 chunk ::CALL() | 181 chunk ::CALL() |
165 { | 182 { |
166 - rtx_e1000_register_read32(&${ctx}, ${reg_offset}); | 183 - rtx_e1000_register_read32(&${ctx}, ${reg_offset}); |
167 + rtx_e1000_register_read32(${ctx}, ${reg_offset}); | 184 + rtx_e1000_register_read32(${ctx}, ${reg_offset}); |
168 } | 185 } |
169 } | 186 } |
170 | 187 |
171 @@ -296,7 +313,7 @@ | 188 @@ -294,9 +312,9 @@ |
172 | 189 } |
173 chunk ::CALL() | 190 } |
191 | |
192 - chunk ::CALL() | |
193 + chunk ::CALL | |
174 { | 194 { |
175 - rtx_e1000_register_write32(&${ctx}, ${reg_offset}); | 195 - rtx_e1000_register_write32(&${ctx}, ${reg_offset}); |
176 + rtx_e1000_register_write32(${ctx}, ${reg_offset}); | 196 + rtx_e1000_register_write32(${ctx}, ${reg_offset}); |
177 } | 197 } |
178 } | 198 } |
179 | 199 |
180 @@ -320,12 +337,13 @@ | 200 @@ -315,17 +333,18 @@ |
201 } | |
202 } | |
203 | |
204 - chunk ::CALL() | |
205 + chunk ::CALL | |
206 { | |
181 } | 207 } |
182 } | 208 } |
183 | 209 |
184 - template sequence e1000::setup_interrupt_handler() | 210 - template sequence e1000::setup_interrupt_handler() |
185 + template sequence e1000::setup_interrupt_handler(Ethernet::Device ctx) | 211 + template sequence e1000::setup_interrupt_handler(Ethernet::Device ctx) |
190 } | 216 } |
191 + | 217 + |
192 chunk LKM::prototypes() | 218 chunk LKM::prototypes() |
193 { | 219 { |
194 static int e1000_setup_interrupt_handler(struct rtx_ethernet_dev *); | 220 static int e1000_setup_interrupt_handler(struct rtx_ethernet_dev *); |
195 @@ -345,20 +363,20 @@ | 221 @@ -345,20 +364,20 @@ |
196 | 222 |
197 if (error) | 223 if (error) |
198 { | 224 { |
199 - ${Log::info("Cannot register the interruption")}; | 225 - ${Log::info("Cannot register the interruption")}; |
200 + ${Log::info("cannot register the interrupt handler")}; | 226 + ${Log::info("cannot register the interrupt handler")}; |
214 - error = e1000_setup_interrupt_handler(rtx_ether_dev); | 240 - error = e1000_setup_interrupt_handler(rtx_ether_dev); |
215 + error = e1000_setup_interrupt_handler(${ctx}); | 241 + error = e1000_setup_interrupt_handler(${ctx}); |
216 if (error) | 242 if (error) |
217 { | 243 { |
218 return error; | 244 return error; |
219 @@ -423,7 +441,7 @@ | 245 @@ -367,7 +386,7 @@ |
220 intr = rtx_e1000_register_read32(ctx, E1000_ICR); | 246 } |
221 if (intr & E1000_INTR_LSC) | 247 } |
222 { | 248 |
249 - template sequence e1000::free_interrupt_handler() | |
250 + template sequence e1000::free_interrupt_handler(Ethernet::Device ctx) | |
251 { | |
252 chunk LKM::prototypes() | |
253 { | |
254 @@ -378,22 +397,21 @@ | |
255 { | |
256 static void e1000_free_interrupt_handler(struct rtx_ethernet_dev *ethernet_ctx) | |
257 { | |
258 - | |
259 free_irq(ethernet_ctx->hw_ctx.irq, ethernet_ctx); | |
260 } | |
261 } | |
262 | |
263 - chunk ::CALL() | |
264 + chunk ::CALL | |
265 { | |
266 - e1000_free_interrupt_handler(rtx_ether_dev); | |
267 + e1000_free_interrupt_handler(${ctx}); | |
268 } | |
269 } | |
270 | |
271 - template sequence e1000::activate_device_interruption() | |
272 + template sequence e1000::activate_device_interruption(Ethernet::Device ctx) | |
273 { | |
274 - chunk ::CALL() | |
275 + chunk ::CALL | |
276 { | |
277 - rtx_e1000_register_write32(ctx, E1000_IMS, | |
278 + rtx_e1000_register_write32(&${ctx}->hw_ctx, E1000_IMS, | |
279 E1000_INTR_TXDW | | |
280 E1000_INTR_TXQE | | |
281 E1000_INTR_LSC | | |
282 @@ -402,11 +420,11 @@ | |
283 } | |
284 } | |
285 | |
286 - template sequence e1000::set_up_device() | |
287 + template sequence e1000::set_up_device(Ethernet::Device ctx) | |
288 { | |
289 - chunk ::CALL() | |
290 + chunk ::CALL | |
291 { | |
292 - rtx_e1000_register_set32(ctx, E1000_CTRL, | |
293 + rtx_e1000_register_set32(&${ctx}->hw_ctx, E1000_CTRL, | |
294 E1000_CMD_ASDE | | |
295 E1000_CMD_SLU | | |
296 E1000_CMD_LRST | | |
297 @@ -414,20 +432,20 @@ | |
298 } | |
299 } | |
300 | |
301 - template sequence e1000::handle_intr() | |
302 + template sequence e1000::handle_interrupt(Ethernet::Device ctx) | |
303 { | |
304 - chunk ::CALL() | |
305 + chunk ::CALL | |
306 { | |
307 int intr; | |
308 | |
309 - intr = rtx_e1000_register_read32(ctx, E1000_ICR); | |
310 - if (intr & E1000_INTR_LSC) | |
311 - { | |
223 - ${Log::info("Link status changed")}; | 312 - ${Log::info("Link status changed")}; |
224 + ${Log::info("cable link status changed")}; | 313 - } |
225 } | 314 - |
226 | 315 + intr = rtx_e1000_register_read32(&${ctx}->hw_ctx, E1000_ICR); |
227 if (intr) | 316 if (intr) |
317 { | |
318 + if (intr & E1000_INTR_LSC) | |
319 + { | |
320 + ${Log::info("cable link status changed")}; | |
321 + } | |
322 + | |
323 return IRQ_HANDLED; | |
324 } | |
325 } | |
228 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti | 326 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti |
229 --- a/rathaxes/samples/e1000/e1000.rti | 327 --- a/rathaxes/samples/e1000/e1000.rti |
230 +++ b/rathaxes/samples/e1000/e1000.rti | 328 +++ b/rathaxes/samples/e1000/e1000.rti |
231 @@ -1,25 +1,22 @@ | 329 @@ -1,25 +1,22 @@ |
232 interface e1000 : Socket, Ethernet, PCI, LKM | 330 interface e1000 : Socket, Ethernet, PCI, LKM |
257 { | 355 { |
258 + /* should take PCI::Device and Ethernet::Device args: */ | 356 + /* should take PCI::Device and Ethernet::Device args: */ |
259 provided chunk Ethernet::destroy_device; | 357 provided chunk Ethernet::destroy_device; |
260 provided chunk ::CALL; | 358 provided chunk ::CALL; |
261 } | 359 } |
262 @@ -35,9 +32,9 @@ | 360 @@ -28,44 +25,43 @@ |
361 * This should take an e1000::Context as the first argument but this was | |
362 * not working as wished. | |
363 */ | |
364 - provided sequence e1000::print_status() | |
365 + provided sequence e1000::print_status(Ethernet::Device) | |
366 { | |
367 provided chunk LKM::prototypes; | |
368 provided chunk LKM::code; | |
263 provided chunk ::CALL; | 369 provided chunk ::CALL; |
264 } | 370 } |
265 | 371 |
266 - provided sequence e1000::setup_interrupt_handler() | 372 - provided sequence e1000::setup_interrupt_handler() |
267 + provided sequence e1000::setup_interrupt_handler(Ethernet::Device) | 373 + provided sequence e1000::setup_interrupt_handler(Ethernet::Device) |
269 - provided chunk LKM::includes; // work without this one | 375 - provided chunk LKM::includes; // work without this one |
270 + provided chunk LKM::includes; // works without this one | 376 + provided chunk LKM::includes; // works without this one |
271 provided chunk LKM::prototypes; | 377 provided chunk LKM::prototypes; |
272 provided chunk LKM::code; | 378 provided chunk LKM::code; |
273 provided chunk ::CALL; | 379 provided chunk ::CALL; |
380 } | |
381 | |
382 - provided sequence e1000::free_interrupt_handler() | |
383 + provided sequence e1000::free_interrupt_handler(Ethernet::Device) | |
384 { | |
385 provided chunk LKM::prototypes; | |
386 provided chunk LKM::code; | |
387 provided chunk ::CALL; | |
388 } | |
389 | |
390 - provided sequence e1000::activate_device_interruption() | |
391 + provided sequence e1000::activate_device_interruption(Ethernet::Device) | |
392 { | |
393 provided chunk ::CALL; | |
394 } | |
395 | |
396 - provided sequence e1000::set_up_device() | |
397 + provided sequence e1000::set_up_device(Ethernet::Device) | |
398 { | |
399 provided chunk ::CALL; | |
400 } | |
401 | |
402 - provided sequence e1000::handle_intr() | |
403 + provided sequence e1000::handle_interrupt(Ethernet::Device) | |
404 { | |
405 provided chunk ::CALL; | |
406 } | |
407 | |
408 - | |
409 provided sequence e1000::register_read32(e1000::Context, e1000::Register) | |
410 { | |
411 provided chunk LKM::prototypes; | |
274 diff --git a/rathaxes/samples/e1000/ethernet.blt b/rathaxes/samples/e1000/ethernet.blt | 412 diff --git a/rathaxes/samples/e1000/ethernet.blt b/rathaxes/samples/e1000/ethernet.blt |
275 --- a/rathaxes/samples/e1000/ethernet.blt | 413 --- a/rathaxes/samples/e1000/ethernet.blt |
276 +++ b/rathaxes/samples/e1000/ethernet.blt | 414 +++ b/rathaxes/samples/e1000/ethernet.blt |
277 @@ -1,5 +1,10 @@ | 415 @@ -1,5 +1,10 @@ |
278 with Ethernet, PCI, LKM, Log | 416 with Ethernet, PCI, LKM, Log |
339 @@ -66,7 +84,7 @@ | 477 @@ -66,7 +84,7 @@ |
340 { | 478 { |
341 static int rtx_ethernet_xmit(struct sk_buff* skb, struct net_device *dev) | 479 static int rtx_ethernet_xmit(struct sk_buff* skb, struct net_device *dev) |
342 { | 480 { |
343 - ${pointcut ::IMPLEMENTATION}; | 481 - ${pointcut ::IMPLEMENTATION}; |
344 + ${pointcut ::IMPLEMENTATION(local.skb, local.dev)}; | 482 + ${pointcut ::IMPLEMENTATION(local.dev, local.skb)}; |
345 | 483 |
346 return 0; | 484 return 0; |
347 } | 485 } |
348 @@ -87,7 +105,7 @@ | 486 @@ -87,7 +105,7 @@ |
349 struct rtx_ethernet_dev* rtx_ether_dev = netdev_priv(dev); | 487 struct rtx_ethernet_dev* rtx_ether_dev = netdev_priv(dev); |
512 provided pointcut Ethernet::destroy_device; | 650 provided pointcut Ethernet::destroy_device; |
513 } | 651 } |
514 diff --git a/rathaxes/samples/e1000/lkm.rtx b/rathaxes/samples/e1000/lkm.rtx | 652 diff --git a/rathaxes/samples/e1000/lkm.rtx b/rathaxes/samples/e1000/lkm.rtx |
515 --- a/rathaxes/samples/e1000/lkm.rtx | 653 --- a/rathaxes/samples/e1000/lkm.rtx |
516 +++ b/rathaxes/samples/e1000/lkm.rtx | 654 +++ b/rathaxes/samples/e1000/lkm.rtx |
517 @@ -2,50 +2,50 @@ | 655 @@ -2,50 +2,61 @@ |
518 { | 656 { |
519 Ethernet::open(Ethernet::Device dev) | 657 Ethernet::open(Ethernet::Device dev) |
520 { | 658 { |
521 - Log::info("Open the device"); | 659 - Log::info("Open the device"); |
522 - e1000::setup_interrupt_handler(); | 660 - e1000::setup_interrupt_handler(); |
523 - Log::info("Interrupt handler installed"); | 661 - Log::info("Interrupt handler installed"); |
524 + Log::info("open the device"); | 662 - e1000::set_up_device(); |
663 - e1000::activate_device_interruption(); | |
664 + Log::info("opening the device"); | |
665 + | |
666 + /* | |
667 + * Maybe e1000::create_device should be called from here, to be | |
668 + * more coherent. | |
669 + */ | |
670 + | |
525 + e1000::setup_interrupt_handler(dev); | 671 + e1000::setup_interrupt_handler(dev); |
526 + Log::info("interrupt handler installed"); | 672 + Log::info("interrupt handler installed"); |
527 e1000::set_up_device(); | 673 + |
528 e1000::activate_device_interruption(); | 674 + e1000::set_up_device(dev); |
675 + Log::info("device activated"); | |
676 + | |
677 + e1000::activate_device_interruption(dev); | |
678 + | |
679 + e1000::print_status(dev); | |
529 } | 680 } |
530 | 681 |
531 Ethernet::close(Ethernet::Device dev) | 682 Ethernet::close(Ethernet::Device dev) |
532 { | 683 { |
533 - Log::info("Close the device"); | 684 - Log::info("Close the device"); |
534 + Log::info("close the device"); | 685 - e1000::free_interrupt_handler(); |
535 e1000::free_interrupt_handler(); | 686 + Log::info("closing the device"); |
687 + e1000::free_interrupt_handler(dev); | |
536 } | 688 } |
537 | 689 |
538 Ethernet::interrupt_handler(Ethernet::Device dev) | 690 Ethernet::interrupt_handler(Ethernet::Device dev) |
539 { | 691 { |
540 - Log::info("Got an interruption"); | 692 - Log::info("Got an interruption"); |
693 - e1000::handle_intr(); | |
541 + Log::info("got an interruption"); | 694 + Log::info("got an interruption"); |
542 e1000::handle_intr(); | 695 + e1000::handle_interrupt(dev); |
543 } | 696 } |
544 | 697 |
545 Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb) | 698 Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb) |
546 { | 699 { |
547 - Log::info("We have one packet to transmit!"); | 700 - Log::info("We have one packet to transmit!"); |