Mercurial > archived > louis > epitech > mq > rathaxes
comparison rathaxes_change_the_abstract_type_notation_in_the_e1000_sample.patch @ 107:f42751b8ca99
Fix the interrupt handler refactoring patch and update the abstract type notation patch accordingly
author | Louis Opter <louis@lse.epita.fr> |
---|---|
date | Sun, 24 Mar 2013 21:47:39 -0700 |
parents | 976a4b87803f |
children | 7efe3212db3a |
comparison
equal
deleted
inserted
replaced
106:976a4b87803f | 107:f42751b8ca99 |
---|---|
1 # HG changeset patch | 1 # HG changeset patch |
2 # Parent f046837f963dcba715cebe8b6dc40e7bbe2ce598 | 2 # Parent 6122a310f97196aadba20973d9218aa24528bd3d |
3 rathaxes: change the abstract type notation in the e1000 sample | 3 rathaxes: change the abstract type notation in the e1000 sample |
4 | 4 |
5 Starting with ra24db32bf134 Rathaxes types are generated differently: you | 5 Starting with ra24db32bf134 Rathaxes types are generated differently: you |
6 don't define entire structures anymore, but only the fields. And the | 6 don't define entire structures anymore, but only the fields. And the |
7 compiler generate a typedef'ed structure on top of it. | 7 compiler generate a typedef'ed structure on top of it. |
267 - struct net_device ndev; | 267 - struct net_device ndev; |
268 + struct net_device data; | 268 + struct net_device data; |
269 } | 269 } |
270 | 270 |
271 chunk LKM::includes() | 271 chunk LKM::includes() |
272 @@ -59,9 +59,15 @@ | 272 @@ -59,11 +59,16 @@ |
273 #include <linux/netdevice.h> | 273 #include <linux/netdevice.h> |
274 } | 274 } |
275 | 275 |
276 + method init(Builtin::symbol dev) | 276 + method init(Builtin::symbol dev) |
277 + { | 277 + { |
278 + ${self} = (${Ethernet::AbstractDevice} *)${dev}; | 278 + ${self} = (${Ethernet::AbstractDevice} *)${dev}; |
279 + } | 279 + } |
280 + | 280 + |
281 map | 281 map |
282 { | 282 { |
283 - netdev: ${self}->ndev; | 283 - netdev: ${self}->ndev; |
284 + k_net_dev: ((struct net_device *)${self}); | 284 + k_net_dev: ((struct net_device *)${self}); |
285 /* This could be another init method for Ethernet::Device: */ | |
286 - rtx_ether_ctx: netdev_priv(&${self}->ndev); | |
285 + rtx_ether_ctx: netdev_priv((struct net_device *)${self}); | 287 + rtx_ether_ctx: netdev_priv((struct net_device *)${self}); |
286 } | 288 } |
287 } | 289 } |
288 | 290 |
289 @@ -88,25 +94,33 @@ | 291 @@ -90,25 +95,33 @@ |
290 #include <linux/etherdevice.h> | 292 #include <linux/etherdevice.h> |
291 } | 293 } |
292 | 294 |
293 - method init(Ethernet::AbstractDevice net_dev, PCI::AbstractDevice pci_dev) | 295 - method init(Ethernet::AbstractDevice net_dev, PCI::AbstractDevice pci_dev) |
294 + /* XXX: if the first arg is not called rtx_net_dev, it breaks. */ | 296 + /* XXX: if the first arg is not called rtx_net_dev, it breaks. */ |
325 + dev_addr: ((struct net_device *)(${self})->net_dev)->dev_addr; | 327 + dev_addr: ((struct net_device *)(${self})->net_dev)->dev_addr; |
326 + irq: ((struct pci_dev *)(${self})->pci_dev)->irq; | 328 + irq: ((struct pci_dev *)(${self})->pci_dev)->irq; |
327 } | 329 } |
328 } | 330 } |
329 | 331 |
330 @@ -126,8 +140,17 @@ | 332 @@ -128,8 +141,17 @@ |
331 { | 333 { |
332 static int rtx_ethernet_open(struct net_device *dev) | 334 static int rtx_ethernet_open(struct net_device *dev) |
333 { | 335 { |
334 - ${Ethernet::Device} *rtx_ether_ctx = netdev_priv(dev); | 336 - ${Ethernet::Device} *rtx_ether_ctx = netdev_priv(dev); |
335 + /* | 337 + /* |
344 | 346 |
345 + ${Ethernet::Device} *rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx}; | 347 + ${Ethernet::Device} *rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx}; |
346 ${cast local.rtx_ether_ctx as Ethernet::Device}; | 348 ${cast local.rtx_ether_ctx as Ethernet::Device}; |
347 | 349 |
348 int error; | 350 int error; |
349 @@ -187,8 +210,13 @@ | 351 @@ -189,8 +211,13 @@ |
350 { | 352 { |
351 static int rtx_ethernet_close(struct net_device *dev) | 353 static int rtx_ethernet_close(struct net_device *dev) |
352 { | 354 { |
353 - ${Ethernet::Device} *rtx_ether_ctx = netdev_priv(dev); | 355 - ${Ethernet::Device} *rtx_ether_ctx = netdev_priv(dev); |
354 + ${Ethernet::AbstractDevice} *rtx_net_dev; | 356 + ${Ethernet::AbstractDevice} *rtx_net_dev; |
359 | 361 |
360 + ${Ethernet::Device} *rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx}; | 362 + ${Ethernet::Device} *rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx}; |
361 ${cast local.rtx_ether_ctx as Ethernet::Device}; | 363 ${cast local.rtx_ether_ctx as Ethernet::Device}; |
362 | 364 |
363 /* TODO: change this pointcut into a pointcut/adapter/callback: */ | 365 /* TODO: change this pointcut into a pointcut/adapter/callback: */ |
364 @@ -221,9 +249,13 @@ | 366 @@ -225,6 +252,7 @@ |
365 { | 367 { |
366 static enum irqreturn rtx_ethernet_interrupt_handler(int irq, void *dev_id) | 368 ${Ethernet::AbstractDevice} *rtx_net_dev = dev_id; |
367 { | 369 ${cast local.rtx_net_dev as Ethernet::AbstractDevice}; |
368 - ${Ethernet::Device} *rtx_ether_ctx = dev_id; | 370 + |
369 + ${Ethernet::AbstractDevice} *rtx_net_dev = dev_id; | 371 ${Ethernet::Device} *rtx_ether_ctx; |
370 + ${cast local.rtx_net_dev as Ethernet::AbstractDevice}; | |
371 | |
372 + ${Ethernet::Device} *rtx_ether_ctx; | |
373 ${cast local.rtx_ether_ctx as Ethernet::Device}; | 372 ${cast local.rtx_ether_ctx as Ethernet::Device}; |
374 + rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx}; | 373 rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx}; |
375 + | 374 @@ -258,23 +286,26 @@ |
376 ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx)}; | |
377 | |
378 return IRQ_NONE; | |
379 @@ -253,23 +285,26 @@ | |
380 */ | 375 */ |
381 chunk PCI::pci_probe_hook(PCI::Device rtx_pci_dev) | 376 chunk PCI::pci_probe_hook(PCI::Device rtx_pci_dev) |
382 { | 377 { |
383 + ${Ethernet::AbstractDevice} *rtx_net_dev; | 378 + ${Ethernet::AbstractDevice} *rtx_net_dev; |
384 ${Ethernet::Device} *rtx_ether_ctx; | 379 ${Ethernet::Device} *rtx_ether_ctx; |
410 - error = register_netdev(&${local.net_dev.netdev}); | 405 - error = register_netdev(&${local.net_dev.netdev}); |
411 + error = register_netdev(${local.rtx_net_dev.k_net_dev}); | 406 + error = register_netdev(${local.rtx_net_dev.k_net_dev}); |
412 if (error) | 407 if (error) |
413 { | 408 { |
414 ${Log::info("cannot register the driver in the net subsystem")}; | 409 ${Log::info("cannot register the driver in the net subsystem")}; |
415 @@ -281,14 +316,11 @@ | 410 @@ -286,14 +317,11 @@ |
416 * XXX: the cast is here because the compiler resolve the | 411 * XXX: the cast is here because the compiler resolve the |
417 * type of rtx_pci_dev.pci_device to the type of | 412 * type of rtx_pci_dev.pci_device to the type of |
418 * rtx_pci_dev instead of the type of rtx_pci_dev.pci_device. | 413 * rtx_pci_dev instead of the type of rtx_pci_dev.pci_device. |
419 - * | 414 - * |
420 - * Also, I'm getting placeholder in the generated code if | 415 - * Also, I'm getting placeholder in the generated code if |
429 + { /* XXX: I end up with a placeholder if I don't open a scope */ | 424 + { /* XXX: I end up with a placeholder if I don't open a scope */ |
430 + ${local.rtx_ether_ctx.init(local.rtx_net_dev, local.workaround)}; | 425 + ${local.rtx_ether_ctx.init(local.rtx_net_dev, local.workaround)}; |
431 } | 426 } |
432 | 427 |
433 /* Register ourselves in the parent context: */ | 428 /* Register ourselves in the parent context: */ |
434 @@ -310,7 +342,7 @@ | 429 @@ -315,7 +343,7 @@ |
435 ${pointcut Ethernet::adapter_load_mac_address(local.rtx_ether_ctx)}; | 430 ${pointcut Ethernet::adapter_load_mac_address(local.rtx_ether_ctx)}; |
436 memcpy(${local.rtx_ether_ctx.perm_addr}, | 431 memcpy(${local.rtx_ether_ctx.perm_addr}, |
437 ${local.rtx_ether_ctx.dev_addr}, | 432 ${local.rtx_ether_ctx.dev_addr}, |
438 - ${local.net_dev.netdev}.addr_len); | 433 - ${local.net_dev.netdev}.addr_len); |
439 + ${local.rtx_net_dev.k_net_dev}->addr_len); | 434 + ${local.rtx_net_dev.k_net_dev}->addr_len); |
440 } | 435 } |
441 | 436 |
442 /* This chunk should be removed (see #26) */ | 437 /* This chunk should be removed (see #26) */ |
443 @@ -327,15 +359,15 @@ | 438 @@ -332,15 +360,15 @@ |
444 */ | 439 */ |
445 chunk PCI::pci_remove_hook(PCI::Device rtx_pci_dev) | 440 chunk PCI::pci_remove_hook(PCI::Device rtx_pci_dev) |
446 { | 441 { |
447 - ${Ethernet::Device} *rtx_ether_ctx = ${rtx_pci_dev.context}; | 442 - ${Ethernet::Device} *rtx_ether_ctx = ${rtx_pci_dev.context}; |
448 - ${Ethernet::AbstractDevice} *rtx_ether_dev = (${Ethernet::AbstractDevice}*) ${local.rtx_ether_ctx.net_device}; | 443 - ${Ethernet::AbstractDevice} *rtx_ether_dev = (${Ethernet::AbstractDevice}*) ${local.rtx_ether_ctx.net_device}; |
464 | 459 |
465 /* This chunk should be removed (see #26) */ | 460 /* This chunk should be removed (see #26) */ |
466 diff --git a/rathaxes/samples/e1000/ethernet.rti b/rathaxes/samples/e1000/ethernet.rti | 461 diff --git a/rathaxes/samples/e1000/ethernet.rti b/rathaxes/samples/e1000/ethernet.rti |
467 --- a/rathaxes/samples/e1000/ethernet.rti | 462 --- a/rathaxes/samples/e1000/ethernet.rti |
468 +++ b/rathaxes/samples/e1000/ethernet.rti | 463 +++ b/rathaxes/samples/e1000/ethernet.rti |
469 @@ -16,8 +16,15 @@ | 464 @@ -16,13 +16,14 @@ |
470 provided type AbstractDevice | 465 provided type AbstractDevice |
471 { | 466 { |
472 chunk LKM::includes(); | 467 chunk LKM::includes(); |
473 + method init(Builtin::symbol); | 468 + method init(Builtin::symbol); |
474 decl data_types(); | 469 decl data_types(); |
475 - attribute Builtin::symbol.scalar netdev; | 470 - attribute Builtin::symbol.scalar netdev; |
476 + | 471 + attribute Builtin::symbol.scalar k_net_dev; |
477 + attribute Builtin::symbol.scalar k_net_dev; | 472 /* |
478 + /* | 473 * XXX: should be a Ethernet::Device, but that causes a circular |
479 + * XXX: should be a Ethernet::Device, but that causes a circular | 474 * dependency: |
480 + * dependency. | 475 */ |
481 + */ | 476 - attribute Builtin::symbol rtx_ether_ctx; |
482 + attribute Builtin::symbol.scalar rtx_ether_ctx; | 477 + attribute Builtin::symbol.scalar rtx_ether_ctx; |
483 } | 478 } |
484 | 479 |
485 provided type Device | 480 provided type Device |
486 diff --git a/rathaxes/samples/e1000/pci.blt b/rathaxes/samples/e1000/pci.blt | 481 diff --git a/rathaxes/samples/e1000/pci.blt b/rathaxes/samples/e1000/pci.blt |
487 --- a/rathaxes/samples/e1000/pci.blt | 482 --- a/rathaxes/samples/e1000/pci.blt |