Mercurial > archived > louis > epitech > mq > rathaxes
diff rathaxes_change_the_abstract_type_notation_in_the_e1000_sample.patch @ 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 |
line wrap: on
line diff
--- 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) {