changeset 136:8229a46ec658

Wip, it generates now…
author Louis Opter <louis@lse.epita.fr>
date Sun, 12 Jan 2014 18:33:09 -0800
parents 9c6ae3a2e180
children 8bbdb488f6fe
files rathaxes_sample_e1000_rewrite_device_dependent_code.patch
diffstat 1 files changed, 32 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/rathaxes_sample_e1000_rewrite_device_dependent_code.patch	Sat Jan 11 18:42:05 2014 -0800
+++ b/rathaxes_sample_e1000_rewrite_device_dependent_code.patch	Sun Jan 12 18:33:09 2014 -0800
@@ -1,5 +1,5 @@
 # HG changeset patch
-# Parent 53d3ca9da9c4cd680cf5982b9e972903fb4d3231
+# Parent 1229971cfa561a1c788a407620ce545eac7d0141
 rathaxes: rewrite/refactor all the e1000 device dependent code
 
 diff --git a/notes.txt b/notes.txt
@@ -59,20 +59,6 @@
          if (rtxIntrospect_InferPlaceHolderTypes<placeHolder.node.body.type>(placeHolder.node.body, local_node) == false)
          {
              pushItem to_remove;
-diff --git a/rathaxes/compiler/passes/back/rtxPlaceHolders.inc.cws b/rathaxes/compiler/passes/back/rtxPlaceHolders.inc.cws
---- a/rathaxes/compiler/passes/back/rtxPlaceHolders.inc.cws
-+++ b/rathaxes/compiler/passes/back/rtxPlaceHolders.inc.cws
-@@ -394,7 +394,10 @@
-                 { rtxPH_mapPlaceHolder(local_node.expr.id, compile, node_idx, "target_pointcut"); }
-             }
-             else
-+            {
-+                traceLine(CYAN + "LOUIS: local_node.expr: " + toString(local_node.expr) + DEFAULT_COLOR);
-                 rtxPH_compile<local_node.expr.type>(local_node.expr, compile, node_idx);
-+            }
-         }
-         // Label
-         if (existVariable(local_node.label) && rtxPH_havePlaceHolder(local_node.label))
 diff --git a/rathaxes/samples/e1000/CMakeLists.txt b/rathaxes/samples/e1000/CMakeLists.txt
 --- a/rathaxes/samples/e1000/CMakeLists.txt
 +++ b/rathaxes/samples/e1000/CMakeLists.txt
@@ -696,7 +682,7 @@
          {
              E1000_TXD_DTYP_D        = 0x00100000, /* Data Descriptor */
              E1000_TXD_DTYP_C        = 0x00000000, /* Context Descriptor */
-@@ -701,326 +140,687 @@
+@@ -701,326 +140,700 @@
          }
      }
  
@@ -785,9 +771,8 @@
 +            unsigned char           *io_addr;
 +            // XXX Forced to hardcode the type because there is a circular
 +            // dependency between the rings and the context.
-+            // TODO: get the right generated types:
-+            int                     tx_ring;
-+            int                     rx_ring;
++            rtxType_e1000_TxRing    tx_ring;
++            rtxType_e1000_RxRing    rx_ring;
 +        }
 +
 +        chunk LKM::includes()
@@ -902,8 +887,18 @@
 +                // XXX doesn't work: ${local.hw_ctx.init(rtx_ether_ctx, io_addr)};
 +                ${local.hw_ctx.net_dev} = ${rtx_ether_ctx};
 +                ${local.hw_ctx.io_addr} = ${io_addr};
-+                ${local.hw_ctx.rx_ring.init(local.hw_ctx, config.rx_ring_size)};
-+                ${local.hw_ctx.tx_ring.init(local.hw_ctx, config.tx_ring_size)};
++                // XXX doesn't work: ${local.hw_ctx.rx_ring.init(local.hw_ctx, config.rx_ring_size)};
++                rtx_e1000_ring_init(
++                    &${local.hw_ctx.rx_ring},
++                    ${config.rx_ring_size},
++                    sizeof(rtxType_e1000_RxDescriptor)
++                );
++                // XXX doesn't work: ${local.hw_ctx.tx_ring.init(local.hw_ctx, config.tx_ring_size)};
++                rtx_e1000_ring_init(
++                    &${local.hw_ctx.tx_ring},
++                    ${config.tx_ring_size},
++                    sizeof(rtxType_e1000_TxDescriptor)
++                );
 +            }
 +        }
 +
