annotate rathaxes_add_lkm_ethernet_sample.patch @ 39:d761c8c625d3

Try to read a register on the card
author Louis Opter <louis@lse.epitech.net>
date Sun, 08 Jan 2012 14:47:03 +0100
parents f43900ad7e66
children 0ff39df29c46
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
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
5 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
6 --- a/rathaxes/samples/CMakeLists.txt
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
7 +++ 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
8 @@ -1,2 +1,3 @@
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
9 ADD_SUBDIRECTORY(helloworld)
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
10 +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
11 ADD_SUBDIRECTORY(syntax)
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
12 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
13 new file mode 100644
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
14 --- /dev/null
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
15 +++ 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
16 @@ -0,0 +1,7 @@
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
17 +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
18 + 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
19 + 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
20 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
21 +# 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
22 +# 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
23 +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
24 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
25 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
26 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
27 +++ b/rathaxes/samples/lkm/e1000.blt
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
28 @@ -0,0 +1,170 @@
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
29 +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
30 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
31 + template type e1000::Context()
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 + chunk LKM::includes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
34 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
35 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
36 + * 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
37 + * 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
38 + * (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
39 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
40 + 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
41 + 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
42 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
43 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
44 + chunk ::decl()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
45 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
46 + struct rtx_e1000_ctx
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 + int bars;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
49 + unsigned char /* __iomem */ *ioaddr;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
50 + };
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 +
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
53 + chunk ::init(bars, ioaddr)
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
54 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
55 + ${self}.bars = ${bars};
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
56 + ${self}.ioaddr = ${ioaddr};
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
57 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
58 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
59 + map
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
60 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
61 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
62 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
63 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
64 + template type e1000::Register()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
65 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
66 + chunk LKM::includes()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
67 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
68 + typedef int ${e1000::Register};
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
69 + 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
70 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
71 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
72 + chunk ::decl()
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 + enum rtx_e1000_registers
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 + E1000_CTRL = 0x00000,
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
77 + E1000_CTRL_DUP = 0x00004,
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
78 + E1000_STATUS = 0x00008,
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
79 + E1000_EEPROM_FLASH = 0x00010,
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
80 + E1000_EEPROM_READ = 0x00014,
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
81 + E1000_CTRL_EXT = 0x00018,
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
82 + E1000_FLA = 0x0001C,
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
83 + E1000_MDIC = 0x00020,
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
84 + };
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 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
87 + chunk ::init(value)
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
88 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
89 + ${self} = ${value};
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
90 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
91 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
92 + map
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
93 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
94 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
95 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
96 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
97 + template sequence e1000::create_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
98 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
99 + chunk Ethernet::create_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
100 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
101 + 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
102 + 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
103 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
104 + ${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
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 + 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
108 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
109 + ${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
110 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
111 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
112 + if (${config.set_master})
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
113 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
114 + pci_set_master(pdev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
115 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
116 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
117 + /* 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
118 + 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
119 + 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
120 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
121 + ${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
122 + }
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
123 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
124 + /* Now we can reset the card and load its mac address */
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
125 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
126 + /*
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
127 + * We should have been able to do something along those lines, but
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
128 + * it didn't work so we made the call manually.
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
129 + *
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
130 + * Ideally:
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
131 + * ${e1000::register_read32(rtx_ether_ctx->hw_ctx, E1000_STATUS)};
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
132 + *
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
133 + * Ideally2, not sure about the syntax on the register parameter:
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
134 + * ${e1000::register_read32(rtx_ether_ctx->hw_ctx, ${e1000::Register.E1000_STATUS})};
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
135 + *
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
136 + * "Acceptable":
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
137 + * typedef int ${e1000::Register}; // cnorm __std__ workaround
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
138 + * ${e1000::Register} reg_status;
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
139 + * ${e1000.init(E1000_STATUS); // didn't work, so we used the next line
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
140 + * reg_status = E1000_STATUS;
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
141 + * ${e1000::register_read32(rtx_ether_ctx->hw_ctx, reg_status)};
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
142 + *
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
143 + */
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
144 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
145 + unsigned int status = rtx_e1000_register_read32(&rtx_ether_ctx->hw_ctx, E1000_STATUS);
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
146 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
147 + pr_info("Status of the e1000 card:\n");
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
148 + pr_info("\tStatus: %i\n", status);
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
149 + pr_info("\tMode: %s\n", (status & 1) ? "Full": "Half");
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
150 + pr_info("\tLink: %s\n", (status & 2) ? "UP" : "Down");
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
151 + pr_info("\tTransmission: %s\n", (status & 4) ? "Paused" : "Ok");
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
152 + pr_info("\tInterface: %s\n", (status & 3) == 3 ? "UP" : "Down");
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
153 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
154 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
155 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
156 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
157 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
158 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
159 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
160 + template sequence e1000::destroy_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
161 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
162 + chunk Ethernet::destroy_device
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
163 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
164 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
165 + * 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
166 + * 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
167 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
168 + 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
169 + 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
170 + 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
171 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
172 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
173 + chunk ::CALL
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 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
176 + }
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
177 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
178 + 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
179 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
180 + chunk LKM::prototypes()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
181 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
182 + 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
183 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
184 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
185 + chunk LKM::code()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
186 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
187 + 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
188 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
189 + 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
190 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
191 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
192 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
193 + chunk ::CALL()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
194 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
195 + 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
196 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
197 + }
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
198 +}
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
199 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
200 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
201 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
202 +++ b/rathaxes/samples/lkm/e1000.rti
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
203 @@ -0,0 +1,39 @@
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
204 +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
205 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
206 + provided type e1000::Context;
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
207 + provided type e1000::Register;
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
208 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
209 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
210 + * 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
211 + * 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
212 + * the instrumented C code.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
213 + *
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
214 + * 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
215 + * 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
216 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
217 + provided sequence e1000::create_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
218 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
219 + provided chunk Ethernet::create_device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
220 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
221 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
222 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
223 + provided sequence e1000::destroy_device()
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 + provided chunk Ethernet::destroy_device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
226 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
227 + }
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
228 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
229 + /*
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
230 + * It should also take an e1000::Context argument as the first parameter.
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
231 + * But we weren't able to call the sequence afterwards, with expression
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
232 + * like:
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
233 + *
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
234 + * ${e1000::register_read32(rtx_ether_ctx->hw_ctx, E1000_STATUS)};
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
235 + */
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
236 + 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
237 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
238 + provided chunk LKM::prototypes;
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
239 + provided chunk LKM::code;
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
240 + provided chunk ::CALL;
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
241 + }
38
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 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
244 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
245 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
246 +++ 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
247 @@ -0,0 +1,207 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
248 +with Ethernet, PCI, LKM, Log
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
249 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
250 + template type Ethernet::Device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
251 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
252 + chunk LKM::includes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
253 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
254 + #include <linux/netdevice.h>
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
255 + #include <linux/etherdevice.h>
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
256 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
257 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
258 + chunk ::decl()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
259 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
260 + struct rtx_ethernet_dev
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
261 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
262 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
263 + * 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
264 + * 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
265 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
266 + struct pci_dev *pci_dev;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
267 + struct net_device *net_dev;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
268 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
269 + /* while waiting on issue #8 */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
270 + 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
271 + };
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
272 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
273 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
274 + chunk ::init(net_dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
275 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
276 + ${self} = ${net_dev};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
277 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
278 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
279 + map
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
280 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
281 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
282 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
283 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
284 + 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
285 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
286 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
287 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
288 + 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
289 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
290 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
291 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
292 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
293 + 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
294 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
295 + ${pointcut ::IMPLEMENTATION};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
296 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
297 + return 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
298 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
299 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
300 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
301 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
302 + 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
303 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
304 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
305 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
306 + 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
307 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
308 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
309 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
310 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
311 + 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
312 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
313 + ${pointcut ::IMPLEMENTATION};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
314 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
315 + return 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
316 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
317 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
318 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
319 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
320 + 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
321 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
322 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
323 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
324 + 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
325 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
326 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
327 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
328 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
329 + 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
330 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
331 + ${pointcut ::IMPLEMENTATION};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
332 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
333 + return 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
334 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
335 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
336 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
337 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
338 + 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
339 + {
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 + * 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
342 + * it.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
343 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
344 + chunk LKM::prototypes()
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 + 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
347 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
348 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
349 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
350 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
351 + 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
352 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
353 + ${pointcut ::IMPLEMENTATION};
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 + return IRQ_NONE;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
356 + }
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
360 + 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
361 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
362 + chunk LKM::data()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
363 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
364 + 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
365 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
366 + .ndo_open = rtx_ethernet_open,
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
367 + .ndo_stop = rtx_ethernet_close,
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
368 + .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
369 + };
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
370 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
371 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
372 + chunk PCI::pci_probe_hook()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
373 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
374 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
375 + * 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
376 + * dialect.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
377 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
378 + typedef int ${Ethernet::Device};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
379 + ${Ethernet::Device} *rtx_ether_ctx;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
380 + struct net_device *net_dev;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
381 + int error;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
382 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
383 + error = 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
384 + 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
385 + if (net_dev == 0)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
386 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
387 + ${Log::info("Cannot allocate memory")};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
388 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
389 + * 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
390 + *
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
391 + * 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
392 + * the parent context.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
393 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
394 + return -ENOMEM;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
395 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
396 + 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
397 + net_dev->irq = pdev->irq;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
398 + // 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
399 + 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
400 + //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
401 + 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
402 + 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
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 + * 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
406 + * "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
407 + * "${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
408 + * placeholder, e.g: _1).
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 + * 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
411 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
412 + //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
413 + 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
414 + 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
415 + 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
416 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
417 + ${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
418 + return error;
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 + /* 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
422 + //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
423 + 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
424 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
425 + ${pointcut Ethernet::create_device};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
426 + }
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 + chunk ::CALL
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 + }
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 + 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
434 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
435 + chunk PCI::pci_remove_hook()
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 + 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
438 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
439 + ${pointcut Ethernet::destroy_device};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
440 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
441 + unregister_netdev(net_dev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
442 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
443 + * 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
444 + * 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
445 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
446 + free_netdev(net_dev);
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 + chunk ::CALL
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 + }
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 +}
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 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
456 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
457 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
458 +++ 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
459 @@ -0,0 +1,47 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
460 +interface Ethernet : Socket, PCI, LKM
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 + provided type Ethernet::Device;
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 + required variable ::string Ethernet::ifname;
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 + 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
467 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
468 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
469 + provided chunk LKM::code;
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
472 + 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
473 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
474 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
475 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
476 + }
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 + 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
479 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
480 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
481 + provided chunk LKM::code;
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 + 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
485 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
486 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
487 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
488 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
489 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
490 + 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
491 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
492 + provided chunk LKM::data;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
493 + 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
494 + provided chunk ::CALL;
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 + provided pointcut Ethernet::create_device;
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
499 + 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
500 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
501 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
502 + 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
503 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
504 + provided pointcut Ethernet::destroy_device;
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 +}
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
507 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
508 new file mode 100644
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
509 --- /dev/null
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
510 +++ 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
511 @@ -0,0 +1,55 @@
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
512 +with LKM
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
513 +{
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
514 + /* 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
515 + ${pointcut LKM::includes};
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
516 + ${pointcut LKM::prototypes};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
517 + ${pointcut LKM::data};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
518 + ${pointcut LKM::code};
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
519 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
520 + template sequence LKM::init()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
521 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
522 + chunk LKM::includes()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
523 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
524 + #include <linux/module.h>
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
525 + #include <linux/kernel.h>
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
526 + }
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
527 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
528 + chunk LKM::data()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
529 + {
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
530 + MODULE_DESCRIPTION(${config.description});
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
531 + MODULE_AUTHOR(${config.author});
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
532 + MODULE_LICENSE(${config.license});
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
533 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
534 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
535 + chunk LKM::code()
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
536 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
537 + /*
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
538 + * 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
539 + * or __exit.
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
540 + */
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
541 + 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
542 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
543 + ${pointcut ::IMPLEMENTATION};
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
544 + ${pointcut LKM::init_bus_hook};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
545 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
546 + return 0;
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
547 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
548 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
549 + module_init(rtx_module_init);
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
550 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
551 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
552 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
553 + template sequence LKM::exit()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
554 + {
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
555 + chunk LKM::code()
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
556 + {
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
557 + 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
558 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
559 + ${pointcut ::IMPLEMENTATION};
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
560 + ${pointcut LKM::deinit_bus_hook};
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
561 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
562 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
563 + module_exit(rtx_module_exit);
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
564 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
565 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
566 +}
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
567 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
568 new file mode 100644
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
569 --- /dev/null
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
570 +++ 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
571 @@ -0,0 +1,25 @@
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
572 +interface LKM
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
573 +{
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
574 + provided pointcut LKM::includes;
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
575 + /* 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
576 + provided pointcut LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
577 + provided pointcut LKM::data;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
578 + provided pointcut LKM::code;
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
579 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
580 + required variable ::string LKM::author;
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
581 + required variable ::string LKM::description;
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
582 + required variable ::string LKM::license;
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
583 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
584 + required sequence LKM::init()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
585 + {
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
586 + provided chunk LKM::includes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
587 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
588 + 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
589 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
590 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
591 + required sequence LKM::exit()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
592 + {
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
593 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
594 + 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
595 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
596 +}
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
597 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
598 new file mode 100644
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
599 --- /dev/null
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
600 +++ 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
601 @@ -0,0 +1,46 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
602 +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
603 +{
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
604 + Ethernet::open(Ethernet::Device dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
605 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
606 + Log::info("Open the device");
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
607 + }
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 + Ethernet::close(Ethernet::Device dev)
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 + Log::info("Close the device");
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
614 + 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
615 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
616 + Log::info("Got an interruption");
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 + 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 + 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
622 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
623 +
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
624 + LKM::init()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
625 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
626 + Log::info("Hello this is LKM");
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
627 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
628 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
629 + LKM::exit()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
630 + {
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
631 + 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
632 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
633 +}
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
634 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
635 +configuration
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
636 +{
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
637 + LKM::name = "hello";
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
638 + LKM::author = "Rathaxes";
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
639 + 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
640 + LKM::license = "GPL";
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
641 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
642 + PCI::vendor_id = 0x8086;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
643 + PCI::product_id = 0x100f;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
644 + PCI::set_master = true;
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 + Ethernet::ifname = "rtx%d";
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
647 +}
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
648 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
649 new file mode 100644
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
650 --- /dev/null
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
651 +++ b/rathaxes/samples/lkm/log.blt
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
652 @@ -0,0 +1,10 @@
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
653 +with Log
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
654 +{
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
655 + template sequence Log::info(::string msg)
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
656 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
657 + chunk ::CALL
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
658 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
659 + pr_info("%s\n", ${msg});
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
660 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
661 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
662 +}
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
663 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
664 new file mode 100644
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
665 --- /dev/null
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
666 +++ b/rathaxes/samples/lkm/log.rti
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
667 @@ -0,0 +1,7 @@
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
668 +interface Log
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
669 +{
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
670 + provided sequence Log::info(::string)
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
671 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
672 + provided chunk ::CALL;
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
673 + }
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 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
676 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
677 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
678 +++ 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
679 @@ -0,0 +1,143 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
680 +with PCI, LKM, Log
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
681 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
682 + template type PCI::Device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
683 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
684 + chunk LKM::includes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
685 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
686 + #include <linux/pci.h>
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
687 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
688 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
689 + chunk ::decl()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
690 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
691 + struct pci_dev;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
692 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
693 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
694 + chunk ::init(pci_dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
695 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
696 + ${self} = ${pci_dev};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
697 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
698 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
699 + map
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
700 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
701 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
702 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
703 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
704 + 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
705 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
706 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
707 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
708 + 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
709 + const struct pci_device_id *);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
710 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
711 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
712 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
713 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
714 + 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
715 + 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
716 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
717 + int err;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
718 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
719 + err = pci_enable_device(pdev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
720 + if (err < 0)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
721 + goto fail;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
722 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
723 + ${pointcut PCI::pci_probe_hook};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
724 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
725 + return 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
726 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
727 + fail:
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
728 + return err;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
729 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
730 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
731 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
732 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
733 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
734 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
735 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
736 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
737 + 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
738 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
739 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
740 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
741 + 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
742 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
743 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
744 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
745 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
746 + 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
747 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
748 + ${pointcut PCI::pci_remove_hook};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
749 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
750 + pci_disable_device(pdev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
751 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
752 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
753 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
754 + chunk ::CALL()
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 + }
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
759 + template sequence PCI::register()
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 + chunk LKM::data()
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 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
764 + * 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
765 + * 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
766 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
767 + 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
768 + { ${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
769 + { 0, }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
770 + };
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
771 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
772 + 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
773 + .name = ${config.name},
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
774 + .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
775 + .probe = rtx_pci_probe,
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
776 + .remove = rtx_pci_remove
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
777 + };
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
778 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
779 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
780 + chunk LKM::init_bus_hook()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
781 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
782 + int error;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
783 + 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
784 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
785 + ${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
786 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
787 + * 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
788 + * parent context?
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
789 + *
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
790 + * 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
791 + * 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
792 + * context).
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
793 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
794 + return error;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
795 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
796 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
797 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
798 + chunk ::CALL()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
799 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
800 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
801 + * 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
802 + * actually not provided nor required.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
803 + *
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
804 + * 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
805 + * 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
806 + * 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
807 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
808 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
809 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
810 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
811 + template sequence PCI::unregister()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
812 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
813 + chunk LKM::deinit_bus_hook()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
814 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
815 + 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
816 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
817 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
818 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
819 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
820 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
821 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
822 +}
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
823 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
824 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
825 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
826 +++ 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
827 @@ -0,0 +1,36 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
828 +interface PCI : LKM
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
829 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
830 + provided type PCI::Device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
831 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
832 + 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
833 + 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
834 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
835 + provided sequence PCI::register()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
836 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
837 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
838 + provided chunk LKM::data;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
839 + 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
840 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
841 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
842 + provided sequence PCI::unregister()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
843 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
844 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
845 + 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
846 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
847 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
848 + provided sequence PCI::probe(PCI::Device)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
849 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
850 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
851 + provided chunk LKM::code;
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 + 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
854 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
855 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
856 + 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
857 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
858 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
859 + provided 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 + 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
862 + }
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 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
865 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
866 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
867 +++ 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
868 @@ -0,0 +1,27 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
869 +with Socket, LKM
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
870 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
871 + template type Socket::SKBuff()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
872 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
873 + chunk LKM::includes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
874 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
875 + #include <linux/skbuff.h>
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 + chunk ::decl()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
879 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
880 + struct sk_buff;
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 + chunk ::init()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
884 + {
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
887 + map
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
888 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
889 + // 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
890 + // 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
891 + // 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
892 + // 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
893 + }
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 +}
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
896 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
897 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
898 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
899 +++ 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
900 @@ -0,0 +1,4 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
901 +interface Socket : LKM
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 + provided type Socket::SKBuff;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
904 +}