33
|
1 # HG changeset patch
|
|
2 # Parent 4920b3a97ad6f031437c63ca3ae756678fde92a3
|
|
3 rathaxes: initialize the ethernet subsystem in an elegant implicit way
|
|
4
|
|
5 diff -r 4920b3a97ad6 -r c3265ca219d5 rathaxes/samples/lkm/e1000.blt
|
|
6 --- a/rathaxes/samples/lkm/e1000.blt Sat Jan 07 23:09:24 2012 +0100
|
|
7 +++ b/rathaxes/samples/lkm/e1000.blt Sun Jan 08 00:13:22 2012 +0100
|
|
8 @@ -62,7 +62,6 @@
|
|
9 {
|
|
10 // XXX: add a check in order to avoid freeing none allocated
|
|
11 // resources.
|
|
12 - struct net_device *net_dev = pci_get_drvdata(pdev);
|
|
13 struct rtx_ethernet_dev* rtx_ether_ctx = netdev_priv(net_dev);
|
|
14 iounmap(rtx_ether_ctx->hw_ctx.ioaddr);
|
|
15 pci_release_selected_regions(pdev, rtx_ether_ctx->hw_ctx.bars);
|
|
16 diff -r 4920b3a97ad6 -r c3265ca219d5 rathaxes/samples/lkm/ethernet.blt
|
|
17 --- a/rathaxes/samples/lkm/ethernet.blt Sat Jan 07 23:09:24 2012 +0100
|
|
18 +++ b/rathaxes/samples/lkm/ethernet.blt Sun Jan 08 00:13:22 2012 +0100
|
|
19 @@ -125,7 +125,7 @@
|
|
20 };
|
|
21 }
|
|
22
|
|
23 - chunk ::CALL
|
|
24 + chunk PCI::pci_probe_hook()
|
|
25 {
|
|
26 /*
|
|
27 * This typedef is needed to workaround a bug in CNorm __std__
|
|
28 @@ -174,12 +174,18 @@
|
|
29 //pci_set_drvdata(${pdev}, net_dev);
|
|
30 pci_set_drvdata(pdev, net_dev);
|
|
31 }
|
|
32 +
|
|
33 + chunk ::CALL
|
|
34 + {
|
|
35 + }
|
|
36 }
|
|
37
|
|
38 template sequence Ethernet::exit(PCI::Device pdev)
|
|
39 {
|
|
40 - chunk ::CALL
|
|
41 + chunk PCI::pci_remove_hook()
|
|
42 {
|
|
43 + struct net_device *net_dev = pci_get_drvdata(pdev);
|
|
44 +
|
|
45 unregister_netdev(net_dev);
|
|
46 /*
|
|
47 * If we had some cleanup todo with struct rtx_ether_ctx we would
|
|
48 @@ -187,5 +193,10 @@
|
|
49 */
|
|
50 free_netdev(net_dev);
|
|
51 }
|
|
52 +
|
|
53 + chunk ::CALL
|
|
54 + {
|
|
55 + }
|
|
56 }
|
|
57 }
|
|
58 +
|
|
59 diff -r 4920b3a97ad6 -r c3265ca219d5 rathaxes/samples/lkm/ethernet.rti
|
|
60 --- a/rathaxes/samples/lkm/ethernet.rti Sat Jan 07 23:09:24 2012 +0100
|
|
61 +++ b/rathaxes/samples/lkm/ethernet.rti Sun Jan 08 00:13:22 2012 +0100
|
|
62 @@ -28,10 +28,10 @@
|
|
63 provided chunk LKM::code;
|
|
64 }
|
|
65
|
|
66 - /* Kinda extends PCI::probe */
|
|
67 provided sequence Ethernet::init(PCI::Device)
|
|
68 {
|
|
69 provided chunk LKM::data;
|
|
70 + provided chunk PCI::pci_probe_hook;
|
|
71 provided chunk ::CALL;
|
|
72 }
|
|
73
|
|
74 @@ -39,5 +39,6 @@
|
|
75 provided sequence Ethernet::exit(PCI::Device)
|
|
76 {
|
|
77 provided chunk ::CALL;
|
|
78 + provided chunk PCI::pci_remove_hook;
|
|
79 }
|
|
80 }
|
|
81 diff -r 4920b3a97ad6 -r c3265ca219d5 rathaxes/samples/lkm/lkm.rtx
|
|
82 --- a/rathaxes/samples/lkm/lkm.rtx Sat Jan 07 23:09:24 2012 +0100
|
|
83 +++ b/rathaxes/samples/lkm/lkm.rtx Sun Jan 08 00:13:22 2012 +0100
|
|
84 @@ -20,19 +20,19 @@
|
|
85 Log::info("We have one packet to transmit!");
|
|
86 }
|
|
87
|
|
88 - PCI::probe(PCI::Device dev)
|
|
89 - {
|
|
90 - Log::info("Probe the device");
|
|
91 - Ethernet::init(dev);
|
|
92 - e1000::create();
|
|
93 - }
|
|
94 +// PCI::probe(PCI::Device dev)
|
|
95 +// {
|
|
96 +// Log::info("Probe the device");
|
|
97 +// Ethernet::init(dev);
|
|
98 +// e1000::create();
|
|
99 +// }
|
|
100
|
|
101 - PCI::remove(PCI::Device dev)
|
|
102 - {
|
|
103 - Log::info("Remove the pci device");
|
|
104 - e1000::destroy();
|
|
105 - Ethernet::exit(dev);
|
|
106 - }
|
|
107 +// PCI::remove(PCI::Device dev)
|
|
108 +// {
|
|
109 +// Log::info("Remove the pci device");
|
|
110 +// e1000::destroy();
|
|
111 +// Ethernet::exit(dev);
|
|
112 +// }
|
|
113
|
|
114 LKM::init()
|
|
115 {
|
|
116 diff -r 4920b3a97ad6 -r c3265ca219d5 rathaxes/samples/lkm/pci.blt
|
|
117 --- a/rathaxes/samples/lkm/pci.blt Sat Jan 07 23:09:24 2012 +0100
|
|
118 +++ b/rathaxes/samples/lkm/pci.blt Sun Jan 08 00:13:22 2012 +0100
|
|
119 @@ -53,7 +53,7 @@
|
|
120 if (err < 0)
|
|
121 goto fail;
|
|
122
|
|
123 - ${pointcut ::IMPLEMENTATION};
|
|
124 + ${pointcut PCI::pci_probe_hook};
|
|
125
|
|
126 return 0;
|
|
127
|
|
128 @@ -61,6 +61,10 @@
|
|
129 return err;
|
|
130 }
|
|
131 }
|
|
132 +
|
|
133 + chunk ::CALL
|
|
134 + {
|
|
135 + }
|
|
136 }
|
|
137
|
|
138 template sequence PCI::remove(PCI::Device pdev)
|
|
139 @@ -74,11 +78,15 @@
|
|
140 {
|
|
141 static void rtx_pci_remove(struct pci_dev *pdev)
|
|
142 {
|
|
143 - ${pointcut ::IMPLEMENTATION};
|
|
144 + ${pointcut PCI::pci_remove_hook};
|
|
145
|
|
146 pci_disable_device(pdev);
|
|
147 }
|
|
148 }
|
|
149 +
|
|
150 + chunk ::CALL()
|
|
151 + {
|
|
152 + }
|
|
153 }
|
|
154
|
|
155 template sequence PCI::register()
|
|
156 diff -r 4920b3a97ad6 -r c3265ca219d5 rathaxes/samples/lkm/pci.rti
|
|
157 --- a/rathaxes/samples/lkm/pci.rti Sat Jan 07 23:09:24 2012 +0100
|
|
158 +++ b/rathaxes/samples/lkm/pci.rti Sun Jan 08 00:13:22 2012 +0100
|
|
159 @@ -23,15 +23,19 @@
|
|
160 provided chunk LKM::deinit_bus_hook;
|
|
161 }
|
|
162
|
|
163 - required sequence PCI::probe(PCI::Device)
|
|
164 + provided sequence PCI::probe(PCI::Device)
|
|
165 {
|
|
166 provided chunk LKM::prototypes;
|
|
167 provided chunk LKM::code;
|
|
168 +
|
|
169 + provided pointcut PCI::pci_probe_hook;
|
|
170 }
|
|
171
|
|
172 - required sequence PCI::remove(PCI::Device)
|
|
173 + provided sequence PCI::remove(PCI::Device)
|
|
174 {
|
|
175 provided chunk LKM::prototypes;
|
|
176 provided chunk LKM::code;
|
|
177 +
|
|
178 + provided pointcut PCI::pci_remove_hook;
|
|
179 }
|
|
180 }
|