changeset 113:b22983cb9e3a

WIP, thanks joa for some fixes on the compiler
author Louis Opter <louis@lse.epita.fr>
date Sat, 20 Jul 2013 20:45:39 -0700
parents bfe10def90e3
children 8eac160e5f1c
files rathaxes_compiler_passes_correctly_resolve_all_variables_subidentifiers.patch rathaxes_samples_e1000_add_alloc_sequences_in_socket.patch rathaxes_samples_e1000_use_the_dma_abstraction_in_socket.patch series
diffstat 4 files changed, 181 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rathaxes_compiler_passes_correctly_resolve_all_variables_subidentifiers.patch	Sat Jul 20 20:45:39 2013 -0700
@@ -0,0 +1,55 @@
+# HG changeset patch
+# User David Pineau <dav.pineau@gmail.com>, Louis Opter <louis@lse.epita.fr>
+# Parent 0f12e80e810de1a9927db1f25dbea49acd73ae3c
+rathxes: correctly resolve all variable subidentifier
+
+For example, for a variable like "local.sk_buff.k_dma_handle" type
+introspection won't stop at "local.sk_buff" anymore but go all the way
+down "local.sk_buff.k_dma_handle" which means that the expression will
+yield the correct type.
+
+diff --git a/rathaxes/compiler/passes/back/rtxIntrospect.inc.cws b/rathaxes/compiler/passes/back/rtxIntrospect.inc.cws
+--- a/rathaxes/compiler/passes/back/rtxIntrospect.inc.cws
++++ b/rathaxes/compiler/passes/back/rtxIntrospect.inc.cws
+@@ -752,7 +752,28 @@
+             if (findElement(theVar.name, theChunk.type_map))
+                 ref theType = theChunk.type_map[theVar.name];
+             insert param.rtype;
+-            setall param.rtype = theType;
++            if (getArraySize(param.identifiers) > 2)
++            {
++                local subType;
++                local fieldList;
++                foreach field in param.identifiers
++                {
++                    pushItem fieldList;
++                    fieldList#back = field.name;
++                }
++                removeFirstElement(fieldList);
++                removeFirstElement(fieldList);
++                if (rtxTypingLookup_ResolveTypeFields(theType, fieldList, theChunk, theChunk#root /* XXX dummy */, subType) == false)
++                {
++                    error(RED + "[Error] Could not resolve type fields for variable '"
++                          + theVar + "'" + DEFAULT_COLOR);
++                }
++                setall param.rtype = subType;
++            }
++            else
++            {
++                setall param.rtype = theType;
++            }
+         }
+         pushItem params;
+         setall params#back = param.rtype.name;
+diff --git a/rathaxes/compiler/passes/common/rtxResolve.inc.cws b/rathaxes/compiler/passes/common/rtxResolve.inc.cws
+--- a/rathaxes/compiler/passes/common/rtxResolve.inc.cws
++++ b/rathaxes/compiler/passes/common/rtxResolve.inc.cws
+@@ -887,7 +887,7 @@
+     local       phName = "_"+local_node#parent.block_idx;
+     local       phIdx = 0;
+     localref    theParent = local_node#parent.ref_placeholder#parent;
+-    if (local_node#parent.type_target != "target_pointcut")
++    if (local_node#parent.type_target != "target_pointcut" && local_node#parent.type_target != "target_expr")
+     {
+         error(RED + "[Error] inject<\"__rtx_tpl_sequence_call__\">: Wrong target type ("
+               + local_node#parent.type_target + ")" + DEFAULT_COLOR);
--- a/rathaxes_samples_e1000_add_alloc_sequences_in_socket.patch	Fri Jul 19 19:12:10 2013 -0700
+++ b/rathaxes_samples_e1000_add_alloc_sequences_in_socket.patch	Sat Jul 20 20:45:39 2013 -0700
@@ -1,21 +1,20 @@
 # HG changeset patch
-# Parent 0082bea09b4bed6ed6215afb7a14d43a948cecd8
+# Parent 9f743313820393d900d65aa6f2532c7d820de04b
 Add alloc_rx and alloc_tx in the Socket abstraction
 
 This will help to hide platform dependent code from
 e1000::set_up_device.
 
-
 diff --git a/rathaxes/samples/e1000/socket.rti b/rathaxes/samples/e1000/socket.rti
 --- a/rathaxes/samples/e1000/socket.rti
 +++ b/rathaxes/samples/e1000/socket.rti
 @@ -1,4 +1,4 @@
--interface Socket : LKM, Device
-+interface Socket : LKM, Device, Ethernet, Builtin
+-interface Socket : LKM, Device, DMA
++interface Socket : LKM, Device, DMA, Ethernet, Builtin
  {
      /* The SKBuff type from the kernel */
      provided type   AbstractSKBuff
-@@ -10,14 +10,24 @@
+@@ -10,15 +10,25 @@
  
      provided type   SKBuff
      {
@@ -47,5 +46,6 @@
 +    provided sequence   alloc_tx(Ethernet::Device, Builtin::number)
 +    {
 +        chunk   ::CALL();
-     }
- }
+ 
+         attribute   Socket::AbstractSKBuff.ref      k_sk_buff;
+         attribute   DMA::AbstractDMAHandle.scalar   k_dma_handle;
--- a/rathaxes_samples_e1000_use_the_dma_abstraction_in_socket.patch	Fri Jul 19 19:12:10 2013 -0700
+++ b/rathaxes_samples_e1000_use_the_dma_abstraction_in_socket.patch	Sat Jul 20 20:45:39 2013 -0700
@@ -1,7 +1,65 @@
 # HG changeset patch
-# Parent c571aba317b28723d36bf15393be227b41fce242
+# Parent 05460906d5aba5d3671969d9ac53182d0ac91649
 Replace Linux specific code in Socket by DMA calls
 
+diff --git a/rathaxes/samples/e1000/dma.blt b/rathaxes/samples/e1000/dma.blt
+--- a/rathaxes/samples/e1000/dma.blt
++++ b/rathaxes/samples/e1000/dma.blt
+@@ -14,7 +14,7 @@
+ 
+         map
+         {
+-            k_dma_handle: ((dma_addr_t *)${self});
++            k_dma_handle: ((dma_addr_t)${self});
+         }
+     }
+ 
+@@ -51,7 +51,7 @@
+     {
+         chunk  ::CALL()
+         {
+-            dma_map_single(${dev.k_device}, ${buf}, ${size}, ${dir.dma_direction});
++            ((${DMA::AbstractDMAHandle})dma_map_single(${dev.k_device}, ${buf}, ${size}, ${dir.dma_direction}));
+         }
+     }
+ 
+@@ -63,11 +63,19 @@
+         }
+     }
+ 
++    template sequence   mapping_error(Device::AbstractDevice dev, AbstractDMAHandle handle)
++    {
++        chunk ::CALL()
++        {
++            dma_mapping_error(${dev.k_device}, ${handle.k_dma_handle});
++        }
++    }
++
+     template sequence   alloc_coherent(Device::AbstractDevice dev, Builtin::number size, AbstractDMAHandle handle)
+     {
+         chunk  ::CALL()
+         {
+-            dma_alloc_coherent(${dev.k_device}, ${size}, ${handle.k_dma_handle}, GFP_KERNEL);
++            dma_alloc_coherent(${dev.k_device}, ${size}, &${handle.k_dma_handle}, GFP_KERNEL);
+         }
+     }
+ 
+diff --git a/rathaxes/samples/e1000/dma.rti b/rathaxes/samples/e1000/dma.rti
+--- a/rathaxes/samples/e1000/dma.rti
++++ b/rathaxes/samples/e1000/dma.rti
+@@ -29,6 +29,12 @@
+         provided chunk  ::CALL();
+     }
+ 
++    /* XXX: Until we have a real error handling mechanism: */
++    provided sequence   mapping_error(Device::AbstractDevice, AbstractDMAHandle)
++    {
++        provided chunk  ::CALL(); /* -> != 0 if the mapping failed */
++    }
++
+     provided sequence   alloc_coherent(Device::AbstractDevice, Builtin::number, AbstractDMAHandle)
+     {
+         /* return the addr and the handle via the AbstractDMAHandle ptr: */
 diff --git a/rathaxes/samples/e1000/socket.blt b/rathaxes/samples/e1000/socket.blt
 --- a/rathaxes/samples/e1000/socket.blt
 +++ b/rathaxes/samples/e1000/socket.blt
@@ -26,30 +84,44 @@
              static void rtx_socket_skbuff_dump_infos(${Socket::SKBuff.ref});
 -            static int  rtx_socket_skbuff_map(${Socket::SKBuff.ref}, struct device *, enum dma_data_direction);
 -            static void rtx_socket_skbuff_unmap_and_free(${Socket::SKBuff.ref}, struct device *, enum dma_data_direction);
-+            static int  rtx_socket_skbuff_map(${Socket::SKBuff.ref}, struct device *, ${DMA::DMADirection});
-+            static void rtx_socket_skbuff_unmap_and_free(${Socket::SKBuff.ref}, struct device *, ${DMA::DMADirection});
++            static int  rtx_socket_skbuff_map(${Socket::SKBuff.ref}, ${Device::AbstractDevice.ref}, ${DMA::DMADirection.scalar});
++            static void rtx_socket_skbuff_unmap_and_free(${Socket::SKBuff.ref}, struct device *, ${DMA::DMADirection.scalar});
          }
  
          chunk   LKM::code()
-@@ -66,7 +66,7 @@
+@@ -65,23 +65,21 @@
+             }
  
              static int rtx_socket_skbuff_map(${Socket::SKBuff.ref} self,
-                                              struct device *dev,
+-                                             struct device *dev,
 -                                             enum dma_data_direction direction)
-+                                             ${DMA::DMADirection} direction)
++                                             ${Device::AbstractDevice.ref} dev,
++                                             ${DMA::DMADirection.scalar} direction)
              {
-                 ${Socket::AbstractSKBuff.ref}   skb = self->skbuff;
+-                ${Socket::AbstractSKBuff.ref}   skb = self->skbuff;
+-
+-                WARN_ON(!${local.skb.k_sk_buff});
+-                WARN_ON(self->dma_handle);
++                WARN_ON(!${local.self.k_sk_buff});
++                WARN_ON(${local.self.k_dma_handle});
  
-@@ -77,7 +77,7 @@
-                         dev,
+                 self->dma_handle = dma_map_single(
+-                        dev,
++                        ${dev.k_device},
                          ${local.skb.k_sk_buff},
                          skb_headlen(${local.skb.k_sk_buff}),
 -                        direction);
+-                int err = dma_mapping_error(dev, self->dma_handle);
 +                        ${local.direction.dma_direction});
