annotate rathaxes_correctly_use_chunk_and_template_sequences_parameters_in_e1000.patch @ 62:b43bed449cc2

Start a series on the e1000 sample
author Louis Opter <louis@lse.epitech.net>
date Fri, 17 Feb 2012 15:15:28 +0100
parents
children b820c4604946
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
62
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1 # HG changeset patch
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
2 # Parent d759597ad67d463fa77467b2443120315980c70b
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
3 # User Louis Opter <louis@lse.epitech.net>, David Pineau <dav.pineau@gmail.com>
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
4 rathaxes: correctly use chunk and template sequences parameters in the e1000 sample
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
5
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
6 diff --git a/rathaxes/samples/e1000/ethernet.blt b/rathaxes/samples/e1000/ethernet.blt
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
7 --- a/rathaxes/samples/e1000/ethernet.blt
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
8 +++ b/rathaxes/samples/e1000/ethernet.blt
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
9 @@ -1,5 +1,10 @@
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
10 with Ethernet, PCI, LKM, Log
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
11 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
12 + /*
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
13 + * Unlike PCI::Device, Ethernet::Device doesn't match the struct net_device
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
14 + * from Linux. Ethernet::Device is the type that we use in the private
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
15 + * field of the struct net_device.
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
16 + */
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
17 template type Ethernet::Device()
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
18 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
19 chunk LKM::includes()
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
20 @@ -10,7 +15,14 @@
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
21
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
22 chunk ::decl()
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
23 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
24 - struct rtx_ethernet_dev
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
25 + /*
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
26 + * So, at first sight, it sucks to typedef it as pointer but (for
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
27 + * now) it makes sense for two reasons:
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
28 + * - This structure will always be used through a pointer;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
29 + * - This remove the ambiguity of pointer/not-pointer in the
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
30 + * ::init() chunk.
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
31 + */
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
32 + typedef struct rtx_ethernet_dev
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
33 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
34 /*
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
35 * I think it's useless to use the ${PCI::Device} "abstraction"
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
36 @@ -21,12 +33,18 @@
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
37
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
38 /* while waiting on issue #8 */
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
39 struct rtx_e1000_ctx hw_ctx;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
40 - };
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
41 + } *rtx_ethernet_dev_p;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
42 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
43
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
44 - chunk ::init(net_dev)
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
45 + chunk ::init(net_dev, pci_dev)
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
46 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
47 - ${self} = ${net_dev};
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
48 + ${self} = netdev_priv(${net_dev});
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
49 + /*
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
50 + * We can use -> because we know that ${self} will be always a
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
51 + * pointer ("thanks" to the typedef)
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
52 + */
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
53 + ${self}->pci_dev = ${pci_dev};
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
54 + ${self}->net_dev = ${net_dev};
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
55 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
56
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
57 map
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
58 @@ -45,7 +63,7 @@
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
59 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
60 static int rtx_ethernet_open(struct net_device *dev)
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
61 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
62 - struct rtx_ethernet_dev* rtx_ether_dev = netdev_priv(dev);
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
63 + struct rtx_ethernet_dev* rtx_ether_dev = netdev_priv(dev);
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
64 struct rtx_e1000_ctx* ctx = &rtx_ether_dev->hw_ctx;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
65
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
66 ${pointcut ::IMPLEMENTATION};
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
67 @@ -121,7 +139,7 @@
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
68 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
69 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
70
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
71 - template sequence Ethernet::init(PCI::Device pdev)
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
72 + template sequence Ethernet::init()
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
73 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
74 chunk LKM::data()
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
75 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
76 @@ -133,18 +151,20 @@
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
77 };
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
78 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
79
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
80 - chunk PCI::pci_probe_hook()
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
81 + /* For now the type is not handled, so we just omit it (see #17) */
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
82 + chunk PCI::pci_probe_hook(/* PCI::Device */ pdev)
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
83 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
84 /*
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
85 * This typedef is needed to workaround a bug in CNorm __std__
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
86 * dialect.
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
87 */
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
88 typedef int ${Ethernet::Device};
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
89 - ${Ethernet::Device} *rtx_ether_ctx;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
90 - struct net_device *net_dev;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
91 +
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
92 + ${Ethernet::Device} rtx_ether_ctx;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
93 + struct net_device *net_dev;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
94 int error;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
95
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
96 - error = 0;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
97 + /* Initialize the net_device structure */
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
98 net_dev = alloc_etherdev(sizeof(*rtx_ether_ctx));
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
99 if (net_dev == 0)
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
100 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
101 @@ -152,53 +172,42 @@
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
102 /*
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
103 * Again, the error should be "raised" in the parent context.
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
104 *
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
105 - * Here we know that we should return ENOMEM because *we* wrote
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
106 + * Here we know that we can return ENOMEM because *we* wrote
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
107 * the parent context.
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
108 */
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
109 return -ENOMEM;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
110 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
111 + SET_NETDEV_DEV(net_dev, &${pdev}->dev);
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
112 strlcpy(net_dev->name, ${config.ifname}, sizeof(net_dev->name));
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
113 - net_dev->irq = pdev->irq;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
114 - // Maybe we should try ${rtx_ether_ctx.init()} here:
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
115 - rtx_ether_ctx = netdev_priv(net_dev);
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
116 - //rtx_ether_ctx->pci_dev = ${pdev};
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
117 - rtx_ether_ctx->pci_dev = pdev; // In the meantime do it directly
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
118 - rtx_ether_ctx->net_dev = net_dev;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
119 + net_dev->irq = ${pdev}->irq;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
120 + net_dev->netdev_ops = &rtx_ether_ops;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
121
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
122 - /*
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
123 - * The substitution of ${pdev} fails here. I also tried to add a
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
124 - * "substitute method" to the PCI::Device that was just doing
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
125 - * "${self}" but it didn't work either (it was subsituted by a
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
126 - * placeholder, e.g: _1).
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
127 - *
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
128 - * That's why we cheated a bit and named all the arguments pdev.
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
129 - */
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
130 - //SET_NETDEV_DEV(net_dev, &${pdev}->dev);
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
131 - SET_NETDEV_DEV(net_dev, &pdev->dev);
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
132 - net_dev->netdev_ops = &rtx_ether_ops;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
133 - if ((error = register_netdev(net_dev)))
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
134 + error = register_netdev(net_dev);
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
135 + if (error)
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
136 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
137 ${Log::info("Cannot register the driver")};
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
138 return error;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
139 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
140
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
141 - /* same problem as above with ${pdev} */
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
142 - //pci_set_drvdata(${pdev}, net_dev);
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
143 - pci_set_drvdata(pdev, net_dev);
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
144 + /* Initialize our context held by the net_device structure */
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
145 + ${rtx_ether_ctx.init(local.net_dev, pdev)};
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
146 +
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
147 + pci_set_drvdata(${pdev}, net_dev);
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
148
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
149 ${pointcut Ethernet::create_device};
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
150 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
151
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
152 + /* This chunk should be remove (see #26) */
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
153 chunk ::CALL
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
154 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
155 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
156 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
157
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
158 - template sequence Ethernet::exit(PCI::Device pdev)
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
159 + template sequence Ethernet::exit()
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
160 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
161 - chunk PCI::pci_remove_hook()
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
162 + chunk PCI::pci_remove_hook(/* PCI::Device */ pdev)
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
163 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
164 - struct net_device *net_dev = pci_get_drvdata(pdev);
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
165 + struct net_device *net_dev = pci_get_drvdata(${pdev});
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
166
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
167 ${pointcut Ethernet::destroy_device};
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
168
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
169 @@ -210,6 +219,7 @@
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
170 free_netdev(net_dev);
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
171 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
172
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
173 + /* This chunk should be remove (see #26) */
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
174 chunk ::CALL
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
175 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
176 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
177 diff --git a/rathaxes/samples/e1000/ethernet.rti b/rathaxes/samples/e1000/ethernet.rti
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
178 --- a/rathaxes/samples/e1000/ethernet.rti
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
179 +++ b/rathaxes/samples/e1000/ethernet.rti
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
180 @@ -28,18 +28,16 @@
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
181 provided chunk LKM::code;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
182 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
183
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
184 - provided sequence Ethernet::init(PCI::Device)
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
185 + provided sequence Ethernet::init()
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
186 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
187 provided chunk LKM::data;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
188 provided chunk PCI::pci_probe_hook;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
189 - provided chunk ::CALL;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
190
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
191 provided pointcut Ethernet::create_device;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
192 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
193
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
194 - provided sequence Ethernet::exit(PCI::Device)
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
195 + provided sequence Ethernet::exit()
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
196 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
197 - provided chunk ::CALL;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
198 provided chunk PCI::pci_remove_hook;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
199
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
200 provided pointcut Ethernet::destroy_device;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
201 diff --git a/rathaxes/samples/e1000/pci.blt b/rathaxes/samples/e1000/pci.blt
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
202 --- a/rathaxes/samples/e1000/pci.blt
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
203 +++ b/rathaxes/samples/e1000/pci.blt
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
204 @@ -22,7 +22,7 @@
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
205 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
206 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
207
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
208 - template sequence PCI::probe(PCI::Device pdev)
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
209 + template sequence PCI::probe()
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
210 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
211 chunk LKM::prototypes()
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
212 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
213 @@ -41,7 +41,8 @@
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
214 if (err < 0)
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
215 goto fail;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
216
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
217 - ${pointcut PCI::pci_probe_hook};
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
218 + /* Use local. to reference a local C variable: */
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
219 + ${pointcut PCI::pci_probe_hook(local.pdev)};
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
220
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
221 return 0;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
222
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
223 @@ -50,12 +51,13 @@
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
224 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
225 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
226
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
227 + /* This chunk should be remove (see #26) */
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
228 chunk ::CALL
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
229 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
230 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
231 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
232
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
233 - template sequence PCI::remove(PCI::Device pdev)
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
234 + template sequence PCI::remove()
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
235 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
236 chunk LKM::prototypes()
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
237 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
238 @@ -66,12 +68,13 @@
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
239 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
240 static void rtx_pci_remove(struct pci_dev *pdev)
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
241 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
242 - ${pointcut PCI::pci_remove_hook};
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
243 + ${pointcut PCI::pci_remove_hook(local.pdev)};
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
244
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
245 pci_disable_device(pdev);
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
246 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
247 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
248
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
249 + /* This chunk should be remove (see #26) */
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
250 chunk ::CALL()
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
251 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
252 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
253 @@ -125,6 +128,8 @@
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
254 * This sequence is just "intermediate" code that will just inject
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
255 * itself in the hook LKM::init_bus_hook for which this sequence
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
256 * has a chunk (see above chunk).
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
257 + *
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
258 + * -> Should be removed see #26
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
259 */
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
260 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
261 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
262 @@ -136,6 +141,7 @@
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
263 pci_unregister_driver(&rtx_pci_driver);
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
264 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
265
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
266 + /* This chunk should be removed */
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
267 chunk ::CALL
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
268 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
269 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
270 diff --git a/rathaxes/samples/e1000/pci.rti b/rathaxes/samples/e1000/pci.rti
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
271 --- a/rathaxes/samples/e1000/pci.rti
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
272 +++ b/rathaxes/samples/e1000/pci.rti
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
273 @@ -18,7 +18,7 @@
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
274 provided chunk LKM::deinit_bus_hook;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
275 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
276
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
277 - provided sequence PCI::probe(PCI::Device)
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
278 + provided sequence PCI::probe()
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
279 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
280 provided chunk LKM::prototypes;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
281 provided chunk LKM::code;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
282 @@ -26,7 +26,7 @@
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
283 provided pointcut PCI::pci_probe_hook;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
284 }
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
285
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
286 - provided sequence PCI::remove(PCI::Device)
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
287 + provided sequence PCI::remove()
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
288 {
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
289 provided chunk LKM::prototypes;
b43bed449cc2 Start a series on the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
290 provided chunk LKM::code;