annotate rathaxes_add_lkm_ethernet_sample.patch @ 38:f43900ad7e66

Fold All The Patches on the LKM Sample
author Louis Opter <louis@lse.epitech.net>
date Sun, 08 Jan 2012 01:51:34 +0100
parents rathaxes_add_a_linux_lkm.patch@44a25ffd5c8c
children d761c8c625d3
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 @@
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
17 +ADD_RATHAXES_SOURCES(lkm 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).
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
23 +ADD_RATHAXES_LKM(lkm_hello lkm)
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
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
28 @@ -0,0 +1,80 @@
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 */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
41 + ${e1000::Context} force_declaration_in_includes;
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
53 + map
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
54 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
55 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
56 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
57 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
58 + template sequence e1000::create_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
59 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
60 + chunk Ethernet::create_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
61 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
62 + 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
63 + 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
64 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
65 + ${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
66 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
67 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
68 + 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
69 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
70 + ${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
71 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
72 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
73 + if (${config.set_master})
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
74 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
75 + pci_set_master(pdev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
76 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
77 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
78 + /* 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
79 + 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
80 + 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
81 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
82 + ${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
83 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
84 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
85 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
86 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
87 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
88 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
89 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
90 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
91 + template sequence e1000::destroy_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
92 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
93 + chunk Ethernet::destroy_device
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 + * 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
97 + * 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
98 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
99 + 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
100 + 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
101 + 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
102 + }
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 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
105 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
106 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
107 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
108 +}
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
109 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
110 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
111 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
112 +++ 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
113 @@ -0,0 +1,24 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
114 +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
115 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
116 + provided type e1000::Context;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
117 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
118 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
119 + * 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
120 + * 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
121 + * the instrumented C code.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
122 + *
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
123 + * 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
124 + * 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
125 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
126 + provided sequence e1000::create_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
127 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
128 + provided chunk Ethernet::create_device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
129 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
130 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
131 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
132 + provided sequence e1000::destroy_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
133 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
134 + provided chunk Ethernet::destroy_device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
135 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
136 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
137 +}
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
138 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
139 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
140 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
141 +++ 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
142 @@ -0,0 +1,207 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
143 +with Ethernet, PCI, LKM, Log
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
144 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
145 + template type Ethernet::Device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
146 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
147 + chunk LKM::includes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
148 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
149 + #include <linux/netdevice.h>
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
150 + #include <linux/etherdevice.h>
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
151 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
152 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
153 + chunk ::decl()
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 + struct rtx_ethernet_dev
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 + * 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
159 + * 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
160 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
161 + struct pci_dev *pci_dev;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
162 + struct net_device *net_dev;
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 + /* while waiting on issue #8 */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
165 + 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
166 + };
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
169 + chunk ::init(net_dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
170 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
171 + ${self} = ${net_dev};
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
174 + map
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 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
177 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
178 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
179 + 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
180 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
181 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
182 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
183 + 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
184 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
185 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
186 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
187 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
188 + 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
189 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
190 + ${pointcut ::IMPLEMENTATION};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
191 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
192 + return 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
193 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
194 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
195 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
196 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
197 + 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
198 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
199 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
200 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
201 + 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
202 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
203 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
204 + chunk LKM::code()
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 + 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
207 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
208 + ${pointcut ::IMPLEMENTATION};
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 + return 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
211 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
212 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
213 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
214 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
215 + 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
216 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
217 + chunk LKM::prototypes()
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 + 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
220 + }
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 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
223 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
224 + 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
225 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
226 + ${pointcut ::IMPLEMENTATION};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
227 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
228 + return 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
229 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
230 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
231 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
232 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
233 + 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
234 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
235 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
236 + * 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
237 + * it.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
238 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
239 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
240 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
241 + 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
242 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
243 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
244 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
245 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
246 + 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
247 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
248 + ${pointcut ::IMPLEMENTATION};
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 + return IRQ_NONE;
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 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
253 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
254 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
255 + 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
256 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
257 + chunk LKM::data()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
258 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
259 + 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
260 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
261 + .ndo_open = rtx_ethernet_open,
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
262 + .ndo_stop = rtx_ethernet_close,
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
263 + .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
264 + };
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
267 + chunk PCI::pci_probe_hook()
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 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
270 + * 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
271 + * dialect.
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 + typedef int ${Ethernet::Device};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
274 + ${Ethernet::Device} *rtx_ether_ctx;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
275 + struct net_device *net_dev;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
276 + int error;
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 + error = 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
279 + 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
280 + if (net_dev == 0)
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 + ${Log::info("Cannot allocate memory")};
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 + * 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
285 + *
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
286 + * 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
287 + * the parent context.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
288 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
289 + return -ENOMEM;
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 + 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
292 + net_dev->irq = pdev->irq;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
293 + // 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
294 + 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
295 + //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
296 + 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
297 + 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
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 + * 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
301 + * "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
302 + * "${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
303 + * placeholder, e.g: _1).
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
304 + *
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
305 + * 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
306 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
307 + //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
308 + 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
309 + 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
310 + 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
311 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
312 + ${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
313 + return error;
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
316 + /* 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
317 + //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
318 + 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
319 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
320 + ${pointcut Ethernet::create_device};
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
323 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
324 + {
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
328 + 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
329 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
330 + chunk PCI::pci_remove_hook()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
331 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
332 + 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
333 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
334 + ${pointcut Ethernet::destroy_device};
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 + unregister_netdev(net_dev);
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 + * 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
339 + * 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
340 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
341 + free_netdev(net_dev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
342 + }
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 ::CALL
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 + }
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
350 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
351 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
352 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
353 +++ 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
354 @@ -0,0 +1,47 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
355 +interface Ethernet : Socket, PCI, LKM
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 + provided type Ethernet::Device;
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 + required variable ::string Ethernet::ifname;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
360 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
361 + 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
362 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
363 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
364 + provided chunk LKM::code;
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
367 + 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
368 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
369 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
370 + provided chunk LKM::code;
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
373 + 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
374 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
375 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
376 + provided chunk LKM::code;
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
379 + 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
380 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
381 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
382 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
383 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
384 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
385 + 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
386 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
387 + provided chunk LKM::data;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
388 + 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
389 + provided chunk ::CALL;
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 + provided pointcut Ethernet::create_device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
392 + }
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 + 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
395 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
396 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
397 + 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
398 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
399 + provided pointcut Ethernet::destroy_device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
400 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
401 +}
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
402 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
403 new file mode 100644
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
404 --- /dev/null
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
405 +++ 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
406 @@ -0,0 +1,55 @@
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
407 +with LKM
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
408 +{
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
409 + /* 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
410 + ${pointcut LKM::includes};
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
411 + ${pointcut LKM::prototypes};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
412 + ${pointcut LKM::data};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
413 + ${pointcut LKM::code};
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
414 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
415 + template sequence LKM::init()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
416 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
417 + chunk LKM::includes()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
418 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
419 + #include <linux/module.h>
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
420 + #include <linux/kernel.h>
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
421 + }
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
422 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
423 + chunk LKM::data()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
424 + {
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
425 + MODULE_DESCRIPTION(${config.description});
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
426 + MODULE_AUTHOR(${config.author});
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
427 + MODULE_LICENSE(${config.license});
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
428 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
429 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
430 + chunk LKM::code()
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
431 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
432 + /*
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
433 + * 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
434 + * or __exit.
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
435 + */
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
436 + 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
437 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
438 + ${pointcut ::IMPLEMENTATION};
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
439 + ${pointcut LKM::init_bus_hook};
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 + return 0;
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
442 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
443 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
444 + module_init(rtx_module_init);
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
445 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
446 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
447 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
448 + template sequence LKM::exit()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
449 + {
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
450 + chunk LKM::code()
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
451 + {
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
452 + 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
453 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
454 + ${pointcut ::IMPLEMENTATION};
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
455 + ${pointcut LKM::deinit_bus_hook};
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
456 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
457 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
458 + module_exit(rtx_module_exit);
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
459 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
460 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
461 +}
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
462 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
463 new file mode 100644
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
464 --- /dev/null
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
465 +++ 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
466 @@ -0,0 +1,25 @@
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
467 +interface LKM
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
468 +{
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
469 + provided pointcut LKM::includes;
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
470 + /* 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
471 + provided pointcut LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
472 + provided pointcut LKM::data;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
473 + provided pointcut LKM::code;
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
474 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
475 + required variable ::string LKM::author;
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
476 + required variable ::string LKM::description;
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
477 + required variable ::string LKM::license;
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
478 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
479 + required sequence LKM::init()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
480 + {
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
481 + provided chunk LKM::includes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
482 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
483 + 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
484 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
485 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
486 + required sequence LKM::exit()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
487 + {
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
488 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
489 + 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
490 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
491 +}
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
492 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
493 new file mode 100644
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
494 --- /dev/null
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
495 +++ 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
496 @@ -0,0 +1,46 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
497 +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
498 +{
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
499 + Ethernet::open(Ethernet::Device dev)
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 + Log::info("Open the device");
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
502 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
503 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
504 + Ethernet::close(Ethernet::Device dev)
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 + Log::info("Close the device");
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
507 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
508 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
509 + 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
510 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
511 + Log::info("Got an interruption");
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
512 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
513 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
514 + 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
515 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
516 + 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
517 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
518 +
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
519 + LKM::init()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
520 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
521 + Log::info("Hello this is LKM");
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
522 + }
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 + LKM::exit()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
525 + {
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
526 + 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
527 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
528 +}
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
529 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
530 +configuration
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
531 +{
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
532 + LKM::name = "hello";
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
533 + LKM::author = "Rathaxes";
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
534 + 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
535 + LKM::license = "GPL";
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
536 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
537 + PCI::vendor_id = 0x8086;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
538 + PCI::product_id = 0x100f;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
539 + PCI::set_master = true;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
540 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
541 + Ethernet::ifname = "rtx%d";
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 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
544 new file mode 100644
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
545 --- /dev/null
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
546 +++ b/rathaxes/samples/lkm/log.blt
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
547 @@ -0,0 +1,10 @@
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
548 +with Log
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
549 +{
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
550 + template sequence Log::info(::string msg)
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 + chunk ::CALL
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
553 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
554 + pr_info("%s\n", ${msg});
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
555 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
556 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
557 +}
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
558 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
559 new file mode 100644
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
560 --- /dev/null
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
561 +++ b/rathaxes/samples/lkm/log.rti
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
562 @@ -0,0 +1,7 @@
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
563 +interface Log
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 + provided sequence Log::info(::string)
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 + provided chunk ::CALL;
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
568 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
569 +}
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
570 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
571 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
572 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
573 +++ 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
574 @@ -0,0 +1,143 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
575 +with PCI, LKM, Log
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
576 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
577 + template type PCI::Device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
578 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
579 + chunk LKM::includes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
580 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
581 + #include <linux/pci.h>
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
582 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
583 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
584 + chunk ::decl()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
585 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
586 + struct pci_dev;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
587 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
588 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
589 + chunk ::init(pci_dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
590 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
591 + ${self} = ${pci_dev};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
592 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
593 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
594 + map
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
595 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
596 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
597 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
598 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
599 + 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
600 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
601 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
602 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
603 + 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
604 + const struct pci_device_id *);
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
607 + chunk LKM::code()
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 + 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
610 + 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
611 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
612 + int err;
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 + err = pci_enable_device(pdev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
615 + if (err < 0)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
616 + goto fail;
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 + ${pointcut PCI::pci_probe_hook};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
619 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
620 + return 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
621 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
622 + fail:
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
623 + return err;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
624 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
625 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
626 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
627 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
628 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
629 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
630 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
631 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
632 + 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
633 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
634 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
635 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
636 + 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
637 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
638 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
639 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
640 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
641 + 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
642 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
643 + ${pointcut PCI::pci_remove_hook};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
644 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
645 + pci_disable_device(pdev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
646 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
647 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
648 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
649 + chunk ::CALL()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
650 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
651 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
652 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
653 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
654 + template sequence PCI::register()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
655 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
656 + chunk LKM::data()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
657 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
658 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
659 + * 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
660 + * 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
661 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
662 + 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
663 + { ${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
664 + { 0, }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
665 + };
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
666 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
667 + 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
668 + .name = ${config.name},
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
669 + .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
670 + .probe = rtx_pci_probe,
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
671 + .remove = rtx_pci_remove
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
672 + };
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
673 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
674 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
675 + chunk LKM::init_bus_hook()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
676 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
677 + int error;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
678 + 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
679 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
680 + ${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
681 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
682 + * 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
683 + * parent context?
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
684 + *
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
685 + * 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
686 + * 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
687 + * context).
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 + return error;
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 + }
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 + chunk ::CALL()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
694 + {
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 + * 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
697 + * actually not provided nor required.
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 + * 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
700 + * 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
701 + * 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
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 + }
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 + template sequence PCI::unregister()
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 + chunk LKM::deinit_bus_hook()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
709 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
710 + 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
711 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
712 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
713 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
714 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
715 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
716 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
717 +}
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
718 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
719 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
720 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
721 +++ 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
722 @@ -0,0 +1,36 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
723 +interface PCI : LKM
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 + provided type PCI::Device;
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 + 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
728 + 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
729 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
730 + provided sequence PCI::register()
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 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
733 + provided chunk LKM::data;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
734 + 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
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 + provided sequence PCI::unregister()
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 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
740 + 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
741 + }
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 + 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
744 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
745 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
746 + provided chunk LKM::code;
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 + 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
749 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
750 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
751 + 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
752 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
753 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
754 + provided chunk LKM::code;
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 + 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
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 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
760 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
761 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
762 +++ 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
763 @@ -0,0 +1,27 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
764 +with Socket, LKM
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
765 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
766 + template type Socket::SKBuff()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
767 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
768 + chunk LKM::includes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
769 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
770 + #include <linux/skbuff.h>
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
773 + chunk ::decl()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
774 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
775 + struct sk_buff;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
776 + }
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 + chunk ::init()
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 + }
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 + map
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
783 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
784 + // 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
785 + // 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
786 + // 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
787 + // 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
788 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
789 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
790 +}
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
791 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
792 new file mode 100644
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
793 --- /dev/null
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
794 +++ 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
795 @@ -0,0 +1,4 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
796 +interface Socket : LKM
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 + provided type Socket::SKBuff;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
799 +}