Mercurial > archived > louis > epitech > mq > rathaxes
comparison rathaxes_add_lkm_ethernet_sample.patch @ 47:cf7d541b9331
Re-order patches + quick fixes
author | Louis Opter <louis@lse.epitech.net> |
---|---|
date | Fri, 13 Jan 2012 11:59:42 +0100 |
parents | bab559e0392b |
children |
comparison
equal
deleted
inserted
replaced
46:1cf60e316d19 | 47:cf7d541b9331 |
---|---|
1 # HG changeset patch | 1 # HG changeset patch |
2 # Parent 6d6b478219da142368f4e458b8a348f4d87867d9 | 2 # User Thomas Sanchez <thomas.sanchz@gmail.com>, Louis Opter <louis@lse.epita.fr> |
3 rathaxes: add the PCI/Ethernet part of a Linux Intel e1000 network card driver | 3 # Parent 3a7169517431da7a5a9a3c411ff95927c55f214f |
4 rathaxes: add the beginning of a Linux Intel e1000 network card driver | |
4 | 5 |
5 diff -r 6d6b478219da maintainers/CMakeScripts/UseRathaxes.cmake | 6 - With working LKM/PCI/Ethernet parts; |
6 --- a/maintainers/CMakeScripts/UseRathaxes.cmake Mon Jan 09 19:24:10 2012 +0100 | 7 - Some interruption handling POC; |
7 +++ b/maintainers/CMakeScripts/UseRathaxes.cmake Mon Jan 09 22:16:54 2012 +0100 | 8 - Directly compiles to a .ko object. |
9 | |
10 diff --git a/maintainers/CMakeScripts/Templates/MakefileLKM.in b/maintainers/CMakeScripts/Templates/MakefileLKM.in | |
11 --- a/maintainers/CMakeScripts/Templates/MakefileLKM.in | |
12 +++ b/maintainers/CMakeScripts/Templates/MakefileLKM.in | |
13 @@ -1,5 +1,9 @@ | |
14 -KDIR = /lib/modules/$(shell uname -r)/build | |
15 -obj-m := @LKM_OBJECTS@ | |
16 +# Disable this "coding-style" warning (seriously, you have to compile with | |
17 +# -pedantic to get it...) | |
18 +EXTRA_CFLAGS = -Wno-declaration-after-statement | |
19 + | |
20 +KDIR = /lib/modules/$(shell uname -r)/build | |
21 +obj-m := @LKM_OBJECTS@ | |
22 | |
23 all: | |
24 $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) modules | |
25 diff --git a/maintainers/CMakeScripts/UseRathaxes.cmake b/maintainers/CMakeScripts/UseRathaxes.cmake | |
26 --- a/maintainers/CMakeScripts/UseRathaxes.cmake | |
27 +++ b/maintainers/CMakeScripts/UseRathaxes.cmake | |
8 @@ -193,6 +193,8 @@ | 28 @@ -193,6 +193,8 @@ |
9 | 29 |
10 SET(KERNEL_OBJECT_NAME "${RATHAXES_SOURCE}_${SYSTEM}.ko") | 30 SET(KERNEL_OBJECT_NAME "${RATHAXES_SOURCE}_${SYSTEM}.ko") |
11 ADD_CUSTOM_COMMAND(OUTPUT "${KERNEL_OBJECT_NAME}" | 31 ADD_CUSTOM_COMMAND(OUTPUT "${KERNEL_OBJECT_NAME}" |
12 + # … | 32 + # … |
13 + COMMAND "sed" "-i" "/TARTE/ d" "${RATHAXES_SOURCE}_${SYSTEM}.c" | 33 + COMMAND "sed" "-i" "/TARTE/ d" "${RATHAXES_SOURCE}_${SYSTEM}.c" |
14 # The linux Makefile to build kernel module is quite | 34 # The linux Makefile to build kernel module is quite |
15 # picky about file location and its own name. Let's | 35 # picky about file location and its own name. Let's |
16 # copy our source side by side with the Makefile: | 36 # copy our source side by side with the Makefile: |
17 diff -r 6d6b478219da rathaxes/samples/CMakeLists.txt | 37 diff --git a/rathaxes/samples/CMakeLists.txt b/rathaxes/samples/CMakeLists.txt |
18 --- a/rathaxes/samples/CMakeLists.txt Mon Jan 09 19:24:10 2012 +0100 | 38 --- a/rathaxes/samples/CMakeLists.txt |
19 +++ b/rathaxes/samples/CMakeLists.txt Mon Jan 09 22:16:54 2012 +0100 | 39 +++ b/rathaxes/samples/CMakeLists.txt |
20 @@ -1,2 +1,3 @@ | 40 @@ -1,2 +1,3 @@ |
21 ADD_SUBDIRECTORY(helloworld) | 41 ADD_SUBDIRECTORY(helloworld) |
22 +ADD_SUBDIRECTORY(lkm) | |
23 ADD_SUBDIRECTORY(syntax) | 42 ADD_SUBDIRECTORY(syntax) |
24 diff -r 6d6b478219da rathaxes/samples/lkm/CMakeLists.txt | 43 +ADD_SUBDIRECTORY(e1000) |
25 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | 44 diff --git a/rathaxes/samples/e1000/CMakeLists.txt b/rathaxes/samples/e1000/CMakeLists.txt |
26 +++ b/rathaxes/samples/lkm/CMakeLists.txt Mon Jan 09 22:16:54 2012 +0100 | 45 new file mode 100644 |
46 --- /dev/null | |
47 +++ b/rathaxes/samples/e1000/CMakeLists.txt | |
27 @@ -0,0 +1,7 @@ | 48 @@ -0,0 +1,7 @@ |
28 +ADD_RATHAXES_SOURCES(lkm_src lkm.rtx | 49 +ADD_RATHAXES_SOURCES(e1000_src lkm.rtx |
29 + RTI log.rti lkm.rti pci.rti socket.rti ethernet.rti e1000.rti | 50 + RTI log.rti lkm.rti pci.rti socket.rti ethernet.rti e1000.rti |
30 + BLT log.blt lkm.blt pci.blt socket.blt ethernet.blt e1000.blt) | 51 + BLT log.blt lkm.blt pci.blt socket.blt ethernet.blt e1000.blt) |
31 + | 52 + |
32 +# We can't name lkm since it's already used as the target name to generate the | 53 +# We can't name lkm since it's already used as the target name to generate the |
33 +# source (with ADD_RATHAXES_SOURCES). | 54 +# source (with ADD_RATHAXES_SOURCES). |
34 +ADD_RATHAXES_LKM(lkm lkm_src) | 55 +ADD_RATHAXES_LKM(e1000 e1000_src) |
35 diff -r 6d6b478219da rathaxes/samples/lkm/e1000.blt | 56 diff --git a/rathaxes/samples/e1000/e1000.blt b/rathaxes/samples/e1000/e1000.blt |
36 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | 57 new file mode 100644 |
37 +++ b/rathaxes/samples/lkm/e1000.blt Mon Jan 09 22:16:54 2012 +0100 | 58 --- /dev/null |
59 +++ b/rathaxes/samples/e1000/e1000.blt | |
38 @@ -0,0 +1,435 @@ | 60 @@ -0,0 +1,435 @@ |
39 +with e1000, Ethernet, Socket, PCI, LKM, Log | 61 +with e1000, Ethernet, Socket, PCI, LKM, Log |
40 +{ | 62 +{ |
41 + template type e1000::Context() | 63 + template type e1000::Context() |
42 + { | 64 + { |
161 + E1000_INTR_LSC = 0x00000004, /* Link Status Change */ | 183 + E1000_INTR_LSC = 0x00000004, /* Link Status Change */ |
162 + E1000_INTR_RXSEQ = 0x00000008, /* rx sequence error */ | 184 + E1000_INTR_RXSEQ = 0x00000008, /* rx sequence error */ |
163 + E1000_INTR_RXDMT0 = 0x00000010, /* rx desc min. threshold (0) */ | 185 + E1000_INTR_RXDMT0 = 0x00000010, /* rx desc min. threshold (0) */ |
164 + E1000_INTR_RXO = 0x00000040, /* rx overrun */ | 186 + E1000_INTR_RXO = 0x00000040, /* rx overrun */ |
165 + E1000_INTR_RXT0 = 0x00000080, /* rx timer intr (ring 0) */ | 187 + E1000_INTR_RXT0 = 0x00000080, /* rx timer intr (ring 0) */ |
166 + E1000_INTR_MDAC = 0x00000200 /* MDIO access complete */ | 188 + E1000_INTR_MDAC = 0x00000200 /* MDIO access complete */ |
167 + | |
168 + }; | 189 + }; |
169 + } | 190 + } |
170 + | 191 + |
171 + map | 192 + map |
172 + { | 193 + { |
431 + template sequence e1000::activate_device_interruption() | 452 + template sequence e1000::activate_device_interruption() |
432 + { | 453 + { |
433 + chunk ::CALL() | 454 + chunk ::CALL() |
434 + { | 455 + { |
435 + rtx_e1000_register_write32(ctx, E1000_IMS, | 456 + rtx_e1000_register_write32(ctx, E1000_IMS, |
436 + E1000_INTR_TXDW | | 457 + E1000_INTR_TXDW | |
437 + E1000_INTR_TXQE | | 458 + E1000_INTR_TXQE | |
438 + E1000_INTR_LSC | | 459 + E1000_INTR_LSC | |
439 + E1000_INTR_RXO | | 460 + E1000_INTR_RXO | |
440 + E1000_INTR_RXT0); | 461 + E1000_INTR_RXT0); |
441 + } | 462 + } |
442 + } | 463 + } |
443 + | 464 + |
444 + template sequence e1000::set_up_device() | 465 + template sequence e1000::set_up_device() |
445 + { | 466 + { |
446 + chunk ::CALL() | 467 + chunk ::CALL() |
447 + { | 468 + { |
448 + rtx_e1000_register_set32(ctx, E1000_CTRL, E1000_CMD_ASDE | 469 + rtx_e1000_register_set32(ctx, E1000_CTRL, |
449 + | E1000_CMD_SLU | 470 + E1000_CMD_ASDE | |
450 + | E1000_CMD_LRST | 471 + E1000_CMD_SLU | |
451 + | E1000_CMD_PHY_RST); | 472 + E1000_CMD_LRST | |
473 + E1000_CMD_PHY_RST); | |
452 + } | 474 + } |
453 + } | 475 + } |
454 + | 476 + |
455 + template sequence e1000::handle_intr() | 477 + template sequence e1000::handle_intr() |
456 + { | 478 + { |
469 + return IRQ_HANDLED; | 491 + return IRQ_HANDLED; |
470 + } | 492 + } |
471 + } | 493 + } |
472 + } | 494 + } |
473 +} | 495 +} |
474 diff -r 6d6b478219da rathaxes/samples/lkm/e1000.rti | 496 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti |
475 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | 497 new file mode 100644 |
476 +++ b/rathaxes/samples/lkm/e1000.rti Mon Jan 09 22:16:54 2012 +0100 | 498 --- /dev/null |
499 +++ b/rathaxes/samples/e1000/e1000.rti | |
477 @@ -0,0 +1,89 @@ | 500 @@ -0,0 +1,89 @@ |
478 +interface e1000 : Socket, Ethernet, PCI, LKM | 501 +interface e1000 : Socket, Ethernet, PCI, LKM |
479 +{ | 502 +{ |
480 + provided type e1000::Context; | 503 + provided type e1000::Context; |
481 + provided type e1000::Register; | 504 + provided type e1000::Register; |
562 + provided chunk LKM::prototypes; | 585 + provided chunk LKM::prototypes; |
563 + provided chunk LKM::code; | 586 + provided chunk LKM::code; |
564 + provided chunk ::CALL; | 587 + provided chunk ::CALL; |
565 + } | 588 + } |
566 +} | 589 +} |
567 diff -r 6d6b478219da rathaxes/samples/lkm/ethernet.blt | 590 diff --git a/rathaxes/samples/e1000/ethernet.blt b/rathaxes/samples/e1000/ethernet.blt |
568 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | 591 new file mode 100644 |
569 +++ b/rathaxes/samples/lkm/ethernet.blt Mon Jan 09 22:16:54 2012 +0100 | 592 --- /dev/null |
593 +++ b/rathaxes/samples/e1000/ethernet.blt | |
570 @@ -0,0 +1,218 @@ | 594 @@ -0,0 +1,218 @@ |
571 +with Ethernet, PCI, LKM, Log | 595 +with Ethernet, PCI, LKM, Log |
572 +{ | 596 +{ |
573 + template type Ethernet::Device() | 597 + template type Ethernet::Device() |
574 + { | 598 + { |
784 + { | 808 + { |
785 + } | 809 + } |
786 + } | 810 + } |
787 +} | 811 +} |
788 + | 812 + |
789 diff -r 6d6b478219da rathaxes/samples/lkm/ethernet.rti | 813 diff --git a/rathaxes/samples/e1000/ethernet.rti b/rathaxes/samples/e1000/ethernet.rti |
790 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | 814 new file mode 100644 |
791 +++ b/rathaxes/samples/lkm/ethernet.rti Mon Jan 09 22:16:54 2012 +0100 | 815 --- /dev/null |
816 +++ b/rathaxes/samples/e1000/ethernet.rti | |
792 @@ -0,0 +1,47 @@ | 817 @@ -0,0 +1,47 @@ |
793 +interface Ethernet : Socket, PCI, LKM | 818 +interface Ethernet : Socket, PCI, LKM |
794 +{ | 819 +{ |
795 + provided type Ethernet::Device; | 820 + provided type Ethernet::Device; |
796 + | 821 + |
835 + provided chunk PCI::pci_remove_hook; | 860 + provided chunk PCI::pci_remove_hook; |
836 + | 861 + |
837 + provided pointcut Ethernet::destroy_device; | 862 + provided pointcut Ethernet::destroy_device; |
838 + } | 863 + } |
839 +} | 864 +} |
840 diff -r 6d6b478219da rathaxes/samples/lkm/lkm.blt | 865 diff --git a/rathaxes/samples/e1000/lkm.blt b/rathaxes/samples/e1000/lkm.blt |
841 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | 866 new file mode 100644 |
842 +++ b/rathaxes/samples/lkm/lkm.blt Mon Jan 09 22:16:54 2012 +0100 | 867 --- /dev/null |
868 +++ b/rathaxes/samples/e1000/lkm.blt | |
843 @@ -0,0 +1,55 @@ | 869 @@ -0,0 +1,55 @@ |
844 +with LKM | 870 +with LKM |
845 +{ | 871 +{ |
846 + /* Skel of the generated C file: */ | 872 + /* Skel of the generated C file: */ |
847 + ${pointcut LKM::includes}; | 873 + ${pointcut LKM::includes}; |
894 + | 920 + |
895 + module_exit(rtx_module_exit); | 921 + module_exit(rtx_module_exit); |
896 + } | 922 + } |
897 + } | 923 + } |
898 +} | 924 +} |
899 diff -r 6d6b478219da rathaxes/samples/lkm/lkm.rti | 925 diff --git a/rathaxes/samples/e1000/lkm.rti b/rathaxes/samples/e1000/lkm.rti |
900 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | 926 new file mode 100644 |
901 +++ b/rathaxes/samples/lkm/lkm.rti Mon Jan 09 22:16:54 2012 +0100 | 927 --- /dev/null |
928 +++ b/rathaxes/samples/e1000/lkm.rti | |
902 @@ -0,0 +1,25 @@ | 929 @@ -0,0 +1,25 @@ |
903 +interface LKM | 930 +interface LKM |
904 +{ | 931 +{ |
905 + provided pointcut LKM::includes; | 932 + provided pointcut LKM::includes; |
906 + /* maybe it should be possible to use chunk ::decl in sequence templates? */ | 933 + /* maybe it should be possible to use chunk ::decl in sequence templates? */ |
923 + { | 950 + { |
924 + provided chunk LKM::code; | 951 + provided chunk LKM::code; |
925 + provided pointcut LKM::deinit_bus_hook; | 952 + provided pointcut LKM::deinit_bus_hook; |
926 + } | 953 + } |
927 +} | 954 +} |
928 diff -r 6d6b478219da rathaxes/samples/lkm/lkm.rtx | 955 diff --git a/rathaxes/samples/e1000/lkm.rtx b/rathaxes/samples/e1000/lkm.rtx |
929 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | 956 new file mode 100644 |
930 +++ b/rathaxes/samples/lkm/lkm.rtx Mon Jan 09 22:16:54 2012 +0100 | 957 --- /dev/null |
958 +++ b/rathaxes/samples/e1000/lkm.rtx | |
931 @@ -0,0 +1,52 @@ | 959 @@ -0,0 +1,52 @@ |
932 +device LKM use LKM, PCI, Ethernet, Log | 960 +device LKM use LKM, PCI, Ethernet, Log |
933 +{ | 961 +{ |
934 + Ethernet::open(Ethernet::Device dev) | 962 + Ethernet::open(Ethernet::Device dev) |
935 + { | 963 + { |
979 + PCI::product_id = 0x100f; | 1007 + PCI::product_id = 0x100f; |
980 + PCI::set_master = true; | 1008 + PCI::set_master = true; |
981 + | 1009 + |
982 + Ethernet::ifname = "rtx%d"; | 1010 + Ethernet::ifname = "rtx%d"; |
983 +} | 1011 +} |
984 diff -r 6d6b478219da rathaxes/samples/lkm/log.blt | 1012 diff --git a/rathaxes/samples/e1000/log.blt b/rathaxes/samples/e1000/log.blt |
985 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | 1013 new file mode 100644 |
986 +++ b/rathaxes/samples/lkm/log.blt Mon Jan 09 22:16:54 2012 +0100 | 1014 --- /dev/null |
1015 +++ b/rathaxes/samples/e1000/log.blt | |
987 @@ -0,0 +1,10 @@ | 1016 @@ -0,0 +1,10 @@ |
988 +with Log | 1017 +with Log |
989 +{ | 1018 +{ |
990 + template sequence Log::info(::string msg) | 1019 + template sequence Log::info(::string msg) |
991 + { | 1020 + { |
993 + { | 1022 + { |
994 + pr_info("%s\n", ${msg}); | 1023 + pr_info("%s\n", ${msg}); |
995 + } | 1024 + } |
996 + } | 1025 + } |
997 +} | 1026 +} |
998 diff -r 6d6b478219da rathaxes/samples/lkm/log.rti | 1027 diff --git a/rathaxes/samples/e1000/log.rti b/rathaxes/samples/e1000/log.rti |
999 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | 1028 new file mode 100644 |
1000 +++ b/rathaxes/samples/lkm/log.rti Mon Jan 09 22:16:54 2012 +0100 | 1029 --- /dev/null |
1030 +++ b/rathaxes/samples/e1000/log.rti | |
1001 @@ -0,0 +1,7 @@ | 1031 @@ -0,0 +1,7 @@ |
1002 +interface Log | 1032 +interface Log |
1003 +{ | 1033 +{ |
1004 + provided sequence Log::info(::string) | 1034 + provided sequence Log::info(::string) |
1005 + { | 1035 + { |
1006 + provided chunk ::CALL; | 1036 + provided chunk ::CALL; |
1007 + } | 1037 + } |
1008 +} | 1038 +} |
1009 diff -r 6d6b478219da rathaxes/samples/lkm/pci.blt | 1039 diff --git a/rathaxes/samples/e1000/pci.blt b/rathaxes/samples/e1000/pci.blt |
1010 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | 1040 new file mode 100644 |
1011 +++ b/rathaxes/samples/lkm/pci.blt Mon Jan 09 22:16:54 2012 +0100 | 1041 --- /dev/null |
1042 +++ b/rathaxes/samples/e1000/pci.blt | |
1012 @@ -0,0 +1,143 @@ | 1043 @@ -0,0 +1,143 @@ |
1013 +with PCI, LKM, Log | 1044 +with PCI, LKM, Log |
1014 +{ | 1045 +{ |
1015 + template type PCI::Device() | 1046 + template type PCI::Device() |
1016 + { | 1047 + { |
1151 + chunk ::CALL | 1182 + chunk ::CALL |
1152 + { | 1183 + { |
1153 + } | 1184 + } |
1154 + } | 1185 + } |
1155 +} | 1186 +} |
1156 diff -r 6d6b478219da rathaxes/samples/lkm/pci.rti | 1187 diff --git a/rathaxes/samples/e1000/pci.rti b/rathaxes/samples/e1000/pci.rti |
1157 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | 1188 new file mode 100644 |
1158 +++ b/rathaxes/samples/lkm/pci.rti Mon Jan 09 22:16:54 2012 +0100 | 1189 --- /dev/null |
1190 +++ b/rathaxes/samples/e1000/pci.rti | |
1159 @@ -0,0 +1,36 @@ | 1191 @@ -0,0 +1,36 @@ |
1160 +interface PCI : LKM | 1192 +interface PCI : LKM |
1161 +{ | 1193 +{ |
1162 + provided type PCI::Device; | 1194 + provided type PCI::Device; |
1163 + | 1195 + |
1191 + provided chunk LKM::code; | 1223 + provided chunk LKM::code; |
1192 + | 1224 + |
1193 + provided pointcut PCI::pci_remove_hook; | 1225 + provided pointcut PCI::pci_remove_hook; |
1194 + } | 1226 + } |
1195 +} | 1227 +} |
1196 diff -r 6d6b478219da rathaxes/samples/lkm/socket.blt | 1228 diff --git a/rathaxes/samples/e1000/socket.blt b/rathaxes/samples/e1000/socket.blt |
1197 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | 1229 new file mode 100644 |
1198 +++ b/rathaxes/samples/lkm/socket.blt Mon Jan 09 22:16:54 2012 +0100 | 1230 --- /dev/null |
1231 +++ b/rathaxes/samples/e1000/socket.blt | |
1199 @@ -0,0 +1,27 @@ | 1232 @@ -0,0 +1,27 @@ |
1200 +with Socket, LKM | 1233 +with Socket, LKM |
1201 +{ | 1234 +{ |
1202 + template type Socket::SKBuff() | 1235 + template type Socket::SKBuff() |
1203 + { | 1236 + { |
1217 + | 1250 + |
1218 + map | 1251 + map |
1219 + { | 1252 + { |
1220 + // some work may have to be done here in order | 1253 + // some work may have to be done here in order |
1221 + // to access to some field of the sk_buff. | 1254 + // to access to some field of the sk_buff. |
1222 + // We should determine if all the sk_buff managment | 1255 + // We should determine if all the sk_buff management |
1223 + // can be abstracted from the user. | 1256 + // can be abstracted from the user. |
1224 + } | 1257 + } |
1225 + } | 1258 + } |
1226 +} | 1259 +} |
1227 diff -r 6d6b478219da rathaxes/samples/lkm/socket.rti | 1260 diff --git a/rathaxes/samples/e1000/socket.rti b/rathaxes/samples/e1000/socket.rti |
1228 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | 1261 new file mode 100644 |
1229 +++ b/rathaxes/samples/lkm/socket.rti Mon Jan 09 22:16:54 2012 +0100 | 1262 --- /dev/null |
1263 +++ b/rathaxes/samples/e1000/socket.rti | |
1230 @@ -0,0 +1,4 @@ | 1264 @@ -0,0 +1,4 @@ |
1231 +interface Socket : LKM | 1265 +interface Socket : LKM |
1232 +{ | 1266 +{ |
1233 + provided type Socket::SKBuff; | 1267 + provided type Socket::SKBuff; |
1234 +} | 1268 +} |