comparison rathaxes_change_the_abstract_type_notation_in_the_e1000_sample.patch @ 105:fb20f01ea997

Wip, note: the interrupt handler refactoring patch is broken, I have to find the fix from the abstract type notation patch
author Louis Opter <louis@lse.epita.fr>
date Fri, 22 Mar 2013 00:25:52 -0700
parents c4c33ac02b93
children 976a4b87803f
comparison
equal deleted inserted replaced
104:c4c33ac02b93 105:fb20f01ea997
1 # HG changeset patch 1 # HG changeset patch
2 # Parent 6603911e89e5f98231c90bccf4f4cb9d5534e000 2 # Parent 1fa9b24e6012b2d53f1a84d4606cf3b6b9685fef
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.
34 kernel_api_function((struct net_device *)my_struct); 34 kernel_api_function((struct net_device *)my_struct);
35 35
36 Which is, I believe, more intuitive and coherent with how you would 36 Which is, I believe, more intuitive and coherent with how you would
37 initialize the my_struct pointer here with a return value from the 37 initialize the my_struct pointer here with a return value from the
38 kernel (i.e: with a cast into rtx_GeneratedType *). 38 kernel (i.e: with a cast into rtx_GeneratedType *).
39
40 39
41 diff --git a/rathaxes/samples/e1000/device.blt b/rathaxes/samples/e1000/device.blt 40 diff --git a/rathaxes/samples/e1000/device.blt b/rathaxes/samples/e1000/device.blt
42 --- a/rathaxes/samples/e1000/device.blt 41 --- a/rathaxes/samples/e1000/device.blt
43 +++ b/rathaxes/samples/e1000/device.blt 42 +++ b/rathaxes/samples/e1000/device.blt
44 @@ -18,7 +18,7 @@ 43 @@ -18,7 +18,7 @@
285 + k_net_dev: ((struct net_device *)${self}); 284 + k_net_dev: ((struct net_device *)${self});
286 + rtx_ether_ctx: netdev_priv((struct net_device *)${self}); 285 + rtx_ether_ctx: netdev_priv((struct net_device *)${self});
287 } 286 }
288 } 287 }
289 288
290 @@ -88,24 +94,33 @@ 289 @@ -88,25 +94,33 @@
291 #include <linux/etherdevice.h> 290 #include <linux/etherdevice.h>
292 } 291 }
293 292
294 - method init(Ethernet::AbstractDevice net_dev, PCI::AbstractDevice pci_dev) 293 - method init(Ethernet::AbstractDevice net_dev, PCI::AbstractDevice pci_dev)
295 + /* XXX: if the first arg is not called rtx_net_dev, it breaks. */ 294 + /* XXX: if the first arg is not called rtx_net_dev, it breaks. */
319 + device: (&((struct pci_dev *)(${self})->pci_dev)->dev); 318 + device: (&((struct pci_dev *)(${self})->pci_dev)->dev);
320 pci_device: ${self}->pci_dev; 319 pci_device: ${self}->pci_dev;
321 net_device: ${self}->net_dev; 320 net_device: ${self}->net_dev;
322 - perm_addr: ${self}->net_dev->ndev.perm_addr; 321 - perm_addr: ${self}->net_dev->ndev.perm_addr;
323 - dev_addr: ${self}->net_dev->ndev.dev_addr; 322 - dev_addr: ${self}->net_dev->ndev.dev_addr;
323 - irq: ${self}->pci_dev->data.irq;
324 + perm_addr: ((struct net_device *)(${self})->net_dev)->perm_addr; 324 + perm_addr: ((struct net_device *)(${self})->net_dev)->perm_addr;
325 + dev_addr: ((struct net_device *)(${self})->net_dev)->dev_addr; 325 + dev_addr: ((struct net_device *)(${self})->net_dev)->dev_addr;
326 + irq: ((struct pci_dev *)(${self})->pci_dev)->irq; 326 + irq: ((struct pci_dev *)(${self})->pci_dev)->irq;
327 } 327 }
328 } 328 }
329 329
330 @@ -125,8 +140,17 @@ 330 @@ -126,8 +140,17 @@
331 { 331 {
332 static int rtx_ethernet_open(struct net_device *dev) 332 static int rtx_ethernet_open(struct net_device *dev)
333 { 333 {
334 - ${Ethernet::Device} *rtx_ether_ctx = netdev_priv(dev); 334 - ${Ethernet::Device} *rtx_ether_ctx = netdev_priv(dev);
335 + /* 335 + /*
344 344
345 + ${Ethernet::Device} *rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx}; 345 + ${Ethernet::Device} *rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx};
346 ${cast local.rtx_ether_ctx as Ethernet::Device}; 346 ${cast local.rtx_ether_ctx as Ethernet::Device};
347 347
348 int error; 348 int error;
349 @@ -186,8 +210,13 @@ 349 @@ -187,8 +210,13 @@
350 { 350 {
351 static int rtx_ethernet_close(struct net_device *dev) 351 static int rtx_ethernet_close(struct net_device *dev)
352 { 352 {
353 - ${Ethernet::Device} *rtx_ether_ctx = netdev_priv(dev); 353 - ${Ethernet::Device} *rtx_ether_ctx = netdev_priv(dev);
354 + ${Ethernet::AbstractDevice} *rtx_net_dev; 354 + ${Ethernet::AbstractDevice} *rtx_net_dev;
359 359
360 + ${Ethernet::Device} *rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx}; 360 + ${Ethernet::Device} *rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx};
361 ${cast local.rtx_ether_ctx as Ethernet::Device}; 361 ${cast local.rtx_ether_ctx as Ethernet::Device};
362 362
363 /* TODO: change this pointcut into a pointcut/adapter/callback: */ 363 /* TODO: change this pointcut into a pointcut/adapter/callback: */
364 @@ -220,9 +249,13 @@ 364 @@ -221,9 +249,13 @@
365 { 365 {
366 static enum irqreturn rtx_ethernet_interrupt_handler(int irq, void *dev_id) 366 static enum irqreturn rtx_ethernet_interrupt_handler(int irq, void *dev_id)
367 { 367 {
368 - ${Ethernet::Device} *rtx_ether_ctx = dev_id; 368 - ${Ethernet::Device} *rtx_ether_ctx = dev_id;
369 + ${Ethernet::AbstractDevice} *rtx_net_dev = dev_id; 369 + ${Ethernet::AbstractDevice} *rtx_net_dev = dev_id;
374 + rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx}; 374 + rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx};
375 + 375 +
376 ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx)}; 376 ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx)};
377 377
378 return IRQ_NONE; 378 return IRQ_NONE;
379 @@ -252,23 +285,26 @@ 379 @@ -253,23 +285,26 @@
380 */ 380 */
381 chunk PCI::pci_probe_hook(PCI::Device rtx_pci_dev) 381 chunk PCI::pci_probe_hook(PCI::Device rtx_pci_dev)
382 { 382 {
383 + ${Ethernet::AbstractDevice} *rtx_net_dev; 383 + ${Ethernet::AbstractDevice} *rtx_net_dev;
384 ${Ethernet::Device} *rtx_ether_ctx; 384 ${Ethernet::Device} *rtx_ether_ctx;
410 - error = register_netdev(&${local.net_dev.netdev}); 410 - error = register_netdev(&${local.net_dev.netdev});
411 + error = register_netdev(${local.rtx_net_dev.k_net_dev}); 411 + error = register_netdev(${local.rtx_net_dev.k_net_dev});
412 if (error) 412 if (error)
413 { 413 {
414 ${Log::info("cannot register the driver in the net subsystem")}; 414 ${Log::info("cannot register the driver in the net subsystem")};
415 @@ -280,14 +316,11 @@ 415 @@ -281,14 +316,11 @@
416 * XXX: the cast is here because the compiler resolve the 416 * XXX: the cast is here because the compiler resolve the
417 * type of rtx_pci_dev.pci_device to the type of 417 * 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. 418 * rtx_pci_dev instead of the type of rtx_pci_dev.pci_device.
419 - * 419 - *
420 - * Also, I'm getting placeholder in the generated code if 420 - * 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 */ 429 + { /* 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)}; 430 + ${local.rtx_ether_ctx.init(local.rtx_net_dev, local.workaround)};
431 } 431 }
432 432
433 /* Register ourselves in the parent context: */ 433 /* Register ourselves in the parent context: */
434 @@ -309,7 +342,7 @@ 434 @@ -310,7 +342,7 @@
435 ${pointcut Ethernet::adapter_load_mac_address(local.rtx_ether_ctx)}; 435 ${pointcut Ethernet::adapter_load_mac_address(local.rtx_ether_ctx)};
436 memcpy(${local.rtx_ether_ctx.perm_addr}, 436 memcpy(${local.rtx_ether_ctx.perm_addr},
437 ${local.rtx_ether_ctx.dev_addr}, 437 ${local.rtx_ether_ctx.dev_addr},
438 - ${local.net_dev.netdev}.addr_len); 438 - ${local.net_dev.netdev}.addr_len);
439 + ${local.rtx_net_dev.k_net_dev}->addr_len); 439 + ${local.rtx_net_dev.k_net_dev}->addr_len);
440 } 440 }
441 441
442 /* This chunk should be removed (see #26) */ 442 /* This chunk should be removed (see #26) */
443 @@ -326,15 +359,15 @@ 443 @@ -327,15 +359,15 @@
444 */ 444 */
445 chunk PCI::pci_remove_hook(PCI::Device rtx_pci_dev) 445 chunk PCI::pci_remove_hook(PCI::Device rtx_pci_dev)
446 { 446 {
447 - ${Ethernet::Device} *rtx_ether_ctx = ${rtx_pci_dev.context}; 447 - ${Ethernet::Device} *rtx_ether_ctx = ${rtx_pci_dev.context};
448 - ${Ethernet::AbstractDevice} *rtx_ether_dev = (${Ethernet::AbstractDevice}*) ${local.rtx_ether_ctx.net_device}; 448 - ${Ethernet::AbstractDevice} *rtx_ether_dev = (${Ethernet::AbstractDevice}*) ${local.rtx_ether_ctx.net_device};
481 + */ 481 + */
482 + attribute Builtin::symbol rtx_ether_ctx; 482 + attribute Builtin::symbol rtx_ether_ctx;
483 } 483 }
484 484
485 provided type Device 485 provided type Device
486 @@ -34,8 +41,9 @@ 486 @@ -34,9 +41,9 @@
487 * I'd like to use better names here, but I'd like to understand the 487 * I'd like to use better names here, but I'd like to understand the
488 * difference between the two first: 488 * difference between the two first:
489 */ 489 */
490 - attribute Builtin::symbol perm_addr; 490 - attribute Builtin::symbol perm_addr;
491 - attribute Builtin::symbol dev_addr; 491 - attribute Builtin::symbol dev_addr;
492 - attribute Builtin::symbol irq;
492 + attribute Builtin::symbol perm_addr; 493 + attribute Builtin::symbol perm_addr;
493 + attribute Builtin::symbol dev_addr; 494 + attribute Builtin::symbol dev_addr;
494 + attribute Builtin::symbol irq; 495 + attribute Builtin::symbol irq;
495 } 496 }
496 497