changeset 108:7efe3212db3a

Put the patches on e1000 above the patches on the compiler
author Louis Opter <louis@lse.epita.fr>
date Sun, 31 Mar 2013 20:00:09 -0700
parents f42751b8ca99
children 3523e795bdf9
files E1000_UpdateToScalarRef rathaxes_change_the_abstract_type_notation_in_the_e1000_sample.patch rathaxes_e1000_move_the_interrupt_init_and_cleanup_into_ethernet.patch series
diffstat 4 files changed, 231 insertions(+), 301 deletions(-) [+]
line wrap: on
line diff
--- a/E1000_UpdateToScalarRef	Sun Mar 24 21:47:39 2013 -0700
+++ b/E1000_UpdateToScalarRef	Sun Mar 31 20:00:09 2013 -0700
@@ -1,5 +1,5 @@
 # HG changeset patch
-# Parent 9e6d855c6c477852924e13d354686f18d2036a0e
+# Parent 04c8e190a3b0e60993026d109e6ff2bb383e5e23
 Update the e1000 sample with the new features
 
 diff --git a/rathaxes/samples/e1000/e1000.blt b/rathaxes/samples/e1000/e1000.blt
@@ -61,40 +61,37 @@
              {
                  if (self->tail == self->head) /* ring is empty */
                      return 256; /* XXX: ${config.tx_ring_size}; */
-@@ -169,19 +169,17 @@
+@@ -169,14 +169,13 @@
                  return self->head - self->tail;
              }
  
 -            static int          rtx_e1000_tx_ring_tso_cksum_offload(${e1000::TxRing} *self, ${Socket::SKBuff} *skb)
 +            static int          rtx_e1000_tx_ring_tso_cksum_offload(${e1000::TxRing.ref} self, ${Socket::SKBuff.ref} skb)
              {
-                 /* XXX We can't use ${skb} here because it's a pointer */
--                ${Socket::AbstractSKBuff} *k_skb = skb->skbuff;
--                ${cast local.k_skb as Socket::AbstractSKBuff};
-+                ${Socket::AbstractSKBuff.ref} k_skb = skb->skbuff;
-                 return skb_is_gso(${local.k_skb.k_sk_buff}) || ${local.k_skb.k_sk_buff}->ip_summed == CHECKSUM_PARTIAL;
+-                ${Socket::AbstractSKBuff} *abs_skb = skb->skbuff;
+-                ${cast local.abs_skb as Socket::AbstractSKBuff};
++                ${Socket::AbstractSKBuff.ref} abs_skb = skb->skbuff;
+                 return skb_is_gso(&${local.abs_skb.data}) || ${local.abs_skb.data}.ip_summed == CHECKSUM_PARTIAL;
              }
  
 -            static void         rtx_e1000_tx_ring_put(${e1000::TxRing} *self, ${Socket::SKBuff} *skb)
 +            static void         rtx_e1000_tx_ring_put(${e1000::TxRing.ref} self, ${Socket::SKBuff.ref} skb)
              {
-                 /* XXX We can't use ${skb} here because it's a pointer */
--                ${Socket::AbstractSKBuff} *k_skb = skb->skbuff;
--                ${cast local.k_skb as Socket::AbstractSKBuff};
-+                ${Socket::AbstractSKBuff.ref} k_skb = skb->skbuff;
                  WARN_ON(!skb);
  
-                 /*
-@@ -192,7 +190,7 @@
+@@ -188,9 +187,8 @@
                   * code shouldn't be aware of it and use something more
                   * abstract.
                   */
+-                ${Socket::AbstractSKBuff} *abs_skb = skb->skbuff;
+-                ${cast local.abs_skb as Socket::AbstractSKBuff};
 -                ${e1000::TxDescriptor} *tx_desc = &self->base[self->tail];
++                ${Socket::AbstractSKBuff.ref} abs_skb = skb->skbuff;
 +                ${e1000::TxDescriptor.ref} tx_desc = &self->base[self->tail];
                  tx_desc->lower.data = cpu_to_le32(
                          E1000_TXD_CMD_EOP  |
                          E1000_TXD_CMD_IFCS |
-@@ -205,7 +203,7 @@
+@@ -203,7 +201,7 @@
              }
  
              /* FIXME: See issue #54 */
@@ -104,15 +101,15 @@
                  pr_info("%s: start_xmit: moving tail to %d/%d", ${config.name}, self->tail, ${config.tx_ring_size});
                  rtx_e1000_register_write32(hw_ctx, E1000_TDT, self->tail);
 @@ -271,7 +269,7 @@
-                                                Builtin::symbol ioaddr)
+                                                Builtin::number irq)
          {
              {
 -                ${e1000::Context} *hw_ctx = &${rtx_ether_ctx}->hw_ctx;
 +                ${e1000::Context.ref} hw_ctx = &${rtx_ether_ctx}->hw_ctx;
                  hw_ctx->bars = ${bars};
                  hw_ctx->ioaddr = ${ioaddr};
-             }
-@@ -280,8 +278,9 @@
+                 hw_ctx->irq = ${irq};
+@@ -281,8 +279,9 @@
          chunk   Ethernet::adapter_reset(Ethernet::Device rtx_ether_ctx)
          {
              {
@@ -124,7 +121,7 @@
                  udelay(10);
              }
          }
-@@ -289,7 +288,7 @@
+@@ -290,7 +289,7 @@
          chunk   Ethernet::adapter_load_mac_address(Ethernet::Device rtx_ether_ctx)
          {
              {
@@ -133,7 +130,7 @@
                  /* Shamelessly borrowed from Minix */
                  for (int i = 0; i < 3; ++i)
                  {
-@@ -468,12 +467,12 @@
+@@ -469,12 +468,12 @@
      {
          chunk   LKM::prototypes()
          {
@@ -148,7 +145,7 @@
              {
                  unsigned int status = rtx_e1000_register_read32(hw_ctx, E1000_STATUS);
                      ${Log::info("card status:")};
-@@ -518,13 +517,13 @@
+@@ -519,13 +518,13 @@
          chunk   LKM::prototypes()
          {
              /* FIXME: See issue #54 */
@@ -164,7 +161,7 @@
              {
                  return ioread32(ctx->ioaddr + reg_offset);
              }
-@@ -541,13 +540,13 @@
+@@ -542,13 +541,13 @@
          chunk   LKM::prototypes()
          {
              /* FIXME: See issue #54 */
@@ -180,7 +177,7 @@
              {
                  iowrite32(value, ctx->ioaddr + reg_offset);
              }
-@@ -564,13 +563,13 @@
+@@ -565,13 +564,13 @@
          chunk   LKM::prototypes()
          {
              /* FIXME: See issue #54 */
@@ -196,7 +193,7 @@
              {
                  iowrite32(rtx_e1000_register_read32(ctx, reg_offset) | value, ctx->ioaddr + reg_offset);
              }
-@@ -587,13 +586,13 @@
+@@ -588,13 +587,13 @@
          chunk   LKM::prototypes()
          {
              /* FIXME: See issue #54 */
@@ -212,7 +209,7 @@
              {
                  iowrite32(rtx_e1000_register_read32(ctx, reg_offset) & ~value, ctx->ioaddr + reg_offset);
              }
-@@ -644,7 +643,7 @@
+@@ -707,7 +706,7 @@
               * e1000::Context? (but we would need to make it point back to
               * the struct net_device)
               */
@@ -221,35 +218,30 @@
              hw_ctx = &${rtx_ether_ctx}->hw_ctx;
  
              /*
-@@ -755,7 +754,7 @@
+@@ -816,11 +815,10 @@
+              * Allocate the skbuffs, map them for DMA, and write their address
+              * in the corresponding descriptor.
               */
+-            ${Ethernet::AbstractDevice} *rtx_ether_dev = ${rtx_ether_ctx.net_device};
+-            ${cast local.rtx_ether_dev as Ethernet::AbstractDevice};
++            ${Ethernet::AbstractDevice.ref} rtx_ether_dev = ${rtx_ether_ctx.net_device};
              for (i = 0; i != ${config.rx_ring_size}; ++i)
              {
--                hw_ctx->rx_ring.skbuffs[i].skbuff = (${Socket::AbstractSKBuff}*)netdev_alloc_skb(
+-                hw_ctx->rx_ring.skbuffs[i].skbuff = (${Socket::AbstractSKBuff}*)  netdev_alloc_skb(
 +                hw_ctx->rx_ring.skbuffs[i].skbuff = (${Socket::AbstractSKBuff.ref})netdev_alloc_skb(
-                         ${rtx_ether_ctx.net_device.k_net_dev}, /* XXX: .k_net_dev isn't expanded here */
+                         &${rtx_ether_dev.netdev},
                          ${config.rx_buffer_len});
                  if (!hw_ctx->rx_ring.skbuffs[i].skbuff)
-@@ -894,8 +893,7 @@
-              * XXX: Not generated if named "hw_ctx" (which is funny because
-              * it's used and works in the template right above this one):
-              */
--            ${e1000::Context} *hw_ctx_;
--            ${cast local.hw_ctx_ as e1000::Context};
-+            ${e1000::Context.ref} hw_ctx_;
-             hw_ctx_ = &${rtx_ether_ctx}->hw_ctx;
+@@ -954,7 +952,7 @@
+     {
+         chunk   ::CALL()
+         {
+-            ${e1000::Context} *hw_ctx;
++            ${e1000::Context.ref} hw_ctx;
+             hw_ctx = &${rtx_ether_ctx}->hw_ctx;
  
              /*
-@@ -911,7 +909,7 @@
-                         ${config.rx_buffer_len},
-                         DMA_FROM_DEVICE);
-                 /* XXX Go through the rtx types (Socket::SKBuff, AbstractSKBuff) */
--                dev_kfree_skb(hw_ctx_->rx_ring.skbuffs[i].skbuff);
-+                dev_kfree_skb((struct sk_buff*)hw_ctx_->rx_ring.skbuffs[i].skbuff);
-             }
-             dma_free_coherent(${rtx_ether_ctx.device}, hw_ctx_->rx_ring.size,
-                     hw_ctx_->rx_ring.base, hw_ctx_->rx_ring.dma_base);
-@@ -973,14 +971,14 @@
+@@ -1031,14 +1029,14 @@
               */
  
              ${Socket::SKBuff} skb;
@@ -263,24 +255,15 @@
              ${local.skb.init(kernel_skb)};
              hw_ctx = &${rtx_ether_ctx}->hw_ctx;
              tx_ring = &hw_ctx->tx_ring;
--            devp = (${Device::AbstractDevice}*)${rtx_ether_ctx.device};
-+            devp = (${Device::AbstractDevice.ref})${rtx_ether_ctx.device};
+-            devp = (${Device::AbstractDevice}*) &${rtx_ether_ctx.device};
++            devp = (${Device::AbstractDevice.ref})&${rtx_ether_ctx.device};
  
              ${Log::info("xmit: skbuff details:")};
              /*
 diff --git a/rathaxes/samples/e1000/ethernet.blt b/rathaxes/samples/e1000/ethernet.blt
 --- a/rathaxes/samples/e1000/ethernet.blt
 +++ b/rathaxes/samples/e1000/ethernet.blt
-@@ -61,7 +61,7 @@
- 
-         method  init(Builtin::symbol dev)
-         {
--            ${self} = (${Ethernet::AbstractDevice} *)${dev};
-+            ${self} = (${Ethernet::AbstractDevice.ref})${dev};
-         }
- 
-         map
-@@ -79,8 +79,8 @@
+@@ -73,8 +73,8 @@
               * I think it's useless to use the ${PCI::AbstractDevice} "abstraction"
               * here, since we already are in a Linux specific context.
               */
@@ -291,24 +274,18 @@
  
              /*
               * In the long-term, this may disappear for a new concept allowing
-@@ -144,14 +144,12 @@
-                  * XXX The casts are here because the compiler doesn't resolve
-                  * "enclosed" type (e.g: local.var.enclosed) correctly.
-                  */
--                ${Ethernet::AbstractDevice} *rtx_net_dev;
--                ${cast local.rtx_net_dev as Ethernet::AbstractDevice};
-+                ${Ethernet::AbstractDevice.ref} rtx_net_dev;
-                 { /* XXX: I end up with a placeholder if I don't open a scope */
-                     ${local.rtx_net_dev.init(local.dev)};
-                 }
+@@ -120,9 +120,8 @@
+         {
+             static int  rtx_ethernet_open(struct net_device *dev)
+             {
+-                ${Ethernet::Device} *rtx_ether_ctx = netdev_priv(dev);
++                ${Ethernet::Device.ref} rtx_ether_ctx = netdev_priv(dev);
  
--                ${Ethernet::Device} *rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx};
 -                ${cast local.rtx_ether_ctx as Ethernet::Device};
-+                ${Ethernet::Device.ref} rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx};
+                 ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx)};
  
-                 int error;
-                 {
-@@ -189,10 +187,8 @@
+                 return 0;
+@@ -141,10 +140,8 @@
          {
              static int  rtx_ethernet_xmit(struct sk_buff* kernel_skb, struct net_device *net_dev)
              {
@@ -321,101 +298,93 @@
  
                  ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx, local.rtx_skb)};
              }
-@@ -210,14 +206,12 @@
+@@ -162,9 +159,8 @@
          {
              static int  rtx_ethernet_close(struct net_device *dev)
              {
--                ${Ethernet::AbstractDevice} *rtx_net_dev;
--                ${cast local.rtx_net_dev as Ethernet::AbstractDevice};
-+                ${Ethernet::AbstractDevice.ref} rtx_net_dev;
-                 { /* XXX: I end up with a placeholder if I don't open a scope */
-                     ${local.rtx_net_dev.init(local.dev)};
-                 }
+-                ${Ethernet::Device} *rtx_ether_ctx = netdev_priv(dev);
++                ${Ethernet::Device.ref} rtx_ether_ctx = netdev_priv(dev);
  
--                ${Ethernet::Device} *rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx};
 -                ${cast local.rtx_ether_ctx as Ethernet::Device};
-+                ${Ethernet::Device.ref} rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx};
+                 ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx)};
  
-                 /* TODO: change this pointcut into a pointcut/adapter/callback: */
-                 {
-@@ -249,11 +243,9 @@
+                 return 0;
+@@ -187,9 +183,8 @@
          {
              static enum irqreturn   rtx_ethernet_interrupt_handler(int irq, void *dev_id)
              {
--                ${Ethernet::AbstractDevice} *rtx_net_dev = dev_id;
--                ${cast local.rtx_net_dev as Ethernet::AbstractDevice};
-+                ${Ethernet::AbstractDevice.ref} rtx_net_dev = dev_id;
+-                ${Ethernet::Device} *rtx_ether_ctx = dev_id;
++                ${Ethernet::Device.ref} rtx_ether_ctx = dev_id;
  
--                ${Ethernet::Device} *rtx_ether_ctx;
 -                ${cast local.rtx_ether_ctx as Ethernet::Device};
-+                ${Ethernet::Device.ref} rtx_ether_ctx;
-                 rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx};
+                 ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx)};
  
-                 ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx)};
-@@ -285,12 +277,11 @@
+                 return IRQ_NONE;
+@@ -219,11 +214,10 @@
           */
          chunk PCI::pci_probe_hook(PCI::Device rtx_pci_dev)
          {
--            ${Ethernet::AbstractDevice} *rtx_net_dev;
 -            ${Ethernet::Device} *rtx_ether_ctx;
--            ${cast local.rtx_net_dev as Ethernet::AbstractDevice};
-+            ${Ethernet::AbstractDevice.ref} rtx_net_dev;
+-            ${Ethernet::AbstractDevice} *net_dev;
+-            ${cast local.net_dev as Ethernet::AbstractDevice};
 +            ${Ethernet::Device.ref} rtx_ether_ctx;
++            ${Ethernet::AbstractDevice.ref} net_dev;
  
-             /* Cast the result back into our "transparent wrapper" type */
--            rtx_net_dev = (${Ethernet::AbstractDevice}*)alloc_etherdev(sizeof(*rtx_ether_ctx));
-+            rtx_net_dev = (${Ethernet::AbstractDevice.ref})alloc_etherdev(sizeof(*rtx_ether_ctx));
-             if (!rtx_net_dev)
+-            net_dev = (${Ethernet::AbstractDevice}*) alloc_etherdev(sizeof(*rtx_ether_ctx));
++            net_dev = (${Ethernet::AbstractDevice.ref})alloc_etherdev(sizeof(*rtx_ether_ctx));
+             if (!net_dev)
              {
                  ${Log::info("cannot allocate the ethernet device context")};
-@@ -317,8 +308,7 @@
-              * type of rtx_pci_dev.pci_device to the type of
-              * rtx_pci_dev instead of the type of rtx_pci_dev.pci_device.
+@@ -252,8 +246,7 @@
+              * I don't open a scope here.
               */
--            ${PCI::AbstractDevice} *workaround = ${rtx_pci_dev.pci_device};
--            ${cast local.workaround as PCI::AbstractDevice};
-+            ${PCI::AbstractDevice.ref} workaround = ${rtx_pci_dev.pci_device};
-             { /* XXX: I end up with a placeholder if I don't open a scope */
-                 ${local.rtx_ether_ctx.init(local.rtx_net_dev, local.workaround)};
+             {
+-                ${PCI::AbstractDevice} *rtx_pdev = ${rtx_pci_dev.pci_device};
+-                ${cast local.rtx_pdev as PCI::AbstractDevice};
++                ${PCI::AbstractDevice.ref} rtx_pdev = ${rtx_pci_dev.pci_device};
+                 ${local.rtx_ether_ctx.init(local.net_dev, local.rtx_pdev)};
              }
-@@ -333,8 +323,7 @@
-              */
-             int bars = ${rtx_pci_dev.bars};
-             unsigned char /* __iomem */ *ioaddr = ${rtx_pci_dev.ioaddr};
--            ${cast local.bars as Builtin::number};
+ 
+@@ -270,7 +263,6 @@
+             int irq = ${rtx_pci_dev.irq};
+             ${cast local.bars as Builtin::number};
+             ${cast local.irq as Builtin::number};
 -            ${cast local.rtx_ether_ctx as Ethernet::Device};
-+            ${cast local.bars as Builtin::number.scalar};
              ${pointcut Ethernet::adapter_init_context(local.rtx_ether_ctx,
                                                        local.bars,
-                                                       local.ioaddr)};
-@@ -359,12 +348,10 @@
+                                                       local.ioaddr,
+@@ -296,13 +288,11 @@
           */
          chunk   PCI::pci_remove_hook(PCI::Device rtx_pci_dev)
          {
--            ${Ethernet::Device} *rtx_ether_ctx = ${rtx_pci_dev.rtx_drv_context};
--            ${cast local.rtx_ether_ctx as Ethernet::Device}; /* XXX */
-+            ${Ethernet::Device.ref} rtx_ether_ctx = ${rtx_pci_dev.rtx_drv_context};
+-            ${Ethernet::Device} *rtx_ether_ctx = ${rtx_pci_dev.context};
+-            ${Ethernet::AbstractDevice} *rtx_ether_dev = (${Ethernet::AbstractDevice}*) ${local.rtx_ether_ctx.net_device};
++            ${Ethernet::Device.ref} rtx_ether_ctx = ${rtx_pci_dev.context};
++            ${Ethernet::AbstractDevice.ref} rtx_ether_dev = (${Ethernet::AbstractDevice.ref})${local.rtx_ether_ctx.net_device};
+ 
              BUG_ON(!rtx_ether_ctx);
  
--            ${Ethernet::AbstractDevice} *rtx_net_dev = ${local.rtx_ether_ctx.net_device};
--            ${cast local.rtx_net_dev as Ethernet::AbstractDevice}; /* XXX */
-+            ${Ethernet::AbstractDevice.ref} rtx_net_dev = ${local.rtx_ether_ctx.net_device};
- 
-             unregister_netdev(${local.rtx_net_dev.k_net_dev});
-             free_netdev(${local.rtx_net_dev.k_net_dev});
+-            ${cast local.rtx_ether_ctx as Ethernet::Device};
+-            ${cast local.rtx_ether_dev as Ethernet::AbstractDevice};
+             unregister_netdev(&${local.rtx_ether_dev.netdev});
+             free_netdev(&${local.rtx_ether_dev.netdev});
+         }
+@@ -313,4 +303,3 @@
+         }
+     }
+ }
+-
 diff --git a/rathaxes/samples/e1000/ethernet.rti b/rathaxes/samples/e1000/ethernet.rti
 --- a/rathaxes/samples/e1000/ethernet.rti
 +++ b/rathaxes/samples/e1000/ethernet.rti
-@@ -41,9 +41,9 @@
+@@ -34,8 +34,8 @@
           * I'd like to use better names here, but I'd like to understand the
           * difference between the two first:
           */
 -        attribute   Builtin::symbol.scalar      perm_addr;
 -        attribute   Builtin::symbol.scalar      dev_addr;
--        attribute   Builtin::symbol.scalar      irq;
-+        attribute   Builtin::symbol.ref        perm_addr;
-+        attribute   Builtin::symbol.ref        dev_addr;
-+        attribute   Builtin::symbol.ref        irq;
++        attribute   Builtin::symbol.ref perm_addr;
++        attribute   Builtin::symbol.ref dev_addr;
      }
  
      required sequence   open(Ethernet::Device)
@@ -449,8 +418,8 @@
                  int error;
 -                ${PCI::AbstractDevice}  *enable_pdev = self->pdev;
 -                ${cast local.enable_pdev as PCI::AbstractDevice};
-+                ${PCI::AbstractDevice.ref}  enable_pdev = self->pdev;
-                 error = pci_enable_device(${local.enable_pdev.k_pci_dev});
++                ${PCI::AbstractDevice.ref} enable_pdev = self->pdev;
+                 error = pci_enable_device(&${local.enable_pdev.data});
                  if (error)
                      return error;
 @@ -62,10 +61,9 @@
@@ -465,7 +434,7 @@
 +                ${PCI::AbstractDevice.ref}  disable_pdev = self->pdev;
                  if (self->ioaddr)
                      iounmap(self->ioaddr);
-                 pci_release_selected_regions(${local.disable_pdev.k_pci_dev}, self->bars);
+                 pci_release_selected_regions(&${local.disable_pdev.data}, self->bars);
 @@ -75,8 +73,7 @@
  
          method  init(PCI::AbstractDevice pdev)
@@ -474,7 +443,7 @@
 -            ${cast local.workaround as PCI::AbstractDevice};
 +            ${PCI::AbstractDevice.ref} workaround = (${PCI::AbstractDevice.ref})pdev;
              ${self}->pdev = ${pdev};
-             ${self}->bars = pci_select_bars(${local.workaround.k_pci_dev}, IORESOURCE_MEM);
+             ${self}->bars = pci_select_bars(&${local.workaround.data}, IORESOURCE_MEM);
              ${self}->ioaddr = NULL;
 @@ -95,8 +92,7 @@
  
@@ -483,7 +452,7 @@
 -            ${PCI::AbstractDevice} *select_ioaddr_pdev = ${self}->pdev;
 -            ${cast local.select_ioaddr_pdev as PCI::AbstractDevice};
 +            ${PCI::AbstractDevice.ref} select_ioaddr_pdev = ${self}->pdev;
-             ${self}->ioaddr = pci_ioremap_bar(${local.select_ioaddr_pdev.k_pci_dev}, ${bar});
+             ${self}->ioaddr = pci_ioremap_bar(&${local.select_ioaddr_pdev.data}, ${bar});
          }
  
 @@ -131,9 +127,8 @@
@@ -517,9 +486,9 @@
              {
 -                ${PCI::AbstractDevice}  *rtx_pdev = (${PCI::AbstractDevice}*)pdev;
 -                ${cast local.rtx_pdev as PCI::AbstractDevice};
--                ${PCI::Device} *rtx_pci_dev = ${rtx_pdev.rtx_pci_ctx};
-+                ${PCI::AbstractDevice.ref}  rtx_pdev = (${PCI::AbstractDevice.ref})pdev;
-+                ${PCI::Device.ref} rtx_pci_dev = ${rtx_pdev.rtx_pci_ctx};
+-                ${PCI::Device} *rtx_pci_dev = ${rtx_pdev.drv_data};
++                ${PCI::AbstractDevice.ref} rtx_pdev = (${PCI::AbstractDevice.ref})pdev;
++                ${PCI::Device.ref} rtx_pci_dev = ${rtx_pdev.drv_data};
  
                  BUG_ON(!rtx_pci_dev);
  
@@ -564,11 +533,11 @@
                   */
 -                ${Socket::AbstractSKBuff}   *skb = self->skbuff;
 -                ${cast local.skb as Socket::AbstractSKBuff};
-+                ${Socket::AbstractSKBuff.ref}   skb = self->skbuff;
-                 ${Ethernet::ProtocolId} ethernet_proto = { .id = be16_to_cpu(${local.skb.k_sk_buff}->protocol) };
- 
++                ${Socket::AbstractSKBuff.ref} skb = self->skbuff;
+                 ${Ethernet::ProtocolId} ethernet_proto = { .id = be16_to_cpu(${local.skb.data}.protocol) };
                  static const char * const ip_summed_values[] = {
-@@ -66,12 +65,11 @@
+                     "none", "unnecessary", "complete", "partial"
+@@ -65,12 +64,11 @@
                  );
              }
  
@@ -581,8 +550,8 @@
 -                ${cast local.skb as Socket::AbstractSKBuff};
 +                ${Socket::AbstractSKBuff.ref}   skb = self->skbuff;
  
-                 WARN_ON(!${local.skb.k_sk_buff});
-                 WARN_ON(self->dma_handle);
+                 WARN_ON(!skb);
+                 WARN_ON(!${local.skb.data}.data);
 @@ -90,12 +88,11 @@
                  return 0;
              }
@@ -596,5 +565,5 @@
 -                ${cast local.skb as Socket::AbstractSKBuff};
 +                ${Socket::AbstractSKBuff.ref}   skb = self->skbuff;
  
-                 WARN_ON(!${local.skb.k_sk_buff});
- 
+                 WARN_ON(!${local.skb});
+                 WARN_ON(!${local.skb.data}.data);
--- a/rathaxes_change_the_abstract_type_notation_in_the_e1000_sample.patch	Sun Mar 24 21:47:39 2013 -0700
+++ b/rathaxes_change_the_abstract_type_notation_in_the_e1000_sample.patch	Sun Mar 31 20:00:09 2013 -0700
@@ -1,5 +1,5 @@
 # HG changeset patch
-# Parent 6122a310f97196aadba20973d9218aa24528bd3d
+# Parent e201e5967e6fdec65fff42256b9a1418bc24b9be
 rathaxes: change the abstract type notation in the e1000 sample
 
 Starting with ra24db32bf134 Rathaxes types are generated differently: you
@@ -63,34 +63,24 @@
 diff --git a/rathaxes/samples/e1000/e1000.blt b/rathaxes/samples/e1000/e1000.blt
 --- a/rathaxes/samples/e1000/e1000.blt
 +++ b/rathaxes/samples/e1000/e1000.blt
-@@ -171,13 +171,17 @@
+@@ -171,8 +171,8 @@
  
-             static int          rtx_e1000_tx_ring_tso_cksum_offload(${e1000::TxRing} *self, ${Socket::SKBuff} *skb)
+             static int          rtx_e1000_tx_ring_tso_cksum_offload(${e1000::TxRing.ref} self, ${Socket::SKBuff.ref} skb)
              {
--                ${Socket::AbstractSKBuff} *abs_skb = skb->skbuff;
--                ${cast local.abs_skb as Socket::AbstractSKBuff};
+-                ${Socket::AbstractSKBuff.ref} abs_skb = skb->skbuff;
 -                return skb_is_gso(&${local.abs_skb.data}) || ${local.abs_skb.data}.ip_summed == CHECKSUM_PARTIAL;
-+                /* XXX We can't use ${skb} here because it's a pointer */
-+                ${Socket::AbstractSKBuff} *k_skb = skb->skbuff;
-+                ${cast local.k_skb as Socket::AbstractSKBuff};
++                ${Socket::AbstractSKBuff.ref} k_skb = skb->skbuff;
 +                return skb_is_gso(${local.k_skb.k_sk_buff}) || ${local.k_skb.k_sk_buff}->ip_summed == CHECKSUM_PARTIAL;
              }
  
-             static void         rtx_e1000_tx_ring_put(${e1000::TxRing} *self, ${Socket::SKBuff} *skb)
-             {
-+                /* XXX We can't use ${skb} here because it's a pointer */
-+                ${Socket::AbstractSKBuff} *k_skb = skb->skbuff;
-+                ${cast local.k_skb as Socket::AbstractSKBuff};
-                 WARN_ON(!skb);
- 
-                 /*
-@@ -188,17 +192,15 @@
+             static void         rtx_e1000_tx_ring_put(${e1000::TxRing.ref} self, ${Socket::SKBuff.ref} skb)
+@@ -187,16 +187,16 @@
                   * code shouldn't be aware of it and use something more
                   * abstract.
                   */
--                ${Socket::AbstractSKBuff} *abs_skb = skb->skbuff;
--                ${cast local.abs_skb as Socket::AbstractSKBuff};
-                 ${e1000::TxDescriptor} *tx_desc = &self->base[self->tail];
+-                ${Socket::AbstractSKBuff.ref} abs_skb = skb->skbuff;
++                ${Socket::AbstractSKBuff.ref} k_skb = skb->skbuff;
+                 ${e1000::TxDescriptor.ref} tx_desc = &self->base[self->tail];
                  tx_desc->lower.data = cpu_to_le32(
                          E1000_TXD_CMD_EOP  |
                          E1000_TXD_CMD_IFCS |
@@ -104,7 +94,7 @@
                  self->tail = (self->tail + 1) % ${config.tx_ring_size};
              }
  
-@@ -733,7 +735,7 @@
+@@ -732,7 +732,7 @@
              hw_ctx->rx_ring.size = ${config.rx_ring_size} * sizeof(*hw_ctx->rx_ring.base);
              hw_ctx->rx_ring.size = ALIGN(hw_ctx->rx_ring.size, 4096);
              hw_ctx->rx_ring.base = dma_alloc_coherent(
@@ -113,22 +103,21 @@
                      hw_ctx->rx_ring.size,
                      &hw_ctx->rx_ring.dma_base,
                      GFP_KERNEL);
-@@ -751,12 +753,10 @@
+@@ -750,11 +750,10 @@
               * Allocate the skbuffs, map them for DMA, and write their address
               * in the corresponding descriptor.
               */
--            ${Ethernet::AbstractDevice} *rtx_ether_dev = ${rtx_ether_ctx.net_device};
--            ${cast local.rtx_ether_dev as Ethernet::AbstractDevice};
+-            ${Ethernet::AbstractDevice.ref} rtx_ether_dev = ${rtx_ether_ctx.net_device};
              for (i = 0; i != ${config.rx_ring_size}; ++i)
              {
--                hw_ctx->rx_ring.skbuffs[i].skbuff = (${Socket::AbstractSKBuff}*)  netdev_alloc_skb(
+-                hw_ctx->rx_ring.skbuffs[i].skbuff = (${Socket::AbstractSKBuff.ref})netdev_alloc_skb(
 -                        &${rtx_ether_dev.netdev},
 +                hw_ctx->rx_ring.skbuffs[i].skbuff = (${Socket::AbstractSKBuff}*)netdev_alloc_skb(
 +                        ${rtx_ether_ctx.net_device.k_net_dev}, /* XXX: .k_net_dev isn't expanded here */
                          ${config.rx_buffer_len});
                  if (!hw_ctx->rx_ring.skbuffs[i].skbuff)
                  {
-@@ -764,11 +764,11 @@
+@@ -762,11 +761,11 @@
                      goto err_skbuffs_alloc;
                  }
                  hw_ctx->rx_ring.skbuffs[i].dma_handle = dma_map_single(
@@ -143,7 +132,7 @@
                          hw_ctx->rx_ring.skbuffs[i].dma_handle);
                  if (dma_error)
                  {
-@@ -820,7 +820,7 @@
+@@ -818,7 +817,7 @@
              hw_ctx->tx_ring.size = ${config.tx_ring_size} * sizeof(*hw_ctx->tx_ring.base);
              hw_ctx->tx_ring.size = ALIGN(hw_ctx->tx_ring.size, 4096);
              hw_ctx->tx_ring.base = dma_alloc_coherent(
@@ -152,7 +141,7 @@
                      hw_ctx->tx_ring.size,
                      &hw_ctx->tx_ring.dma_base,
                      GFP_KERNEL);
-@@ -863,15 +863,16 @@
+@@ -861,15 +860,16 @@
              while (i--)
              {
                  dma_unmap_single(
@@ -172,23 +161,22 @@
                      hw_ctx->rx_ring.base, hw_ctx->rx_ring.dma_base);
          err_rx_ring_alloc:
              return -ENOMEM;
-@@ -889,8 +890,13 @@
+@@ -887,8 +887,12 @@
      {
          chunk   ::CALL()
          {
--            ${e1000::Context} *hw_ctx;
+-            ${e1000::Context.ref} hw_ctx;
 -            hw_ctx = &${rtx_ether_ctx}->hw_ctx;
 +            /*
 +             * XXX: Not generated if named "hw_ctx" (which is funny because
 +             * it's used and works in the template right above this one):
 +             */
-+            ${e1000::Context} *hw_ctx_;
-+            ${cast local.hw_ctx_ as e1000::Context};
++            ${e1000::Context.ref} hw_ctx_;
 +            hw_ctx_ = &${rtx_ether_ctx}->hw_ctx;
  
              /*
               * Free the rx ring:
-@@ -900,22 +906,23 @@
+@@ -898,22 +902,26 @@
              for (int i = 0; i != ${config.rx_ring_size}; ++i)
              {
                  dma_unmap_single(
@@ -199,8 +187,11 @@
                          ${config.rx_buffer_len},
                          DMA_FROM_DEVICE);
 -                dev_kfree_skb(&hw_ctx->rx_ring.skbuffs[i].skbuff->data);
-+                /* XXX Go through the rtx types (Socket::SKBuff, AbstractSKBuff) */
-+                dev_kfree_skb(hw_ctx_->rx_ring.skbuffs[i].skbuff);
++                /* XXX Leaking cast
++                 * (We should go through the rtx types (Socket::SKBuff,
++                 * AbstractSKBuff)
++                 */
++                dev_kfree_skb((struct sk_buff *)hw_ctx_->rx_ring.skbuffs[i].skbuff);
              }
 -            dma_free_coherent(&${rtx_ether_ctx.device}, hw_ctx->rx_ring.size,
 -                    hw_ctx->rx_ring.base, hw_ctx->rx_ring.dma_base);
@@ -219,12 +210,12 @@
              ${Log::info("free_rx_tx: tx ring free'ed")};
          }
      }
-@@ -973,13 +980,13 @@
+@@ -971,13 +979,13 @@
              ${local.skb.init(kernel_skb)};
              hw_ctx = &${rtx_ether_ctx}->hw_ctx;
              tx_ring = &hw_ctx->tx_ring;
--            devp = (${Device::AbstractDevice}*) &${rtx_ether_ctx.device};
-+            devp = (${Device::AbstractDevice}*)${rtx_ether_ctx.device};
+-            devp = (${Device::AbstractDevice.ref})&${rtx_ether_ctx.device};
++            devp = (${Device::AbstractDevice.ref})${rtx_ether_ctx.device};
  
              ${Log::info("xmit: skbuff details:")};
              /*
@@ -237,7 +228,7 @@
               */
              /*
               * XXX: doesn't work (I tried to pass self explicitely too):
-@@ -1012,8 +1019,8 @@
+@@ -1010,8 +1018,8 @@
  
              /* 2. Map the data */
  
@@ -248,7 +239,7 @@
              {
                  ${Log::info("xmit: can't DMA map a SKbuff")};
                  goto err_skb_map_to;
-@@ -1032,7 +1039,7 @@
+@@ -1030,7 +1038,7 @@
          err_offload:
          err_skb_map_to:
              /* XXX: ${local.skb.unmap_to_and_free(local.dev)}; */
@@ -329,62 +320,48 @@
          }
      }
  
-@@ -128,8 +141,17 @@
+@@ -128,7 +141,15 @@
          {
              static int  rtx_ethernet_open(struct net_device *dev)
              {
--                ${Ethernet::Device} *rtx_ether_ctx = netdev_priv(dev);
+-                ${Ethernet::Device.ref} rtx_ether_ctx = netdev_priv(dev);
 +                /*
 +                 * XXX The casts are here because the compiler doesn't resolve
 +                 * "enclosed" type (e.g: local.var.enclosed) correctly.
 +                 */
-+                ${Ethernet::AbstractDevice} *rtx_net_dev;
-+                ${cast local.rtx_net_dev as Ethernet::AbstractDevice};
++                ${Ethernet::AbstractDevice.ref} rtx_net_dev;
 +                { /* XXX: I end up with a placeholder if I don't open a scope */
 +                    ${local.rtx_net_dev.init(local.dev)};
 +                }
- 
-+                ${Ethernet::Device} *rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx};
-                 ${cast local.rtx_ether_ctx as Ethernet::Device};
++                ${Ethernet::Device.ref} rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx};
  
                  int error;
-@@ -189,8 +211,13 @@
+                 {
+@@ -181,7 +202,12 @@
          {
              static int  rtx_ethernet_close(struct net_device *dev)
              {
--                ${Ethernet::Device} *rtx_ether_ctx = netdev_priv(dev);
-+                ${Ethernet::AbstractDevice} *rtx_net_dev;
-+                ${cast local.rtx_net_dev as Ethernet::AbstractDevice};
+-                ${Ethernet::Device.ref} rtx_ether_ctx = netdev_priv(dev);
++                ${Ethernet::AbstractDevice.ref} rtx_net_dev;
 +                { /* XXX: I end up with a placeholder if I don't open a scope */
 +                    ${local.rtx_net_dev.init(local.dev)};
 +                }
- 
-+                ${Ethernet::Device} *rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx};
-                 ${cast local.rtx_ether_ctx as Ethernet::Device};
++
++                ${Ethernet::Device.ref} rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx};
  
                  /* TODO: change this pointcut into a pointcut/adapter/callback: */
-@@ -225,6 +252,7 @@
-             {
-                 ${Ethernet::AbstractDevice} *rtx_net_dev = dev_id;
-                 ${cast local.rtx_net_dev as Ethernet::AbstractDevice};
-+
-                 ${Ethernet::Device} *rtx_ether_ctx;
-                 ${cast local.rtx_ether_ctx as Ethernet::Device};
-                 rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx};
-@@ -258,23 +286,26 @@
+                 {
+@@ -246,22 +272,24 @@
           */
          chunk PCI::pci_probe_hook(PCI::Device rtx_pci_dev)
          {
-+            ${Ethernet::AbstractDevice} *rtx_net_dev;
-             ${Ethernet::Device} *rtx_ether_ctx;
--            ${Ethernet::AbstractDevice} *net_dev;
--            ${cast local.net_dev as Ethernet::AbstractDevice};
-+            ${cast local.rtx_net_dev as Ethernet::AbstractDevice};
++            ${Ethernet::AbstractDevice.ref} rtx_net_dev;
+             ${Ethernet::Device.ref} rtx_ether_ctx;
+-            ${Ethernet::AbstractDevice.ref} net_dev;
  
--            net_dev = (${Ethernet::AbstractDevice}*) alloc_etherdev(sizeof(*rtx_ether_ctx));
+-            net_dev = (${Ethernet::AbstractDevice.ref})alloc_etherdev(sizeof(*rtx_ether_ctx));
 -            if (!net_dev)
-+            /* Cast the result back into our "transparent wrapper" type */
-+            rtx_net_dev = (${Ethernet::AbstractDevice}*)alloc_etherdev(sizeof(*rtx_ether_ctx));
++            rtx_net_dev = (${Ethernet::AbstractDevice.ref})alloc_etherdev(sizeof(*rtx_ether_ctx));
 +            if (!rtx_net_dev)
              {
                  ${Log::info("cannot allocate the ethernet device context")};
@@ -407,7 +384,7 @@
              if (error)
              {
                  ${Log::info("cannot register the driver in the net subsystem")};
-@@ -286,14 +317,11 @@
+@@ -273,13 +301,11 @@
               * XXX: the cast is here because the compiler resolve the
               * type of rtx_pci_dev.pci_device to the type of
               * rtx_pci_dev instead of the type of rtx_pci_dev.pci_device.
@@ -416,17 +393,16 @@
 -             * I don't open a scope here.
               */
 -            {
--                ${PCI::AbstractDevice} *rtx_pdev = ${rtx_pci_dev.pci_device};
--                ${cast local.rtx_pdev as PCI::AbstractDevice};
+-                ${PCI::AbstractDevice.ref} rtx_pdev = ${rtx_pci_dev.pci_device};
 -                ${local.rtx_ether_ctx.init(local.net_dev, local.rtx_pdev)};
-+            ${PCI::AbstractDevice} *workaround = ${rtx_pci_dev.pci_device};
++            ${PCI::AbstractDevice.ref} workaround = ${rtx_pci_dev.pci_device};
 +            ${cast local.workaround as PCI::AbstractDevice};
 +            { /* XXX: I end up with a placeholder if I don't open a scope */
 +                ${local.rtx_ether_ctx.init(local.rtx_net_dev, local.workaround)};
              }
  
              /* Register ourselves in the parent context: */
-@@ -315,7 +343,7 @@
+@@ -300,7 +326,7 @@
              ${pointcut Ethernet::adapter_load_mac_address(local.rtx_ether_ctx)};
              memcpy(${local.rtx_ether_ctx.perm_addr},
                     ${local.rtx_ether_ctx.dev_addr},
@@ -435,24 +411,19 @@
          }
  
          /* This chunk should be removed (see #26) */
-@@ -332,15 +360,15 @@
+@@ -317,13 +343,12 @@
           */
          chunk   PCI::pci_remove_hook(PCI::Device rtx_pci_dev)
          {
--            ${Ethernet::Device} *rtx_ether_ctx = ${rtx_pci_dev.context};
--            ${Ethernet::AbstractDevice} *rtx_ether_dev = (${Ethernet::AbstractDevice}*) ${local.rtx_ether_ctx.net_device};
+-            ${Ethernet::Device.ref} rtx_ether_ctx = ${rtx_pci_dev.context};
+-            ${Ethernet::AbstractDevice.ref} rtx_ether_dev = (${Ethernet::AbstractDevice.ref})${local.rtx_ether_ctx.net_device};
 -
-+            ${Ethernet::Device} *rtx_ether_ctx = ${rtx_pci_dev.rtx_drv_context};
-+            ${cast local.rtx_ether_ctx as Ethernet::Device}; /* XXX */
++            ${Ethernet::Device.ref} rtx_ether_ctx = ${rtx_pci_dev.rtx_drv_context};
              BUG_ON(!rtx_ether_ctx);
  
--            ${cast local.rtx_ether_ctx as Ethernet::Device};
--            ${cast local.rtx_ether_dev as Ethernet::AbstractDevice};
 -            unregister_netdev(&${local.rtx_ether_dev.netdev});
 -            free_netdev(&${local.rtx_ether_dev.netdev});
-+            ${Ethernet::AbstractDevice} *rtx_net_dev = ${local.rtx_ether_ctx.net_device};
-+            ${cast local.rtx_net_dev as Ethernet::AbstractDevice}; /* XXX */
-+
++            ${Ethernet::AbstractDevice.ref} rtx_net_dev = ${local.rtx_ether_ctx.net_device};
 +            unregister_netdev(${local.rtx_net_dev.k_net_dev});
 +            free_netdev(${local.rtx_net_dev.k_net_dev});
          }
@@ -473,7 +444,7 @@
           * XXX: should be a Ethernet::Device, but that causes a circular
           * dependency:
           */
--        attribute   Builtin::symbol rtx_ether_ctx;
+-        attribute   Builtin::symbol.scalar rtx_ether_ctx;
 +        attribute   Builtin::symbol.scalar  rtx_ether_ctx;
      }
  
@@ -501,10 +472,10 @@
          }
      }
  
-@@ -52,13 +52,13 @@
+@@ -51,13 +51,13 @@
+             {
                  int error;
-                 ${PCI::AbstractDevice}  *enable_pdev = self->pdev;
-                 ${cast local.enable_pdev as PCI::AbstractDevice};
+                 ${PCI::AbstractDevice.ref} enable_pdev = self->pdev;
 -                error = pci_enable_device(&${local.enable_pdev.data});
 +                error = pci_enable_device(${local.enable_pdev.k_pci_dev});
                  if (error)
@@ -518,8 +489,8 @@
                  return 0;
              }
  
-@@ -68,8 +68,8 @@
-                 ${cast local.disable_pdev as PCI::AbstractDevice};
+@@ -66,8 +66,8 @@
+                 ${PCI::AbstractDevice.ref}  disable_pdev = self->pdev;
                  if (self->ioaddr)
                      iounmap(self->ioaddr);
 -                pci_release_selected_regions(&${local.disable_pdev.data}, self->bars);
@@ -529,19 +500,19 @@
              }
          }
  
-@@ -78,7 +78,7 @@
-             ${PCI::AbstractDevice} * workaround = (${PCI::AbstractDevice}*)pdev;
-             ${cast local.workaround as PCI::AbstractDevice};
+@@ -75,7 +75,7 @@
+         {
+             ${PCI::AbstractDevice.ref} workaround = (${PCI::AbstractDevice.ref})pdev;
              ${self}->pdev = ${pdev};
 -            ${self}->bars = pci_select_bars(&${local.workaround.data}, IORESOURCE_MEM);
 +            ${self}->bars = pci_select_bars(${local.workaround.k_pci_dev}, IORESOURCE_MEM);
              ${self}->ioaddr = NULL;
              ${self}->context = NULL;
          }
-@@ -97,20 +97,20 @@
+@@ -93,20 +93,20 @@
+         method  select_ioaddr(Builtin::number bar)
          {
-             ${PCI::AbstractDevice} *select_ioaddr_pdev = ${self}->pdev;
-             ${cast local.select_ioaddr_pdev as PCI::AbstractDevice};
+             ${PCI::AbstractDevice.ref} select_ioaddr_pdev = ${self}->pdev;
 -            ${self}->ioaddr = pci_ioremap_bar(&${local.select_ioaddr_pdev.data}, ${bar});
 +            ${self}->ioaddr = pci_ioremap_bar(${local.select_ioaddr_pdev.k_pci_dev}, ${bar});
          }
@@ -564,7 +535,7 @@
              bars: ${self}->bars;
              ioaddr: ${self}->ioaddr;
              BAR_0: 0;
-@@ -151,7 +151,7 @@
+@@ -146,7 +146,7 @@
                      ${local.rtx_pci_dev.init(local.rtx_pdev)};
                  }
  
@@ -573,7 +544,7 @@
                  pci_set_drvdata(pdev, rtx_pci_dev);
  
                  /* ${local.rtx_pci_dev.enable()}; */
-@@ -184,7 +184,7 @@
+@@ -173,7 +173,7 @@
                  return 0;
  
              fail:
@@ -582,15 +553,16 @@
                  pci_set_drvdata(pdev, NULL);
                  kfree(rtx_pci_dev);
                  return error;
-@@ -210,7 +210,7 @@
+@@ -198,8 +198,7 @@
+             static void rtx_pci_remove(struct pci_dev *pdev)
              {
-                 ${PCI::AbstractDevice}  *rtx_pdev = (${PCI::AbstractDevice}*)pdev;
-                 ${cast local.rtx_pdev as PCI::AbstractDevice};
--                ${PCI::Device} *rtx_pci_dev = ${rtx_pdev.drv_data};
-+                ${PCI::Device} *rtx_pci_dev = ${rtx_pdev.rtx_pci_ctx};
- 
+                 ${PCI::AbstractDevice.ref} rtx_pdev = (${PCI::AbstractDevice.ref})pdev;
+-                ${PCI::Device.ref} rtx_pci_dev = ${rtx_pdev.drv_data};
+-
++                ${PCI::Device.ref} rtx_pci_dev = ${rtx_pdev.rtx_pci_ctx};
                  BUG_ON(!rtx_pci_dev);
  
+                 ${pointcut PCI::pci_remove_hook(local.rtx_pci_dev)};
 diff --git a/rathaxes/samples/e1000/pci.rti b/rathaxes/samples/e1000/pci.rti
 --- a/rathaxes/samples/e1000/pci.rti
 +++ b/rathaxes/samples/e1000/pci.rti
@@ -639,13 +611,12 @@
          }
      }
  
-@@ -46,11 +46,12 @@
+@@ -45,11 +45,11 @@
+                  * arguments yet.
                   */
-                 ${Socket::AbstractSKBuff}   *skb = self->skbuff;
-                 ${cast local.skb as Socket::AbstractSKBuff};
+                 ${Socket::AbstractSKBuff.ref} skb = self->skbuff;
 -                ${Ethernet::ProtocolId} ethernet_proto = { .id = be16_to_cpu(${local.skb.data}.protocol) };
 +                ${Ethernet::ProtocolId} ethernet_proto = { .id = be16_to_cpu(${local.skb.k_sk_buff}->protocol) };
-+
                  static const char * const ip_summed_values[] = {
                      "none", "unnecessary", "complete", "partial"
                  };
@@ -654,7 +625,7 @@
  
                  pr_info(
                          "\t protocol = %#-5x (%s) ip_summed = %d (%s)\n"
-@@ -59,8 +60,8 @@
+@@ -58,8 +58,8 @@
                          "\t gso_size = %-5u gso_segs = %-5u gso_type = %-5u",
                          /* XXX: can't use ${local.ethernet_proto.id} here (issue #52): */
                          ethernet_proto.id, ${local.ethernet_proto.str},
@@ -665,9 +636,9 @@
                          shinfo->nr_frags, shinfo->gso_size, shinfo->gso_segs, shinfo->gso_type
                  );
              }
-@@ -72,14 +73,13 @@
-                 ${Socket::AbstractSKBuff}   *skb = self->skbuff;
-                 ${cast local.skb as Socket::AbstractSKBuff};
+@@ -70,14 +70,13 @@
+             {
+                 ${Socket::AbstractSKBuff.ref}   skb = self->skbuff;
  
 -                WARN_ON(!skb);
 -                WARN_ON(!${local.skb.data}.data);
@@ -683,9 +654,9 @@
                          direction);
                  int err = dma_mapping_error(dev, self->dma_handle);
                  if (err)
-@@ -97,18 +97,17 @@
-                 ${Socket::AbstractSKBuff}   *skb = self->skbuff;
-                 ${cast local.skb as Socket::AbstractSKBuff};
+@@ -94,18 +93,17 @@
+             {
+                 ${Socket::AbstractSKBuff.ref}   skb = self->skbuff;
  
 -                WARN_ON(!${local.skb});
 -                WARN_ON(!${local.skb.data}.data);
@@ -705,7 +676,7 @@
                  self->skbuff = 0;
              }
          }
-@@ -131,22 +130,22 @@
+@@ -128,22 +126,22 @@
  
          method   map_to(Device::AbstractDevice dev)
          {
--- a/rathaxes_e1000_move_the_interrupt_init_and_cleanup_into_ethernet.patch	Sun Mar 24 21:47:39 2013 -0700
+++ b/rathaxes_e1000_move_the_interrupt_init_and_cleanup_into_ethernet.patch	Sun Mar 31 20:00:09 2013 -0700
@@ -1,5 +1,5 @@
 # HG changeset patch
-# Parent a611642de7f291e4749a7f44027f9ebaa0cde75c
+# Parent 7be52c02870a053b3a12e75423226c252e256c6b
 Move the interrupt handler init/cleanup out of e1000.blt
 
 This is not device dependant and can be done from the Ethernet subsystem
@@ -9,7 +9,7 @@
 diff --git a/rathaxes/samples/e1000/e1000.blt b/rathaxes/samples/e1000/e1000.blt
 --- a/rathaxes/samples/e1000/e1000.blt
 +++ b/rathaxes/samples/e1000/e1000.blt
-@@ -249,7 +249,6 @@
+@@ -247,7 +247,6 @@
          {
              int                         bars;
              unsigned char /* __iomem */ *ioaddr;
@@ -17,7 +17,7 @@
  
              ${e1000::RxRing}    rx_ring;
              ${e1000::TxRing}    tx_ring;
-@@ -267,14 +266,12 @@
+@@ -265,14 +264,12 @@
  
          chunk   Ethernet::adapter_init_context(Ethernet::Device rtx_ether_ctx,
                                                 Builtin::number bars,
@@ -26,14 +26,14 @@
 +                                               Builtin::symbol ioaddr)
          {
              {
-                 ${e1000::Context} *hw_ctx = &${rtx_ether_ctx}->hw_ctx;
+                 ${e1000::Context.ref} hw_ctx = &${rtx_ether_ctx}->hw_ctx;
                  hw_ctx->bars = ${bars};
                  hw_ctx->ioaddr = ${ioaddr};
 -                hw_ctx->irq = ${irq};
              }
          }
  
-@@ -606,68 +603,6 @@
+@@ -605,68 +602,6 @@
          }
      }
  
@@ -175,11 +175,10 @@
          chunk LKM::prototypes()
          {
              static int  rtx_ethernet_open(struct net_device *);
-@@ -123,9 +131,28 @@
-                 ${Ethernet::Device} *rtx_ether_ctx = netdev_priv(dev);
+@@ -122,6 +130,20 @@
+             {
+                 ${Ethernet::Device.ref} rtx_ether_ctx = netdev_priv(dev);
  
-                 ${cast local.rtx_ether_ctx as Ethernet::Device};
-+
 +                int error;
 +                {
 +                    ${Log::info("installing the interrupt handler")};
@@ -192,24 +191,16 @@
 +                if (error)
 +                {
 +                    ${Log::info("Cannot register the interrupt handler")};
-+                    goto error;
++                    return error;
 +                }
-+
                  ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx)};
  
                  return 0;
-+
-+            error:
-+                return error;
-             }
-         }
-     }
-@@ -165,7 +192,16 @@
-                 ${Ethernet::Device} *rtx_ether_ctx = netdev_priv(dev);
+@@ -161,7 +183,15 @@
+             {
+                 ${Ethernet::Device.ref} rtx_ether_ctx = netdev_priv(dev);
  
-                 ${cast local.rtx_ether_ctx as Ethernet::Device};
 -                ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx)};
-+
 +                /* TODO: change this pointcut into a pointcut/adapter/callback: */
 +                {
 +                    ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx)};
@@ -222,29 +213,24 @@
  
                  return 0;
              }
-@@ -187,9 +223,12 @@
+@@ -183,7 +213,9 @@
          {
              static enum irqreturn   rtx_ethernet_interrupt_handler(int irq, void *dev_id)
              {
--                ${Ethernet::Device} *rtx_ether_ctx = dev_id;
-+                ${Ethernet::AbstractDevice} *rtx_net_dev = dev_id;
-+                ${cast local.rtx_net_dev as Ethernet::AbstractDevice};
-+                ${Ethernet::Device} *rtx_ether_ctx;
-+                ${cast local.rtx_ether_ctx as Ethernet::Device};
+-                ${Ethernet::Device.ref} rtx_ether_ctx = dev_id;
++                ${Ethernet::AbstractDevice.ref} rtx_net_dev = dev_id;
++                ${Ethernet::Device.ref} rtx_ether_ctx;
 +                rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx};
  
--                ${cast local.rtx_ether_ctx as Ethernet::Device};
                  ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx)};
  
-                 return IRQ_NONE;
-@@ -267,14 +306,11 @@
+@@ -260,13 +292,10 @@
               */
              int bars = ${rtx_pci_dev.bars};
              unsigned char /* __iomem */ *ioaddr = ${rtx_pci_dev.ioaddr};
 -            int irq = ${rtx_pci_dev.irq};
              ${cast local.bars as Builtin::number};
 -            ${cast local.irq as Builtin::number};
-             ${cast local.rtx_ether_ctx as Ethernet::Device};
              ${pointcut Ethernet::adapter_init_context(local.rtx_ether_ctx,
                                                        local.bars,
 -                                                      local.ioaddr,
@@ -264,15 +250,19 @@
 +         * XXX: should be a Ethernet::Device, but that causes a circular
 +         * dependency:
 +         */
-+        attribute   Builtin::symbol rtx_ether_ctx;
++        attribute   Builtin::symbol.scalar rtx_ether_ctx;
      }
  
      provided type   Device
-@@ -36,10 +41,12 @@
+@@ -34,12 +39,14 @@
+          * I'd like to use better names here, but I'd like to understand the
+          * difference between the two first:
           */
-         attribute   Builtin::symbol.scalar      perm_addr;
-         attribute   Builtin::symbol.scalar      dev_addr;
-+        attribute   Builtin::symbol.scalar      irq;
+-        attribute   Builtin::symbol.ref perm_addr;
+-        attribute   Builtin::symbol.ref dev_addr;
++        attribute   Builtin::symbol.ref     perm_addr;
++        attribute   Builtin::symbol.ref     dev_addr;
++        attribute   Builtin::symbol.scalar  irq;
      }
  
      required sequence   open(Ethernet::Device)
--- a/series	Sun Mar 24 21:47:39 2013 -0700
+++ b/series	Sun Mar 31 20:00:09 2013 -0700
@@ -1,8 +1,8 @@
 maintainers_fix_indentation_in_use_rathaxes.patch
-rathaxes_e1000_move_the_interrupt_init_and_cleanup_into_ethernet.patch
-rathaxes_change_the_abstract_type_notation_in_the_e1000_sample.patch
 FixScalarRefCasts
 FixScalarRefPlaceholders
 FixScalarRefUnstrictBug
 FixRecursiveTypeFieldResolution
 E1000_UpdateToScalarRef
+rathaxes_e1000_move_the_interrupt_init_and_cleanup_into_ethernet.patch
+rathaxes_change_the_abstract_type_notation_in_the_e1000_sample.patch