annotate rathaxes_add_lkm_ethernet_sample.patch @ 42:e0cd016d4fc5

Restore the reset code and print the mac address
author Louis Opter <louis@lse.epitech.net>
date Sun, 08 Jan 2012 16:54:10 +0100
parents 87704b867fb0
children 4b51f5628787
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
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
2 # Parent b995d8934956b83383c144303178f3eb383d0acf
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
3 rathaxes: add the PCI/Ethernet part of a Linux Intel e1000 network card driver
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
4
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
5 diff --git a/maintainers/CMakeScripts/UseRathaxes.cmake b/maintainers/CMakeScripts/UseRathaxes.cmake
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
6 --- a/maintainers/CMakeScripts/UseRathaxes.cmake
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
7 +++ b/maintainers/CMakeScripts/UseRathaxes.cmake
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
8 @@ -193,6 +193,8 @@
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
9
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
10 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
11 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
12 + # …
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
13 + 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
14 # 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
15 # 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
16 # copy our source side by side with the Makefile:
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
17 diff --git a/rathaxes/samples/CMakeLists.txt b/rathaxes/samples/CMakeLists.txt
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
18 --- a/rathaxes/samples/CMakeLists.txt
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
19 +++ 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
20 @@ -1,2 +1,3 @@
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
21 ADD_SUBDIRECTORY(helloworld)
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
22 +ADD_SUBDIRECTORY(lkm)
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
23 ADD_SUBDIRECTORY(syntax)
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
24 diff --git a/rathaxes/samples/lkm/CMakeLists.txt b/rathaxes/samples/lkm/CMakeLists.txt
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
25 new file mode 100644
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
26 --- /dev/null
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
27 +++ b/rathaxes/samples/lkm/CMakeLists.txt
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
28 @@ -0,0 +1,7 @@
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
29 +ADD_RATHAXES_SOURCES(lkm_src lkm.rtx
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
30 + 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
31 + 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
32 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
33 +# 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
34 +# source (with ADD_RATHAXES_SOURCES).
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
35 +ADD_RATHAXES_LKM(lkm lkm_src)
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
36 diff --git a/rathaxes/samples/lkm/e1000.blt b/rathaxes/samples/lkm/e1000.blt
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
37 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
38 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
39 +++ b/rathaxes/samples/lkm/e1000.blt
42
e0cd016d4fc5 Restore the reset code and print the mac address
Louis Opter <louis@lse.epitech.net>
parents: 41
diff changeset
40 @@ -0,0 +1,293 @@
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
41 +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
42 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
43 + template type e1000::Context()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
44 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
45 + chunk LKM::includes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
46 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
47 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
48 + * 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
49 + * 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
50 + * (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
51 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
52 + 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
53 + 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
54 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
55 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
56 + chunk ::decl()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
57 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
58 + struct rtx_e1000_ctx
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
59 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
60 + int bars;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
61 + unsigned char /* __iomem */ *ioaddr;
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 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
64 +
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
65 + chunk ::init(bars, ioaddr)
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
66 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
67 + ${self}.bars = ${bars};
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
68 + ${self}.ioaddr = ${ioaddr};
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
69 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
70 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
71 + map
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
72 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
73 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
74 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
75 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
76 + template type e1000::Register()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
77 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
78 + chunk LKM::includes()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
79 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
80 + typedef int ${e1000::Register};
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
81 + 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
82 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
83 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
84 + chunk ::decl()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
85 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
86 + enum rtx_e1000_registers
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
87 + {
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
88 + E1000_CTRL = 0x00000, /* Device Control - RW */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
89 + 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
90 + E1000_STATUS = 0x00008, /* Device Status - RO */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
91 + 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
92 + 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
93 + 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
94 + E1000_FLA = 0x0001C, /* Flash Access - RW */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
95 + E1000_MDIC = 0x00020 /* MDI Control - RW */
39
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 + }
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 ::init(value)
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 + ${self} = ${value};
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
102 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
103 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
104 + map
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
105 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
106 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
107 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
108 +
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
109 + template type e1000::Commands()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
110 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
111 + chunk LKM::includes()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
112 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
113 + typedef int ${e1000::Commands};
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
114 + 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
115 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
116 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
117 + chunk ::decl()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
118 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
119 + enum rtx_e1000_commands
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
120 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
121 + 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
122 + 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
123 + 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
124 + 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
125 + 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
126 + 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
127 + 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
128 + 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
129 + 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
130 + 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
131 + 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
132 + 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
133 + 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
134 + 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
135 + 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
136 + E1000_CMD_FRCSPD = 0x00000800, /* Force Speed */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
137 + E1000_CMD_FRCDPX = 0x00001000, /* Force Duplex */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
138 + 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
139 + 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
140 + 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
141 + 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
142 + 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
143 + 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
144 + 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
145 + 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
146 + 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
147 + 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
148 + 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
149 + 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
150 + E1000_CMD_RST = 0x04000000, /* Global reset */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
151 + 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
152 + 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
153 + 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
154 + 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
155 + E1000_CMD_PHY_RST = 0x80000000, /* PHY Reset */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
156 + E1000_CMD_SW2FW_INT = 0x02000000 /* Initiate an interrupt to manageability engine */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
157 + };
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
158 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
159 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
160 + map
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
161 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
162 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
163 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
164 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
165 + template sequence e1000::create_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
166 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
167 + chunk Ethernet::create_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
168 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
169 + 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
170 + 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
171 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
172 + ${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
173 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
174 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
175 + 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
176 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
177 + ${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
178 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
179 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
180 + if (${config.set_master})
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
181 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
182 + pci_set_master(pdev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
183 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
184 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
185 + /* 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
186 + 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
187 + 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
188 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
189 + ${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
190 + }
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
191 +
41
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
192 + /* Reset the card */
42
e0cd016d4fc5 Restore the reset code and print the mac address
Louis Opter <louis@lse.epitech.net>
parents: 41
diff changeset
193 + 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
194 + udelay(10);
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
195 +
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
196 + /* 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
197 + int i = 0;
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
198 + 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
199 + {
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
200 + 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
201 +
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
202 + int value;
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
203 + /* 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
204 + 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
205 + while ((value & (1 << 4)) == 0)
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
206 + 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
207 +
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
208 + 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
209 + 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
210 + }
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
211 +
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
212 + 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
213 + 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
214 + 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
215 +
e0cd016d4fc5 Restore the reset code and print the mac address
Louis Opter <louis@lse.epitech.net>
parents: 41
diff changeset
216 + pr_info("e1000::create: Mac Adress: %x:%x:%x:%x:%x:%x\n",
e0cd016d4fc5 Restore the reset code and print the mac address
Louis Opter <louis@lse.epitech.net>
parents: 41
diff changeset
217 + rtx_ether_ctx->net_dev->dev_addr[0],
e0cd016d4fc5 Restore the reset code and print the mac address
Louis Opter <louis@lse.epitech.net>
parents: 41
diff changeset
218 + rtx_ether_ctx->net_dev->dev_addr[1],
e0cd016d4fc5 Restore the reset code and print the mac address
Louis Opter <louis@lse.epitech.net>
parents: 41
diff changeset
219 + rtx_ether_ctx->net_dev->dev_addr[2],
e0cd016d4fc5 Restore the reset code and print the mac address
Louis Opter <louis@lse.epitech.net>
parents: 41
diff changeset
220 + rtx_ether_ctx->net_dev->dev_addr[3],
e0cd016d4fc5 Restore the reset code and print the mac address
Louis Opter <louis@lse.epitech.net>
parents: 41
diff changeset
221 + rtx_ether_ctx->net_dev->dev_addr[4],
e0cd016d4fc5 Restore the reset code and print the mac address
Louis Opter <louis@lse.epitech.net>
parents: 41
diff changeset
222 + rtx_ether_ctx->net_dev->dev_addr[5]);
e0cd016d4fc5 Restore the reset code and print the mac address
Louis Opter <louis@lse.epitech.net>
parents: 41
diff changeset
223 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
224 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
225 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
226 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
227 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
228 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
229 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
230 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
231 + template sequence e1000::destroy_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
232 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
233 + chunk Ethernet::destroy_device
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
234 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
235 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
236 + * 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
237 + * 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
238 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
239 + 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
240 + 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
241 + 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
242 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
243 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
244 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
245 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
246 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
247 + }
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
248 +
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
249 + template sequence e1000::print_status()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
250 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
251 + chunk LKM::prototypes()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
252 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
253 + 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
254 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
255 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
256 + chunk LKM::code()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
257 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
258 + 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
259 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
260 + 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
261 + pr_info("rtx_e1000 status: \n");
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
262 + 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
263 + 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
264 + 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
265 + 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
266 + 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
267 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
268 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
269 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
270 + chunk ::CALL
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
271 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
272 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
273 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
274 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
275 + /*
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
276 + * 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
277 + * 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
278 + *
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
279 + * Ideally:
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
280 + * ${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
281 + *
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
282 + * 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
283 + * ${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
284 + *
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
285 + * "Acceptable":
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
286 + * 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
287 + * ${e1000::Register} reg_status;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
288 + * ${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
289 + * reg_status = E1000_STATUS;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
290 + * ${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
291 + */
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
292 + 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
293 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
294 + chunk LKM::prototypes()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
295 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
296 + 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
297 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
298 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
299 + chunk LKM::code()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
300 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
301 + 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
302 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
303 + 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
304 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
305 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
306 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
307 + chunk ::CALL()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
308 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
309 + 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
310 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
311 + }
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
312 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
313 + 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
314 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
315 + chunk LKM::prototypes()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
316 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
317 + 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
318 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
319 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
320 + chunk LKM::code()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
321 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
322 + 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
323 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
324 + iowrite32(value, ctx->ioaddr + reg_offset);
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
325 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
326 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
327 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
328 + chunk ::CALL()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
329 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
330 + 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
331 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
332 + }
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
333 +}
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
334 diff --git a/rathaxes/samples/lkm/e1000.rti b/rathaxes/samples/lkm/e1000.rti
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
335 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
336 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
337 +++ b/rathaxes/samples/lkm/e1000.rti
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
338 @@ -0,0 +1,51 @@
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
339 +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
340 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
341 + provided type e1000::Context;
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
342 + provided type e1000::Register;
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
343 + provided type e1000::Commands;
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
344 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
345 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
346 + * 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
347 + * 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
348 + * the instrumented C code.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
349 + *
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
350 + * 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
351 + * 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
352 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
353 + provided sequence e1000::create_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
354 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
355 + provided chunk Ethernet::create_device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
356 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
357 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
358 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
359 + provided sequence e1000::destroy_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
360 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
361 + provided chunk Ethernet::destroy_device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
362 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
363 + }
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
364 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
365 + /*
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
366 + * 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
367 + * not working as wished.
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
368 + */
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
369 + provided sequence e1000::print_status()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
370 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
371 + provided chunk LKM::prototypes;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
372 + provided chunk LKM::code;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
373 + provided chunk ::CALL;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
374 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
375 +
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
376 + 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
377 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
378 + provided chunk LKM::prototypes;
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
379 + provided chunk LKM::code;
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
380 + provided chunk ::CALL;
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
381 + }
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
382 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
383 + 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
384 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
385 + provided chunk LKM::prototypes;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
386 + provided chunk LKM::code;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
387 + provided chunk ::CALL;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
388 + }
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
389 +}
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
390 diff --git a/rathaxes/samples/lkm/ethernet.blt b/rathaxes/samples/lkm/ethernet.blt
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
391 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
392 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
393 +++ b/rathaxes/samples/lkm/ethernet.blt
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
394 @@ -0,0 +1,207 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
395 +with Ethernet, PCI, LKM, Log
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
396 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
397 + template type Ethernet::Device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
398 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
399 + chunk LKM::includes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
400 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
401 + #include <linux/netdevice.h>
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
402 + #include <linux/etherdevice.h>
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
403 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
404 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
405 + chunk ::decl()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
406 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
407 + struct rtx_ethernet_dev
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
408 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
409 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
410 + * 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
411 + * 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
412 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
413 + struct pci_dev *pci_dev;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
414 + struct net_device *net_dev;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
415 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
416 + /* while waiting on issue #8 */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
417 + 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
418 + };
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
419 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
420 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
421 + chunk ::init(net_dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
422 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
423 + ${self} = ${net_dev};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
424 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
425 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
426 + map
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
427 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
428 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
429 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
430 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
431 + 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
432 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
433 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
434 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
435 + 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
436 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
437 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
438 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
439 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
440 + 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
441 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
442 + ${pointcut ::IMPLEMENTATION};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
443 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
444 + return 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
445 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
446 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
447 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
448 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
449 + 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
450 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
451 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
452 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
453 + 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
454 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
455 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
456 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
457 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
458 + 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
459 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
460 + ${pointcut ::IMPLEMENTATION};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
461 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
462 + return 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
463 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
464 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
465 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
466 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
467 + 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
468 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
469 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
470 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
471 + 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
472 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
473 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
474 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
475 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
476 + 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
477 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
478 + ${pointcut ::IMPLEMENTATION};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
479 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
480 + return 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
481 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
482 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
483 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
484 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
485 + 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
486 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
487 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
488 + * 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
489 + * it.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
490 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
491 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
492 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
493 + 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
494 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
495 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
496 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
497 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
498 + 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
499 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
500 + ${pointcut ::IMPLEMENTATION};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
501 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
502 + return IRQ_NONE;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
503 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
504 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
505 + }
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 + 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
508 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
509 + chunk LKM::data()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
510 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
511 + 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
512 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
513 + .ndo_open = rtx_ethernet_open,
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
514 + .ndo_stop = rtx_ethernet_close,
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
515 + .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
516 + };
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
517 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
518 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
519 + chunk PCI::pci_probe_hook()
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 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
522 + * 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
523 + * dialect.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
524 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
525 + typedef int ${Ethernet::Device};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
526 + ${Ethernet::Device} *rtx_ether_ctx;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
527 + struct net_device *net_dev;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
528 + int error;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
529 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
530 + error = 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
531 + 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
532 + if (net_dev == 0)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
533 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
534 + ${Log::info("Cannot allocate memory")};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
535 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
536 + * 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
537 + *
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
538 + * 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
539 + * the parent context.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
540 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
541 + return -ENOMEM;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
542 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
543 + 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
544 + net_dev->irq = pdev->irq;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
545 + // 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
546 + 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
547 + //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
548 + 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
549 + 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
550 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
551 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
552 + * 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
553 + * "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
554 + * "${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
555 + * placeholder, e.g: _1).
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
556 + *
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
557 + * 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
558 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
559 + //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
560 + 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
561 + 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
562 + 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
563 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
564 + ${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
565 + return error;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
566 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
567 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
568 + /* 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
569 + //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
570 + 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
571 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
572 + ${pointcut Ethernet::create_device};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
573 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
574 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
575 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
576 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
577 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
578 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
579 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
580 + 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
581 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
582 + chunk PCI::pci_remove_hook()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
583 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
584 + 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
585 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
586 + ${pointcut Ethernet::destroy_device};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
587 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
588 + unregister_netdev(net_dev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
589 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
590 + * 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
591 + * 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
592 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
593 + free_netdev(net_dev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
594 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
595 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
596 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
597 + {
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 + }
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
602 diff --git a/rathaxes/samples/lkm/ethernet.rti b/rathaxes/samples/lkm/ethernet.rti
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
603 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
604 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
605 +++ b/rathaxes/samples/lkm/ethernet.rti
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
606 @@ -0,0 +1,47 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
607 +interface Ethernet : Socket, PCI, LKM
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 + provided type Ethernet::Device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
610 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
611 + required variable ::string Ethernet::ifname;
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 + 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
614 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
615 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
616 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
617 + }
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 + 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
620 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
621 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
622 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
623 + }
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 + 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
626 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
627 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
628 + provided chunk LKM::code;
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 + 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
632 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
633 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
634 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
635 + }
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 + 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
638 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
639 + provided chunk LKM::data;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
640 + 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
641 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
642 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
643 + provided pointcut Ethernet::create_device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
644 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
645 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
646 + 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
647 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
648 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
649 + 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
650 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
651 + provided pointcut Ethernet::destroy_device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
652 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
653 +}
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
654 diff --git a/rathaxes/samples/lkm/lkm.blt b/rathaxes/samples/lkm/lkm.blt
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
655 new file mode 100644
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
656 --- /dev/null
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
657 +++ b/rathaxes/samples/lkm/lkm.blt
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
658 @@ -0,0 +1,55 @@
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
659 +with LKM
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
660 +{
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
661 + /* 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
662 + ${pointcut LKM::includes};
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
663 + ${pointcut LKM::prototypes};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
664 + ${pointcut LKM::data};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
665 + ${pointcut LKM::code};
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
666 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
667 + template sequence LKM::init()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
668 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
669 + chunk LKM::includes()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
670 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
671 + #include <linux/module.h>
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
672 + #include <linux/kernel.h>
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
673 + }
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
674 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
675 + chunk LKM::data()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
676 + {
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
677 + MODULE_DESCRIPTION(${config.description});
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
678 + MODULE_AUTHOR(${config.author});
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
679 + MODULE_LICENSE(${config.license});
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
680 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
681 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
682 + chunk LKM::code()
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
683 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
684 + /*
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
685 + * 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
686 + * or __exit.
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
687 + */
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
688 + 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
689 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
690 + ${pointcut ::IMPLEMENTATION};
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
691 + ${pointcut LKM::init_bus_hook};
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 + return 0;
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
694 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
695 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
696 + module_init(rtx_module_init);
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
697 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
698 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
699 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
700 + template sequence LKM::exit()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
701 + {
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
702 + chunk LKM::code()
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
703 + {
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
704 + 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
705 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
706 + ${pointcut ::IMPLEMENTATION};
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
707 + ${pointcut LKM::deinit_bus_hook};
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
708 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
709 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
710 + module_exit(rtx_module_exit);
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
711 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
712 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
713 +}
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
714 diff --git a/rathaxes/samples/lkm/lkm.rti b/rathaxes/samples/lkm/lkm.rti
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
715 new file mode 100644
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
716 --- /dev/null
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
717 +++ b/rathaxes/samples/lkm/lkm.rti
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
718 @@ -0,0 +1,25 @@
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
719 +interface LKM
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
720 +{
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
721 + provided pointcut LKM::includes;
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
722 + /* 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
723 + provided pointcut LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
724 + provided pointcut LKM::data;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
725 + provided pointcut LKM::code;
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
726 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
727 + required variable ::string LKM::author;
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
728 + required variable ::string LKM::description;
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
729 + required variable ::string LKM::license;
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
730 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
731 + required sequence LKM::init()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
732 + {
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
733 + provided chunk LKM::includes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
734 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
735 + 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
736 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
737 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
738 + required sequence LKM::exit()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
739 + {
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
740 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
741 + 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
742 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
743 +}
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
744 diff --git a/rathaxes/samples/lkm/lkm.rtx b/rathaxes/samples/lkm/lkm.rtx
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
745 new file mode 100644
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
746 --- /dev/null
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
747 +++ b/rathaxes/samples/lkm/lkm.rtx
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
748 @@ -0,0 +1,46 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
749 +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
750 +{
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
751 + Ethernet::open(Ethernet::Device dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
752 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
753 + Log::info("Open the device");
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
754 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
755 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
756 + Ethernet::close(Ethernet::Device dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
757 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
758 + Log::info("Close the device");
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
759 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
760 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
761 + 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
762 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
763 + Log::info("Got an interruption");
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
764 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
765 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
766 + 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
767 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
768 + 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
769 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
770 +
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
771 + LKM::init()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
772 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
773 + Log::info("Hello this is LKM");
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
774 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
775 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
776 + LKM::exit()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
777 + {
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
778 + 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
779 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
780 +}
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
781 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
782 +configuration
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
783 +{
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
784 + LKM::name = "hello";
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
785 + LKM::author = "Rathaxes";
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
786 + 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
787 + LKM::license = "GPL";
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 + PCI::vendor_id = 0x8086;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
790 + PCI::product_id = 0x100f;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
791 + PCI::set_master = true;
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 + Ethernet::ifname = "rtx%d";
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
794 +}
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
795 diff --git a/rathaxes/samples/lkm/log.blt b/rathaxes/samples/lkm/log.blt
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
796 new file mode 100644
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
797 --- /dev/null
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
798 +++ b/rathaxes/samples/lkm/log.blt
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
799 @@ -0,0 +1,10 @@
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
800 +with Log
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
801 +{
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
802 + template sequence Log::info(::string msg)
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
803 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
804 + chunk ::CALL
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
805 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
806 + pr_info("%s\n", ${msg});
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
807 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
808 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
809 +}
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
810 diff --git a/rathaxes/samples/lkm/log.rti b/rathaxes/samples/lkm/log.rti
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
811 new file mode 100644
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
812 --- /dev/null
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
813 +++ b/rathaxes/samples/lkm/log.rti
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
814 @@ -0,0 +1,7 @@
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
815 +interface Log
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
816 +{
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
817 + provided sequence Log::info(::string)
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
818 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
819 + provided chunk ::CALL;
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
820 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
821 +}
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
822 diff --git a/rathaxes/samples/lkm/pci.blt b/rathaxes/samples/lkm/pci.blt
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
823 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
824 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
825 +++ b/rathaxes/samples/lkm/pci.blt
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
826 @@ -0,0 +1,143 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
827 +with PCI, LKM, Log
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 + template type PCI::Device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
830 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
831 + chunk LKM::includes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
832 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
833 + #include <linux/pci.h>
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 + chunk ::decl()
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 + struct pci_dev;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
839 + }
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 + chunk ::init(pci_dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
842 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
843 + ${self} = ${pci_dev};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
844 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
845 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
846 + map
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 + }
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
851 + 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
852 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
853 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
854 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
855 + 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
856 + const struct pci_device_id *);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
857 + }
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 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
860 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
861 + 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
862 + 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
863 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
864 + int err;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
865 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
866 + err = pci_enable_device(pdev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
867 + if (err < 0)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
868 + goto fail;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
869 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
870 + ${pointcut PCI::pci_probe_hook};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
871 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
872 + return 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
873 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
874 + fail:
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
875 + return err;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
876 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
877 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
878 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
879 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
880 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
881 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
882 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
883 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
884 + 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
885 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
886 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
887 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
888 + 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
889 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
890 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
891 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
892 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
893 + 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
894 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
895 + ${pointcut PCI::pci_remove_hook};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
896 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
897 + pci_disable_device(pdev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
898 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
899 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
900 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
901 + chunk ::CALL()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
902 + {
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 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
905 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
906 + template sequence PCI::register()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
907 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
908 + chunk LKM::data()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
909 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
910 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
911 + * 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
912 + * 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
913 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
914 + 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
915 + { ${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
916 + { 0, }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
917 + };
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
918 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
919 + 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
920 + .name = ${config.name},
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
921 + .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
922 + .probe = rtx_pci_probe,
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
923 + .remove = rtx_pci_remove
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
924 + };
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
925 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
926 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
927 + chunk LKM::init_bus_hook()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
928 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
929 + int error;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
930 + 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
931 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
932 + ${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
933 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
934 + * 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
935 + * parent context?
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
936 + *
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
937 + * 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
938 + * 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
939 + * context).
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
940 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
941 + return error;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
942 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
943 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
944 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
945 + chunk ::CALL()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
946 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
947 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
948 + * 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
949 + * actually not provided nor required.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
950 + *
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
951 + * 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
952 + * 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
953 + * 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
954 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
955 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
956 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
957 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
958 + template sequence PCI::unregister()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
959 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
960 + chunk LKM::deinit_bus_hook()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
961 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
962 + 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
963 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
964 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
965 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
966 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
967 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
968 + }
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 diff --git a/rathaxes/samples/lkm/pci.rti b/rathaxes/samples/lkm/pci.rti
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
971 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
972 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
973 +++ b/rathaxes/samples/lkm/pci.rti
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
974 @@ -0,0 +1,36 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
975 +interface PCI : LKM
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 + provided type PCI::Device;
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 + 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
980 + 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
981 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
982 + provided sequence PCI::register()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
983 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
984 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
985 + provided chunk LKM::data;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
986 + 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
987 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
988 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
989 + provided sequence PCI::unregister()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
990 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
991 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
992 + 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
993 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
994 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
995 + 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
996 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
997 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
998 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
999 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1000 + 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
1001 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1002 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1003 + 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
1004 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1005 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1006 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1007 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1008 + 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
1009 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1010 +}
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1011 diff --git a/rathaxes/samples/lkm/socket.blt b/rathaxes/samples/lkm/socket.blt
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1012 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1013 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1014 +++ b/rathaxes/samples/lkm/socket.blt
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1015 @@ -0,0 +1,27 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1016 +with Socket, LKM
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1017 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1018 + template type Socket::SKBuff()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1019 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1020 + chunk LKM::includes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1021 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1022 + #include <linux/skbuff.h>
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1023 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1024 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1025 + chunk ::decl()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1026 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1027 + struct sk_buff;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1028 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1029 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1030 + chunk ::init()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1031 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1032 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1033 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1034 + map
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1035 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1036 + // 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
1037 + // to access to some field of the sk_buff.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1038 + // We should determine if all the sk_buff managment
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1039 + // 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
1040 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1041 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1042 +}
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1043 diff --git a/rathaxes/samples/lkm/socket.rti b/rathaxes/samples/lkm/socket.rti
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1044 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1045 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1046 +++ b/rathaxes/samples/lkm/socket.rti
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1047 @@ -0,0 +1,4 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1048 +interface Socket : LKM
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 + provided type Socket::SKBuff;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1051 +}