Mercurial > archived > louis > epitech > mq > rathaxes
comparison rathaxes_sample_e1000_rewrite_device_dependent_code.patch @ 138:6527e078252c
Wip
author | Louis Opter <kalessin@kalessin.fr> |
---|---|
date | Sun, 19 Jan 2014 13:45:30 -0800 |
parents | 8bbdb488f6fe |
children | ab3a2aa22f95 |
comparison
equal
deleted
inserted
replaced
137:8bbdb488f6fe | 138:6527e078252c |
---|---|
1 # HG changeset patch | 1 # HG changeset patch |
2 # Parent d71e19169c392a9509bf816bf2ca7858212df878 | 2 # Parent 06f2b107580ea4f01d8e9333161d1e1b5f0de759 |
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 |
8 +++ b/notes.txt | 8 +++ b/notes.txt |
9 @@ -0,0 +1,47 @@ | 9 @@ -0,0 +1,52 @@ |
10 +Remarks for David & Lionel: | 10 +Remarks for David & Lionel: |
11 + | 11 + |
12 +- Too much changes to not start over; | 12 +- Too much changes to not start over; |
13 +- Lack of methods is extremely annoying and requires a lot of workarounds (e.g: | 13 +- Lack of methods is extremely annoying and requires a lot of workarounds (e.g: |
14 + see the register read/write/set/unset methods on e1000::Context); | 14 + see the register read/write/set/unset methods on e1000::Context); |
43 +- Why the DMA sequences are taking an AbstractDMAHandle instead of a DMAHandle? | 43 +- Why the DMA sequences are taking an AbstractDMAHandle instead of a DMAHandle? |
44 +- Right now the Ethernet subsystem hooks into the PCI subsystem via the | 44 +- Right now the Ethernet subsystem hooks into the PCI subsystem via the |
45 + Ethernet::init sequence, maybe the content of this sequence should be moved | 45 + Ethernet::init sequence, maybe the content of this sequence should be moved |
46 + under the Ethernet::Device type definition (maybe we could solve the | 46 + under the Ethernet::Device type definition (maybe we could solve the |
47 + free_netdev call in case of failure at the same time); | 47 + free_netdev call in case of failure at the same time); |
48 +- PCI::Device.device should be PCI::Device.k_device. | 48 +- Likewise sequences in the PCI subsystem could be moved to the PCI::Device |
49 + type definition; | |
50 +- PCI::Device.device should be PCI::Device.k_device; | |
51 +- The Ethernet's chunk for PCI::pci_remove_hook should probably call cleanup | |
52 + functions from the Context and the Rings, unless the kernel alway calls | |
53 + rtx_ethernet_close first automatically. | |
49 + | 54 + |
50 +Questions: | 55 +Questions: |
51 + | 56 + |
52 +Compiler bugs: | 57 +Compiler bugs: |
53 + | 58 + |
687 - decl data_types() | 692 - decl data_types() |
688 + decl data_types() | 693 + decl data_types() |
689 { | 694 { |
690 E1000_TXD_DTYP_D = 0x00100000, /* Data Descriptor */ | 695 E1000_TXD_DTYP_D = 0x00100000, /* Data Descriptor */ |
691 E1000_TXD_DTYP_C = 0x00000000, /* Context Descriptor */ | 696 E1000_TXD_DTYP_C = 0x00000000, /* Context Descriptor */ |
692 @@ -701,326 +140,701 @@ | 697 @@ -701,326 +140,703 @@ |
693 } | 698 } |
694 } | 699 } |
695 | 700 |
696 - /* TODO: make that a method of e1000::Context */ | 701 - /* TODO: make that a method of e1000::Context */ |
697 - template sequence e1000::print_status(Ethernet::Device rtx_ether_ctx) | 702 - template sequence e1000::print_status(Ethernet::Device rtx_ether_ctx) |
821 pr_info("\tInterface: %s\n", (status & 3) == 3 ? "Up" : "Down"); | 826 pr_info("\tInterface: %s\n", (status & 3) == 3 ? "Up" : "Down"); |
822 } | 827 } |
823 + | 828 + |
824 + static unsigned int rtx_e1000_reg_read32(${e1000::Context} self, ${e1000::Register} reg) | 829 + static unsigned int rtx_e1000_reg_read32(${e1000::Context} self, ${e1000::Register} reg) |
825 + { | 830 + { |
826 + // XXX The compiler adds a & if I use ${local.self.io_addr}: | 831 + // XXX The compiler generates &self->io_addr instead of |
832 + // self->io_addr if I use ${local.self.io_addr}: | |
827 + return ioread32(self->io_addr + reg); | 833 + return ioread32(self->io_addr + reg); |
828 + } | 834 + } |
829 + | 835 + |
830 + static void rtx_e1000_reg_write32(${e1000::Context} self, | 836 + static void rtx_e1000_reg_write32(${e1000::Context} self, |
831 + ${e1000::Register} reg, | 837 + ${e1000::Register} reg, |
997 + rtx_e1000_tx_ring_configure(&hw_ctx->tx_ring); | 1003 + rtx_e1000_tx_ring_configure(&hw_ctx->tx_ring); |
998 + | 1004 + |
999 + err_alloc_tx_ring: | 1005 + err_alloc_tx_ring: |
1000 + rtx_e1000_rx_ring_free_resources(&hw_ctx->rx_ring); | 1006 + rtx_e1000_rx_ring_free_resources(&hw_ctx->rx_ring); |
1001 + err_alloc_rx_ring: | 1007 + err_alloc_rx_ring: |
1002 + // XXX Can't return here since we don't know the context. | 1008 + // XXX Can't return here since we don't know the context, |
1003 + // TODO: hardcode a goto | 1009 + // anyway, hardcoded goto: |
1004 + (void)1; | 1010 + goto rtx_ethernet_open_fail; |
1005 + } | 1011 + } |
1006 + } | 1012 + } |
1007 + | 1013 + |
1008 + chunk Ethernet::adapter_enable_interrupts(Ethernet::Device rtx_ether_ctx) | 1014 + chunk Ethernet::adapter_enable_interrupts(Ethernet::Device rtx_ether_ctx) |
1009 + { | 1015 + { |
1193 + // 4. Setup the receive descriptor ring | 1199 + // 4. Setup the receive descriptor ring |
1194 + | 1200 + |
1195 + int i; | 1201 + int i; |
1196 + | 1202 + |
1197 + // Allocate the descriptors | 1203 + // Allocate the descriptors |
1198 + hw_ctx->rx_ring.base = ${DMA::alloc_coherent( | 1204 + ${local.self.descs} = ${DMA::alloc_coherent( |
1199 + local.self.hw_ctx.net_dev.device, local.self.size, | 1205 + local.self.hw_ctx.net_dev.device, local.self.size, |
1200 + local.self.dma.dma_handle | 1206 + local.self.dma.dma_handle |
1201 + )}; | 1207 + )}; |
1202 + if (!hw_ctx->rx_ring.base) { | 1208 + |
1209 + if (!${local.self.descs}) { | |
1203 + ${Log::info("adapter_init_rx: cannot allocate the descriptors for the rx ring")}; | 1210 + ${Log::info("adapter_init_rx: cannot allocate the descriptors for the rx ring")}; |
1204 + goto err_rx_ring_alloc; | 1211 + goto err_rx_ring_alloc; |
1205 + } | 1212 + } |
1206 + | 1213 + |
1207 + ${Log::info("adapter_init_rx: rx descriptors allocated")}; | 1214 + // XXX The generated code is completely scrambled if this is |
1215 + // not scoped: | |
1216 + { ${Log::info("adapter_init_rx: rx descriptors allocated")}; } | |
1208 + | 1217 + |
1209 + // Allocate the skbuffs, map them for DMA, and write their address | 1218 + // Allocate the skbuffs, map them for DMA, and write their address |
1210 + // in the corresponding descriptor. | 1219 + // in the corresponding descriptor. |
1211 +// for (i = 0; i != ${config.rx_ring_size}; ++i) { | 1220 +// for (i = 0; i != ${config.rx_ring_size}; ++i) { |
1212 +// ${Socket::SKBuff.ref} skbuff = &hw_ctx->rx_ring.skbuffs[i]; | 1221 +// ${Socket::SKBuff.ref} skbuff = &hw_ctx->rx_ring.skbuffs[i]; |
1363 + rtx_e1000_rx_ring_configure(${self}); | 1372 + rtx_e1000_rx_ring_configure(${self}); |
1364 + } | 1373 + } |
1365 + | 1374 + |
1366 + map | 1375 + map |
1367 + { | 1376 + { |
1368 + // TODO: fix cast to directly get the attributes from the Ring: | 1377 + hw_ctx: ${self}->ring.hw_ctx; |
1369 + hw_ctx: ((int)(${self})->hw_ctx); | 1378 + dma: ${self}->ring.dma; |
1370 + dma: ((int)(${self})->dma); | 1379 + size: ${self}->ring.size; |
1371 + size: ((int)(${self})->size); | 1380 + descs: ${self}->ring.descs; |
1372 + descs: ((int)(${self})->descs); | 1381 + buffs: ${self}->ring.buffs; |
1373 + buffs: ((int)(${self})->buffs); | 1382 + desc_size: sizeof(rtxType_e1000_RxDescriptor); // XXX hardcoded |
1374 + desc_size: sizeof(/* TODO: get the generated type... ${e1000::RxDescriptor} */int); | |
1375 } | 1383 } |
1376 } | 1384 } |
1377 | 1385 |
1378 - template sequence e1000::register_set32(e1000::Context ctx, e1000::Register reg_offset, ::number value) | 1386 - template sequence e1000::register_set32(e1000::Context ctx, e1000::Register reg_offset, ::number value) |
1379 + template type e1000::TxRing() | 1387 + template type e1000::TxRing() |
1632 - err_offload: | 1640 - err_offload: |
1633 - err_skb_map_to: | 1641 - err_skb_map_to: |
1634 - /* XXX: ${local.skb.unmap_to_and_free(local.dev)}; */ | 1642 - /* XXX: ${local.skb.unmap_to_and_free(local.dev)}; */ |
1635 - rtx_socket_skbuff_unmap_and_free(&skb, ${devp.k_device}, DMA_TO_DEVICE); | 1643 - rtx_socket_skbuff_unmap_and_free(&skb, ${devp.k_device}, DMA_TO_DEVICE); |
1636 - return NETDEV_TX_OK; | 1644 - return NETDEV_TX_OK; |
1637 + // TODO: fix cast to directly get the attributes from the Ring: | 1645 + hw_ctx: ${self}->ring.hw_ctx; |
1638 + hw_ctx: ((int)(${self})->hw_ctx); | 1646 + dma: ${self}->ring.dma; |
1639 + dma: ((int)(${self})->dma); | 1647 + size: ${self}->ring.size; |
1640 + size: ((int)(${self})->size); | 1648 + descs: ${self}->ring.descs; |
1641 + descs: ((int)(${self})->descs); | 1649 + buffs: ${self}->ring.buffs; |
1642 + buffs: ((int)(${self})->buffs); | 1650 + desc_size: sizeof(rtxType_e1000_TxDescriptor); // XXX hardcoded |
1643 + desc_size: sizeof(/* TODO: get the generated type ${e1000::TxDescriptor} */int); | |
1644 } | 1651 } |
1645 } | 1652 } |
1646 } | 1653 } |
1647 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti | 1654 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti |
1648 --- a/rathaxes/samples/e1000/e1000.rti | 1655 --- a/rathaxes/samples/e1000/e1000.rti |
1963 - template sequence Ethernet::open(Ethernet::Device dev) | 1970 - template sequence Ethernet::open(Ethernet::Device dev) |
1964 + template sequence Ethernet::open() | 1971 + template sequence Ethernet::open() |
1965 { | 1972 { |
1966 chunk LKM::includes() | 1973 chunk LKM::includes() |
1967 { | 1974 { |
1968 @@ -157,100 +160,114 @@ | 1975 @@ -157,100 +160,115 @@ |
1969 | 1976 |
1970 chunk LKM::prototypes() | 1977 chunk LKM::prototypes() |
1971 { | 1978 { |
1972 - static int rtx_ethernet_open(struct net_device *); | 1979 - static int rtx_ethernet_open(struct net_device *); |
1973 + static int rtx_ethernet_open(struct net_device *); | 1980 + static int rtx_ethernet_open(struct net_device *); |
1981 - /* | 1988 - /* |
1982 - * XXX The casts are here because the compiler doesn't resolve | 1989 - * XXX The casts are here because the compiler doesn't resolve |
1983 - * "enclosed" type (e.g: local.var.enclosed) correctly. | 1990 - * "enclosed" type (e.g: local.var.enclosed) correctly. |
1984 - */ | 1991 - */ |
1985 ${Ethernet::AbstractDevice.ref} rtx_net_dev; | 1992 ${Ethernet::AbstractDevice.ref} rtx_net_dev; |
1986 { /* XXX: I end up with a placeholder if I don't open a scope */ | 1993 - { /* XXX: I end up with a placeholder if I don't open a scope */ |
1987 ${local.rtx_net_dev.init(local.dev)}; | 1994 - ${local.rtx_net_dev.init(local.dev)}; |
1988 } | 1995 - } |
1996 + ${local.rtx_net_dev.init(local.dev)}; | |
1989 ${Ethernet::Device.ref} rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx}; | 1997 ${Ethernet::Device.ref} rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx}; |
1990 | 1998 |
1991 - int error; | 1999 - int error; |
1992 - { | 2000 - { |
1993 - ${Log::info("installing the interrupt handler")}; | 2001 - ${Log::info("installing the interrupt handler")}; |
2017 - ${pointcut Ethernet::adapter_init_rx(local.rtx_ether_ctx)}; | 2025 - ${pointcut Ethernet::adapter_init_rx(local.rtx_ether_ctx)}; |
2018 - ${pointcut Ethernet::adapter_init_tx(local.rtx_ether_ctx)}; | 2026 - ${pointcut Ethernet::adapter_init_tx(local.rtx_ether_ctx)}; |
2019 - ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx)}; | 2027 - ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx)}; |
2020 + | 2028 + |
2021 + ${pointcut Ethernet::adapter_enable_interrupts(local.rtx_ether_ctx)}; | 2029 + ${pointcut Ethernet::adapter_enable_interrupts(local.rtx_ether_ctx)}; |
2030 + | |
2031 + return 0; | |
2032 + | |
2033 + rtx_ethernet_open_fail: | |
2034 + return -EIO; // XXX Probably not appropriate. | |
2035 + } | |
2036 + } | |
2037 + | |
2038 + /* XXX This chunk should be removed (see #26) */ | |
2039 + chunk ::CALL() | |
2040 + { | |
2041 + } | |
2042 + } | |
2043 + | |
2044 + template sequence Ethernet::send() | |
2045 + { | |
2046 + chunk LKM::prototypes() | |
2047 + { | |
2048 + static int rtx_ethernet_xmit(struct sk_buff *skb, struct net_device *dev); | |
2049 + } | |
2050 + | |
2051 + chunk LKM::code() | |
2052 + { | |
2053 + static int rtx_ethernet_xmit(struct sk_buff *k_skb, struct net_device *net_dev) | |
2054 + { | |
2055 + ${Ethernet::Device.ref} rtx_ether_ctx = netdev_priv(net_dev); | |
2056 + ${Socket::SKBuff.ref} rtx_skb; | |
2057 + | |
2058 + ${cast local.k_skb as Socket::AbstractSKBuff.ref}; | |
2059 + ${local.rtx_skb.init(local.k_skb)}; | |
2060 + | |
2061 + ${Log::info("we have one packet to transmit!")}; | |
2062 + ${pointcut Ethernet::adapter_xmit(local.rtx_ether_ctx, local.rtx_skb)}; | |
2063 + } | |
2064 + } | |
2065 + | |
2066 + /* XXX This chunk should be removed (see #26) */ | |
2067 + chunk ::CALL() | |
2068 + { | |
2069 + } | |
2070 + } | |
2071 + | |
2072 + template sequence Ethernet::close() | |
2073 + { | |
2074 + chunk LKM::prototypes() | |
2075 + { | |
2076 + static int rtx_ethernet_close(struct net_device *); | |
2077 + } | |
2078 + | |
2079 + chunk LKM::code() | |
2080 + { | |
2081 + static int rtx_ethernet_close(struct net_device *net_dev) | |
2082 + { | |
2083 + ${cast local.net_dev as Ethernet::AbstractDevice.ref}; | |
2084 + ${Ethernet::Device.ref} rtx_ether_ctx = ${local.net_dev.rtx_ether_ctx}; | |
2085 + | |
2086 + ${pointcut Ethernet::adapter_disable_rx(local.rtx_ether_ctx)}; | |
2087 + | |
2088 + netif_tx_disable(net_dev); | |
2089 + ${pointcut Ethernet::adapter_disable_tx(local.rtx_ether_ctx)}; | |
2090 + | |
2091 + ${pointcut Ethernet::adapter_disable_interrupts(local.rtx_ether_ctx)}; | |
2092 + free_irq(${local.rtx_ether_ctx.irq}, dev); | |
2093 + ${Log::info("interrupt handler free'ed")}; | |
2094 + | |
2095 + // TODO/XXX: There is definitely more stuff to do around here | |
2096 + // (e.g: clean the rings, flush some stuff...) | |
2097 + | |
2098 + ${pointcut Ethernet::adapter_reset(local.rtx_ether_ctx)}; | |
2099 + ${pointcut Ethernet::adapter_free_rx_tx(local.rtx_ether_ctx)}; | |
2022 | 2100 |
2023 return 0; | 2101 return 0; |
2024 } | 2102 } |
2025 } | 2103 } |
2026 + | 2104 - } |
2105 | |
2106 - template sequence Ethernet::send(Ethernet::Device dev, Socket::AbstractSKBuff skb) | |
2107 - { | |
2108 - chunk LKM::prototypes() | |
2027 + /* XXX This chunk should be removed (see #26) */ | 2109 + /* XXX This chunk should be removed (see #26) */ |
2028 + chunk ::CALL() | 2110 + chunk ::CALL() |
2029 + { | 2111 { |
2030 + } | 2112 - static int rtx_ethernet_xmit(struct sk_buff* skb, struct net_device *dev); |
2113 - } | |
2114 - | |
2115 - chunk LKM::code() | |
2116 - { | |
2117 - static int rtx_ethernet_xmit(struct sk_buff* kernel_skb, struct net_device *net_dev) | |
2118 - { | |
2119 - ${Ethernet::Device.ref} rtx_ether_ctx = netdev_priv(net_dev); | |
2120 - ${Socket::AbstractSKBuff.ref} rtx_skb = (${Socket::AbstractSKBuff.ref}) kernel_skb; | |
2121 - | |
2122 - ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx, local.rtx_skb)}; | |
2123 - } | |
2124 } | |
2031 } | 2125 } |
2032 | 2126 |
2033 - template sequence Ethernet::send(Ethernet::Device dev, Socket::AbstractSKBuff skb) | |
2034 + template sequence Ethernet::send() | |
2035 { | |
2036 chunk LKM::prototypes() | |
2037 { | |
2038 - static int rtx_ethernet_xmit(struct sk_buff* skb, struct net_device *dev); | |
2039 + static int rtx_ethernet_xmit(struct sk_buff *skb, struct net_device *dev); | |
2040 } | |
2041 | |
2042 chunk LKM::code() | |
2043 { | |
2044 - static int rtx_ethernet_xmit(struct sk_buff* kernel_skb, struct net_device *net_dev) | |
2045 + static int rtx_ethernet_xmit(struct sk_buff *k_skb, struct net_device *net_dev) | |
2046 { | |
2047 ${Ethernet::Device.ref} rtx_ether_ctx = netdev_priv(net_dev); | |
2048 - ${Socket::AbstractSKBuff.ref} rtx_skb = (${Socket::AbstractSKBuff.ref}) kernel_skb; | |
2049 + ${Socket::SKBuff.ref} rtx_skb; | |
2050 | |
2051 - ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx, local.rtx_skb)}; | |
2052 + ${cast local.k_skb as Socket::AbstractSKBuff.ref}; | |
2053 + ${local.rtx_skb.init(local.k_skb)}; | |
2054 + | |
2055 + ${Log::info("we have one packet to transmit!")}; | |
2056 + ${pointcut Ethernet::adapter_xmit(local.rtx_ether_ctx, local.rtx_skb)}; | |
2057 } | |
2058 } | |
2059 + | |
2060 + /* XXX This chunk should be removed (see #26) */ | |
2061 + chunk ::CALL() | |
2062 + { | |
2063 + } | |
2064 } | |
2065 | |
2066 - template sequence Ethernet::close(Ethernet::Device dev) | 2127 - template sequence Ethernet::close(Ethernet::Device dev) |
2067 + template sequence Ethernet::close() | 2128 - { |
2068 { | 2129 - chunk LKM::prototypes() |
2069 chunk LKM::prototypes() | 2130 - { |
2070 { | |
2071 - static int rtx_ethernet_close(struct net_device *); | 2131 - static int rtx_ethernet_close(struct net_device *); |
2072 + static int rtx_ethernet_close(struct net_device *); | 2132 - } |
2073 } | 2133 - |
2074 | 2134 - chunk LKM::code() |
2075 chunk LKM::code() | 2135 - { |
2076 { | |
2077 - static int rtx_ethernet_close(struct net_device *dev) | 2136 - static int rtx_ethernet_close(struct net_device *dev) |
2078 + static int rtx_ethernet_close(struct net_device *net_dev) | 2137 - { |
2079 { | |
2080 - ${Ethernet::AbstractDevice.ref} rtx_net_dev; | 2138 - ${Ethernet::AbstractDevice.ref} rtx_net_dev; |
2081 - { /* XXX: I end up with a placeholder if I don't open a scope */ | 2139 - { /* XXX: I end up with a placeholder if I don't open a scope */ |
2082 - ${local.rtx_net_dev.init(local.dev)}; | 2140 - ${local.rtx_net_dev.init(local.dev)}; |
2083 - } | 2141 - } |
2084 + ${cast local.net_dev as Ethernet::AbstractDevice.ref}; | 2142 - |
2085 + ${Ethernet::Device.ref} rtx_ether_ctx = ${local.net_dev.rtx_ether_ctx}; | |
2086 | |
2087 - ${Ethernet::Device.ref} rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx}; | 2143 - ${Ethernet::Device.ref} rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx}; |
2088 + ${pointcut Ethernet::adapter_disable_rx(local.rtx_ether_ctx)}; | 2144 - |
2089 | |
2090 - /* TODO: change this pointcut into a pointcut/adapter/callback: */ | 2145 - /* TODO: change this pointcut into a pointcut/adapter/callback: */ |
2091 - { | 2146 - { |
2092 - ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx)}; | 2147 - ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx)}; |
2093 - } | 2148 - } |
2094 + netif_tx_disable(net_dev); | 2149 - |
2095 + ${pointcut Ethernet::adapter_disable_tx(local.rtx_ether_ctx)}; | 2150 - free_irq(${local.rtx_ether_ctx.irq}, dev); |
2096 | |
2097 + ${pointcut Ethernet::adapter_disable_interrupts(local.rtx_ether_ctx)}; | |
2098 free_irq(${local.rtx_ether_ctx.irq}, dev); | |
2099 - { | 2151 - { |
2100 - ${Log::info("interrupt handler free'ed")}; | 2152 - ${Log::info("interrupt handler free'ed")}; |
2101 - } | 2153 - } |
2102 + ${Log::info("interrupt handler free'ed")}; | 2154 - |
2103 + | 2155 - return 0; |
2104 + // TODO/XXX: There is definitely more stuff to do around here | 2156 - } |
2105 + // (e.g: clean the rings, flush some stuff...) | 2157 - } |
2106 + | 2158 - } |
2107 + ${pointcut Ethernet::adapter_reset(local.rtx_ether_ctx)}; | 2159 - |
2108 + ${pointcut Ethernet::adapter_free_rx_tx(local.rtx_ether_ctx)}; | |
2109 | |
2110 return 0; | |
2111 } | |
2112 } | |
2113 + | |
2114 + /* XXX This chunk should be removed (see #26) */ | |
2115 + chunk ::CALL() | |
2116 + { | |
2117 + } | |
2118 } | |
2119 | |
2120 - template sequence Ethernet::interrupt_handler(Ethernet::Device dev) | 2160 - template sequence Ethernet::interrupt_handler(Ethernet::Device dev) |
2121 + template sequence Ethernet::interrupt_handler() | 2161 + template sequence Ethernet::interrupt_handler() |
2122 { | 2162 { |
2123 /* | 2163 /* |
2124 * We can't use the irqreturn_t type here because CNornm doesn't know | 2164 * We can't use the irqreturn_t type here because CNornm doesn't know |
2125 @@ -258,29 +275,34 @@ | 2165 @@ -258,29 +276,34 @@ |
2126 */ | 2166 */ |
2127 chunk LKM::prototypes() | 2167 chunk LKM::prototypes() |
2128 { | 2168 { |
2129 - static enum irqreturn rtx_ethernet_interrupt_handler(int, void *); | 2169 - static enum irqreturn rtx_ethernet_interrupt_handler(int, void *); |
2130 + static enum irqreturn rtx_ethernet_interrupt_handler(int, void *); | 2170 + static enum irqreturn rtx_ethernet_interrupt_handler(int, void *); |
2159 - static const struct net_device_ops rtx_ether_ops = | 2199 - static const struct net_device_ops rtx_ether_ops = |
2160 + static const struct net_device_ops rtx_ether_ops = | 2200 + static const struct net_device_ops rtx_ether_ops = |
2161 { | 2201 { |
2162 .ndo_open = rtx_ethernet_open, | 2202 .ndo_open = rtx_ethernet_open, |
2163 .ndo_stop = rtx_ethernet_close, | 2203 .ndo_stop = rtx_ethernet_close, |
2164 @@ -288,74 +310,65 @@ | 2204 @@ -288,74 +311,65 @@ |
2165 }; | 2205 }; |
2166 } | 2206 } |
2167 | 2207 |
2168 - /* | 2208 - /* |
2169 - * NOTE: for now, the error handling is leaking from PCI::probe(), but | 2209 - * NOTE: for now, the error handling is leaking from PCI::probe(), but |
2287 - /* This chunk should be removed (see #26) */ | 2327 - /* This chunk should be removed (see #26) */ |
2288 + /* XXX This chunk should be removed (see #26) */ | 2328 + /* XXX This chunk should be removed (see #26) */ |
2289 chunk ::CALL() | 2329 chunk ::CALL() |
2290 { | 2330 { |
2291 } | 2331 } |
2292 @@ -369,15 +382,17 @@ | 2332 @@ -369,15 +383,17 @@ |
2293 */ | 2333 */ |
2294 chunk PCI::pci_remove_hook(PCI::Device rtx_pci_dev) | 2334 chunk PCI::pci_remove_hook(PCI::Device rtx_pci_dev) |
2295 { | 2335 { |
2296 - ${Ethernet::Device.ref} rtx_ether_ctx = ${rtx_pci_dev.rtx_drv_context}; | 2336 - ${Ethernet::Device.ref} rtx_ether_ctx = ${rtx_pci_dev.rtx_drv_context}; |
2297 - BUG_ON(!rtx_ether_ctx); | 2337 - BUG_ON(!rtx_ether_ctx); |
2560 - ${self}->bars = pci_select_bars(${local.workaround.k_pci_dev}, IORESOURCE_MEM); | 2600 - ${self}->bars = pci_select_bars(${local.workaround.k_pci_dev}, IORESOURCE_MEM); |
2561 + ${self}->bars = pci_select_bars(${pdev.k_pci_dev}, IORESOURCE_MEM); | 2601 + ${self}->bars = pci_select_bars(${pdev.k_pci_dev}, IORESOURCE_MEM); |
2562 ${self}->ioaddr = NULL; | 2602 ${self}->ioaddr = NULL; |
2563 ${self}->context = NULL; | 2603 ${self}->context = NULL; |
2564 } | 2604 } |
2565 @@ -98,7 +97,7 @@ | 2605 @@ -92,13 +91,12 @@ |
2606 | |
2607 method select_ioaddr(Builtin::number bar) | |
2608 { | |
2609 - ${PCI::AbstractDevice.ref} select_ioaddr_pdev = ${self}->pdev; | |
2610 - ${self}->ioaddr = pci_ioremap_bar(${local.select_ioaddr_pdev.k_pci_dev}, ${bar}); | |
2611 + ${self.ioaddr} = pci_ioremap_bar(${self.pci_device.k_pci_dev}, ${bar}); | |
2612 } | |
2566 | 2613 |
2567 method set_rtx_drv_context(Builtin::symbol ctx) | 2614 method set_rtx_drv_context(Builtin::symbol ctx) |
2568 { | 2615 { |
2569 - ${self}->context = ctx; | 2616 - ${self}->context = ctx; |
2570 + ${self.rtx_drv_context} = ${ctx}; | 2617 + ${self.rtx_drv_context} = ${ctx}; |
2571 } | 2618 } |
2572 | 2619 |
2573 map | 2620 map |
2574 @@ -127,7 +126,7 @@ | 2621 @@ -127,7 +125,7 @@ |
2575 const struct pci_device_id *pdev_id) | 2622 const struct pci_device_id *pdev_id) |
2576 { | 2623 { |
2577 int error; | 2624 int error; |
2578 - ${PCI::Device.ref} rtx_pci_dev; | 2625 - ${PCI::Device.ref} rtx_pci_dev; |
2579 + ${PCI::Device.ref} rtx_pci_dev = NULL; | 2626 + ${PCI::Device.ref} rtx_pci_dev = NULL; |
2580 ${PCI::AbstractDevice.ref} rtx_pdev = (${PCI::AbstractDevice.ref})pdev; | 2627 ${PCI::AbstractDevice.ref} rtx_pdev = (${PCI::AbstractDevice.ref})pdev; |
2581 | 2628 |
2582 rtx_pci_dev = kmalloc(sizeof(*rtx_pci_dev), GFP_KERNEL); | 2629 rtx_pci_dev = kmalloc(sizeof(*rtx_pci_dev), GFP_KERNEL); |
2630 @@ -138,13 +136,7 @@ | |
2631 goto fail; | |
2632 } | |
2633 | |
2634 - /* | |
2635 - * XXX: I'm getting placeholder in the generated code if I don't | |
2636 - * open a scope here: | |
2637 - */ | |
2638 - { | |
2639 - ${local.rtx_pci_dev.init(local.rtx_pdev)}; | |
2640 - } | |
2641 + ${local.rtx_pci_dev.init(local.rtx_pdev)}; | |
2642 | |
2643 /* ${local.pdev.set_rtx_context(local.rtx_pci_dev)}; */ | |
2644 pci_set_drvdata(pdev, rtx_pci_dev); | |
2645 @@ -157,14 +149,14 @@ | |
2646 goto fail; | |
2647 } | |
2648 | |
2649 - /* ${local.rtx_pci_dev.select_ioaddr(local.rtx_pci_dev.BAR_0)}; */ | |
2650 - rtx_pci_dev->ioaddr = pci_ioremap_bar( | |
2651 + // XXX #46: ${local.rtx_pci_dev.select_ioaddr(local.rtx_pci_dev.BAR_0)}; | |
2652 + ${local.rtx_pci_dev.ioaddr} = pci_ioremap_bar( | |
2653 pdev, ${local.rtx_pci_dev.BAR_0} | |
2654 ); | |
2655 if (!${local.rtx_pci_dev.ioaddr}) | |
2656 { | |
2657 ${Log::info("can't map the device address space")}; | |
2658 - error = 1; /* XXX anything more approriate? */ | |
2659 + error = -EIO; /* XXX anything more approriate? */ | |
2660 goto fail; | |
2661 } | |
2662 | |
2663 @@ -173,7 +165,7 @@ | |
2664 return 0; | |
2665 | |
2666 fail: | |
2667 - /* ${local.pdev.set_rtx_drv_context(NULL)}; */ | |
2668 + // ${local.pdev.set_rtx_drv_context(NULL)}; | |
2669 pci_set_drvdata(pdev, NULL); | |
2670 kfree(rtx_pci_dev); | |
2671 return error; | |
2583 diff --git a/rathaxes/samples/e1000/socket.blt b/rathaxes/samples/e1000/socket.blt | 2672 diff --git a/rathaxes/samples/e1000/socket.blt b/rathaxes/samples/e1000/socket.blt |
2584 --- a/rathaxes/samples/e1000/socket.blt | 2673 --- a/rathaxes/samples/e1000/socket.blt |
2585 +++ b/rathaxes/samples/e1000/socket.blt | 2674 +++ b/rathaxes/samples/e1000/socket.blt |
2586 @@ -22,16 +22,12 @@ | 2675 @@ -22,16 +22,12 @@ |
2587 { | 2676 { |