Mercurial > archived > louis > epitech > mq > rathaxes
annotate rathaxes_correctly_use_chunk_and_template_sequences_parameters_in_e1000.patch @ 66:901af221334b
Adding implementation poinctuts parameters to e1000 sample
author | David Pineau <dav.pineau@gmail.com> |
---|---|
date | Sat, 18 Feb 2012 15:51:06 +0100 |
parents | 8dc1a3bf372a |
children | b916396fc577 |
rev | line source |
---|---|
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
1 # HG changeset patch |
66
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
2 # Parent 0197bb30a5d0fe40c5c67c510a9f076d2272d45d |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
3 # User Louis Opter <louis@lse.epitech.net>, David Pineau <dav.pineau@gmail.com> |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
4 rathaxes: correctly use chunk and template sequences parameters in the e1000 sample |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
5 |
63 | 6 diff --git a/rathaxes/samples/e1000/e1000.blt b/rathaxes/samples/e1000/e1000.blt |
7 --- a/rathaxes/samples/e1000/e1000.blt | |
8 +++ b/rathaxes/samples/e1000/e1000.blt | |
9 @@ -15,18 +15,20 @@ | |
10 | |
11 chunk ::decl() | |
12 { | |
13 - struct rtx_e1000_ctx | |
14 + /* | |
15 + * Yes, this typedef looks ugly but read the remark about | |
16 + * Ethernet::Device in ethernet.blt. | |
17 + */ | |
18 + typedef struct rtx_e1000_ctx | |
19 { | |
20 int bars; | |
21 unsigned char /* __iomem */ *ioaddr; | |
22 int irq; | |
23 - }; | |
24 + } *rtx_e1000_ctx_p; | |
25 } | |
26 | |
27 - chunk ::init(bars, ioaddr) | |
28 + chunk ::init() | |
29 { | |
30 - ${self}.bars = ${bars}; | |
31 - ${self}.ioaddr = ${ioaddr}; | |
32 } | |
33 | |
34 map | |
35 @@ -136,58 +138,74 @@ | |
36 | |
37 template sequence e1000::create_device() | |
38 { | |
39 - chunk Ethernet::create_device() | |
40 + chunk Ethernet::create_device(/* PCI::Device */ pdev, /* Ethernet::Device */ rtx_ether_ctx) | |
41 { | |
42 - rtx_ether_ctx->hw_ctx.irq = pdev->irq; | |
43 - rtx_ether_ctx->hw_ctx.bars = pci_select_bars(pdev, IORESOURCE_MEM); | |
44 - if (pci_enable_device_mem(pdev)) | |
45 + /* | |
46 + * PCI init stuff: | |
47 + * | |
48 + * Some of that code should be moved in the PCI blts, also at some | |
49 + * point maybe we could do that completely automatically in the PCI | |
50 + * blts. | |
51 + */ | |
52 + | |
53 + /* | |
54 + * We could have used an init function here but since we can't init | |
55 + * all the fields at once (see, ioaddr) and cannot call a C | |
56 + * function within a placeholder (${}), it wasn't really worth it. | |
57 + */ | |
64 | 58 + ${rtx_ether_ctx}->hw_ctx.bars = pci_select_bars(${pdev}, IORESOURCE_MEM); |
59 + ${rtx_ether_ctx}->hw_ctx.irq = ${pdev}->irq; | |
63 | 60 + |
61 + if (pci_enable_device_mem(${pdev})) | |
62 { | |
63 ${Log::info("e1000::create: pci_enable_device_mem failed")}; | |
64 } | |
65 - | |
66 - if (pci_request_selected_regions(pdev, rtx_ether_ctx->hw_ctx.bars, ${config.name})) | |
67 + if (pci_request_selected_regions(${pdev}, ${rtx_ether_ctx}->hw_ctx.bars, ${config.name})) | |
68 { | |
69 ${Log::info("e1000::create: pci_request_selected_regions failed")}; | |
70 } | |
71 - | |
72 if (${config.set_master}) | |
73 { | |
74 - pci_set_master(pdev); | |
75 + pci_set_master(${pdev}); | |
76 } | |
77 | |
78 /* 0 here is for BAR_0: */ | |
79 - rtx_ether_ctx->hw_ctx.ioaddr = pci_ioremap_bar(pdev, 0); | |
80 - if (!rtx_ether_ctx->hw_ctx.ioaddr) | |
81 + ${rtx_ether_ctx}->hw_ctx.ioaddr = pci_ioremap_bar(${pdev}, 0); | |
82 + if (!${rtx_ether_ctx}->hw_ctx.ioaddr) | |
83 { | |
84 ${Log::info("e1000::create: pci_ioremap_bar failed")}; | |
85 } | |
86 | |
87 + /* | |
88 + * The really device specific algorithm starts here (so it should | |
89 + * certainly be written in the frontend): | |
90 + */ | |
91 + | |
92 /* Reset the card */ | |
93 - rtx_e1000_register_write32(&rtx_ether_ctx->hw_ctx, E1000_CTRL, E1000_CMD_RST); | |
94 + rtx_e1000_register_write32(&${rtx_ether_ctx}->hw_ctx, E1000_CTRL, E1000_CMD_RST); | |
95 udelay(10); | |
96 | |
97 - /* Now we can load its mac address */ | |
98 + /* Now we can load its mac address (thanks minix code) */ | |
99 int i = 0; | |
100 - for (i = 0 /* < this is not generated! */; i < 3; ++i) | |
101 + for (i = 0 /* < this is not generated! (cnorm bug) */; i < 3; ++i) | |
102 { | |
103 - rtx_e1000_register_write32(&rtx_ether_ctx->hw_ctx, E1000_EEPROM_READ, (i << 8) | 1); | |
104 + rtx_e1000_register_write32(&${rtx_ether_ctx}->hw_ctx, E1000_EEPROM_READ, (i << 8) | 1); | |
105 | |
106 int value; | |
107 - /* Should be a do { } while(); but the compiler doesn't do { } while(); yet. */ | |
108 - value = rtx_e1000_register_read32(&rtx_ether_ctx->hw_ctx, E1000_EEPROM_READ); | |
109 - while ((value & (1 << 4)) == 0) | |
110 - value = rtx_e1000_register_read32(&rtx_ether_ctx->hw_ctx, E1000_EEPROM_READ); | |
111 + do | |
112 + value = rtx_e1000_register_read32(&${rtx_ether_ctx}->hw_ctx, E1000_EEPROM_READ); | |
113 + while ((value & (1 << 4)) == 0); | |
114 value >>= 16; | |
115 | |
116 - rtx_ether_ctx->net_dev->dev_addr[i * 2] = value & 0xff; | |
117 - rtx_ether_ctx->net_dev->dev_addr[i * 2 + 1] = (value >> 8) & 0xff; | |
118 + ${rtx_ether_ctx}->net_dev->dev_addr[i * 2] = value & 0xff; | |
119 + ${rtx_ether_ctx}->net_dev->dev_addr[i * 2 + 1] = (value >> 8) & 0xff; | |
120 } | |
121 | |
122 - memcpy(rtx_ether_ctx->net_dev->perm_addr, | |
123 - rtx_ether_ctx->net_dev->dev_addr, | |
124 - rtx_ether_ctx->net_dev->addr_len); | |
125 + memcpy(${rtx_ether_ctx}->net_dev->perm_addr, | |
126 + ${rtx_ether_ctx}->net_dev->dev_addr, | |
127 + ${rtx_ether_ctx}->net_dev->addr_len); | |
128 | |
129 - { /* < mais lol. */ | |
130 + { /* < See #10 */ | |
131 ${Log::info("e1000::create: mac address loaded from the EEPROM")}; | |
132 } | |
133 } | |
134 @@ -199,15 +217,14 @@ | |
135 | |
136 template sequence e1000::destroy_device() | |
137 { | |
138 - chunk Ethernet::destroy_device | |
139 + chunk Ethernet::destroy_device(/* PCI::Device */ pdev, /* Ethernet::Device */ rtx_ether_ctx) | |
140 { | |
141 /* | |
142 * Here, we should have some checks to avoid to free resources that | |
143 * haven't been allocated. (e.g: in case of previous errors). | |
144 */ | |
145 - struct rtx_ethernet_dev* rtx_ether_ctx = netdev_priv(net_dev); | |
146 - iounmap(rtx_ether_ctx->hw_ctx.ioaddr); | |
147 - pci_release_selected_regions(pdev, rtx_ether_ctx->hw_ctx.bars); | |
148 + iounmap(${rtx_ether_ctx}->hw_ctx.ioaddr); | |
149 + pci_release_selected_regions(${pdev}, ${rtx_ether_ctx}->hw_ctx.bars); | |
150 } | |
151 | |
152 chunk ::CALL | |
153 @@ -275,7 +292,7 @@ | |
154 | |
155 chunk ::CALL() | |
156 { | |
157 - rtx_e1000_register_read32(&${ctx}, ${reg_offset}); | |
158 + rtx_e1000_register_read32(${ctx}, ${reg_offset}); | |
159 } | |
160 } | |
161 | |
162 @@ -296,7 +313,7 @@ | |
163 | |
164 chunk ::CALL() | |
165 { | |
166 - rtx_e1000_register_write32(&${ctx}, ${reg_offset}); | |
167 + rtx_e1000_register_write32(${ctx}, ${reg_offset}); | |
168 } | |
169 } | |
170 | |
171 @@ -320,7 +337,7 @@ | |
172 } | |
173 } | |
174 | |
175 - template sequence e1000::setup_interrupt_handler() | |
176 + template sequence e1000::setup_interrupt_handler(Ethernet::Device ctx) | |
177 { | |
178 chunk LKM::includes() | |
179 { | |
180 @@ -352,13 +369,13 @@ | |
181 } | |
182 } | |
183 | |
184 - chunk ::CALL() | |
185 + chunk ::CALL | |
186 { | |
187 // this is an hack for the scope | |
188 (void)1; | |
189 { | |
190 int error; | |
191 - error = e1000_setup_interrupt_handler(rtx_ether_dev); | |
192 + error = e1000_setup_interrupt_handler(${ctx}); | |
193 if (error) | |
194 { | |
195 return error; | |
196 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti | |
197 --- a/rathaxes/samples/e1000/e1000.rti | |
198 +++ b/rathaxes/samples/e1000/e1000.rti | |
199 @@ -1,25 +1,22 @@ | |
200 interface e1000 : Socket, Ethernet, PCI, LKM | |
201 { | |
202 provided type e1000::Context; | |
203 + /* | |
204 + * These two types should actually be registers definitions in the frontend: | |
205 + */ | |
206 provided type e1000::Register; | |
207 provided type e1000::Commands; | |
208 | |
209 - /* | |
210 - * This sequence should receive an argument like Ethernet::Device, but it is | |
211 - * unclear about how this argument should be bound to a variable/argument in | |
212 - * the instrumented C code. | |
213 - * | |
214 - * Here again, we rely on the fact that *we* wrote the parent context and | |
215 - * named the C variables we need/use with the same name everywhere. | |
216 - */ | |
217 provided sequence e1000::create_device() | |
218 { | |
219 + /* should take PCI::Device and Ethernet::Device args: */ | |
220 provided chunk Ethernet::create_device; | |
221 provided chunk ::CALL; | |
222 } | |
223 | |
224 provided sequence e1000::destroy_device() | |
225 { | |
226 + /* should take PCI::Device and Ethernet::Device args: */ | |
227 provided chunk Ethernet::destroy_device; | |
228 provided chunk ::CALL; | |
229 } | |
230 @@ -35,9 +32,9 @@ | |
231 provided chunk ::CALL; | |
232 } | |
233 | |
234 - provided sequence e1000::setup_interrupt_handler() | |
235 + provided sequence e1000::setup_interrupt_handler(Ethernet::Device) | |
236 { | |
237 - provided chunk LKM::includes; // work without this one | |
238 + provided chunk LKM::includes; // works without this one | |
239 provided chunk LKM::prototypes; | |
240 provided chunk LKM::code; | |
241 provided chunk ::CALL; | |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
242 diff --git a/rathaxes/samples/e1000/ethernet.blt b/rathaxes/samples/e1000/ethernet.blt |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
243 --- a/rathaxes/samples/e1000/ethernet.blt |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
244 +++ b/rathaxes/samples/e1000/ethernet.blt |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
245 @@ -1,5 +1,10 @@ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
246 with Ethernet, PCI, LKM, Log |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
247 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
248 + /* |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
249 + * Unlike PCI::Device, Ethernet::Device doesn't match the struct net_device |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
250 + * from Linux. Ethernet::Device is the type that we use in the private |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
251 + * field of the struct net_device. |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
252 + */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
253 template type Ethernet::Device() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
254 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
255 chunk LKM::includes() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
256 @@ -10,7 +15,14 @@ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
257 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
258 chunk ::decl() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
259 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
260 - struct rtx_ethernet_dev |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
261 + /* |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
262 + * So, at first sight, it sucks to typedef it as pointer but (for |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
263 + * now) it makes sense for two reasons: |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
264 + * - This structure will always be used through a pointer; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
265 + * - This remove the ambiguity of pointer/not-pointer in the |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
266 + * ::init() chunk. |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
267 + */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
268 + typedef struct rtx_ethernet_dev |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
269 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
270 /* |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
271 * I think it's useless to use the ${PCI::Device} "abstraction" |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
272 @@ -21,12 +33,18 @@ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
273 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
274 /* while waiting on issue #8 */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
275 struct rtx_e1000_ctx hw_ctx; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
276 - }; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
277 + } *rtx_ethernet_dev_p; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
278 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
279 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
280 - chunk ::init(net_dev) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
281 + chunk ::init(net_dev, pci_dev) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
282 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
283 - ${self} = ${net_dev}; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
284 + ${self} = netdev_priv(${net_dev}); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
285 + /* |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
286 + * We can use -> because we know that ${self} will be always a |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
287 + * pointer ("thanks" to the typedef) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
288 + */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
289 + ${self}->pci_dev = ${pci_dev}; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
290 + ${self}->net_dev = ${net_dev}; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
291 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
292 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
293 map |
64 | 294 @@ -45,10 +63,10 @@ |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
295 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
296 static int rtx_ethernet_open(struct net_device *dev) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
297 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
298 - struct rtx_ethernet_dev* rtx_ether_dev = netdev_priv(dev); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
299 + struct rtx_ethernet_dev* rtx_ether_dev = netdev_priv(dev); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
300 struct rtx_e1000_ctx* ctx = &rtx_ether_dev->hw_ctx; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
301 |
64 | 302 - ${pointcut ::IMPLEMENTATION}; |
303 + ${pointcut ::IMPLEMENTATION(local.rtx_ethernet_dev)}; | |
304 | |
305 return 0; | |
306 } | |
66
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
307 @@ -66,7 +84,7 @@ |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
308 { |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
309 static int rtx_ethernet_xmit(struct sk_buff* skb, struct net_device *dev) |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
310 { |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
311 - ${pointcut ::IMPLEMENTATION}; |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
312 + ${pointcut ::IMPLEMENTATION(local.skb, local.dev)}; |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
313 |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
314 return 0; |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
315 } |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
316 @@ -87,7 +105,7 @@ |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
317 struct rtx_ethernet_dev* rtx_ether_dev = netdev_priv(dev); |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
318 struct rtx_e1000_ctx* ctx = &rtx_ether_dev->hw_ctx; |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
319 |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
320 - ${pointcut ::IMPLEMENTATION}; |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
321 + ${pointcut ::IMPLEMENTATION(local.rtx_ether_dev)}; |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
322 |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
323 return 0; |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
324 } |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
325 @@ -114,14 +132,14 @@ |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
326 |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
327 rtx_ether_dev = dev_id; |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
328 ctx = &rtx_ether_dev->hw_ctx; |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
329 - ${pointcut ::IMPLEMENTATION}; |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
330 + ${pointcut ::IMPLEMENTATION(local.rtx_ether_dev)}; |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
331 |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
332 return IRQ_NONE; |
901af221334b
Adding implementation poinctuts parameters to e1000 sample
David Pineau <dav.pineau@gmail.com>
parents:
64
diff
changeset
|
333 } |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
334 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
335 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
336 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
337 - template sequence Ethernet::init(PCI::Device pdev) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
338 + template sequence Ethernet::init() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
339 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
340 chunk LKM::data() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
341 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
342 @@ -133,18 +151,20 @@ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
343 }; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
344 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
345 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
346 - chunk PCI::pci_probe_hook() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
347 + /* For now the type is not handled, so we just omit it (see #17) */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
348 + chunk PCI::pci_probe_hook(/* PCI::Device */ pdev) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
349 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
350 /* |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
351 * This typedef is needed to workaround a bug in CNorm __std__ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
352 * dialect. |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
353 */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
354 typedef int ${Ethernet::Device}; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
355 - ${Ethernet::Device} *rtx_ether_ctx; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
356 - struct net_device *net_dev; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
357 + |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
358 + ${Ethernet::Device} rtx_ether_ctx; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
359 + struct net_device *net_dev; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
360 int error; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
361 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
362 - error = 0; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
363 + /* Initialize the net_device structure */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
364 net_dev = alloc_etherdev(sizeof(*rtx_ether_ctx)); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
365 if (net_dev == 0) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
366 { |
63 | 367 @@ -152,64 +172,54 @@ |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
368 /* |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
369 * Again, the error should be "raised" in the parent context. |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
370 * |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
371 - * Here we know that we should return ENOMEM because *we* wrote |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
372 + * Here we know that we can return ENOMEM because *we* wrote |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
373 * the parent context. |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
374 */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
375 return -ENOMEM; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
376 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
377 + SET_NETDEV_DEV(net_dev, &${pdev}->dev); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
378 strlcpy(net_dev->name, ${config.ifname}, sizeof(net_dev->name)); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
379 - net_dev->irq = pdev->irq; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
380 - // Maybe we should try ${rtx_ether_ctx.init()} here: |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
381 - rtx_ether_ctx = netdev_priv(net_dev); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
382 - //rtx_ether_ctx->pci_dev = ${pdev}; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
383 - rtx_ether_ctx->pci_dev = pdev; // In the meantime do it directly |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
384 - rtx_ether_ctx->net_dev = net_dev; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
385 + net_dev->irq = ${pdev}->irq; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
386 + net_dev->netdev_ops = &rtx_ether_ops; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
387 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
388 - /* |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
389 - * The substitution of ${pdev} fails here. I also tried to add a |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
390 - * "substitute method" to the PCI::Device that was just doing |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
391 - * "${self}" but it didn't work either (it was subsituted by a |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
392 - * placeholder, e.g: _1). |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
393 - * |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
394 - * That's why we cheated a bit and named all the arguments pdev. |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
395 - */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
396 - //SET_NETDEV_DEV(net_dev, &${pdev}->dev); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
397 - SET_NETDEV_DEV(net_dev, &pdev->dev); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
398 - net_dev->netdev_ops = &rtx_ether_ops; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
399 - if ((error = register_netdev(net_dev))) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
400 + error = register_netdev(net_dev); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
401 + if (error) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
402 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
403 ${Log::info("Cannot register the driver")}; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
404 return error; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
405 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
406 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
407 - /* same problem as above with ${pdev} */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
408 - //pci_set_drvdata(${pdev}, net_dev); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
409 - pci_set_drvdata(pdev, net_dev); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
410 + /* Initialize our context held by the net_device structure */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
411 + ${rtx_ether_ctx.init(local.net_dev, pdev)}; |
63 | 412 |
413 - ${pointcut Ethernet::create_device}; | |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
414 + pci_set_drvdata(${pdev}, net_dev); |
63 | 415 + |
416 + ${pointcut Ethernet::create_device(pdev, local.rtx_ether_ctx)}; | |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
417 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
418 |
63 | 419 + /* This chunk should be removed (see #26) */ |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
420 chunk ::CALL |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
421 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
422 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
423 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
424 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
425 - template sequence Ethernet::exit(PCI::Device pdev) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
426 + template sequence Ethernet::exit() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
427 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
428 - chunk PCI::pci_remove_hook() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
429 + chunk PCI::pci_remove_hook(/* PCI::Device */ pdev) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
430 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
431 - struct net_device *net_dev = pci_get_drvdata(pdev); |
63 | 432 + /* workaround for cnorm unstrict */ |
64 | 433 + typedef int ${Ethernet::Device}; |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
434 |
63 | 435 - ${pointcut Ethernet::destroy_device}; |
436 + struct net_device *net_dev = pci_get_drvdata(${pdev}); | |
64 | 437 + ${Ethernet::Device} rtx_ether_ctx = netdev_priv(net_dev); |
63 | 438 + |
439 + ${pointcut Ethernet::destroy_device(pdev, local.rtx_ether_ctx)}; | |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
440 |
63 | 441 unregister_netdev(net_dev); |
442 - /* | |
443 - * If we had some cleanup todo with struct rtx_ether_ctx we would | |
444 - * do a netdev_priv(net_dev) here and do it. | |
445 - */ | |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
446 free_netdev(net_dev); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
447 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
448 |
63 | 449 + /* This chunk should be removed (see #26) */ |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
450 chunk ::CALL |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
451 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
452 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
453 diff --git a/rathaxes/samples/e1000/ethernet.rti b/rathaxes/samples/e1000/ethernet.rti |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
454 --- a/rathaxes/samples/e1000/ethernet.rti |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
455 +++ b/rathaxes/samples/e1000/ethernet.rti |
63 | 456 @@ -28,19 +28,17 @@ |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
457 provided chunk LKM::code; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
458 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
459 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
460 - provided sequence Ethernet::init(PCI::Device) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
461 + provided sequence Ethernet::init() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
462 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
463 provided chunk LKM::data; |
63 | 464 - provided chunk PCI::pci_probe_hook; |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
465 - provided chunk ::CALL; |
63 | 466 + provided chunk PCI::pci_probe_hook; /* should take a PCI::Device arg */ |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
467 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
468 provided pointcut Ethernet::create_device; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
469 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
470 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
471 - provided sequence Ethernet::exit(PCI::Device) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
472 + provided sequence Ethernet::exit() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
473 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
474 - provided chunk ::CALL; |
63 | 475 - provided chunk PCI::pci_remove_hook; |
476 + provided chunk PCI::pci_remove_hook; /* should take a PCI::Device arg */ | |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
477 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
478 provided pointcut Ethernet::destroy_device; |
63 | 479 } |
480 diff --git a/rathaxes/samples/e1000/lkm.rtx b/rathaxes/samples/e1000/lkm.rtx | |
481 --- a/rathaxes/samples/e1000/lkm.rtx | |
482 +++ b/rathaxes/samples/e1000/lkm.rtx | |
483 @@ -3,7 +3,7 @@ | |
484 Ethernet::open(Ethernet::Device dev) | |
485 { | |
486 Log::info("Open the device"); | |
487 - e1000::setup_interrupt_handler(); | |
488 + e1000::setup_interrupt_handler(dev); | |
489 Log::info("Interrupt handler installed"); | |
490 e1000::set_up_device(); | |
491 e1000::activate_device_interruption(); | |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
492 diff --git a/rathaxes/samples/e1000/pci.blt b/rathaxes/samples/e1000/pci.blt |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
493 --- a/rathaxes/samples/e1000/pci.blt |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
494 +++ b/rathaxes/samples/e1000/pci.blt |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
495 @@ -22,7 +22,7 @@ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
496 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
497 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
498 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
499 - template sequence PCI::probe(PCI::Device pdev) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
500 + template sequence PCI::probe() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
501 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
502 chunk LKM::prototypes() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
503 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
504 @@ -41,7 +41,8 @@ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
505 if (err < 0) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
506 goto fail; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
507 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
508 - ${pointcut PCI::pci_probe_hook}; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
509 + /* Use local. to reference a local C variable: */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
510 + ${pointcut PCI::pci_probe_hook(local.pdev)}; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
511 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
512 return 0; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
513 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
514 @@ -50,12 +51,13 @@ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
515 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
516 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
517 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
518 + /* This chunk should be remove (see #26) */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
519 chunk ::CALL |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
520 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
521 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
522 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
523 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
524 - template sequence PCI::remove(PCI::Device pdev) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
525 + template sequence PCI::remove() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
526 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
527 chunk LKM::prototypes() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
528 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
529 @@ -66,12 +68,13 @@ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
530 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
531 static void rtx_pci_remove(struct pci_dev *pdev) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
532 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
533 - ${pointcut PCI::pci_remove_hook}; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
534 + ${pointcut PCI::pci_remove_hook(local.pdev)}; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
535 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
536 pci_disable_device(pdev); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
537 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
538 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
539 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
540 + /* This chunk should be remove (see #26) */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
541 chunk ::CALL() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
542 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
543 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
544 @@ -125,6 +128,8 @@ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
545 * This sequence is just "intermediate" code that will just inject |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
546 * itself in the hook LKM::init_bus_hook for which this sequence |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
547 * has a chunk (see above chunk). |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
548 + * |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
549 + * -> Should be removed see #26 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
550 */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
551 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
552 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
553 @@ -136,6 +141,7 @@ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
554 pci_unregister_driver(&rtx_pci_driver); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
555 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
556 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
557 + /* This chunk should be removed */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
558 chunk ::CALL |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
559 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
560 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
561 diff --git a/rathaxes/samples/e1000/pci.rti b/rathaxes/samples/e1000/pci.rti |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
562 --- a/rathaxes/samples/e1000/pci.rti |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
563 +++ b/rathaxes/samples/e1000/pci.rti |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
564 @@ -18,7 +18,7 @@ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
565 provided chunk LKM::deinit_bus_hook; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
566 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
567 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
568 - provided sequence PCI::probe(PCI::Device) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
569 + provided sequence PCI::probe() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
570 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
571 provided chunk LKM::prototypes; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
572 provided chunk LKM::code; |
63 | 573 @@ -26,11 +26,11 @@ |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
574 provided pointcut PCI::pci_probe_hook; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
575 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
576 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
577 - provided sequence PCI::remove(PCI::Device) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
578 + provided sequence PCI::remove() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
579 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
580 provided chunk LKM::prototypes; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
581 provided chunk LKM::code; |
63 | 582 |
583 - provided pointcut PCI::pci_remove_hook; | |
584 + provided pointcut PCI::pci_remove_hook; /* Should take a PCI::Device arg */ | |
585 } | |
586 } |