annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1 # HG changeset patch
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
2 # User Thomas Sanchez <thomas.sanchz@gmail.com>, Louis Opter <louis@lse.epita.fr>
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
3 # Parent 3a7169517431da7a5a9a3c411ff95927c55f214f
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
4 rathaxes: add the beginning of a Linux Intel e1000 network card driver
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
5
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
6 - With working LKM/PCI/Ethernet parts;
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
7 - Some interruption handling POC;
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
8 - Directly compiles to a .ko object.
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
9
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
10 diff --git a/maintainers/CMakeScripts/Templates/MakefileLKM.in b/maintainers/CMakeScripts/Templates/MakefileLKM.in
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
11 --- a/maintainers/CMakeScripts/Templates/MakefileLKM.in
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
12 +++ b/maintainers/CMakeScripts/Templates/MakefileLKM.in
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
13 @@ -1,5 +1,9 @@
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
14 -KDIR = /lib/modules/$(shell uname -r)/build
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
15 -obj-m := @LKM_OBJECTS@
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
16 +# Disable this "coding-style" warning (seriously, you have to compile with
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
17 +# -pedantic to get it...)
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
18 +EXTRA_CFLAGS = -Wno-declaration-after-statement
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
19 +
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
20 +KDIR = /lib/modules/$(shell uname -r)/build
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
21 +obj-m := @LKM_OBJECTS@
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
22
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
23 all:
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
24 $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) modules
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
25 diff --git a/maintainers/CMakeScripts/UseRathaxes.cmake b/maintainers/CMakeScripts/UseRathaxes.cmake
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
26 --- a/maintainers/CMakeScripts/UseRathaxes.cmake
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
27 +++ b/maintainers/CMakeScripts/UseRathaxes.cmake
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
28 @@ -193,6 +193,8 @@
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
29
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
30 SET(KERNEL_OBJECT_NAME "${RATHAXES_SOURCE}_${SYSTEM}.ko")
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
31 ADD_CUSTOM_COMMAND(OUTPUT "${KERNEL_OBJECT_NAME}"
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
32 + # …
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
33 + COMMAND "sed" "-i" "/TARTE/ d" "${RATHAXES_SOURCE}_${SYSTEM}.c"
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
34 # The linux Makefile to build kernel module is quite
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
35 # picky about file location and its own name. Let's
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
36 # copy our source side by side with the Makefile:
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
37 diff --git a/rathaxes/samples/CMakeLists.txt b/rathaxes/samples/CMakeLists.txt
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
38 --- a/rathaxes/samples/CMakeLists.txt
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
39 +++ b/rathaxes/samples/CMakeLists.txt
10
44a25ffd5c8c Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents: 3
diff changeset
40 @@ -1,2 +1,3 @@
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
41 ADD_SUBDIRECTORY(helloworld)
10
44a25ffd5c8c Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents: 3
diff changeset
42 ADD_SUBDIRECTORY(syntax)
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
43 +ADD_SUBDIRECTORY(e1000)
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
44 diff --git a/rathaxes/samples/e1000/CMakeLists.txt b/rathaxes/samples/e1000/CMakeLists.txt
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
45 new file mode 100644
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
46 --- /dev/null
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
47 +++ b/rathaxes/samples/e1000/CMakeLists.txt
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
48 @@ -0,0 +1,7 @@
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
49 +ADD_RATHAXES_SOURCES(e1000_src lkm.rtx
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
50 + RTI log.rti lkm.rti pci.rti socket.rti ethernet.rti e1000.rti
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
51 + BLT log.blt lkm.blt pci.blt socket.blt ethernet.blt e1000.blt)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
52 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
53 +# We can't name lkm since it's already used as the target name to generate the
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
54 +# source (with ADD_RATHAXES_SOURCES).
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
55 +ADD_RATHAXES_LKM(e1000 e1000_src)
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
56 diff --git a/rathaxes/samples/e1000/e1000.blt b/rathaxes/samples/e1000/e1000.blt
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
57 new file mode 100644
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
58 --- /dev/null
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
59 +++ b/rathaxes/samples/e1000/e1000.blt
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
60 @@ -0,0 +1,435 @@
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
61 +with e1000, Ethernet, Socket, PCI, LKM, Log
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
62 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
63 + template type e1000::Context()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
64 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
65 + chunk LKM::includes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
66 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
67 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
68 + * Force the generation of the structure in the "headers" part, we
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
69 + * have to do this since we do not use the structure in this blt
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
70 + * (we hacked a bit and used it in ethernet.blt directly).
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
71 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
72 + typedef int ${e1000::Context}; /* CNorm __std__ workaround */
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
73 + static const ${e1000::Context} force_struct_rtx_10000_ctx_decl;
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
74 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
75 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
76 + chunk ::decl()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
77 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
78 + struct rtx_e1000_ctx
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
79 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
80 + int bars;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
81 + unsigned char /* __iomem */ *ioaddr;
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
82 + int irq;
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
83 + };
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
84 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
85 +
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
86 + chunk ::init(bars, ioaddr)
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
87 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
88 + ${self}.bars = ${bars};
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
89 + ${self}.ioaddr = ${ioaddr};
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
90 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
91 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
92 + map
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
93 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
94 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
95 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
96 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
97 + template type e1000::Register()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
98 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
99 + chunk LKM::includes()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
100 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
101 + typedef int ${e1000::Register};
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
102 + static const ${e1000::Register} force_enum_rtx_e1000_registers_decl;
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
103 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
104 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
105 + chunk ::decl()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
106 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
107 + enum rtx_e1000_registers
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
108 + {
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
109 + E1000_CTRL = 0x00000, /* Device Control - RW */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
110 + E1000_CTRL_DUP = 0x00004, /* Device Control Duplicate (Shadow) - RW */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
111 + E1000_STATUS = 0x00008, /* Device Status - RO */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
112 + E1000_EEPROM_FLASH = 0x00010, /* EEPROM/Flash Control - RW */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
113 + E1000_EEPROM_READ = 0x00014, /* EEPROM Read - RW */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
114 + E1000_CTRL_EXT = 0x00018, /* Extended Device Control - RW */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
115 + E1000_FLA = 0x0001C, /* Flash Access - RW */
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
116 + E1000_MDIC = 0x00020, /* MDI Control - RW */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
117 + E1000_IMS = 0x000D0, /* Interrupt Mask Set */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
118 + E1000_IMC = 0x000D8, /* Interrupt Mask Clear */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
119 + E1000_ICR = 0x000C0 /* Interrupt Cause Read - R/clr */
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
120 + };
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
121 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
122 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
123 + chunk ::init(value)
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
124 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
125 + ${self} = ${value};
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
126 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
127 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
128 + map
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
129 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
130 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
131 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
132 +
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
133 + template type e1000::Commands()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
134 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
135 + chunk LKM::includes()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
136 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
137 + typedef int ${e1000::Commands};
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
138 + static const ${e1000::Commands} force_enum_rtx_e1000_commands_decls;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
139 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
140 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
141 + chunk ::decl()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
142 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
143 + enum rtx_e1000_commands
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
144 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
145 + E1000_CMD_FD = 0x00000001, /* Full duplex.0=half; 1=full */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
146 + E1000_CMD_BEM = 0x00000002, /* Endian Mode.0=little,1=big */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
147 + E1000_CMD_PRIOR = 0x00000004, /* Priority on PCI. 0=rx,1=fair */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
148 + E1000_CMD_GIO_MASTER_DISABLE = 0x00000004, /* Blocks new Master requests */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
149 + E1000_CMD_LRST = 0x00000008, /* Link reset. 0=normal,1=reset */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
150 + E1000_CMD_TME = 0x00000010, /* Test mode. 0=normal,1=test */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
151 + E1000_CMD_SLE = 0x00000020, /* Serial Link on 0=dis,1=en */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
152 + E1000_CMD_ASDE = 0x00000020, /* Auto-speed detect enable */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
153 + E1000_CMD_SLU = 0x00000040, /* Set link up (Force Link) */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
154 + E1000_CMD_ILOS = 0x00000080, /* Invert Loss-Of Signal */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
155 + E1000_CMD_SPD_SEL = 0x00000300, /* Speed Select Mask */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
156 + E1000_CMD_SPD_10 = 0x00000000, /* Force 10Mb */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
157 + E1000_CMD_SPD_100 = 0x00000100, /* Force 100Mb */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
158 + E1000_CMD_SPD_1000 = 0x00000200, /* Force 1Gb */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
159 + E1000_CMD_BEM32 = 0x00000400, /* Big Endian 32 mode */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
160 + E1000_CMD_FRCSPD = 0x00000800, /* Force Speed */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
161 + E1000_CMD_FRCDPX = 0x00001000, /* Force Duplex */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
162 + E1000_CMD_D_UD_EN = 0x00002000, /* Dock/Undock enable */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
163 + E1000_CMD_D_UD_POLARITY = 0x00004000, /* Defined polarity of Dock/Undock indication in SDP[0] */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
164 + E1000_CMD_FORCE_PHY_RESET = 0x00008000, /* Reset both PHY ports, through PHYRST_N pin */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
165 + E1000_CMD_EXT_LINK_EN = 0x00010000, /* enable link status from external LINK_0 and LINK_1 pins */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
166 + E1000_CMD_SWDPIN0 = 0x00040000, /* SWDPIN 0 value */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
167 + E1000_CMD_SWDPIN1 = 0x00080000, /* SWDPIN 1 value */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
168 + E1000_CMD_SWDPIN2 = 0x00100000, /* SWDPIN 2 value */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
169 + E1000_CMD_SWDPIN3 = 0x00200000, /* SWDPIN 3 value */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
170 + E1000_CMD_SWDPIO0 = 0x00400000, /* SWDPIN 0 Input or output */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
171 + E1000_CMD_SWDPIO1 = 0x00800000, /* SWDPIN 1 input or output */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
172 + E1000_CMD_SWDPIO2 = 0x01000000, /* SWDPIN 2 input or output */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
173 + E1000_CMD_SWDPIO3 = 0x02000000, /* SWDPIN 3 input or output */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
174 + E1000_CMD_RST = 0x04000000, /* Global reset */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
175 + E1000_CMD_RFCE = 0x08000000, /* Receive Flow Control enable */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
176 + E1000_CMD_TFCE = 0x10000000, /* Transmit flow control enable */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
177 + E1000_CMD_RTE = 0x20000000, /* Routing tag enable */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
178 + E1000_CMD_VME = 0x40000000, /* IEEE VLAN mode enable */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
179 + E1000_CMD_PHY_RST = 0x80000000, /* PHY Reset */
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
180 + E1000_CMD_SW2FW_INT = 0x02000000, /* Initiate an interrupt to manageability engine */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
181 + E1000_INTR_TXDW = 0x00000001, /* Transmit desc written back */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
182 + E1000_INTR_TXQE = 0x00000002, /* Transmit Queue empty */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
183 + E1000_INTR_LSC = 0x00000004, /* Link Status Change */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
184 + E1000_INTR_RXSEQ = 0x00000008, /* rx sequence error */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
185 + E1000_INTR_RXDMT0 = 0x00000010, /* rx desc min. threshold (0) */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
186 + E1000_INTR_RXO = 0x00000040, /* rx overrun */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
187 + E1000_INTR_RXT0 = 0x00000080, /* rx timer intr (ring 0) */
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
188 + E1000_INTR_MDAC = 0x00000200 /* MDIO access complete */
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
189 + };
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
190 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
191 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
192 + map
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
193 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
194 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
195 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
196 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
197 + template sequence e1000::create_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
198 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
199 + chunk Ethernet::create_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
200 + {
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
201 + rtx_ether_ctx->hw_ctx.irq = pdev->irq;
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
202 + rtx_ether_ctx->hw_ctx.bars = pci_select_bars(pdev, IORESOURCE_MEM);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
203 + if (pci_enable_device_mem(pdev))
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
204 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
205 + ${Log::info("e1000::create: pci_enable_device_mem failed")};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
206 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
207 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
208 + if (pci_request_selected_regions(pdev, rtx_ether_ctx->hw_ctx.bars, ${config.name}))
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
209 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
210 + ${Log::info("e1000::create: pci_request_selected_regions failed")};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
211 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
212 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
213 + if (${config.set_master})
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
214 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
215 + pci_set_master(pdev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
216 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
217 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
218 + /* 0 here is for BAR_0: */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
219 + rtx_ether_ctx->hw_ctx.ioaddr = pci_ioremap_bar(pdev, 0);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
220 + if (!rtx_ether_ctx->hw_ctx.ioaddr)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
221 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
222 + ${Log::info("e1000::create: pci_ioremap_bar failed")};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
223 + }
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
224 +
41
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
225 + /* Reset the card */
42
e0cd016d4fc5 Restore the reset code and print the mac address
Louis Opter <louis@lse.epitech.net>
parents: 41
diff changeset
226 + rtx_e1000_register_write32(&rtx_ether_ctx->hw_ctx, E1000_CTRL, E1000_CMD_RST);
41
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
227 + udelay(10);
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
228 +
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
229 + /* Now we can load its mac address */
41
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
230 + int i = 0;
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
231 + for (i = 0 /* < this is not generated! */; i < 3; ++i)
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
232 + {
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
233 + rtx_e1000_register_write32(&rtx_ether_ctx->hw_ctx, E1000_EEPROM_READ, (i << 8) | 1);
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
234 +
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
235 + int value;
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
236 + /* Should be a do { } while(); but the compiler doesn't do { } while(); yet. */
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
237 + value = rtx_e1000_register_read32(&rtx_ether_ctx->hw_ctx, E1000_EEPROM_READ);
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
238 + while ((value & (1 << 4)) == 0)
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
239 + value = rtx_e1000_register_read32(&rtx_ether_ctx->hw_ctx, E1000_EEPROM_READ);
43
4b51f5628787 Add a missing shift in the load mac address code
Louis Opter <louis@lse.epitech.net>
parents: 42
diff changeset
240 + value >>= 16;
41
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
241 +
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
242 + rtx_ether_ctx->net_dev->dev_addr[i * 2] = value & 0xff;
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
243 + rtx_ether_ctx->net_dev->dev_addr[i * 2 + 1] = (value >> 8) & 0xff;
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
244 + }
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
245 +
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
246 + memcpy(rtx_ether_ctx->net_dev->perm_addr,
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
247 + rtx_ether_ctx->net_dev->dev_addr,
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
248 + rtx_ether_ctx->net_dev->addr_len);
42
e0cd016d4fc5 Restore the reset code and print the mac address
Louis Opter <louis@lse.epitech.net>
parents: 41
diff changeset
249 +
44
258319759ba3 Print something with Log::info when the mac address is loaded
Louis Opter <louis@lse.epitech.net>
parents: 43
diff changeset
250 + { /* < mais lol. */
258319759ba3 Print something with Log::info when the mac address is loaded
Louis Opter <louis@lse.epitech.net>
parents: 43
diff changeset
251 + ${Log::info("e1000::create: mac address loaded from the EEPROM")};
258319759ba3 Print something with Log::info when the mac address is loaded
Louis Opter <louis@lse.epitech.net>
parents: 43
diff changeset
252 + }
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
253 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
254 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
255 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
256 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
257 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
258 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
259 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
260 + template sequence e1000::destroy_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
261 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
262 + chunk Ethernet::destroy_device
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
263 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
264 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
265 + * Here, we should have some checks to avoid to free resources that
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
266 + * haven't been allocated. (e.g: in case of previous errors).
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
267 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
268 + struct rtx_ethernet_dev* rtx_ether_ctx = netdev_priv(net_dev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
269 + iounmap(rtx_ether_ctx->hw_ctx.ioaddr);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
270 + pci_release_selected_regions(pdev, rtx_ether_ctx->hw_ctx.bars);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
271 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
272 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
273 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
274 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
275 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
276 + }
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
277 +
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
278 + template sequence e1000::print_status()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
279 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
280 + chunk LKM::prototypes()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
281 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
282 + static void rtx_e1000_print_status(struct rtx_e1000_ctx *);
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
283 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
284 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
285 + chunk LKM::code()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
286 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
287 + static void rtx_e1000_print_status(struct rtx_e1000_ctx *ctx)
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
288 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
289 + unsigned int status = rtx_e1000_register_read32(ctx, E1000_STATUS);
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
290 + pr_info("rtx_e1000 status: \n");
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
291 + pr_info("\tRegister value: 0x%x\n", status);
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
292 + pr_info("\tMode: %s\n", (status & 1) ? "Full": "Half");
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
293 + pr_info("\tLink: %s\n", (status & 2) ? "Up" : "Down");
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
294 + pr_info("\tTransmission: %s\n", (status & 4) ? "Paused" : "Ok");
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
295 + pr_info("\tInterface: %s\n", (status & 3) == 3 ? "Up" : "Down");
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
296 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
297 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
298 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
299 + chunk ::CALL
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
300 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
301 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
302 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
303 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
304 + /*
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
305 + * We should have been able to do something along those lines, but
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
306 + * it didn't work so we made the call manually.
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
307 + *
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
308 + * Ideally:
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
309 + * ${e1000::register_read32(rtx_ether_ctx->hw_ctx, E1000_STATUS)};
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
310 + *
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
311 + * Ideally2, not sure about the syntax on the register parameter:
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
312 + * ${e1000::register_read32(rtx_ether_ctx->hw_ctx, ${e1000::Register.E1000_STATUS})};
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
313 + *
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
314 + * "Acceptable":
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
315 + * typedef int ${e1000::Register}; // cnorm __std__ workaround
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
316 + * ${e1000::Register} reg_status;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
317 + * ${e1000.init(E1000_STATUS); // didn't work, so we used the next line
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
318 + * reg_status = E1000_STATUS;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
319 + * ${e1000::register_read32(rtx_ether_ctx->hw_ctx, reg_status)};
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
320 + */
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
321 + template sequence e1000::register_read32(e1000::Context ctx, e1000::Register reg_offset)
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
322 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
323 + chunk LKM::prototypes()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
324 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
325 + static unsigned int rtx_e1000_register_read32(struct rtx_e1000_ctx *, unsigned int);
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
326 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
327 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
328 + chunk LKM::code()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
329 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
330 + static unsigned int rtx_e1000_register_read32(struct rtx_e1000_ctx *ctx, unsigned int reg_offset)
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
331 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
332 + return ioread32(ctx->ioaddr + reg_offset);
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
333 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
334 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
335 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
336 + chunk ::CALL()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
337 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
338 + rtx_e1000_register_read32(&${ctx}, ${reg_offset});
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
339 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
340 + }
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
341 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
342 + template sequence e1000::register_write32(e1000::Context ctx, e1000::Register reg_offset, ::number value)
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
343 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
344 + chunk LKM::prototypes()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
345 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
346 + static void rtx_e1000_register_write32(struct rtx_e1000_ctx *, unsigned int, unsigned int);
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
347 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
348 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
349 + chunk LKM::code()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
350 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
351 + static void rtx_e1000_register_write32(struct rtx_e1000_ctx *ctx, unsigned int reg_offset, unsigned int value)
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
352 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
353 + iowrite32(value, ctx->ioaddr + reg_offset);
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
354 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
355 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
356 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
357 + chunk ::CALL()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
358 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
359 + rtx_e1000_register_write32(&${ctx}, ${reg_offset});
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
360 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
361 + }
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
362 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
363 + template sequence e1000::register_set32(e1000::Context ctx, e1000::Register reg_offset, ::number value)
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
364 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
365 + chunk LKM::prototypes()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
366 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
367 + static void rtx_e1000_register_set32(struct rtx_e1000_ctx *, unsigned int, unsigned int);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
368 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
369 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
370 + chunk LKM::code()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
371 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
372 + static void rtx_e1000_register_set32(struct rtx_e1000_ctx *ctx, unsigned int reg_offset, unsigned int value)
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
373 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
374 + iowrite32(rtx_e1000_register_read32(ctx, reg_offset) | value, ctx->ioaddr + reg_offset);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
375 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
376 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
377 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
378 + chunk ::CALL()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
379 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
380 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
381 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
382 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
383 + template sequence e1000::setup_interrupt_handler()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
384 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
385 + chunk LKM::includes()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
386 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
387 + #include <linux/interrupt.h>
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
388 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
389 + chunk LKM::prototypes()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
390 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
391 + static int e1000_setup_interrupt_handler(struct rtx_ethernet_dev *);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
392 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
393 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
394 + chunk LKM::code()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
395 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
396 + static int e1000_setup_interrupt_handler(struct rtx_ethernet_dev *ethernet_ctx)
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
397 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
398 + int error;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
399 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
400 + error = request_irq(ethernet_ctx->hw_ctx.irq,
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
401 + rtx_ethernet_interrupt_handler,
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
402 + IRQF_SHARED,
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
403 + ${config.name},
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
404 + ethernet_ctx);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
405 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
406 + if (error)
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
407 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
408 + ${Log::info("Cannot register the interruption")};
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
409 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
410 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
411 + return error;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
412 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
413 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
414 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
415 + chunk ::CALL()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
416 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
417 + // this is an hack for the scope
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
418 + (void)1;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
419 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
420 + int error;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
421 + error = e1000_setup_interrupt_handler(rtx_ether_dev);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
422 + if (error)
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
423 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
424 + return error;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
425 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
426 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
427 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
428 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
429 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
430 + template sequence e1000::free_interrupt_handler()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
431 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
432 + chunk LKM::prototypes()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
433 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
434 + static void e1000_free_interrupt_handler(struct rtx_ethernet_dev *ethernet_ctx);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
435 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
436 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
437 + chunk LKM::code()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
438 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
439 + static void e1000_free_interrupt_handler(struct rtx_ethernet_dev *ethernet_ctx)
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
440 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
441 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
442 + free_irq(ethernet_ctx->hw_ctx.irq, ethernet_ctx);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
443 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
444 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
445 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
446 + chunk ::CALL()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
447 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
448 + e1000_free_interrupt_handler(rtx_ether_dev);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
449 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
450 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
451 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
452 + template sequence e1000::activate_device_interruption()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
453 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
454 + chunk ::CALL()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
455 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
456 + rtx_e1000_register_write32(ctx, E1000_IMS,
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
457 + E1000_INTR_TXDW |
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
458 + E1000_INTR_TXQE |
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
459 + E1000_INTR_LSC |
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
460 + E1000_INTR_RXO |
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
461 + E1000_INTR_RXT0);
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
462 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
463 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
464 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
465 + template sequence e1000::set_up_device()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
466 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
467 + chunk ::CALL()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
468 + {
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
469 + rtx_e1000_register_set32(ctx, E1000_CTRL,
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
470 + E1000_CMD_ASDE |
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
471 + E1000_CMD_SLU |
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
472 + E1000_CMD_LRST |
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
473 + E1000_CMD_PHY_RST);
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
474 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
475 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
476 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
477 + template sequence e1000::handle_intr()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
478 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
479 + chunk ::CALL()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
480 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
481 + int intr;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
482 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
483 + intr = rtx_e1000_register_read32(ctx, E1000_ICR);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
484 + if (intr & E1000_INTR_LSC)
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
485 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
486 + ${Log::info("Link status changed")};
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
487 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
488 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
489 + if (intr)
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
490 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
491 + return IRQ_HANDLED;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
492 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
493 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
494 + }
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
495 +}
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
496 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
497 new file mode 100644
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
498 --- /dev/null
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
499 +++ b/rathaxes/samples/e1000/e1000.rti
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
500 @@ -0,0 +1,89 @@
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
501 +interface e1000 : Socket, Ethernet, PCI, LKM
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
502 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
503 + provided type e1000::Context;
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
504 + provided type e1000::Register;
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
505 + provided type e1000::Commands;
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
506 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
507 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
508 + * This sequence should receive an argument like Ethernet::Device, but it is
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
509 + * unclear about how this argument should be bound to a variable/argument in
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
510 + * the instrumented C code.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
511 + *
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
512 + * Here again, we rely on the fact that *we* wrote the parent context and
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
513 + * named the C variables we need/use with the same name everywhere.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
514 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
515 + provided sequence e1000::create_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
516 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
517 + provided chunk Ethernet::create_device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
518 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
519 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
520 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
521 + provided sequence e1000::destroy_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
522 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
523 + provided chunk Ethernet::destroy_device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
524 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
525 + }
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
526 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
527 + /*
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
528 + * This should take an e1000::Context as the first argument but this was
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
529 + * not working as wished.
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
530 + */
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
531 + provided sequence e1000::print_status()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
532 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
533 + provided chunk LKM::prototypes;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
534 + provided chunk LKM::code;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
535 + provided chunk ::CALL;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
536 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
537 +
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
538 + provided sequence e1000::setup_interrupt_handler()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
539 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
540 + provided chunk LKM::includes; // work without this one
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
541 + provided chunk LKM::prototypes;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
542 + provided chunk LKM::code;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
543 + provided chunk ::CALL;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
544 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
545 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
546 + provided sequence e1000::free_interrupt_handler()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
547 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
548 + provided chunk LKM::prototypes;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
549 + provided chunk LKM::code;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
550 + provided chunk ::CALL;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
551 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
552 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
553 + provided sequence e1000::activate_device_interruption()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
554 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
555 + provided chunk ::CALL;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
556 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
557 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
558 + provided sequence e1000::set_up_device()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
559 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
560 + provided chunk ::CALL;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
561 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
562 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
563 + provided sequence e1000::handle_intr()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
564 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
565 + provided chunk ::CALL;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
566 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
567 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
568 +
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
569 + provided sequence e1000::register_read32(e1000::Context, e1000::Register)
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
570 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
571 + provided chunk LKM::prototypes;
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
572 + provided chunk LKM::code;
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
573 + provided chunk ::CALL;
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
574 + }
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
575 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
576 + provided sequence e1000::register_write32(e1000::Context, e1000::Register, ::number)
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
577 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
578 + provided chunk LKM::prototypes;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
579 + provided chunk LKM::code;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
580 + provided chunk ::CALL;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
581 + }
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
582 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
583 + provided sequence e1000::register_set32(e1000::Context, e1000::Register, ::number)
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
584 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
585 + provided chunk LKM::prototypes;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
586 + provided chunk LKM::code;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
587 + provided chunk ::CALL;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
588 + }
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
589 +}
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
590 diff --git a/rathaxes/samples/e1000/ethernet.blt b/rathaxes/samples/e1000/ethernet.blt
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
591 new file mode 100644
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
592 --- /dev/null
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
593 +++ b/rathaxes/samples/e1000/ethernet.blt
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
594 @@ -0,0 +1,218 @@
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
595 +with Ethernet, PCI, LKM, Log
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
596 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
597 + template type Ethernet::Device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
598 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
599 + chunk LKM::includes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
600 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
601 + #include <linux/netdevice.h>
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
602 + #include <linux/etherdevice.h>
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
603 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
604 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
605 + chunk ::decl()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
606 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
607 + struct rtx_ethernet_dev
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
608 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
609 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
610 + * I think it's useless to use the ${PCI::Device} "abstraction"
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
611 + * here, since we are already in a Linux specific context here.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
612 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
613 + struct pci_dev *pci_dev;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
614 + struct net_device *net_dev;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
615 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
616 + /* while waiting on issue #8 */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
617 + struct rtx_e1000_ctx hw_ctx;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
618 + };
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
619 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
620 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
621 + chunk ::init(net_dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
622 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
623 + ${self} = ${net_dev};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
624 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
625 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
626 + map
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
627 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
628 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
629 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
630 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
631 + template sequence Ethernet::open(Ethernet::Device dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
632 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
633 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
634 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
635 + static int rtx_ethernet_open(struct net_device *);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
636 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
637 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
638 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
639 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
640 + static int rtx_ethernet_open(struct net_device *dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
641 + {
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
642 + struct rtx_ethernet_dev* rtx_ether_dev = netdev_priv(dev);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
643 + struct rtx_e1000_ctx* ctx = &rtx_ether_dev->hw_ctx;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
644 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
645 + ${pointcut ::IMPLEMENTATION};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
646 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
647 + return 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
648 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
649 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
650 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
651 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
652 + template sequence Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
653 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
654 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
655 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
656 + static int rtx_ethernet_xmit(struct sk_buff* skb, struct net_device *dev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
657 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
658 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
659 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
660 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
661 + static int rtx_ethernet_xmit(struct sk_buff* skb, struct net_device *dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
662 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
663 + ${pointcut ::IMPLEMENTATION};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
664 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
665 + return 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
666 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
667 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
668 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
669 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
670 + template sequence Ethernet::close(Ethernet::Device dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
671 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
672 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
673 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
674 + static int rtx_ethernet_close(struct net_device *);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
675 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
676 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
677 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
678 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
679 + static int rtx_ethernet_close(struct net_device *dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
680 + {
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
681 + struct rtx_ethernet_dev* rtx_ether_dev = netdev_priv(dev);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
682 + struct rtx_e1000_ctx* ctx = &rtx_ether_dev->hw_ctx;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
683 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
684 + ${pointcut ::IMPLEMENTATION};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
685 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
686 + return 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
687 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
688 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
689 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
690 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
691 + template sequence Ethernet::interrupt_handler(Ethernet::Device dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
692 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
693 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
694 + * We can't use the irqreturn_t type here because CNornm doesn't know
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
695 + * it.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
696 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
697 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
698 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
699 + static enum irqreturn rtx_ethernet_interrupt_handler(int, void *);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
700 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
701 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
702 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
703 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
704 + static enum irqreturn rtx_ethernet_interrupt_handler(int irq, void *dev_id)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
705 + {
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
706 + struct rtx_ethernet_dev* rtx_ether_dev;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
707 + struct rtx_e1000_ctx* ctx;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
708 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
709 + rtx_ether_dev = dev_id;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
710 + ctx = &rtx_ether_dev->hw_ctx;
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
711 + ${pointcut ::IMPLEMENTATION};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
712 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
713 + return IRQ_NONE;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
714 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
715 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
716 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
717 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
718 + template sequence Ethernet::init(PCI::Device pdev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
719 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
720 + chunk LKM::data()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
721 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
722 + static const struct net_device_ops rtx_ether_ops =
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
723 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
724 + .ndo_open = rtx_ethernet_open,
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
725 + .ndo_stop = rtx_ethernet_close,
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
726 + .ndo_start_xmit = rtx_ethernet_xmit,
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
727 + };
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
728 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
729 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
730 + chunk PCI::pci_probe_hook()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
731 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
732 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
733 + * This typedef is needed to workaround a bug in CNorm __std__
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
734 + * dialect.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
735 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
736 + typedef int ${Ethernet::Device};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
737 + ${Ethernet::Device} *rtx_ether_ctx;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
738 + struct net_device *net_dev;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
739 + int error;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
740 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
741 + error = 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
742 + net_dev = alloc_etherdev(sizeof(*rtx_ether_ctx));
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
743 + if (net_dev == 0)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
744 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
745 + ${Log::info("Cannot allocate memory")};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
746 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
747 + * Again, the error should be "raised" in the parent context.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
748 + *
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
749 + * Here we know that we should return ENOMEM because *we* wrote
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
750 + * the parent context.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
751 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
752 + return -ENOMEM;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
753 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
754 + strlcpy(net_dev->name, ${config.ifname}, sizeof(net_dev->name));
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
755 + net_dev->irq = pdev->irq;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
756 + // Maybe we should try ${rtx_ether_ctx.init()} here:
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
757 + rtx_ether_ctx = netdev_priv(net_dev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
758 + //rtx_ether_ctx->pci_dev = ${pdev};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
759 + rtx_ether_ctx->pci_dev = pdev; // In the meantime do it directly
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
760 + rtx_ether_ctx->net_dev = net_dev;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
761 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
762 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
763 + * The substitution of ${pdev} fails here. I also tried to add a
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
764 + * "substitute method" to the PCI::Device that was just doing
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
765 + * "${self}" but it didn't work either (it was subsituted by a
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
766 + * placeholder, e.g: _1).
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
767 + *
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
768 + * That's why we cheated a bit and named all the arguments pdev.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
769 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
770 + //SET_NETDEV_DEV(net_dev, &${pdev}->dev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
771 + SET_NETDEV_DEV(net_dev, &pdev->dev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
772 + net_dev->netdev_ops = &rtx_ether_ops;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
773 + if ((error = register_netdev(net_dev)))
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
774 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
775 + ${Log::info("Cannot register the driver")};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
776 + return error;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
777 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
778 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
779 + /* same problem as above with ${pdev} */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
780 + //pci_set_drvdata(${pdev}, net_dev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
781 + pci_set_drvdata(pdev, net_dev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
782 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
783 + ${pointcut Ethernet::create_device};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
784 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
785 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
786 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
787 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
788 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
789 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
790 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
791 + template sequence Ethernet::exit(PCI::Device pdev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
792 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
793 + chunk PCI::pci_remove_hook()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
794 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
795 + struct net_device *net_dev = pci_get_drvdata(pdev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
796 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
797 + ${pointcut Ethernet::destroy_device};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
798 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
799 + unregister_netdev(net_dev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
800 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
801 + * If we had some cleanup todo with struct rtx_ether_ctx we would
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
802 + * do a netdev_priv(net_dev) here and do it.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
803 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
804 + free_netdev(net_dev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
805 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
806 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
807 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
808 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
809 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
810 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
811 +}
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
812 +
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
813 diff --git a/rathaxes/samples/e1000/ethernet.rti b/rathaxes/samples/e1000/ethernet.rti
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
814 new file mode 100644
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
815 --- /dev/null
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
816 +++ b/rathaxes/samples/e1000/ethernet.rti
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
817 @@ -0,0 +1,47 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
818 +interface Ethernet : Socket, PCI, LKM
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
819 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
820 + provided type Ethernet::Device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
821 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
822 + required variable ::string Ethernet::ifname;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
823 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
824 + required sequence Ethernet::open(Ethernet::Device)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
825 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
826 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
827 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
828 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
829 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
830 + required sequence Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
831 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
832 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
833 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
834 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
835 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
836 + required sequence Ethernet::close(Ethernet::Device)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
837 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
838 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
839 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
840 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
841 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
842 + required sequence Ethernet::interrupt_handler(Ethernet::Device)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
843 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
844 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
845 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
846 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
847 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
848 + provided sequence Ethernet::init(PCI::Device)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
849 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
850 + provided chunk LKM::data;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
851 + provided chunk PCI::pci_probe_hook;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
852 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
853 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
854 + provided pointcut Ethernet::create_device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
855 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
856 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
857 + provided sequence Ethernet::exit(PCI::Device)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
858 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
859 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
860 + provided chunk PCI::pci_remove_hook;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
861 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
862 + provided pointcut Ethernet::destroy_device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
863 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
864 +}
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
865 diff --git a/rathaxes/samples/e1000/lkm.blt b/rathaxes/samples/e1000/lkm.blt
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
866 new file mode 100644
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
867 --- /dev/null
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
868 +++ b/rathaxes/samples/e1000/lkm.blt
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
869 @@ -0,0 +1,55 @@
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
870 +with LKM
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
871 +{
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
872 + /* Skel of the generated C file: */
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
873 + ${pointcut LKM::includes};
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
874 + ${pointcut LKM::prototypes};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
875 + ${pointcut LKM::data};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
876 + ${pointcut LKM::code};
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
877 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
878 + template sequence LKM::init()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
879 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
880 + chunk LKM::includes()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
881 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
882 + #include <linux/module.h>
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
883 + #include <linux/kernel.h>
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
884 + }
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
885 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
886 + chunk LKM::data()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
887 + {
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
888 + MODULE_DESCRIPTION(${config.description});
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
889 + MODULE_AUTHOR(${config.author});
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
890 + MODULE_LICENSE(${config.license});
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
891 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
892 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
893 + chunk LKM::code()
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
894 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
895 + /*
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
896 + * Rathaxes doesn't yet support arbitrary "decorators" like __init
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
897 + * or __exit.
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
898 + */
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
899 + static int __attribute__((__section__(".init.text"))) rtx_module_init(void)
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
900 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
901 + ${pointcut ::IMPLEMENTATION};
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
902 + ${pointcut LKM::init_bus_hook};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
903 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
904 + return 0;
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
905 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
906 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
907 + module_init(rtx_module_init);
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
908 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
909 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
910 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
911 + template sequence LKM::exit()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
912 + {
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
913 + chunk LKM::code()
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
914 + {
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
915 + static void __attribute__((__section__(".exit.text"))) rtx_module_exit(void)
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
916 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
917 + ${pointcut ::IMPLEMENTATION};
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
918 + ${pointcut LKM::deinit_bus_hook};
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
919 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
920 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
921 + module_exit(rtx_module_exit);
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
922 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
923 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
924 +}
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
925 diff --git a/rathaxes/samples/e1000/lkm.rti b/rathaxes/samples/e1000/lkm.rti
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
926 new file mode 100644
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
927 --- /dev/null
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
928 +++ b/rathaxes/samples/e1000/lkm.rti
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
929 @@ -0,0 +1,25 @@
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
930 +interface LKM
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
931 +{
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
932 + provided pointcut LKM::includes;
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
933 + /* maybe it should be possible to use chunk ::decl in sequence templates? */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
934 + provided pointcut LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
935 + provided pointcut LKM::data;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
936 + provided pointcut LKM::code;
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
937 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
938 + required variable ::string LKM::author;
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
939 + required variable ::string LKM::description;
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
940 + required variable ::string LKM::license;
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
941 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
942 + required sequence LKM::init()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
943 + {
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
944 + provided chunk LKM::includes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
945 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
946 + provided pointcut LKM::init_bus_hook;
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
947 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
948 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
949 + required sequence LKM::exit()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
950 + {
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
951 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
952 + provided pointcut LKM::deinit_bus_hook;
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
953 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
954 +}
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
955 diff --git a/rathaxes/samples/e1000/lkm.rtx b/rathaxes/samples/e1000/lkm.rtx
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
956 new file mode 100644
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
957 --- /dev/null
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
958 +++ b/rathaxes/samples/e1000/lkm.rtx
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
959 @@ -0,0 +1,52 @@
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
960 +device LKM use LKM, PCI, Ethernet, Log
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
961 +{
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
962 + Ethernet::open(Ethernet::Device dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
963 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
964 + Log::info("Open the device");
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
965 + e1000::setup_interrupt_handler();
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
966 + Log::info("Interrupt handler installed");
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
967 + e1000::set_up_device();
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
968 + e1000::activate_device_interruption();
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
969 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
970 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
971 + Ethernet::close(Ethernet::Device dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
972 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
973 + Log::info("Close the device");
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
974 + e1000::free_interrupt_handler();
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
975 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
976 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
977 + Ethernet::interrupt_handler(Ethernet::Device dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
978 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
979 + Log::info("Got an interruption");
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
980 + e1000::handle_intr();
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
981 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
982 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
983 + Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
984 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
985 + Log::info("We have one packet to transmit!");
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
986 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
987 +
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
988 + LKM::init()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
989 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
990 + Log::info("Hello this is LKM");
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
991 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
992 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
993 + LKM::exit()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
994 + {
10
44a25ffd5c8c Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents: 3
diff changeset
995 + Log::info("Good bye this was LKM");
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
996 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
997 +}
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
998 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
999 +configuration
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1000 +{
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1001 + LKM::name = "hello";
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1002 + LKM::author = "Rathaxes";
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1003 + LKM::description = "Hello World Loadable Kernel Module (LKM)";
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1004 + LKM::license = "GPL";
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1005 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1006 + PCI::vendor_id = 0x8086;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1007 + PCI::product_id = 0x100f;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1008 + PCI::set_master = true;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1009 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1010 + Ethernet::ifname = "rtx%d";
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1011 +}
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1012 diff --git a/rathaxes/samples/e1000/log.blt b/rathaxes/samples/e1000/log.blt
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1013 new file mode 100644
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1014 --- /dev/null
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1015 +++ b/rathaxes/samples/e1000/log.blt
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1016 @@ -0,0 +1,10 @@
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1017 +with Log
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1018 +{
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1019 + template sequence Log::info(::string msg)
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1020 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1021 + chunk ::CALL
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1022 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1023 + pr_info("%s\n", ${msg});
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1024 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1025 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1026 +}
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1027 diff --git a/rathaxes/samples/e1000/log.rti b/rathaxes/samples/e1000/log.rti
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1028 new file mode 100644
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1029 --- /dev/null
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1030 +++ b/rathaxes/samples/e1000/log.rti
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1031 @@ -0,0 +1,7 @@
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1032 +interface Log
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1033 +{
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1034 + provided sequence Log::info(::string)
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1035 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1036 + provided chunk ::CALL;
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1037 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1038 +}
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1039 diff --git a/rathaxes/samples/e1000/pci.blt b/rathaxes/samples/e1000/pci.blt
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1040 new file mode 100644
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1041 --- /dev/null
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1042 +++ b/rathaxes/samples/e1000/pci.blt
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1043 @@ -0,0 +1,143 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1044 +with PCI, LKM, Log
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1045 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1046 + template type PCI::Device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1047 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1048 + chunk LKM::includes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1049 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1050 + #include <linux/pci.h>
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1051 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1052 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1053 + chunk ::decl()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1054 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1055 + struct pci_dev;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1056 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1057 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1058 + chunk ::init(pci_dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1059 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1060 + ${self} = ${pci_dev};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1061 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1062 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1063 + map
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1064 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1065 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1066 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1067 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1068 + template sequence PCI::probe(PCI::Device pdev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1069 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1070 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1071 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1072 + static int /* __devinit */ rtx_pci_probe(struct pci_dev *,
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1073 + const struct pci_device_id *);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1074 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1075 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1076 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1077 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1078 + static int /* __devinit */ rtx_pci_probe(struct pci_dev *pdev,
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1079 + const struct pci_device_id *pdev_id)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1080 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1081 + int err;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1082 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1083 + err = pci_enable_device(pdev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1084 + if (err < 0)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1085 + goto fail;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1086 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1087 + ${pointcut PCI::pci_probe_hook};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1088 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1089 + return 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1090 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1091 + fail:
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1092 + return err;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1093 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1094 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1095 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1096 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1097 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1098 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1099 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1100 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1101 + template sequence PCI::remove(PCI::Device pdev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1102 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1103 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1104 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1105 + static void rtx_pci_remove(struct pci_dev *);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1106 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1107 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1108 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1109 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1110 + static void rtx_pci_remove(struct pci_dev *pdev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1111 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1112 + ${pointcut PCI::pci_remove_hook};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1113 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1114 + pci_disable_device(pdev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1115 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1116 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1117 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1118 + chunk ::CALL()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1119 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1120 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1121 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1122 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1123 + template sequence PCI::register()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1124 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1125 + chunk LKM::data()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1126 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1127 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1128 + * CNorm doesn't seem to like "dynamic" arrays (i.e: you always
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1129 + * have to specify the exact size).
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1130 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1131 + static struct pci_device_id rtx_pci_device_table[2] = {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1132 + { ${config.vendor_id}, ${config.product_id}, PCI_ANY_ID, PCI_ANY_ID },
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1133 + { 0, }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1134 + };
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1135 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1136 + static struct pci_driver rtx_pci_driver = {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1137 + .name = ${config.name},
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1138 + .id_table = rtx_pci_device_table,
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1139 + .probe = rtx_pci_probe,
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1140 + .remove = rtx_pci_remove
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1141 + };
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1142 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1143 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1144 + chunk LKM::init_bus_hook()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1145 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1146 + int error;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1147 + if ((error = pci_register_driver(&rtx_pci_driver)))
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1148 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1149 + ${Log::info("Cannot register pci driver")};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1150 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1151 + * So we catched the error but how do we return it to the
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1152 + * parent context?
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1153 + *
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1154 + * Here we know that we can just return error, but that's just
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1155 + * a coincidence (and, in this case, *we* wrote the parent
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1156 + * context).
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1157 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1158 + return error;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1159 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1160 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1161 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1162 + chunk ::CALL()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1163 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1164 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1165 + * The implementation of ::CALL is empty. This template sequence is
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1166 + * actually not provided nor required.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1167 + *
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1168 + * This sequence is just "intermediate" code that will just inject
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1169 + * itself in the hook LKM::init_bus_hook for which this sequence
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1170 + * has a chunk (see above chunk).
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1171 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1172 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1173 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1174 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1175 + template sequence PCI::unregister()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1176 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1177 + chunk LKM::deinit_bus_hook()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1178 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1179 + pci_unregister_driver(&rtx_pci_driver);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1180 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1181 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1182 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1183 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1184 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1185 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1186 +}
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1187 diff --git a/rathaxes/samples/e1000/pci.rti b/rathaxes/samples/e1000/pci.rti
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1188 new file mode 100644
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1189 --- /dev/null
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1190 +++ b/rathaxes/samples/e1000/pci.rti
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1191 @@ -0,0 +1,36 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1192 +interface PCI : LKM
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1193 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1194 + provided type PCI::Device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1195 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1196 + required variable ::number PCI::vendor_id;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1197 + required variable ::number PCI::product_id;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1198 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1199 + provided sequence PCI::register()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1200 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1201 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1202 + provided chunk LKM::data;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1203 + provided chunk LKM::init_bus_hook;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1204 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1205 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1206 + provided sequence PCI::unregister()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1207 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1208 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1209 + provided chunk LKM::deinit_bus_hook;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1210 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1211 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1212 + provided sequence PCI::probe(PCI::Device)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1213 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1214 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1215 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1216 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1217 + provided pointcut PCI::pci_probe_hook;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1218 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1219 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1220 + provided sequence PCI::remove(PCI::Device)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1221 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1222 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1223 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1224 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1225 + provided pointcut PCI::pci_remove_hook;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1226 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1227 +}
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1228 diff --git a/rathaxes/samples/e1000/socket.blt b/rathaxes/samples/e1000/socket.blt
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1229 new file mode 100644
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1230 --- /dev/null
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1231 +++ b/rathaxes/samples/e1000/socket.blt
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1232 @@ -0,0 +1,27 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1233 +with Socket, LKM
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1234 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1235 + template type Socket::SKBuff()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1236 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1237 + chunk LKM::includes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1238 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1239 + #include <linux/skbuff.h>
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1240 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1241 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1242 + chunk ::decl()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1243 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1244 + struct sk_buff;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1245 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1246 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1247 + chunk ::init()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1248 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1249 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1250 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1251 + map
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1252 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1253 + // some work may have to be done here in order
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1254 + // to access to some field of the sk_buff.
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1255 + // We should determine if all the sk_buff management
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1256 + // can be abstracted from the user.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1257 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1258 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1259 +}
47
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1260 diff --git a/rathaxes/samples/e1000/socket.rti b/rathaxes/samples/e1000/socket.rti
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1261 new file mode 100644
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1262 --- /dev/null
cf7d541b9331 Re-order patches + quick fixes
Louis Opter <louis@lse.epitech.net>
parents: 45
diff changeset
1263 +++ b/rathaxes/samples/e1000/socket.rti
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1264 @@ -0,0 +1,4 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1265 +interface Socket : LKM
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1266 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1267 + provided type Socket::SKBuff;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1268 +}