Mercurial > archived > louis > epitech > mq > rathaxes
comparison rathaxes_add_lkm_ethernet_sample.patch @ 45:bab559e0392b
rathaxes: enable irq + handle it
author | Thomas Sanchez <thomas.sanchz@gmail.com> |
---|---|
date | Mon, 09 Jan 2012 22:17:12 +0100 |
parents | 258319759ba3 |
children | cf7d541b9331 |
comparison
equal
deleted
inserted
replaced
44:258319759ba3 | 45:bab559e0392b |
---|---|
1 # HG changeset patch | 1 # HG changeset patch |
2 # Parent b995d8934956b83383c144303178f3eb383d0acf | 2 # Parent 6d6b478219da142368f4e458b8a348f4d87867d9 |
3 rathaxes: add the PCI/Ethernet part of a Linux Intel e1000 network card driver | 3 rathaxes: add the PCI/Ethernet part of a Linux Intel e1000 network card driver |
4 | 4 |
5 diff --git a/maintainers/CMakeScripts/UseRathaxes.cmake b/maintainers/CMakeScripts/UseRathaxes.cmake | 5 diff -r 6d6b478219da maintainers/CMakeScripts/UseRathaxes.cmake |
6 --- a/maintainers/CMakeScripts/UseRathaxes.cmake | 6 --- a/maintainers/CMakeScripts/UseRathaxes.cmake Mon Jan 09 19:24:10 2012 +0100 |
7 +++ b/maintainers/CMakeScripts/UseRathaxes.cmake | 7 +++ b/maintainers/CMakeScripts/UseRathaxes.cmake Mon Jan 09 22:16:54 2012 +0100 |
8 @@ -193,6 +193,8 @@ | 8 @@ -193,6 +193,8 @@ |
9 | 9 |
10 SET(KERNEL_OBJECT_NAME "${RATHAXES_SOURCE}_${SYSTEM}.ko") | 10 SET(KERNEL_OBJECT_NAME "${RATHAXES_SOURCE}_${SYSTEM}.ko") |
11 ADD_CUSTOM_COMMAND(OUTPUT "${KERNEL_OBJECT_NAME}" | 11 ADD_CUSTOM_COMMAND(OUTPUT "${KERNEL_OBJECT_NAME}" |
12 + # … | 12 + # … |
13 + COMMAND "sed" "-i" "/TARTE/ d" "${RATHAXES_SOURCE}_${SYSTEM}.c" | 13 + COMMAND "sed" "-i" "/TARTE/ d" "${RATHAXES_SOURCE}_${SYSTEM}.c" |
14 # The linux Makefile to build kernel module is quite | 14 # The linux Makefile to build kernel module is quite |
15 # picky about file location and its own name. Let's | 15 # picky about file location and its own name. Let's |
16 # copy our source side by side with the Makefile: | 16 # copy our source side by side with the Makefile: |
17 diff --git a/rathaxes/samples/CMakeLists.txt b/rathaxes/samples/CMakeLists.txt | 17 diff -r 6d6b478219da rathaxes/samples/CMakeLists.txt |
18 --- a/rathaxes/samples/CMakeLists.txt | 18 --- a/rathaxes/samples/CMakeLists.txt Mon Jan 09 19:24:10 2012 +0100 |
19 +++ b/rathaxes/samples/CMakeLists.txt | 19 +++ b/rathaxes/samples/CMakeLists.txt Mon Jan 09 22:16:54 2012 +0100 |
20 @@ -1,2 +1,3 @@ | 20 @@ -1,2 +1,3 @@ |
21 ADD_SUBDIRECTORY(helloworld) | 21 ADD_SUBDIRECTORY(helloworld) |
22 +ADD_SUBDIRECTORY(lkm) | 22 +ADD_SUBDIRECTORY(lkm) |
23 ADD_SUBDIRECTORY(syntax) | 23 ADD_SUBDIRECTORY(syntax) |
24 diff --git a/rathaxes/samples/lkm/CMakeLists.txt b/rathaxes/samples/lkm/CMakeLists.txt | 24 diff -r 6d6b478219da rathaxes/samples/lkm/CMakeLists.txt |
25 new file mode 100644 | 25 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
26 --- /dev/null | 26 +++ b/rathaxes/samples/lkm/CMakeLists.txt Mon Jan 09 22:16:54 2012 +0100 |
27 +++ b/rathaxes/samples/lkm/CMakeLists.txt | |
28 @@ -0,0 +1,7 @@ | 27 @@ -0,0 +1,7 @@ |
29 +ADD_RATHAXES_SOURCES(lkm_src lkm.rtx | 28 +ADD_RATHAXES_SOURCES(lkm_src lkm.rtx |
30 + RTI log.rti lkm.rti pci.rti socket.rti ethernet.rti e1000.rti | 29 + RTI log.rti lkm.rti pci.rti socket.rti ethernet.rti e1000.rti |
31 + BLT log.blt lkm.blt pci.blt socket.blt ethernet.blt e1000.blt) | 30 + BLT log.blt lkm.blt pci.blt socket.blt ethernet.blt e1000.blt) |
32 + | 31 + |
33 +# We can't name lkm since it's already used as the target name to generate the | 32 +# We can't name lkm since it's already used as the target name to generate the |
34 +# source (with ADD_RATHAXES_SOURCES). | 33 +# source (with ADD_RATHAXES_SOURCES). |
35 +ADD_RATHAXES_LKM(lkm lkm_src) | 34 +ADD_RATHAXES_LKM(lkm lkm_src) |
36 diff --git a/rathaxes/samples/lkm/e1000.blt b/rathaxes/samples/lkm/e1000.blt | 35 diff -r 6d6b478219da rathaxes/samples/lkm/e1000.blt |
37 new file mode 100644 | 36 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
38 --- /dev/null | 37 +++ b/rathaxes/samples/lkm/e1000.blt Mon Jan 09 22:16:54 2012 +0100 |
39 +++ b/rathaxes/samples/lkm/e1000.blt | 38 @@ -0,0 +1,435 @@ |
40 @@ -0,0 +1,289 @@ | |
41 +with e1000, Ethernet, Socket, PCI, LKM, Log | 39 +with e1000, Ethernet, Socket, PCI, LKM, Log |
42 +{ | 40 +{ |
43 + template type e1000::Context() | 41 + template type e1000::Context() |
44 + { | 42 + { |
45 + chunk LKM::includes() | 43 + chunk LKM::includes() |
57 + { | 55 + { |
58 + struct rtx_e1000_ctx | 56 + struct rtx_e1000_ctx |
59 + { | 57 + { |
60 + int bars; | 58 + int bars; |
61 + unsigned char /* __iomem */ *ioaddr; | 59 + unsigned char /* __iomem */ *ioaddr; |
60 + int irq; | |
62 + }; | 61 + }; |
63 + } | 62 + } |
64 + | 63 + |
65 + chunk ::init(bars, ioaddr) | 64 + chunk ::init(bars, ioaddr) |
66 + { | 65 + { |
90 + E1000_STATUS = 0x00008, /* Device Status - RO */ | 89 + E1000_STATUS = 0x00008, /* Device Status - RO */ |
91 + E1000_EEPROM_FLASH = 0x00010, /* EEPROM/Flash Control - RW */ | 90 + E1000_EEPROM_FLASH = 0x00010, /* EEPROM/Flash Control - RW */ |
92 + E1000_EEPROM_READ = 0x00014, /* EEPROM Read - RW */ | 91 + E1000_EEPROM_READ = 0x00014, /* EEPROM Read - RW */ |
93 + E1000_CTRL_EXT = 0x00018, /* Extended Device Control - RW */ | 92 + E1000_CTRL_EXT = 0x00018, /* Extended Device Control - RW */ |
94 + E1000_FLA = 0x0001C, /* Flash Access - RW */ | 93 + E1000_FLA = 0x0001C, /* Flash Access - RW */ |
95 + E1000_MDIC = 0x00020 /* MDI Control - RW */ | 94 + E1000_MDIC = 0x00020, /* MDI Control - RW */ |
95 + E1000_IMS = 0x000D0, /* Interrupt Mask Set */ | |
96 + E1000_IMC = 0x000D8, /* Interrupt Mask Clear */ | |
97 + E1000_ICR = 0x000C0 /* Interrupt Cause Read - R/clr */ | |
96 + }; | 98 + }; |
97 + } | 99 + } |
98 + | 100 + |
99 + chunk ::init(value) | 101 + chunk ::init(value) |
100 + { | 102 + { |
151 + E1000_CMD_RFCE = 0x08000000, /* Receive Flow Control enable */ | 153 + E1000_CMD_RFCE = 0x08000000, /* Receive Flow Control enable */ |
152 + E1000_CMD_TFCE = 0x10000000, /* Transmit flow control enable */ | 154 + E1000_CMD_TFCE = 0x10000000, /* Transmit flow control enable */ |
153 + E1000_CMD_RTE = 0x20000000, /* Routing tag enable */ | 155 + E1000_CMD_RTE = 0x20000000, /* Routing tag enable */ |
154 + E1000_CMD_VME = 0x40000000, /* IEEE VLAN mode enable */ | 156 + E1000_CMD_VME = 0x40000000, /* IEEE VLAN mode enable */ |
155 + E1000_CMD_PHY_RST = 0x80000000, /* PHY Reset */ | 157 + E1000_CMD_PHY_RST = 0x80000000, /* PHY Reset */ |
156 + E1000_CMD_SW2FW_INT = 0x02000000 /* Initiate an interrupt to manageability engine */ | 158 + E1000_CMD_SW2FW_INT = 0x02000000, /* Initiate an interrupt to manageability engine */ |
159 + E1000_INTR_TXDW = 0x00000001, /* Transmit desc written back */ | |
160 + E1000_INTR_TXQE = 0x00000002, /* Transmit Queue empty */ | |
161 + E1000_INTR_LSC = 0x00000004, /* Link Status Change */ | |
162 + E1000_INTR_RXSEQ = 0x00000008, /* rx sequence error */ | |
163 + E1000_INTR_RXDMT0 = 0x00000010, /* rx desc min. threshold (0) */ | |
164 + E1000_INTR_RXO = 0x00000040, /* rx overrun */ | |
165 + E1000_INTR_RXT0 = 0x00000080, /* rx timer intr (ring 0) */ | |
166 + E1000_INTR_MDAC = 0x00000200 /* MDIO access complete */ | |
167 + | |
157 + }; | 168 + }; |
158 + } | 169 + } |
159 + | 170 + |
160 + map | 171 + map |
161 + { | 172 + { |
164 + | 175 + |
165 + template sequence e1000::create_device() | 176 + template sequence e1000::create_device() |
166 + { | 177 + { |
167 + chunk Ethernet::create_device() | 178 + chunk Ethernet::create_device() |
168 + { | 179 + { |
180 + rtx_ether_ctx->hw_ctx.irq = pdev->irq; | |
169 + rtx_ether_ctx->hw_ctx.bars = pci_select_bars(pdev, IORESOURCE_MEM); | 181 + rtx_ether_ctx->hw_ctx.bars = pci_select_bars(pdev, IORESOURCE_MEM); |
170 + if (pci_enable_device_mem(pdev)) | 182 + if (pci_enable_device_mem(pdev)) |
171 + { | 183 + { |
172 + ${Log::info("e1000::create: pci_enable_device_mem failed")}; | 184 + ${Log::info("e1000::create: pci_enable_device_mem failed")}; |
173 + } | 185 + } |
324 + chunk ::CALL() | 336 + chunk ::CALL() |
325 + { | 337 + { |
326 + rtx_e1000_register_write32(&${ctx}, ${reg_offset}); | 338 + rtx_e1000_register_write32(&${ctx}, ${reg_offset}); |
327 + } | 339 + } |
328 + } | 340 + } |
329 +} | 341 + |
330 diff --git a/rathaxes/samples/lkm/e1000.rti b/rathaxes/samples/lkm/e1000.rti | 342 + template sequence e1000::register_set32(e1000::Context ctx, e1000::Register reg_offset, ::number value) |
331 new file mode 100644 | 343 + { |
332 --- /dev/null | 344 + chunk LKM::prototypes() |
333 +++ b/rathaxes/samples/lkm/e1000.rti | 345 + { |
334 @@ -0,0 +1,51 @@ | 346 + static void rtx_e1000_register_set32(struct rtx_e1000_ctx *, unsigned int, unsigned int); |
347 + } | |
348 + | |
349 + chunk LKM::code() | |
350 + { | |
351 + static void rtx_e1000_register_set32(struct rtx_e1000_ctx *ctx, unsigned int reg_offset, unsigned int value) | |
352 + { | |
353 + iowrite32(rtx_e1000_register_read32(ctx, reg_offset) | value, ctx->ioaddr + reg_offset); | |
354 + } | |
355 + } | |
356 + | |
357 + chunk ::CALL() | |
358 + { | |
359 + } | |
360 + } | |
361 + | |
362 + template sequence e1000::setup_interrupt_handler() | |
363 + { | |
364 + chunk LKM::includes() | |
365 + { | |
366 + #include <linux/interrupt.h> | |
367 + } | |
368 + chunk LKM::prototypes() | |
369 + { | |
370 + static int e1000_setup_interrupt_handler(struct rtx_ethernet_dev *); | |
371 + } | |
372 + | |
373 + chunk LKM::code() | |
374 + { | |
375 + static int e1000_setup_interrupt_handler(struct rtx_ethernet_dev *ethernet_ctx) | |
376 + { | |
377 + int error; | |
378 + | |
379 + error = request_irq(ethernet_ctx->hw_ctx.irq, | |
380 + rtx_ethernet_interrupt_handler, | |
381 + IRQF_SHARED, | |
382 + ${config.name}, | |
383 + ethernet_ctx); | |
384 + | |
385 + if (error) | |
386 + { | |
387 + ${Log::info("Cannot register the interruption")}; | |
388 + } | |
389 + | |
390 + return error; | |
391 + } | |
392 + } | |
393 + | |
394 + chunk ::CALL() | |
395 + { | |
396 + // this is an hack for the scope | |
397 + (void)1; | |
398 + { | |
399 + int error; | |
400 + error = e1000_setup_interrupt_handler(rtx_ether_dev); | |
401 + if (error) | |
402 + { | |
403 + return error; | |
404 + } | |
405 + } | |
406 + } | |
407 + } | |
408 + | |
409 + template sequence e1000::free_interrupt_handler() | |
410 + { | |
411 + chunk LKM::prototypes() | |
412 + { | |
413 + static void e1000_free_interrupt_handler(struct rtx_ethernet_dev *ethernet_ctx); | |
414 + } | |
415 + | |
416 + chunk LKM::code() | |
417 + { | |
418 + static void e1000_free_interrupt_handler(struct rtx_ethernet_dev *ethernet_ctx) | |
419 + { | |
420 + | |
421 + free_irq(ethernet_ctx->hw_ctx.irq, ethernet_ctx); | |
422 + } | |
423 + } | |
424 + | |
425 + chunk ::CALL() | |
426 + { | |
427 + e1000_free_interrupt_handler(rtx_ether_dev); | |
428 + } | |
429 + } | |
430 + | |
431 + template sequence e1000::activate_device_interruption() | |
432 + { | |
433 + chunk ::CALL() | |
434 + { | |
435 + rtx_e1000_register_write32(ctx, E1000_IMS, | |
436 + E1000_INTR_TXDW | | |
437 + E1000_INTR_TXQE | | |
438 + E1000_INTR_LSC | | |
439 + E1000_INTR_RXO | | |
440 + E1000_INTR_RXT0); | |
441 + } | |
442 + } | |
443 + | |
444 + template sequence e1000::set_up_device() | |
445 + { | |
446 + chunk ::CALL() | |
447 + { | |
448 + rtx_e1000_register_set32(ctx, E1000_CTRL, E1000_CMD_ASDE | |
449 + | E1000_CMD_SLU | |
450 + | E1000_CMD_LRST | |
451 + | E1000_CMD_PHY_RST); | |
452 + } | |
453 + } | |
454 + | |
455 + template sequence e1000::handle_intr() | |
456 + { | |
457 + chunk ::CALL() | |
458 + { | |
459 + int intr; | |
460 + | |
461 + intr = rtx_e1000_register_read32(ctx, E1000_ICR); | |
462 + if (intr & E1000_INTR_LSC) | |
463 + { | |
464 + ${Log::info("Link status changed")}; | |
465 + } | |
466 + | |
467 + if (intr) | |
468 + { | |
469 + return IRQ_HANDLED; | |
470 + } | |
471 + } | |
472 + } | |
473 +} | |
474 diff -r 6d6b478219da rathaxes/samples/lkm/e1000.rti | |
475 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
476 +++ b/rathaxes/samples/lkm/e1000.rti Mon Jan 09 22:16:54 2012 +0100 | |
477 @@ -0,0 +1,89 @@ | |
335 +interface e1000 : Socket, Ethernet, PCI, LKM | 478 +interface e1000 : Socket, Ethernet, PCI, LKM |
336 +{ | 479 +{ |
337 + provided type e1000::Context; | 480 + provided type e1000::Context; |
338 + provided type e1000::Register; | 481 + provided type e1000::Register; |
339 + provided type e1000::Commands; | 482 + provided type e1000::Commands; |
367 + provided chunk LKM::prototypes; | 510 + provided chunk LKM::prototypes; |
368 + provided chunk LKM::code; | 511 + provided chunk LKM::code; |
369 + provided chunk ::CALL; | 512 + provided chunk ::CALL; |
370 + } | 513 + } |
371 + | 514 + |
372 + provided sequence e1000::register_read32(e1000::Context, e1000::Register) | 515 + provided sequence e1000::setup_interrupt_handler() |
373 + { | 516 + { |
517 + provided chunk LKM::includes; // work without this one | |
374 + provided chunk LKM::prototypes; | 518 + provided chunk LKM::prototypes; |
375 + provided chunk LKM::code; | 519 + provided chunk LKM::code; |
376 + provided chunk ::CALL; | 520 + provided chunk ::CALL; |
377 + } | 521 + } |
378 + | 522 + |
379 + provided sequence e1000::register_write32(e1000::Context, e1000::Register, ::number) | 523 + provided sequence e1000::free_interrupt_handler() |
380 + { | 524 + { |
381 + provided chunk LKM::prototypes; | 525 + provided chunk LKM::prototypes; |
382 + provided chunk LKM::code; | 526 + provided chunk LKM::code; |
383 + provided chunk ::CALL; | 527 + provided chunk ::CALL; |
384 + } | 528 + } |
385 +} | 529 + |
386 diff --git a/rathaxes/samples/lkm/ethernet.blt b/rathaxes/samples/lkm/ethernet.blt | 530 + provided sequence e1000::activate_device_interruption() |
387 new file mode 100644 | 531 + { |
388 --- /dev/null | 532 + provided chunk ::CALL; |
389 +++ b/rathaxes/samples/lkm/ethernet.blt | 533 + } |
390 @@ -0,0 +1,207 @@ | 534 + |
535 + provided sequence e1000::set_up_device() | |
536 + { | |
537 + provided chunk ::CALL; | |
538 + } | |
539 + | |
540 + provided sequence e1000::handle_intr() | |
541 + { | |
542 + provided chunk ::CALL; | |
543 + } | |
544 + | |
545 + | |
546 + provided sequence e1000::register_read32(e1000::Context, e1000::Register) | |
547 + { | |
548 + provided chunk LKM::prototypes; | |
549 + provided chunk LKM::code; | |
550 + provided chunk ::CALL; | |
551 + } | |
552 + | |
553 + provided sequence e1000::register_write32(e1000::Context, e1000::Register, ::number) | |
554 + { | |
555 + provided chunk LKM::prototypes; | |
556 + provided chunk LKM::code; | |
557 + provided chunk ::CALL; | |
558 + } | |
559 + | |
560 + provided sequence e1000::register_set32(e1000::Context, e1000::Register, ::number) | |
561 + { | |
562 + provided chunk LKM::prototypes; | |
563 + provided chunk LKM::code; | |
564 + provided chunk ::CALL; | |
565 + } | |
566 +} | |
567 diff -r 6d6b478219da rathaxes/samples/lkm/ethernet.blt | |
568 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
569 +++ b/rathaxes/samples/lkm/ethernet.blt Mon Jan 09 22:16:54 2012 +0100 | |
570 @@ -0,0 +1,218 @@ | |
391 +with Ethernet, PCI, LKM, Log | 571 +with Ethernet, PCI, LKM, Log |
392 +{ | 572 +{ |
393 + template type Ethernet::Device() | 573 + template type Ethernet::Device() |
394 + { | 574 + { |
395 + chunk LKM::includes() | 575 + chunk LKM::includes() |
433 + | 613 + |
434 + chunk LKM::code() | 614 + chunk LKM::code() |
435 + { | 615 + { |
436 + static int rtx_ethernet_open(struct net_device *dev) | 616 + static int rtx_ethernet_open(struct net_device *dev) |
437 + { | 617 + { |
618 + struct rtx_ethernet_dev* rtx_ether_dev = netdev_priv(dev); | |
619 + struct rtx_e1000_ctx* ctx = &rtx_ether_dev->hw_ctx; | |
620 + | |
438 + ${pointcut ::IMPLEMENTATION}; | 621 + ${pointcut ::IMPLEMENTATION}; |
439 + | 622 + |
440 + return 0; | 623 + return 0; |
441 + } | 624 + } |
442 + } | 625 + } |
469 + | 652 + |
470 + chunk LKM::code() | 653 + chunk LKM::code() |
471 + { | 654 + { |
472 + static int rtx_ethernet_close(struct net_device *dev) | 655 + static int rtx_ethernet_close(struct net_device *dev) |
473 + { | 656 + { |
657 + struct rtx_ethernet_dev* rtx_ether_dev = netdev_priv(dev); | |
658 + struct rtx_e1000_ctx* ctx = &rtx_ether_dev->hw_ctx; | |
659 + | |
474 + ${pointcut ::IMPLEMENTATION}; | 660 + ${pointcut ::IMPLEMENTATION}; |
475 + | 661 + |
476 + return 0; | 662 + return 0; |
477 + } | 663 + } |
478 + } | 664 + } |
491 + | 677 + |
492 + chunk LKM::code() | 678 + chunk LKM::code() |
493 + { | 679 + { |
494 + static enum irqreturn rtx_ethernet_interrupt_handler(int irq, void *dev_id) | 680 + static enum irqreturn rtx_ethernet_interrupt_handler(int irq, void *dev_id) |
495 + { | 681 + { |
682 + struct rtx_ethernet_dev* rtx_ether_dev; | |
683 + struct rtx_e1000_ctx* ctx; | |
684 + | |
685 + rtx_ether_dev = dev_id; | |
686 + ctx = &rtx_ether_dev->hw_ctx; | |
496 + ${pointcut ::IMPLEMENTATION}; | 687 + ${pointcut ::IMPLEMENTATION}; |
497 + | 688 + |
498 + return IRQ_NONE; | 689 + return IRQ_NONE; |
499 + } | 690 + } |
500 + } | 691 + } |
593 + { | 784 + { |
594 + } | 785 + } |
595 + } | 786 + } |
596 +} | 787 +} |
597 + | 788 + |
598 diff --git a/rathaxes/samples/lkm/ethernet.rti b/rathaxes/samples/lkm/ethernet.rti | 789 diff -r 6d6b478219da rathaxes/samples/lkm/ethernet.rti |
599 new file mode 100644 | 790 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
600 --- /dev/null | 791 +++ b/rathaxes/samples/lkm/ethernet.rti Mon Jan 09 22:16:54 2012 +0100 |
601 +++ b/rathaxes/samples/lkm/ethernet.rti | |
602 @@ -0,0 +1,47 @@ | 792 @@ -0,0 +1,47 @@ |
603 +interface Ethernet : Socket, PCI, LKM | 793 +interface Ethernet : Socket, PCI, LKM |
604 +{ | 794 +{ |
605 + provided type Ethernet::Device; | 795 + provided type Ethernet::Device; |
606 + | 796 + |
645 + provided chunk PCI::pci_remove_hook; | 835 + provided chunk PCI::pci_remove_hook; |
646 + | 836 + |
647 + provided pointcut Ethernet::destroy_device; | 837 + provided pointcut Ethernet::destroy_device; |
648 + } | 838 + } |
649 +} | 839 +} |
650 diff --git a/rathaxes/samples/lkm/lkm.blt b/rathaxes/samples/lkm/lkm.blt | 840 diff -r 6d6b478219da rathaxes/samples/lkm/lkm.blt |
651 new file mode 100644 | 841 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
652 --- /dev/null | 842 +++ b/rathaxes/samples/lkm/lkm.blt Mon Jan 09 22:16:54 2012 +0100 |
653 +++ b/rathaxes/samples/lkm/lkm.blt | |
654 @@ -0,0 +1,55 @@ | 843 @@ -0,0 +1,55 @@ |
655 +with LKM | 844 +with LKM |
656 +{ | 845 +{ |
657 + /* Skel of the generated C file: */ | 846 + /* Skel of the generated C file: */ |
658 + ${pointcut LKM::includes}; | 847 + ${pointcut LKM::includes}; |
705 + | 894 + |
706 + module_exit(rtx_module_exit); | 895 + module_exit(rtx_module_exit); |
707 + } | 896 + } |
708 + } | 897 + } |
709 +} | 898 +} |
710 diff --git a/rathaxes/samples/lkm/lkm.rti b/rathaxes/samples/lkm/lkm.rti | 899 diff -r 6d6b478219da rathaxes/samples/lkm/lkm.rti |
711 new file mode 100644 | 900 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
712 --- /dev/null | 901 +++ b/rathaxes/samples/lkm/lkm.rti Mon Jan 09 22:16:54 2012 +0100 |
713 +++ b/rathaxes/samples/lkm/lkm.rti | |
714 @@ -0,0 +1,25 @@ | 902 @@ -0,0 +1,25 @@ |
715 +interface LKM | 903 +interface LKM |
716 +{ | 904 +{ |
717 + provided pointcut LKM::includes; | 905 + provided pointcut LKM::includes; |
718 + /* maybe it should be possible to use chunk ::decl in sequence templates? */ | 906 + /* maybe it should be possible to use chunk ::decl in sequence templates? */ |
735 + { | 923 + { |
736 + provided chunk LKM::code; | 924 + provided chunk LKM::code; |
737 + provided pointcut LKM::deinit_bus_hook; | 925 + provided pointcut LKM::deinit_bus_hook; |
738 + } | 926 + } |
739 +} | 927 +} |
740 diff --git a/rathaxes/samples/lkm/lkm.rtx b/rathaxes/samples/lkm/lkm.rtx | 928 diff -r 6d6b478219da rathaxes/samples/lkm/lkm.rtx |
741 new file mode 100644 | 929 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
742 --- /dev/null | 930 +++ b/rathaxes/samples/lkm/lkm.rtx Mon Jan 09 22:16:54 2012 +0100 |
743 +++ b/rathaxes/samples/lkm/lkm.rtx | 931 @@ -0,0 +1,52 @@ |
744 @@ -0,0 +1,46 @@ | |
745 +device LKM use LKM, PCI, Ethernet, Log | 932 +device LKM use LKM, PCI, Ethernet, Log |
746 +{ | 933 +{ |
747 + Ethernet::open(Ethernet::Device dev) | 934 + Ethernet::open(Ethernet::Device dev) |
748 + { | 935 + { |
749 + Log::info("Open the device"); | 936 + Log::info("Open the device"); |
937 + e1000::setup_interrupt_handler(); | |
938 + Log::info("Interrupt handler installed"); | |
939 + e1000::set_up_device(); | |
940 + e1000::activate_device_interruption(); | |
750 + } | 941 + } |
751 + | 942 + |
752 + Ethernet::close(Ethernet::Device dev) | 943 + Ethernet::close(Ethernet::Device dev) |
753 + { | 944 + { |
754 + Log::info("Close the device"); | 945 + Log::info("Close the device"); |
946 + e1000::free_interrupt_handler(); | |
755 + } | 947 + } |
756 + | 948 + |
757 + Ethernet::interrupt_handler(Ethernet::Device dev) | 949 + Ethernet::interrupt_handler(Ethernet::Device dev) |
758 + { | 950 + { |
759 + Log::info("Got an interruption"); | 951 + Log::info("Got an interruption"); |
952 + e1000::handle_intr(); | |
760 + } | 953 + } |
761 + | 954 + |
762 + Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb) | 955 + Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb) |
763 + { | 956 + { |
764 + Log::info("We have one packet to transmit!"); | 957 + Log::info("We have one packet to transmit!"); |
786 + PCI::product_id = 0x100f; | 979 + PCI::product_id = 0x100f; |
787 + PCI::set_master = true; | 980 + PCI::set_master = true; |
788 + | 981 + |
789 + Ethernet::ifname = "rtx%d"; | 982 + Ethernet::ifname = "rtx%d"; |
790 +} | 983 +} |
791 diff --git a/rathaxes/samples/lkm/log.blt b/rathaxes/samples/lkm/log.blt | 984 diff -r 6d6b478219da rathaxes/samples/lkm/log.blt |
792 new file mode 100644 | 985 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
793 --- /dev/null | 986 +++ b/rathaxes/samples/lkm/log.blt Mon Jan 09 22:16:54 2012 +0100 |
794 +++ b/rathaxes/samples/lkm/log.blt | |
795 @@ -0,0 +1,10 @@ | 987 @@ -0,0 +1,10 @@ |
796 +with Log | 988 +with Log |
797 +{ | 989 +{ |
798 + template sequence Log::info(::string msg) | 990 + template sequence Log::info(::string msg) |
799 + { | 991 + { |
801 + { | 993 + { |
802 + pr_info("%s\n", ${msg}); | 994 + pr_info("%s\n", ${msg}); |
803 + } | 995 + } |
804 + } | 996 + } |
805 +} | 997 +} |
806 diff --git a/rathaxes/samples/lkm/log.rti b/rathaxes/samples/lkm/log.rti | 998 diff -r 6d6b478219da rathaxes/samples/lkm/log.rti |
807 new file mode 100644 | 999 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
808 --- /dev/null | 1000 +++ b/rathaxes/samples/lkm/log.rti Mon Jan 09 22:16:54 2012 +0100 |
809 +++ b/rathaxes/samples/lkm/log.rti | |
810 @@ -0,0 +1,7 @@ | 1001 @@ -0,0 +1,7 @@ |
811 +interface Log | 1002 +interface Log |
812 +{ | 1003 +{ |
813 + provided sequence Log::info(::string) | 1004 + provided sequence Log::info(::string) |
814 + { | 1005 + { |
815 + provided chunk ::CALL; | 1006 + provided chunk ::CALL; |
816 + } | 1007 + } |
817 +} | 1008 +} |
818 diff --git a/rathaxes/samples/lkm/pci.blt b/rathaxes/samples/lkm/pci.blt | 1009 diff -r 6d6b478219da rathaxes/samples/lkm/pci.blt |
819 new file mode 100644 | 1010 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
820 --- /dev/null | 1011 +++ b/rathaxes/samples/lkm/pci.blt Mon Jan 09 22:16:54 2012 +0100 |
821 +++ b/rathaxes/samples/lkm/pci.blt | |
822 @@ -0,0 +1,143 @@ | 1012 @@ -0,0 +1,143 @@ |
823 +with PCI, LKM, Log | 1013 +with PCI, LKM, Log |
824 +{ | 1014 +{ |
825 + template type PCI::Device() | 1015 + template type PCI::Device() |
826 + { | 1016 + { |
961 + chunk ::CALL | 1151 + chunk ::CALL |
962 + { | 1152 + { |
963 + } | 1153 + } |
964 + } | 1154 + } |
965 +} | 1155 +} |
966 diff --git a/rathaxes/samples/lkm/pci.rti b/rathaxes/samples/lkm/pci.rti | 1156 diff -r 6d6b478219da rathaxes/samples/lkm/pci.rti |
967 new file mode 100644 | 1157 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
968 --- /dev/null | 1158 +++ b/rathaxes/samples/lkm/pci.rti Mon Jan 09 22:16:54 2012 +0100 |
969 +++ b/rathaxes/samples/lkm/pci.rti | |
970 @@ -0,0 +1,36 @@ | 1159 @@ -0,0 +1,36 @@ |
971 +interface PCI : LKM | 1160 +interface PCI : LKM |
972 +{ | 1161 +{ |
973 + provided type PCI::Device; | 1162 + provided type PCI::Device; |
974 + | 1163 + |
1002 + provided chunk LKM::code; | 1191 + provided chunk LKM::code; |
1003 + | 1192 + |
1004 + provided pointcut PCI::pci_remove_hook; | 1193 + provided pointcut PCI::pci_remove_hook; |
1005 + } | 1194 + } |
1006 +} | 1195 +} |
1007 diff --git a/rathaxes/samples/lkm/socket.blt b/rathaxes/samples/lkm/socket.blt | 1196 diff -r 6d6b478219da rathaxes/samples/lkm/socket.blt |
1008 new file mode 100644 | 1197 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
1009 --- /dev/null | 1198 +++ b/rathaxes/samples/lkm/socket.blt Mon Jan 09 22:16:54 2012 +0100 |
1010 +++ b/rathaxes/samples/lkm/socket.blt | |
1011 @@ -0,0 +1,27 @@ | 1199 @@ -0,0 +1,27 @@ |
1012 +with Socket, LKM | 1200 +with Socket, LKM |
1013 +{ | 1201 +{ |
1014 + template type Socket::SKBuff() | 1202 + template type Socket::SKBuff() |
1015 + { | 1203 + { |
1034 + // We should determine if all the sk_buff managment | 1222 + // We should determine if all the sk_buff managment |
1035 + // can be abstracted from the user. | 1223 + // can be abstracted from the user. |
1036 + } | 1224 + } |
1037 + } | 1225 + } |
1038 +} | 1226 +} |
1039 diff --git a/rathaxes/samples/lkm/socket.rti b/rathaxes/samples/lkm/socket.rti | 1227 diff -r 6d6b478219da rathaxes/samples/lkm/socket.rti |
1040 new file mode 100644 | 1228 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
1041 --- /dev/null | 1229 +++ b/rathaxes/samples/lkm/socket.rti Mon Jan 09 22:16:54 2012 +0100 |
1042 +++ b/rathaxes/samples/lkm/socket.rti | |
1043 @@ -0,0 +1,4 @@ | 1230 @@ -0,0 +1,4 @@ |
1044 +interface Socket : LKM | 1231 +interface Socket : LKM |
1045 +{ | 1232 +{ |
1046 + provided type Socket::SKBuff; | 1233 + provided type Socket::SKBuff; |
1047 +} | 1234 +} |