Mercurial > archived > louis > epitech > mq > rathaxes
annotate rathaxes_correctly_use_chunk_and_template_sequences_parameters_in_e1000.patch @ 64:8dc1a3bf372a
WIP e1000 sample
author | Louis Opter <louis@lse.epitech.net> |
---|---|
date | Sat, 18 Feb 2012 13:36:07 +0100 |
parents | b820c4604946 |
children | e77a4126576c 901af221334b |
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 |
64 | 2 # Parent e24ae3e49b73a2b799765d863f69f0c956ea2c54 |
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 } | |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
307 @@ -121,7 +139,7 @@ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
308 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
309 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
310 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
311 - template sequence Ethernet::init(PCI::Device pdev) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
312 + template sequence Ethernet::init() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
313 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
314 chunk LKM::data() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
315 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
316 @@ -133,18 +151,20 @@ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
317 }; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
318 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
319 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
320 - chunk PCI::pci_probe_hook() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
321 + /* 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
|
322 + 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
|
323 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
324 /* |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
325 * 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
|
326 * dialect. |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
327 */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
328 typedef int ${Ethernet::Device}; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
329 - ${Ethernet::Device} *rtx_ether_ctx; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
330 - struct net_device *net_dev; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
331 + |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
332 + ${Ethernet::Device} rtx_ether_ctx; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
333 + struct net_device *net_dev; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
334 int error; |
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 - error = 0; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
337 + /* Initialize the net_device structure */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
338 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
|
339 if (net_dev == 0) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
340 { |
63 | 341 @@ -152,64 +172,54 @@ |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
342 /* |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
343 * 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
|
344 * |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
345 - * 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
|
346 + * 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
|
347 * the parent context. |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
348 */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
349 return -ENOMEM; |
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 + SET_NETDEV_DEV(net_dev, &${pdev}->dev); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
352 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
|
353 - net_dev->irq = pdev->irq; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
354 - // 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
|
355 - rtx_ether_ctx = netdev_priv(net_dev); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
356 - //rtx_ether_ctx->pci_dev = ${pdev}; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
357 - 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
|
358 - rtx_ether_ctx->net_dev = net_dev; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
359 + net_dev->irq = ${pdev}->irq; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
360 + net_dev->netdev_ops = &rtx_ether_ops; |
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 - /* |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
363 - * 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
|
364 - * "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
|
365 - * "${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
|
366 - * placeholder, e.g: _1). |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
367 - * |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
368 - * 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
|
369 - */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
370 - //SET_NETDEV_DEV(net_dev, &${pdev}->dev); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
371 - SET_NETDEV_DEV(net_dev, &pdev->dev); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
372 - net_dev->netdev_ops = &rtx_ether_ops; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
373 - if ((error = register_netdev(net_dev))) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
374 + error = register_netdev(net_dev); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
375 + if (error) |
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 ${Log::info("Cannot register the driver")}; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
378 return error; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
379 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
380 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
381 - /* same problem as above with ${pdev} */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
382 - //pci_set_drvdata(${pdev}, net_dev); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
383 - pci_set_drvdata(pdev, net_dev); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
384 + /* 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
|
385 + ${rtx_ether_ctx.init(local.net_dev, pdev)}; |
63 | 386 |
387 - ${pointcut Ethernet::create_device}; | |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
388 + pci_set_drvdata(${pdev}, net_dev); |
63 | 389 + |
390 + ${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
|
391 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
392 |
63 | 393 + /* 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
|
394 chunk ::CALL |
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 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
397 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
398 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
399 - template sequence Ethernet::exit(PCI::Device pdev) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
400 + template sequence Ethernet::exit() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
401 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
402 - chunk PCI::pci_remove_hook() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
403 + 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
|
404 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
405 - struct net_device *net_dev = pci_get_drvdata(pdev); |
63 | 406 + /* workaround for cnorm unstrict */ |
64 | 407 + typedef int ${Ethernet::Device}; |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
408 |
63 | 409 - ${pointcut Ethernet::destroy_device}; |
410 + struct net_device *net_dev = pci_get_drvdata(${pdev}); | |
64 | 411 + ${Ethernet::Device} rtx_ether_ctx = netdev_priv(net_dev); |
63 | 412 + |
413 + ${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
|
414 |
63 | 415 unregister_netdev(net_dev); |
416 - /* | |
417 - * If we had some cleanup todo with struct rtx_ether_ctx we would | |
418 - * do a netdev_priv(net_dev) here and do it. | |
419 - */ | |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
420 free_netdev(net_dev); |
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 |
63 | 423 + /* 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
|
424 chunk ::CALL |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
425 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
426 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
427 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
|
428 --- a/rathaxes/samples/e1000/ethernet.rti |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
429 +++ b/rathaxes/samples/e1000/ethernet.rti |
63 | 430 @@ -28,19 +28,17 @@ |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
431 provided chunk LKM::code; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
432 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
433 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
434 - provided sequence Ethernet::init(PCI::Device) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
435 + provided sequence Ethernet::init() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
436 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
437 provided chunk LKM::data; |
63 | 438 - provided chunk PCI::pci_probe_hook; |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
439 - provided chunk ::CALL; |
63 | 440 + 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
|
441 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
442 provided pointcut Ethernet::create_device; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
443 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
444 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
445 - provided sequence Ethernet::exit(PCI::Device) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
446 + provided sequence Ethernet::exit() |
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 - provided chunk ::CALL; |
63 | 449 - provided chunk PCI::pci_remove_hook; |
450 + 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
|
451 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
452 provided pointcut Ethernet::destroy_device; |
63 | 453 } |
454 diff --git a/rathaxes/samples/e1000/lkm.rtx b/rathaxes/samples/e1000/lkm.rtx | |
455 --- a/rathaxes/samples/e1000/lkm.rtx | |
456 +++ b/rathaxes/samples/e1000/lkm.rtx | |
457 @@ -3,7 +3,7 @@ | |
458 Ethernet::open(Ethernet::Device dev) | |
459 { | |
460 Log::info("Open the device"); | |
461 - e1000::setup_interrupt_handler(); | |
462 + e1000::setup_interrupt_handler(dev); | |
463 Log::info("Interrupt handler installed"); | |
464 e1000::set_up_device(); | |
465 e1000::activate_device_interruption(); | |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
466 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
|
467 --- a/rathaxes/samples/e1000/pci.blt |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
468 +++ b/rathaxes/samples/e1000/pci.blt |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
469 @@ -22,7 +22,7 @@ |
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 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
472 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
473 - template sequence PCI::probe(PCI::Device pdev) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
474 + template sequence PCI::probe() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
475 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
476 chunk LKM::prototypes() |
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 @@ -41,7 +41,8 @@ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
479 if (err < 0) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
480 goto fail; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
481 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
482 - ${pointcut PCI::pci_probe_hook}; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
483 + /* 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
|
484 + ${pointcut PCI::pci_probe_hook(local.pdev)}; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
485 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
486 return 0; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
487 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
488 @@ -50,12 +51,13 @@ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
489 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
490 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
491 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
492 + /* This chunk should be remove (see #26) */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
493 chunk ::CALL |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
494 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
495 } |
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 - template sequence PCI::remove(PCI::Device pdev) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
499 + template sequence PCI::remove() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
500 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
501 chunk LKM::prototypes() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
502 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
503 @@ -66,12 +68,13 @@ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
504 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
505 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
|
506 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
507 - ${pointcut PCI::pci_remove_hook}; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
508 + ${pointcut PCI::pci_remove_hook(local.pdev)}; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
509 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
510 pci_disable_device(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 } |
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 + /* This chunk should be remove (see #26) */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
515 chunk ::CALL() |
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 @@ -125,6 +128,8 @@ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
519 * 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
|
520 * 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
|
521 * has a chunk (see above chunk). |
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 + * -> Should be removed see #26 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
524 */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
525 } |
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 @@ -136,6 +141,7 @@ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
528 pci_unregister_driver(&rtx_pci_driver); |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
529 } |
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 + /* This chunk should be removed */ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
532 chunk ::CALL |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
533 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
534 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
535 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
|
536 --- a/rathaxes/samples/e1000/pci.rti |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
537 +++ b/rathaxes/samples/e1000/pci.rti |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
538 @@ -18,7 +18,7 @@ |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
539 provided chunk LKM::deinit_bus_hook; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
540 } |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
541 |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
542 - provided sequence PCI::probe(PCI::Device) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
543 + provided sequence PCI::probe() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
544 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
545 provided chunk LKM::prototypes; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
546 provided chunk LKM::code; |
63 | 547 @@ -26,11 +26,11 @@ |
62
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
548 provided pointcut PCI::pci_probe_hook; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
549 } |
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 - provided sequence PCI::remove(PCI::Device) |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
552 + provided sequence PCI::remove() |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
553 { |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
554 provided chunk LKM::prototypes; |
b43bed449cc2
Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
555 provided chunk LKM::code; |
63 | 556 |
557 - provided pointcut PCI::pci_remove_hook; | |
558 + provided pointcut PCI::pci_remove_hook; /* Should take a PCI::Device arg */ | |
559 } | |
560 } |