33
|
1 # HG changeset patch
|
34
|
2 # Parent 1cfa6a46c673fae191ce982e2ebd471f9a53ee90
|
33
|
3 rathaxes: initialize the e1000 sepcific code in an elegant implicit way
|
|
4
|
34
|
5 diff -r 1cfa6a46c673 rathaxes/samples/lkm/e1000.blt
|
|
6 --- a/rathaxes/samples/lkm/e1000.blt Sun Jan 08 01:01:14 2012 +0100
|
|
7 +++ b/rathaxes/samples/lkm/e1000.blt Sun Jan 08 01:02:13 2012 +0100
|
33
|
8 @@ -27,9 +27,9 @@
|
|
9 }
|
|
10 }
|
|
11
|
|
12 - template sequence e1000::create()
|
|
13 + template sequence e1000::create_device()
|
|
14 {
|
|
15 - chunk ::CALL
|
|
16 + chunk Ethernet::create_device()
|
|
17 {
|
|
18 rtx_ether_ctx->hw_ctx.bars = pci_select_bars(pdev, IORESOURCE_MEM);
|
|
19 if (pci_enable_device_mem(pdev))
|
34
|
20 @@ -54,18 +54,25 @@
|
33
|
21 ${Log::info("e1000::create: pci_ioremap_bar failed")};
|
|
22 }
|
|
23 }
|
|
24 +
|
|
25 + chunk ::CALL
|
|
26 + {
|
|
27 + }
|
|
28 }
|
|
29
|
|
30 - template sequence e1000::destroy()
|
|
31 + template sequence e1000::destroy_device()
|
|
32 {
|
|
33 - chunk ::CALL
|
|
34 + chunk Ethernet::destroy_device
|
|
35 {
|
|
36 // XXX: add a check in order to avoid freeing none allocated
|
|
37 // resources.
|
34
|
38 struct rtx_ethernet_dev* rtx_ether_ctx = netdev_priv(net_dev);
|
|
39 iounmap(rtx_ether_ctx->hw_ctx.ioaddr);
|
33
|
40 pci_release_selected_regions(pdev, rtx_ether_ctx->hw_ctx.bars);
|
34
|
41 - pci_release_region(pdev, 0);
|
|
42 + }
|
33
|
43 +
|
|
44 + chunk ::CALL
|
|
45 + {
|
34
|
46 }
|
33
|
47 }
|
|
48 }
|
34
|
49 diff -r 1cfa6a46c673 rathaxes/samples/lkm/e1000.rti
|
|
50 --- a/rathaxes/samples/lkm/e1000.rti Sun Jan 08 01:01:14 2012 +0100
|
|
51 +++ b/rathaxes/samples/lkm/e1000.rti Sun Jan 08 01:02:13 2012 +0100
|
33
|
52 @@ -3,13 +3,15 @@
|
|
53 provided type e1000::Context;
|
|
54
|
|
55 /* Not sure if we need the argument */
|
|
56 - provided sequence e1000::create()
|
|
57 + provided sequence e1000::create_device()
|
|
58 {
|
|
59 + provided chunk Ethernet::create_device;
|
|
60 provided chunk ::CALL;
|
|
61 }
|
|
62
|
|
63 - provided sequence e1000::destroy()
|
|
64 + provided sequence e1000::destroy_device()
|
|
65 {
|
|
66 + provided chunk Ethernet::destroy_device;
|
|
67 provided chunk ::CALL;
|
|
68 }
|
|
69 }
|
34
|
70 diff -r 1cfa6a46c673 rathaxes/samples/lkm/ethernet.blt
|
|
71 --- a/rathaxes/samples/lkm/ethernet.blt Sun Jan 08 01:01:14 2012 +0100
|
|
72 +++ b/rathaxes/samples/lkm/ethernet.blt Sun Jan 08 01:02:13 2012 +0100
|
33
|
73 @@ -173,6 +173,7 @@
|
|
74 /* same problem as above with ${pdev} */
|
|
75 //pci_set_drvdata(${pdev}, net_dev);
|
|
76 pci_set_drvdata(pdev, net_dev);
|
|
77 + ${pointcut Ethernet::create_device};
|
|
78 }
|
|
79
|
|
80 chunk ::CALL
|
|
81 @@ -186,6 +187,8 @@
|
|
82 {
|
|
83 struct net_device *net_dev = pci_get_drvdata(pdev);
|
|
84
|
|
85 + ${pointcut Ethernet::destroy_device};
|
|
86 +
|
|
87 unregister_netdev(net_dev);
|
|
88 /*
|
|
89 * If we had some cleanup todo with struct rtx_ether_ctx we would
|
34
|
90 diff -r 1cfa6a46c673 rathaxes/samples/lkm/ethernet.rti
|
|
91 --- a/rathaxes/samples/lkm/ethernet.rti Sun Jan 08 01:01:14 2012 +0100
|
|
92 +++ b/rathaxes/samples/lkm/ethernet.rti Sun Jan 08 01:02:13 2012 +0100
|
33
|
93 @@ -33,6 +33,8 @@
|
|
94 provided chunk LKM::data;
|
|
95 provided chunk PCI::pci_probe_hook;
|
|
96 provided chunk ::CALL;
|
|
97 +
|
|
98 + provided pointcut Ethernet::create_device;
|
|
99 }
|
|
100
|
|
101 /* Likely extends PCI::remove */
|
|
102 @@ -40,5 +42,7 @@
|
|
103 {
|
|
104 provided chunk ::CALL;
|
|
105 provided chunk PCI::pci_remove_hook;
|
|
106 +
|
|
107 + provided pointcut Ethernet::destroy_device;
|
|
108 }
|
|
109 }
|
34
|
110 diff -r 1cfa6a46c673 rathaxes/samples/lkm/lkm.rtx
|
|
111 --- a/rathaxes/samples/lkm/lkm.rtx Sun Jan 08 01:01:14 2012 +0100
|
|
112 +++ b/rathaxes/samples/lkm/lkm.rtx Sun Jan 08 01:02:13 2012 +0100
|
|
113 @@ -20,30 +20,14 @@
|
|
114 Log::info("We have one packet to transmit!");
|
|
115 }
|
|
116
|
|
117 -// PCI::probe(PCI::Device dev)
|
|
118 -// {
|
|
119 -// Log::info("Probe the device");
|
|
120 -// Ethernet::init(dev);
|
|
121 -// e1000::create();
|
|
122 -// }
|
|
123 -
|
|
124 -// PCI::remove(PCI::Device dev)
|
|
125 -// {
|
|
126 -// Log::info("Remove the pci device");
|
|
127 -// e1000::destroy();
|
|
128 -// Ethernet::exit(dev);
|
|
129 -// }
|
|
130 -
|
|
131 LKM::init()
|
|
132 {
|
|
133 Log::info("Hello this is LKM");
|
|
134 - // PCI::register();
|
|
135 }
|
|
136
|
|
137 LKM::exit()
|
|
138 {
|
|
139 Log::info("Good bye this was LKM");
|
|
140 - // PCI::unregister();
|
|
141 }
|
|
142 }
|
|
143
|