comparison rathaxes_sample_e1000_rewrite_device_dependent_code.patch @ 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
comparison
equal deleted inserted replaced
135:9c6ae3a2e180 136:8229a46ec658
1 # HG changeset patch 1 # HG changeset patch
2 # Parent 53d3ca9da9c4cd680cf5982b9e972903fb4d3231 2 # Parent 1229971cfa561a1c788a407620ce545eac7d0141
3 rathaxes: rewrite/refactor all the e1000 device dependent code 3 rathaxes: rewrite/refactor all the e1000 device dependent code
4 4
5 diff --git a/notes.txt b/notes.txt 5 diff --git a/notes.txt b/notes.txt
6 new file mode 100644 6 new file mode 100644
7 --- /dev/null 7 --- /dev/null
57 + if (!placeHolder.node.body.type) 57 + if (!placeHolder.node.body.type)
58 + traceLine(RED + "BUG: placeHolder.node.body.type is missing in rtxIntrospect_walk<\"__rtx_chunk__\">, placeHolder = " + toString(placeHolder) + DEFAULT_COLOR); 58 + traceLine(RED + "BUG: placeHolder.node.body.type is missing in rtxIntrospect_walk<\"__rtx_chunk__\">, placeHolder = " + toString(placeHolder) + DEFAULT_COLOR);
59 if (rtxIntrospect_InferPlaceHolderTypes<placeHolder.node.body.type>(placeHolder.node.body, local_node) == false) 59 if (rtxIntrospect_InferPlaceHolderTypes<placeHolder.node.body.type>(placeHolder.node.body, local_node) == false)
60 { 60 {
61 pushItem to_remove; 61 pushItem to_remove;
62 diff --git a/rathaxes/compiler/passes/back/rtxPlaceHolders.inc.cws b/rathaxes/compiler/passes/back/rtxPlaceHolders.inc.cws
63 --- a/rathaxes/compiler/passes/back/rtxPlaceHolders.inc.cws
64 +++ b/rathaxes/compiler/passes/back/rtxPlaceHolders.inc.cws
65 @@ -394,7 +394,10 @@
66 { rtxPH_mapPlaceHolder(local_node.expr.id, compile, node_idx, "target_pointcut"); }
67 }
68 else
69 + {
70 + traceLine(CYAN + "LOUIS: local_node.expr: " + toString(local_node.expr) + DEFAULT_COLOR);
71 rtxPH_compile<local_node.expr.type>(local_node.expr, compile, node_idx);
72 + }
73 }
74 // Label
75 if (existVariable(local_node.label) && rtxPH_havePlaceHolder(local_node.label))
76 diff --git a/rathaxes/samples/e1000/CMakeLists.txt b/rathaxes/samples/e1000/CMakeLists.txt 62 diff --git a/rathaxes/samples/e1000/CMakeLists.txt b/rathaxes/samples/e1000/CMakeLists.txt
77 --- a/rathaxes/samples/e1000/CMakeLists.txt 63 --- a/rathaxes/samples/e1000/CMakeLists.txt
78 +++ b/rathaxes/samples/e1000/CMakeLists.txt 64 +++ b/rathaxes/samples/e1000/CMakeLists.txt
79 @@ -17,9 +17,9 @@ 65 @@ -17,9 +17,9 @@
80 dma.blt 66 dma.blt
694 - decl data_types() 680 - decl data_types()
695 + decl data_types() 681 + decl data_types()
696 { 682 {
697 E1000_TXD_DTYP_D = 0x00100000, /* Data Descriptor */ 683 E1000_TXD_DTYP_D = 0x00100000, /* Data Descriptor */
698 E1000_TXD_DTYP_C = 0x00000000, /* Context Descriptor */ 684 E1000_TXD_DTYP_C = 0x00000000, /* Context Descriptor */
699 @@ -701,326 +140,687 @@ 685 @@ -701,326 +140,700 @@
700 } 686 }
701 } 687 }
702 688
703 - /* TODO: make that a method of e1000::Context */ 689 - /* TODO: make that a method of e1000::Context */
704 - template sequence e1000::print_status(Ethernet::Device rtx_ether_ctx) 690 - template sequence e1000::print_status(Ethernet::Device rtx_ether_ctx)
783 + ${Ethernet::Device.ref} net_dev; 769 + ${Ethernet::Device.ref} net_dev;
784 + // XXX should be annoted with __iomem: 770 + // XXX should be annoted with __iomem:
785 + unsigned char *io_addr; 771 + unsigned char *io_addr;
786 + // XXX Forced to hardcode the type because there is a circular 772 + // XXX Forced to hardcode the type because there is a circular
787 + // dependency between the rings and the context. 773 + // dependency between the rings and the context.
788 + // TODO: get the right generated types: 774 + rtxType_e1000_TxRing tx_ring;
789 + int tx_ring; 775 + rtxType_e1000_RxRing rx_ring;
790 + int rx_ring;
791 + } 776 + }
792 + 777 +
793 + chunk LKM::includes() 778 + chunk LKM::includes()
794 + { 779 + {
795 + #include <linux/types.h> 780 + #include <linux/types.h>
900 + { 885 + {
901 + ${e1000::Context.ref} hw_ctx = &${rtx_ether_ctx}->hw_ctx; 886 + ${e1000::Context.ref} hw_ctx = &${rtx_ether_ctx}->hw_ctx;
902 + // XXX doesn't work: ${local.hw_ctx.init(rtx_ether_ctx, io_addr)}; 887 + // XXX doesn't work: ${local.hw_ctx.init(rtx_ether_ctx, io_addr)};
903 + ${local.hw_ctx.net_dev} = ${rtx_ether_ctx}; 888 + ${local.hw_ctx.net_dev} = ${rtx_ether_ctx};
904 + ${local.hw_ctx.io_addr} = ${io_addr}; 889 + ${local.hw_ctx.io_addr} = ${io_addr};
905 + ${local.hw_ctx.rx_ring.init(local.hw_ctx, config.rx_ring_size)}; 890 + // XXX doesn't work: ${local.hw_ctx.rx_ring.init(local.hw_ctx, config.rx_ring_size)};
906 + ${local.hw_ctx.tx_ring.init(local.hw_ctx, config.tx_ring_size)}; 891 + rtx_e1000_ring_init(
892 + &${local.hw_ctx.rx_ring},
893 + ${config.rx_ring_size},
894 + sizeof(rtxType_e1000_RxDescriptor)
895 + );
896 + // XXX doesn't work: ${local.hw_ctx.tx_ring.init(local.hw_ctx, config.tx_ring_size)};
897 + rtx_e1000_ring_init(
898 + &${local.hw_ctx.tx_ring},
899 + ${config.tx_ring_size},
900 + sizeof(rtxType_e1000_TxDescriptor)
901 + );
907 + } 902 + }
908 + } 903 + }
909 + 904 +
910 + chunk Ethernet::adapter_reset(Ethernet::Device rtx_ether_ctx) 905 + chunk Ethernet::adapter_reset(Ethernet::Device rtx_ether_ctx)
911 + { 906 + {
972 + ); 967 + );
973 + rtx_e1000_reg_write32(hw_ctx, E1000_FCAH, 0); 968 + rtx_e1000_reg_write32(hw_ctx, E1000_FCAH, 0);
974 + rtx_e1000_reg_write32(hw_ctx, E1000_FCAL, 0); 969 + rtx_e1000_reg_write32(hw_ctx, E1000_FCAL, 0);
975 + rtx_e1000_reg_write32(hw_ctx, E1000_FCT, 0); 970 + rtx_e1000_reg_write32(hw_ctx, E1000_FCT, 0);
976 + rtx_e1000_reg_write32(hw_ctx, E1000_FCTTV, 0); 971 + rtx_e1000_reg_write32(hw_ctx, E1000_FCTTV, 0);
977 + for (int i = 0; i != 64; ++i) 972 + // XXX int i leaks from another chunk and will not be generated
978 + rtx_e1000_reg_write32(hw_ctx, E1000_CRCERRS + i * 4, 0); 973 + // here, let's use a different index name:
974 + for (int j = 0; j != 64; ++j)
975 + rtx_e1000_reg_write32(hw_ctx, E1000_CRCERRS + j * 4, 0);
979 + 976 +
980 + ${Log::info("adapter_setup_rx_tx: general configuration done")}; 977 + ${Log::info("adapter_setup_rx_tx: general configuration done")};
981 + 978 +
982 + int err; 979 + int err;
983 + 980 +
998 + // TODO: hardcode a goto 995 + // TODO: hardcode a goto
999 + (void)1; 996 + (void)1;
1000 + } 997 + }
1001 + } 998 + }
1002 + 999 +
1003 + chunk Ethernet::adapter_enable_interrupts(Ethernet::Device) 1000 + chunk Ethernet::adapter_enable_interrupts(Ethernet::Device rtx_ether_ctx)
1004 + { 1001 + {
1005 + { 1002 + {
1006 + ${e1000::Context.ref} hw_ctx = &${rtx_ether_ctx}->hw_ctx; 1003 + ${e1000::Context.ref} hw_ctx = &${rtx_ether_ctx}->hw_ctx;
1007 + rtx_e1000_reg_write32( 1004 + rtx_e1000_reg_write32(
1008 + hw_ctx, 1005 + hw_ctx,
1077 + rtx_e1000_print_status(${self}); 1074 + rtx_e1000_print_status(${self});
1078 + } 1075 + }
1079 + 1076 +
1080 + map 1077 + map
1081 + { 1078 + {
1082 + io_addr: ${self}->io; 1079 + io_addr: ${self}->io_addr;
1083 + rx_ring: ${self}->rx_ring; 1080 + rx_ring: ${self}->rx_ring;
1084 + tx_ring: ${self}->tx_ring; 1081 + tx_ring: ${self}->tx_ring;
1085 + net_dev: ${self}->net_dev; 1082 + net_dev: ${self}->net_dev;
1086 } 1083 }
1087 } 1084 }
1234 + err_skbuffs_map: 1231 + err_skbuffs_map:
1235 + // XXX leaking cast: (TODO: the data structure changed) 1232 + // XXX leaking cast: (TODO: the data structure changed)
1236 + dev_kfree_skb((struct sk_buff *)hw_ctx->rx_ring.skbuffs[i].skbuff); 1233 + dev_kfree_skb((struct sk_buff *)hw_ctx->rx_ring.skbuffs[i].skbuff);
1237 + } 1234 + }
1238 + 1235 +
1236 + void *descs = ${local.self.descs};
1237 + ${cast local.descs as Builtin::symbol.ref};
1239 + ${DMA::free_coherent( 1238 + ${DMA::free_coherent(
1240 + local.self.hw_ctx.net_dev.device, local.self.size, 1239 + local.self.hw_ctx.net_dev.device, local.self.size,
1241 + local.self.descs, local.self.dma.dma_handle 1240 + local.descs, local.self.dma.dma_handle
1242 + )}; 1241 + )};
1243 + err_rx_ring_alloc: 1242 + err_rx_ring_alloc:
1244 + return -ENOMEM; 1243 + return -ENOMEM;
1245 + } 1244 + }
1246 + 1245 +
1638 } 1637 }
1639 } 1638 }
1640 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti 1639 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti
1641 --- a/rathaxes/samples/e1000/e1000.rti 1640 --- a/rathaxes/samples/e1000/e1000.rti
1642 +++ b/rathaxes/samples/e1000/e1000.rti 1641 +++ b/rathaxes/samples/e1000/e1000.rti
1643 @@ -1,157 +1,123 @@ 1642 @@ -1,157 +1,125 @@
1644 -interface e1000 : Socket, Ethernet, DMA, PCI, LKM, Builtin 1643 -interface e1000 : Socket, Ethernet, DMA, PCI, LKM, Builtin
1645 +interface e1000 : Socket, Ethernet, Device, DMA, PCI, LKM, Builtin 1644 +interface e1000 : Socket, Ethernet, Device, DMA, PCI, LKM, Builtin
1646 { 1645 {
1647 - required variable Builtin::number rx_ring_size; 1646 - required variable Builtin::number rx_ring_size;
1648 - required variable Builtin::number tx_ring_size; 1647 - required variable Builtin::number tx_ring_size;
1704 + method reg_write32(Register, Builtin::number); 1703 + method reg_write32(Register, Builtin::number);
1705 + method reg_set32(Register, Builtin::number); 1704 + method reg_set32(Register, Builtin::number);
1706 + method reg_unset32(Register, Builtin::number); 1705 + method reg_unset32(Register, Builtin::number);
1707 + 1706 +
1708 + // XXX: Circular dependency with the rings, this will prevent us to 1707 + // XXX: Circular dependency with the rings, this will prevent us to
1709 + // call methods even when issue $46 is resolved, and it also forces 1708 + // call methods even when issue $46 is resolved, it also forces us to
1710 + // us to hardcode generated types in the definition of the type: 1709 + // hardcode generated types in the definition of the type, and they
1710 + // can't be "dereferenced" (e.g: local.hw_ctx.rx_ring.desc_size can't
1711 + // work since local.hw_ctx.rx_ring is just going to be a symbol).
1711 + attribute Builtin::symbol.scalar rx_ring; 1712 + attribute Builtin::symbol.scalar rx_ring;
1712 + attribute Builtin::symbol.scalar tx_ring; 1713 + attribute Builtin::symbol.scalar tx_ring;
1713 + attribute Builtin::symbol.scalar io_addr; 1714 + attribute Builtin::symbol.scalar io_addr;
1714 + attribute Ethernet::Device.ref net_dev; 1715 + attribute Ethernet::Device.ref net_dev;
1715 + } 1716 + }
1772 - chunk Ethernet::adapter_setup(Ethernet::Device); 1773 - chunk Ethernet::adapter_setup(Ethernet::Device);
1773 - 1774 -
1774 - attribute RxRing.scalar rx_ring; 1775 - attribute RxRing.scalar rx_ring;
1775 - /* XXX: circular dependency with Contex: */ 1776 - /* XXX: circular dependency with Contex: */
1776 - //attribute TxRing.scalar tx_ring; 1777 - //attribute TxRing.scalar tx_ring;
1777 + attribute RxDescriptor.scalar descs; 1778 + attribute RxDescriptor.ref descs;
1778 + attribute Builtin::number.scalar desc_size; 1779 + attribute Builtin::number.scalar desc_size;
1779 + attribute Buffer.ref buffs; 1780 + attribute Buffer.ref buffs;
1780 } 1781 }
1781 1782
1782 provided type TxRing 1783 provided type TxRing
1888 - provided chunk ::CALL(); 1889 - provided chunk ::CALL();
1889 + // Re-expose all the Ring attributes + the size of a single descriptor: 1890 + // Re-expose all the Ring attributes + the size of a single descriptor:
1890 + attribute Context.ref hw_ctx; 1891 + attribute Context.ref hw_ctx;
1891 + attribute DMA::DMAHandle.scalar dma; 1892 + attribute DMA::DMAHandle.scalar dma;
1892 + attribute Builtin::number.scalar size; 1893 + attribute Builtin::number.scalar size;
1893 + attribute TxDescriptor.scalar descs; 1894 + attribute TxDescriptor.ref descs;
1894 + attribute Builtin::number.scalar desc_size; 1895 + attribute Builtin::number.scalar desc_size;
1895 + attribute Buffer.ref buffs; 1896 + attribute Buffer.ref buffs;
1896 } 1897 }
1897 } 1898 }
1898 diff --git a/rathaxes/samples/e1000/ethernet.blt b/rathaxes/samples/e1000/ethernet.blt 1899 diff --git a/rathaxes/samples/e1000/ethernet.blt b/rathaxes/samples/e1000/ethernet.blt