@@ -974,8 +969,10 @@
 +                rtx_e1000_reg_write32(hw_ctx, E1000_FCAL, 0);
 +                rtx_e1000_reg_write32(hw_ctx, E1000_FCT, 0);
 +                rtx_e1000_reg_write32(hw_ctx, E1000_FCTTV, 0);
-+                for (int i = 0; i != 64; ++i)
-+                    rtx_e1000_reg_write32(hw_ctx, E1000_CRCERRS + i * 4, 0);
++                // XXX int i leaks from another chunk and will not be generated
++                // here, let's use a different index name:
++                for (int j = 0; j != 64; ++j)
++                    rtx_e1000_reg_write32(hw_ctx, E1000_CRCERRS + j * 4, 0);
 +
 +                ${Log::info("adapter_setup_rx_tx: general configuration done")};
 +
@@ -1000,7 +997,7 @@
 +            }
 +        }
 +
-+        chunk Ethernet::adapter_enable_interrupts(Ethernet::Device)
++        chunk Ethernet::adapter_enable_interrupts(Ethernet::Device rtx_ether_ctx)
 +        {
 +            {
 +                ${e1000::Context.ref} hw_ctx = &${rtx_ether_ctx}->hw_ctx;
@@ -1079,7 +1076,7 @@
 +
 +        map
 +        {
-+            io_addr: ${self}->io;
++            io_addr: ${self}->io_addr;
 +            rx_ring: ${self}->rx_ring;
 +            tx_ring: ${self}->tx_ring;
 +            net_dev: ${self}->net_dev;
@@ -1236,9 +1233,11 @@
 +                    dev_kfree_skb((struct sk_buff *)hw_ctx->rx_ring.skbuffs[i].skbuff);
 +                }
 +
++                void *descs = ${local.self.descs};
++                ${cast local.descs as Builtin::symbol.ref};
 +                ${DMA::free_coherent(
 +                    local.self.hw_ctx.net_dev.device, local.self.size,
-+                    local.self.descs, local.self.dma.dma_handle
++                    local.descs, local.self.dma.dma_handle
 +                )};
 +            err_rx_ring_alloc:
 +                return -ENOMEM;
@@ -1640,7 +1639,7 @@
 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti
 --- a/rathaxes/samples/e1000/e1000.rti
 +++ b/rathaxes/samples/e1000/e1000.rti
-@@ -1,157 +1,123 @@
+@@ -1,157 +1,125 @@
 -interface e1000 : Socket, Ethernet, DMA, PCI, LKM, Builtin
 +interface e1000 : Socket, Ethernet, Device, DMA, PCI, LKM, Builtin
  {
@@ -1706,8 +1705,10 @@
 +        method      reg_unset32(Register, Builtin::number);
 +
 +        // XXX: Circular dependency with the rings, this will prevent us to
-+        // call methods even when issue $46 is resolved, and it also forces
-+        // us to hardcode generated types in the definition of the type:
++        // call methods even when issue $46 is resolved, it also forces us to
++        // hardcode generated types in the definition of the type, and they
++        // can't be "dereferenced" (e.g: local.hw_ctx.rx_ring.desc_size can't
++        // work since local.hw_ctx.rx_ring is just going to be a symbol).
 +        attribute   Builtin::symbol.scalar  rx_ring;
 +        attribute   Builtin::symbol.scalar  tx_ring;
 +        attribute   Builtin::symbol.scalar  io_addr;
@@ -1774,7 +1775,7 @@
 -        attribute   RxRing.scalar   rx_ring;
 -        /* XXX: circular dependency with Contex: */
 -        //attribute   TxRing.scalar   tx_ring;
-+        attribute   RxDescriptor.scalar     descs;
++        attribute   RxDescriptor.ref        descs;
 +        attribute   Builtin::number.scalar  desc_size;
 +        attribute   Buffer.ref              buffs;
      }
@@ -1890,7 +1891,7 @@
 +        attribute   Context.ref             hw_ctx;
 +        attribute   DMA::DMAHandle.scalar   dma;
 +        attribute   Builtin::number.scalar  size;
-+        attribute   TxDescriptor.scalar     descs;
++        attribute   TxDescriptor.ref        descs;
 +        attribute   Builtin::number.scalar  desc_size;
 +        attribute   Buffer.ref              buffs;
      }