-                 int err = dma_mapping_error(dev, self->dma_handle);
++                int err = ${DMA::mapping_error(local.dev, local.self.k_dma_handle)};
                  if (err)
                  {
-@@ -89,7 +89,7 @@
+-                    self->dma_handle = 0;
++                    ${local.self.k_dma_handle} = 0;
+                     return err;
+                 }
+                 return 0;
+@@ -89,7 +87,7 @@
  
              static void rtx_socket_skbuff_unmap_and_free(${Socket::SKBuff.ref} self,
                                                           struct device *dev,
@@ -58,7 +130,7 @@
              {
                  ${Socket::AbstractSKBuff.ref}   skb = self->skbuff;
  
-@@ -100,7 +100,7 @@
+@@ -100,7 +98,7 @@
                      dma_unmap_single(dev,
                              self->dma_handle,
                              skb_headlen(${local.skb.k_sk_buff}),
@@ -67,12 +139,12 @@
                      self->dma_handle = 0;
                  }
                  dev_kfree_skb_any(${local.skb.k_sk_buff});
-@@ -126,22 +126,22 @@
+@@ -126,30 +124,32 @@
  
          method   map_to(Device::AbstractDevice dev)
          {
 -            rtx_socket_skbuff_map(${self}, ${dev.k_device}, DMA_TO_DEVICE);
-+            rtx_socket_skbuff_map(${self}, ${dev.k_device}, RTX_DMA_TO_DEVICE);
++            rtx_socket_skbuff_map(${self}, ${dev}, RTX_DMA_TO_DEVICE);
          }
  
          method   map_from(Device::AbstractDevice dev)
@@ -94,3 +166,35 @@
          }
  
          map
+         {
+-            // some work may have to be done here in order
+-            // to access to some field of the sk_buff.
+-            // We should determine if all the sk_buff management
+-            // can be abstracted from the user.
++            // Some work may have to be done here in order to access to some
++            // field of the sk_buff. We should determine if all the sk_buff
++            // management can be abstracted from the user. But this is at least
++            // useful for internal use:
++            k_sk_buff: ((struct skbuff *)(${self}->skbuff));
++            k_dma_handle: ((dma_addr_t)(${self}->dma_handle));
+         }
+     }
+ }
+diff --git a/rathaxes/samples/e1000/socket.rti b/rathaxes/samples/e1000/socket.rti
+--- a/rathaxes/samples/e1000/socket.rti
++++ b/rathaxes/samples/e1000/socket.rti
+@@ -1,4 +1,4 @@
+-interface Socket : LKM, Device
++interface Socket : LKM, Device, DMA
+ {
+     /* The SKBuff type from the kernel */
+     provided type   AbstractSKBuff
+@@ -19,5 +19,8 @@
+         method      map_from(Device::AbstractDevice);
+         method      unmap_to_and_free(Device::AbstractDevice);
+         method      unmap_from_and_free(Device::AbstractDevice);
++
++        attribute   Socket::AbstractSKBuff.ref      k_sk_buff;
++        attribute   DMA::AbstractDMAHandle.scalar   k_dma_handle;
+     }
+ }
--- a/series	Fri Jul 19 19:12:10 2013 -0700
+++ b/series	Sat Jul 20 20:45:39 2013 -0700
@@ -1,3 +1,4 @@
+rathaxes_compiler_passes_correctly_resolve_all_variables_subidentifiers.patch
 rathaxes_samples_e1000_add_a_dma_abstraction.patch
 rathaxes_samples_e1000_use_the_dma_abstraction_in_socket.patch
 rathaxes_samples_e1000_add_alloc_sequences_in_socket.patch