comparison rathaxes_cleanups_in_ethernet_rti_blt.patch @ 98:147519512c3d

Commit before pulling Joa's changes
author Louis Opter <louis@lse.epita.fr>
date Thu, 22 Nov 2012 16:41:18 -0800
parents 2cc8fda4c4e3
children e2c237d6c37b
comparison
equal deleted inserted replaced
97:ffdb018893e2 98:147519512c3d
1 # HG changeset patch 1 # HG changeset patch
2 # Parent 72057981213815c2bc5f34f50a997ea2e28f2fdc 2 # Parent 6cc56c206e65a31121a9e9745003fed8276b0b60
3 rathaxes: tidy up ethernet.{rti,blt} in the e1000 sample 3 rathaxes: tidy up ethernet.{rti,blt} in the e1000 sample
4 4
5 - Remove typedefs; 5 - Remove typedefs;
6 - Rename Ethernet::SubContext in Ethernet::HardwareContext: I think this 6 - Rename Ethernet::SubContext in Ethernet::HardwareContext: I think this
7 is more clear. This pointcut is here to allow the underlying real 7 is more clear. This pointcut is here to allow the underlying real
8 device to store its private data structure within the context of the 8 device to store its private data structure within the context of the
9 Ethernet subsystem. 9 Ethernet subsystem.
10 10
11
12 diff --git a/rathaxes/samples/e1000/e1000.blt b/rathaxes/samples/e1000/e1000.blt 11 diff --git a/rathaxes/samples/e1000/e1000.blt b/rathaxes/samples/e1000/e1000.blt
13 --- a/rathaxes/samples/e1000/e1000.blt 12 --- a/rathaxes/samples/e1000/e1000.blt
14 +++ b/rathaxes/samples/e1000/e1000.blt 13 +++ b/rathaxes/samples/e1000/e1000.blt
15 @@ -268,7 +268,7 @@ 14 @@ -284,7 +284,7 @@
15 };
16 }
16 17
17 template type e1000::Context()
18 {
19 - chunk Ethernet::SubContext() 18 - chunk Ethernet::SubContext()
20 + chunk Ethernet::HardwareContext() 19 + chunk Ethernet::HardwareContext()
21 { 20 {
22 /* 21 /*
23 * Force the generation of the structure in the "headers" part, we 22 * Force the generation of the structure in the "headers" part, we
24 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti 23 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti
25 --- a/rathaxes/samples/e1000/e1000.rti 24 --- a/rathaxes/samples/e1000/e1000.rti
26 +++ b/rathaxes/samples/e1000/e1000.rti 25 +++ b/rathaxes/samples/e1000/e1000.rti
27 @@ -10,7 +10,7 @@ 26 @@ -9,7 +9,7 @@
27 {
28 method decl();
28 29
29 provided type Context
30 {
31 - chunk Ethernet::SubContext(); 30 - chunk Ethernet::SubContext();
32 + chunk Ethernet::HardwareContext(); 31 + chunk Ethernet::HardwareContext();
33 method decl(); 32
34 method init(); 33 /* Callbacks/Hooks which should probably be in the front-end: */
35 } 34 chunk Ethernet::adapter_init_context(Ethernet::Device,
36 diff --git a/rathaxes/samples/e1000/ethernet.blt b/rathaxes/samples/e1000/ethernet.blt 35 diff --git a/rathaxes/samples/e1000/ethernet.blt b/rathaxes/samples/e1000/ethernet.blt
37 --- a/rathaxes/samples/e1000/ethernet.blt 36 --- a/rathaxes/samples/e1000/ethernet.blt
38 +++ b/rathaxes/samples/e1000/ethernet.blt 37 +++ b/rathaxes/samples/e1000/ethernet.blt
39 @@ -59,7 +59,7 @@ 38 @@ -59,7 +59,7 @@
40 39
58 - */ 57 - */
59 - typedef struct rtx_ethernet_dev 58 - typedef struct rtx_ethernet_dev
60 + struct rtx_ethernet_dev 59 + struct rtx_ethernet_dev
61 { 60 {
62 /* 61 /*
63 * I think it's useless to use the ${PCI::Device} "abstraction" 62 * I think it's useless to use the ${PCI::AbstractDevice} "abstraction"
64 @@ -96,8 +89,8 @@ 63 @@ -96,8 +89,8 @@
65 * In the long-term, this may disappear for a new concept allowing 64 * In the long-term, this may disappear for a new concept allowing
66 * to embbed a descriptor defined and manipulated by the front-end 65 * to embbed a descriptor defined and manipulated by the front-end
67 */ 66 */
68 - ${pointcut Ethernet::SubContext()}; 67 - ${pointcut Ethernet::SubContext()};
69 - } *rtx_ethernet_dev_p; 68 - } *rtx_ethernet_dev_p;
70 + ${pointcut Ethernet::HardwareContext()}; 69 + ${pointcut Ethernet::HardwareContext()};
71 + }; 70 + };
72 } 71 }
73 72
74 chunk ::init(Ethernet::AbstractDevice net_dev, PCI::Device pci_dev) 73 chunk ::init(Ethernet::AbstractDevice net_dev, PCI::AbstractDevice pci_dev)
75 @@ -105,7 +98,7 @@ 74 @@ -105,7 +98,7 @@
76 ${self} = netdev_priv(${net_dev}); 75 ${self} = netdev_priv(${net_dev});
77 /* 76 /*
78 * We can use -> because we know that ${self} will be always a 77 * We can use -> because we know that ${self} will be always a
79 - * pointer ("thanks" to the typedef) 78 - * pointer ("thanks" to the typedef)
80 + * pointer, but the ambiguity sucks. 79 + * pointer, but the ambiguity sucks.
81 */ 80 */
82 ${self}->pci_dev = ${pci_dev}; 81 ${self}->pci_dev = ${pci_dev};
83 ${self}->net_dev = ${net_dev}; 82 ${self}->net_dev = ${net_dev};
84 @@ -213,12 +206,8 @@ 83 @@ -129,8 +122,9 @@
85 /* For now the type is not handled, so we just omit it (see #17) */
86 chunk PCI::pci_probe_hook(PCI::Device pdev)
87 { 84 {
88 - /* 85 static int rtx_ethernet_open(struct net_device *dev)
89 - * This typedef is needed to workaround a bug in CNorm __std__ 86 {
90 - * dialect. 87 - ${Ethernet::Device} rtx_ether_dev = netdev_priv(dev);
91 - */ 88 + ${Ethernet::Device} *rtx_ether_dev = netdev_priv(dev);
92 ${Ethernet::Device} rtx_ether_ctx;
93 - struct net_device *net_dev;
94 + ${Ethernet::AbstractDevice} net_dev;
95 int error;
96 89
97 /* Initialize the net_device structure */ 90 + ${cast local.rtx_ether_dev as Ethernet::Device};
98 @@ -264,8 +253,7 @@ 91 ${pointcut ::IMPLEMENTATION(local.rtx_ether_dev)};
99 { 92
100 chunk PCI::pci_remove_hook(PCI::Device pdev) 93 return 0;
94 @@ -149,8 +143,10 @@
101 { 95 {
102 - /* workaround for cnorm unstrict */ 96 static int rtx_ethernet_xmit(struct sk_buff* kernel_skb, struct net_device *net_dev)
103 - struct net_device *net_dev = pci_get_drvdata(${pdev}); 97 {
104 + ${Ethernet::AbstractDevice} net_dev = pci_get_drvdata(${pdev}); 98 - ${Ethernet::Device} rtx_ethernet_dev = netdev_priv(net_dev);
105 ${Ethernet::Device} rtx_ether_ctx = netdev_priv(net_dev); 99 + ${Ethernet::Device} *rtx_ethernet_dev = netdev_priv(net_dev);
100 ${cast local.kernel_skb as Socket::AbstractSKBuff};
101 +
102 + ${cast local.rtx_ethernet_dev as Ethernet::Device};
103 ${pointcut ::IMPLEMENTATION(local.rtx_ethernet_dev, local.kernel_skb)};
104 }
105 }
106 @@ -167,8 +163,9 @@
107 {
108 static int rtx_ethernet_close(struct net_device *dev)
109 {
110 - ${Ethernet::Device} rtx_ether_dev = netdev_priv(dev);
111 + ${Ethernet::Device} *rtx_ether_dev = netdev_priv(dev);
106 112
107 ${pointcut Ethernet::destroy_device(pdev, local.rtx_ether_ctx)}; 113 + ${cast local.rtx_ether_dev as Ethernet::Device};
114 ${pointcut ::IMPLEMENTATION(local.rtx_ether_dev)};
115
116 return 0;
117 @@ -191,8 +188,9 @@
118 {
119 static enum irqreturn rtx_ethernet_interrupt_handler(int irq, void *dev_id)
120 {
121 - ${Ethernet::Device} rtx_ether_dev = dev_id;
122 + ${Ethernet::Device} *rtx_ether_dev = dev_id;
123
124 + ${cast local.rtx_ether_dev as Ethernet::Device};
125 ${pointcut ::IMPLEMENTATION(local.rtx_ether_dev)};
126
127 return IRQ_NONE;
128 @@ -222,8 +220,8 @@
129 */
130 chunk PCI::pci_probe_hook(PCI::Device rtx_pci_dev)
131 {
132 - ${Ethernet::Device} rtx_ether_ctx;
133 - ${Ethernet::AbstractDevice} net_dev;
134 + ${Ethernet::Device} *rtx_ether_ctx;
135 + ${Ethernet::AbstractDevice} *net_dev;
136
137 net_dev = alloc_etherdev(sizeof(*rtx_ether_ctx));
138 if (!net_dev)
139 @@ -272,6 +270,7 @@
140 int irq = ${rtx_pci_dev.irq};
141 ${cast local.bars as Builtin::number};
142 ${cast local.irq as Builtin::number};
143 + ${cast local.rtx_ether_ctx as Ethernet::Device};
144 ${pointcut Ethernet::adapter_init_context(local.rtx_ether_ctx,
145 local.bars,
146 local.ioaddr,
147 @@ -294,10 +293,11 @@
148 */
149 chunk PCI::pci_remove_hook(PCI::Device rtx_pci_dev)
150 {
151 - ${Ethernet::Device} rtx_ether_ctx = ${rtx_pci_dev.context};
152 + ${Ethernet::Device} *rtx_ether_ctx = ${rtx_pci_dev.context};
153
154 BUG_ON(!rtx_ether_ctx);
155
156 + ${cast local.rtx_ether_ctx as Ethernet::Device};
157 unregister_netdev(${local.rtx_ether_ctx.net_device});
158 free_netdev(${local.rtx_ether_ctx.net_device});
159 }
108 diff --git a/rathaxes/samples/e1000/ethernet.rti b/rathaxes/samples/e1000/ethernet.rti 160 diff --git a/rathaxes/samples/e1000/ethernet.rti b/rathaxes/samples/e1000/ethernet.rti
109 --- a/rathaxes/samples/e1000/ethernet.rti 161 --- a/rathaxes/samples/e1000/ethernet.rti
110 +++ b/rathaxes/samples/e1000/ethernet.rti 162 +++ b/rathaxes/samples/e1000/ethernet.rti
111 @@ -27,7 +27,7 @@ 163 @@ -22,7 +22,7 @@
112 chunk LKM::includes(); 164 chunk LKM::includes();
113 method decl(); 165 method decl();
114 method init(Ethernet::AbstractDevice, PCI::Device); 166 method init(Ethernet::AbstractDevice, PCI::AbstractDevice);
115 - pointcut Ethernet::SubContext(); 167 - pointcut Ethernet::SubContext();
116 + pointcut Ethernet::HardwareContext(); 168 + pointcut Ethernet::HardwareContext();
117 }
118 169
119 required sequence open(Ethernet::Device) 170 attribute PCI::AbstractDevice pci_device;
171 attribute Ethernet::AbstractDevice net_device;