comparison rathaxes_e1000_move_the_interrupt_init_and_cleanup_into_ethernet.patch @ 107:f42751b8ca99

Fix the interrupt handler refactoring patch and update the abstract type notation patch accordingly
author Louis Opter <louis@lse.epita.fr>
date Sun, 24 Mar 2013 21:47:39 -0700
parents 976a4b87803f
children 7efe3212db3a
comparison
equal deleted inserted replaced
106:976a4b87803f 107:f42751b8ca99
1 # HG changeset patch 1 # HG changeset patch
2 # Parent db54879402d420664f53e83cb7f55204571a9a8e 2 # Parent a611642de7f291e4749a7f44027f9ebaa0cde75c
3 Move the interrupt handler init/cleanup out of e1000.blt 3 Move the interrupt handler init/cleanup out of e1000.blt
4 4
5 This is not device dependant and can be done from the Ethernet subsystem 5 This is not device dependant and can be done from the Ethernet subsystem
6 right now, (plus the interrupt handler itself was already in the 6 right now, (plus the interrupt handler itself was already in the
7 Ethernet subsytem). 7 Ethernet subsytem).
144 -with Ethernet, PCI, LKM, Log 144 -with Ethernet, PCI, LKM, Log
145 +with Ethernet, PCI, LKM, Log, Builtin 145 +with Ethernet, PCI, LKM, Log, Builtin
146 { 146 {
147 template type Ethernet::ProtocolId() 147 template type Ethernet::ProtocolId()
148 { 148 {
149 @@ -106,11 +106,17 @@ 149 @@ -61,7 +61,9 @@
150
151 map
152 {
153 - netdev: ${self}->ndev;
154 + netdev: ${self}->ndev;
155 + /* This could be another init method for Ethernet::Device: */
156 + rtx_ether_ctx: netdev_priv(&${self}->ndev);
157 }
158 }
159
160 @@ -106,11 +108,17 @@
150 net_device: ${self}->net_dev; 161 net_device: ${self}->net_dev;
151 perm_addr: ${self}->net_dev->ndev.perm_addr; 162 perm_addr: ${self}->net_dev->ndev.perm_addr;
152 dev_addr: ${self}->net_dev->ndev.dev_addr; 163 dev_addr: ${self}->net_dev->ndev.dev_addr;
153 + irq: ${self}->pci_dev->data.irq; 164 + irq: ${self}->pci_dev->data.irq;
154 } 165 }
162 + } 173 + }
163 + 174 +
164 chunk LKM::prototypes() 175 chunk LKM::prototypes()
165 { 176 {
166 static int rtx_ethernet_open(struct net_device *); 177 static int rtx_ethernet_open(struct net_device *);
167 @@ -123,9 +129,28 @@ 178 @@ -123,9 +131,28 @@
168 ${Ethernet::Device} *rtx_ether_ctx = netdev_priv(dev); 179 ${Ethernet::Device} *rtx_ether_ctx = netdev_priv(dev);
169 180
170 ${cast local.rtx_ether_ctx as Ethernet::Device}; 181 ${cast local.rtx_ether_ctx as Ethernet::Device};
171 + 182 +
172 + int error; 183 + int error;
191 + error: 202 + error:
192 + return error; 203 + return error;
193 } 204 }
194 } 205 }
195 } 206 }
196 @@ -165,7 +190,16 @@ 207 @@ -165,7 +192,16 @@
197 ${Ethernet::Device} *rtx_ether_ctx = netdev_priv(dev); 208 ${Ethernet::Device} *rtx_ether_ctx = netdev_priv(dev);
198 209
199 ${cast local.rtx_ether_ctx as Ethernet::Device}; 210 ${cast local.rtx_ether_ctx as Ethernet::Device};
200 - ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx)}; 211 - ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx)};
201 + 212 +
209 + ${Log::info("interrupt handler free'ed")}; 220 + ${Log::info("interrupt handler free'ed")};
210 + } 221 + }
211 222
212 return 0; 223 return 0;
213 } 224 }
214 @@ -267,14 +301,11 @@ 225 @@ -187,9 +223,12 @@
226 {
227 static enum irqreturn rtx_ethernet_interrupt_handler(int irq, void *dev_id)
228 {
229 - ${Ethernet::Device} *rtx_ether_ctx = dev_id;
230 + ${Ethernet::AbstractDevice} *rtx_net_dev = dev_id;
231 + ${cast local.rtx_net_dev as Ethernet::AbstractDevice};
232 + ${Ethernet::Device} *rtx_ether_ctx;
233 + ${cast local.rtx_ether_ctx as Ethernet::Device};
234 + rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx};
235
236 - ${cast local.rtx_ether_ctx as Ethernet::Device};
237 ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx)};
238
239 return IRQ_NONE;
240 @@ -267,14 +306,11 @@
215 */ 241 */
216 int bars = ${rtx_pci_dev.bars}; 242 int bars = ${rtx_pci_dev.bars};
217 unsigned char /* __iomem */ *ioaddr = ${rtx_pci_dev.ioaddr}; 243 unsigned char /* __iomem */ *ioaddr = ${rtx_pci_dev.ioaddr};
218 - int irq = ${rtx_pci_dev.irq}; 244 - int irq = ${rtx_pci_dev.irq};
219 ${cast local.bars as Builtin::number}; 245 ${cast local.bars as Builtin::number};
228 ${pointcut Ethernet::adapter_load_mac_address(local.rtx_ether_ctx)}; 254 ${pointcut Ethernet::adapter_load_mac_address(local.rtx_ether_ctx)};
229 memcpy(${local.rtx_ether_ctx.perm_addr}, 255 memcpy(${local.rtx_ether_ctx.perm_addr},
230 diff --git a/rathaxes/samples/e1000/ethernet.rti b/rathaxes/samples/e1000/ethernet.rti 256 diff --git a/rathaxes/samples/e1000/ethernet.rti b/rathaxes/samples/e1000/ethernet.rti
231 --- a/rathaxes/samples/e1000/ethernet.rti 257 --- a/rathaxes/samples/e1000/ethernet.rti
232 +++ b/rathaxes/samples/e1000/ethernet.rti 258 +++ b/rathaxes/samples/e1000/ethernet.rti
233 @@ -36,10 +36,12 @@ 259 @@ -18,6 +18,11 @@
260 chunk LKM::includes();
261 decl data_types();
262 attribute Builtin::symbol.scalar netdev;
263 + /*
264 + * XXX: should be a Ethernet::Device, but that causes a circular
265 + * dependency:
266 + */
267 + attribute Builtin::symbol rtx_ether_ctx;
268 }
269
270 provided type Device
271 @@ -36,10 +41,12 @@
234 */ 272 */
235 attribute Builtin::symbol.scalar perm_addr; 273 attribute Builtin::symbol.scalar perm_addr;
236 attribute Builtin::symbol.scalar dev_addr; 274 attribute Builtin::symbol.scalar dev_addr;
237 + attribute Builtin::symbol.scalar irq; 275 + attribute Builtin::symbol.scalar irq;
238 } 276 }
241 { 279 {
242 + provided chunk LKM::includes(); 280 + provided chunk LKM::includes();
243 provided chunk LKM::prototypes(); 281 provided chunk LKM::prototypes();
244 provided chunk LKM::code(); 282 provided chunk LKM::code();
245 } 283 }
246 @@ -69,8 +71,7 @@ 284 @@ -69,8 +76,7 @@
247 285
248 provided pointcut Ethernet::adapter_init_context(Ethernet::Device, 286 provided pointcut Ethernet::adapter_init_context(Ethernet::Device,
249 Builtin::number, 287 Builtin::number,
250 - Builtin::symbol, 288 - Builtin::symbol,
251 - Builtin::number); 289 - Builtin::number);