annotate rathaxes_change_the_abstract_type_notation_in_the_e1000_sample.patch @ 105:fb20f01ea997

Wip, note: the interrupt handler refactoring patch is broken, I have to find the fix from the abstract type notation patch
author Louis Opter <louis@lse.epita.fr>
date Fri, 22 Mar 2013 00:25:52 -0700
parents c4c33ac02b93
children 976a4b87803f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
1 # HG changeset patch
105
fb20f01ea997 Wip, note: the interrupt handler refactoring patch is broken, I have to find the fix from the abstract type notation patch
Louis Opter <louis@lse.epita.fr>
parents: 104
diff changeset
2 # Parent 1fa9b24e6012b2d53f1a84d4606cf3b6b9685fef
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
3 rathaxes: change the abstract type notation in the e1000 sample
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
4
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
5 Starting with ra24db32bf134 Rathaxes types are generated differently: you
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
6 don't define entire structures anymore, but only the fields. And the
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
7 compiler generate a typedef'ed structure on top of it.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
8
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
9 This works fine, except for "abstract types" (the types defined by —and
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
10 used to interact with— the kernel). We need to define these types as
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
11 Rathaxes types to interact with them, in Rathaxes, but with
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
12 ra24db32bf134 it means that we loose (hide) the original type from the
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
13 kernel, making it very difficult to use "abstract types" with the
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
14 kernels APIs.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
15
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
16 For example, here the hypothetical generated struct for the abstract
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
17 type "struct net_device" from Linux would be:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
18
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
19 typedef struct {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
20 struct net_device data;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
21 } rtx_GeneratedType;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
22
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
23 And here is how we have to use it:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
24
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
25 rtx_GeneratedType *my_struct;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
26 kernel_api_function(&my_struct->data);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
27
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
28 This &my_struct->data is actually always a nop, but it's confusing and
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
29 hard to understand.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
30
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
31 This changeset changes the notation to:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
32
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
33 rtx_GeneratedType *my_struct;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
34 kernel_api_function((struct net_device *)my_struct);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
35
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
36 Which is, I believe, more intuitive and coherent with how you would
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
37 initialize the my_struct pointer here with a return value from the
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
38 kernel (i.e: with a cast into rtx_GeneratedType *).
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
39
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
40 diff --git a/rathaxes/samples/e1000/device.blt b/rathaxes/samples/e1000/device.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
41 --- a/rathaxes/samples/e1000/device.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
42 +++ b/rathaxes/samples/e1000/device.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
43 @@ -18,7 +18,7 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
44
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
45 map
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
46 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
47 - data: ${self}->data;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
48 + k_device: ((struct device *)${self});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
49 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
50 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
51 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
52 diff --git a/rathaxes/samples/e1000/device.rti b/rathaxes/samples/e1000/device.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
53 --- a/rathaxes/samples/e1000/device.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
54 +++ b/rathaxes/samples/e1000/device.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
55 @@ -5,6 +5,6 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
56 decl data_types();
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
57 chunk LKM::includes();
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
58 method init();
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
59 - attribute Builtin::symbol data;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
60 + attribute Builtin::symbol k_device;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
61 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
62 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
63 diff --git a/rathaxes/samples/e1000/e1000.blt b/rathaxes/samples/e1000/e1000.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
64 --- a/rathaxes/samples/e1000/e1000.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
65 +++ b/rathaxes/samples/e1000/e1000.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
66 @@ -171,13 +171,17 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
67
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
68 static int rtx_e1000_tx_ring_tso_cksum_offload(${e1000::TxRing} *self, ${Socket::SKBuff} *skb)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
69 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
70 - ${Socket::AbstractSKBuff} *abs_skb = skb->skbuff;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
71 - ${cast local.abs_skb as Socket::AbstractSKBuff};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
72 - return skb_is_gso(&${local.abs_skb.data}) || ${local.abs_skb.data}.ip_summed == CHECKSUM_PARTIAL;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
73 + /* XXX We can't use ${skb} here because it's a pointer */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
74 + ${Socket::AbstractSKBuff} *k_skb = skb->skbuff;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
75 + ${cast local.k_skb as Socket::AbstractSKBuff};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
76 + return skb_is_gso(${local.k_skb.k_sk_buff}) || ${local.k_skb.k_sk_buff}->ip_summed == CHECKSUM_PARTIAL;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
77 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
78
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
79 static void rtx_e1000_tx_ring_put(${e1000::TxRing} *self, ${Socket::SKBuff} *skb)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
80 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
81 + /* XXX We can't use ${skb} here because it's a pointer */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
82 + ${Socket::AbstractSKBuff} *k_skb = skb->skbuff;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
83 + ${cast local.k_skb as Socket::AbstractSKBuff};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
84 WARN_ON(!skb);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
85
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
86 /*
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
87 @@ -188,17 +192,15 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
88 * code shouldn't be aware of it and use something more
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
89 * abstract.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
90 */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
91 - ${Socket::AbstractSKBuff} *abs_skb = skb->skbuff;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
92 - ${cast local.abs_skb as Socket::AbstractSKBuff};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
93 ${e1000::TxDescriptor} *tx_desc = &self->base[self->tail];
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
94 tx_desc->lower.data = cpu_to_le32(
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
95 E1000_TXD_CMD_EOP |
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
96 E1000_TXD_CMD_IFCS |
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
97 E1000_TXD_CMD_RS |
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
98 - skb_headlen(&${local.abs_skb.data}));
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
99 + skb_headlen(${local.k_skb.k_sk_buff}));
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
100 tx_desc->upper.data = 0;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
101 tx_desc->buff_addr = cpu_to_le64(skb->dma_handle);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
102 - memcpy(&self->skbuffs[self->tail], skb, sizeof(*skb));
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
103 + memcpy(&self->skbuffs[self->tail], ${local.k_skb.k_sk_buff}, sizeof(*${local.k_skb.k_sk_buff}));
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
104 self->tail = (self->tail + 1) % ${config.tx_ring_size};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
105 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
106
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
107 @@ -733,7 +735,7 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
108 hw_ctx->rx_ring.size = ${config.rx_ring_size} * sizeof(*hw_ctx->rx_ring.base);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
109 hw_ctx->rx_ring.size = ALIGN(hw_ctx->rx_ring.size, 4096);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
110 hw_ctx->rx_ring.base = dma_alloc_coherent(
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
111 - &${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
112 + ${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
113 hw_ctx->rx_ring.size,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
114 &hw_ctx->rx_ring.dma_base,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
115 GFP_KERNEL);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
116 @@ -751,12 +753,10 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
117 * Allocate the skbuffs, map them for DMA, and write their address
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
118 * in the corresponding descriptor.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
119 */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
120 - ${Ethernet::AbstractDevice} *rtx_ether_dev = ${rtx_ether_ctx.net_device};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
121 - ${cast local.rtx_ether_dev as Ethernet::AbstractDevice};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
122 for (i = 0; i != ${config.rx_ring_size}; ++i)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
123 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
124 - hw_ctx->rx_ring.skbuffs[i].skbuff = (${Socket::AbstractSKBuff}*) netdev_alloc_skb(
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
125 - &${rtx_ether_dev.netdev},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
126 + hw_ctx->rx_ring.skbuffs[i].skbuff = (${Socket::AbstractSKBuff}*)netdev_alloc_skb(
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
127 + ${rtx_ether_ctx.net_device.k_net_dev}, /* XXX: .k_net_dev isn't expanded here */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
128 ${config.rx_buffer_len});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
129 if (!hw_ctx->rx_ring.skbuffs[i].skbuff)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
130 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
131 @@ -764,11 +764,11 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
132 goto err_skbuffs_alloc;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
133 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
134 hw_ctx->rx_ring.skbuffs[i].dma_handle = dma_map_single(
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
135 - &${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
136 - &hw_ctx->rx_ring.skbuffs[i].skbuff->data,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
137 + ${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
138 + (struct sk_buff *)hw_ctx->rx_ring.skbuffs[i].skbuff, /* XXX leaking cast */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
139 ${config.rx_buffer_len},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
140 DMA_FROM_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
141 - int dma_error = dma_mapping_error(&${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
142 + int dma_error = dma_mapping_error(${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
143 hw_ctx->rx_ring.skbuffs[i].dma_handle);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
144 if (dma_error)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
145 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
146 @@ -820,7 +820,7 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
147 hw_ctx->tx_ring.size = ${config.tx_ring_size} * sizeof(*hw_ctx->tx_ring.base);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
148 hw_ctx->tx_ring.size = ALIGN(hw_ctx->tx_ring.size, 4096);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
149 hw_ctx->tx_ring.base = dma_alloc_coherent(
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
150 - &${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
151 + ${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
152 hw_ctx->tx_ring.size,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
153 &hw_ctx->tx_ring.dma_base,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
154 GFP_KERNEL);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
155 @@ -863,15 +863,16 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
156 while (i--)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
157 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
158 dma_unmap_single(
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
159 - &${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
160 + ${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
161 hw_ctx->rx_ring.skbuffs[i].dma_handle,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
162 ${config.rx_buffer_len},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
163 DMA_FROM_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
164 err_skbuffs_map:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
165 - dev_kfree_skb(&hw_ctx->rx_ring.skbuffs[i].skbuff->data);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
166 + /* XXX leaking cast: */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
167 + dev_kfree_skb((struct sk_buff *)hw_ctx->rx_ring.skbuffs[i].skbuff);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
168 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
169
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
170 - dma_free_coherent(&${rtx_ether_ctx.device}, hw_ctx->rx_ring.size,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
171 + dma_free_coherent(${rtx_ether_ctx.device}, hw_ctx->rx_ring.size,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
172 hw_ctx->rx_ring.base, hw_ctx->rx_ring.dma_base);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
173 err_rx_ring_alloc:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
174 return -ENOMEM;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
175 @@ -889,8 +890,13 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
176 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
177 chunk ::CALL()
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
178 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
179 - ${e1000::Context} *hw_ctx;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
180 - hw_ctx = &${rtx_ether_ctx}->hw_ctx;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
181 + /*
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
182 + * XXX: Not generated if named "hw_ctx" (which is funny because
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
183 + * it's used and works in the template right above this one):
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
184 + */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
185 + ${e1000::Context} *hw_ctx_;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
186 + ${cast local.hw_ctx_ as e1000::Context};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
187 + hw_ctx_ = &${rtx_ether_ctx}->hw_ctx;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
188
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
189 /*
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
190 * Free the rx ring:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
191 @@ -900,22 +906,23 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
192 for (int i = 0; i != ${config.rx_ring_size}; ++i)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
193 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
194 dma_unmap_single(
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
195 - &${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
196 - (dma_addr_t)hw_ctx->rx_ring.skbuffs[i].dma_handle,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
197 + ${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
198 + (dma_addr_t)hw_ctx_->rx_ring.skbuffs[i].dma_handle,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
199 ${config.rx_buffer_len},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
200 DMA_FROM_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
201 - dev_kfree_skb(&hw_ctx->rx_ring.skbuffs[i].skbuff->data);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
202 + /* XXX Go through the rtx types (Socket::SKBuff, AbstractSKBuff) */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
203 + dev_kfree_skb(hw_ctx_->rx_ring.skbuffs[i].skbuff);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
204 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
205 - dma_free_coherent(&${rtx_ether_ctx.device}, hw_ctx->rx_ring.size,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
206 - hw_ctx->rx_ring.base, hw_ctx->rx_ring.dma_base);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
207 + dma_free_coherent(${rtx_ether_ctx.device}, hw_ctx_->rx_ring.size,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
208 + hw_ctx_->rx_ring.base, hw_ctx_->rx_ring.dma_base);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
209 ${Log::info("free_rx_tx: rx ring free'ed")};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
210
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
211 /*
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
212 * Free the tx ring:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
213 * - Free the descriptors array.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
214 */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
215 - dma_free_coherent(&${rtx_ether_ctx.device}, hw_ctx->tx_ring.size,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
216 - hw_ctx->tx_ring.base, hw_ctx->tx_ring.dma_base);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
217 + dma_free_coherent(${rtx_ether_ctx.device}, hw_ctx_->tx_ring.size,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
218 + hw_ctx_->tx_ring.base, hw_ctx_->tx_ring.dma_base);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
219 ${Log::info("free_rx_tx: tx ring free'ed")};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
220 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
221 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
222 @@ -973,13 +980,13 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
223 ${local.skb.init(kernel_skb)};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
224 hw_ctx = &${rtx_ether_ctx}->hw_ctx;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
225 tx_ring = &hw_ctx->tx_ring;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
226 - devp = (${Device::AbstractDevice}*) &${rtx_ether_ctx.device};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
227 + devp = (${Device::AbstractDevice}*)${rtx_ether_ctx.device};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
228
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
229 ${Log::info("xmit: skbuff details:")};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
230 /*
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
231 - * skb is not expand on the bound C variable (should be rtx_skbuff),
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
232 - * which is funny because it works for the sequence template call
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
233 - * right after.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
234 + * skb does not expand on the bound C variable (should be
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
235 + * rtx_skbuff), which is funny because it works for the
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
236 + * sequence template call right after.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
237 */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
238 /*
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
239 * XXX: doesn't work (I tried to pass self explicitely too):
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
240 @@ -1012,8 +1019,8 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
241
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
242 /* 2. Map the data */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
243
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
244 - /* XXX: ${local.skb.map_to(local.devp)}; */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
245 - if (rtx_socket_skbuff_map(&skb, &${devp.data}, DMA_TO_DEVICE))
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
246 + /* XXX: ${local.skb.map_to(devp.k_device)}; */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
247 + if (rtx_socket_skbuff_map(&skb, ${devp.k_device}, DMA_TO_DEVICE))
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
248 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
249 ${Log::info("xmit: can't DMA map a SKbuff")};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
250 goto err_skb_map_to;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
251 @@ -1032,7 +1039,7 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
252 err_offload:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
253 err_skb_map_to:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
254 /* XXX: ${local.skb.unmap_to_and_free(local.dev)}; */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
255 - rtx_socket_skbuff_unmap_and_free(&skb, &${devp.data}, DMA_TO_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
256 + rtx_socket_skbuff_unmap_and_free(&skb, ${devp.k_device}, DMA_TO_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
257 return NETDEV_TX_OK;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
258 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
259 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
260 diff --git a/rathaxes/samples/e1000/ethernet.blt b/rathaxes/samples/e1000/ethernet.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
261 --- a/rathaxes/samples/e1000/ethernet.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
262 +++ b/rathaxes/samples/e1000/ethernet.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
263 @@ -51,7 +51,7 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
264 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
265 decl data_types()
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
266 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
267 - struct net_device ndev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
268 + struct net_device data;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
269 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
270
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
271 chunk LKM::includes()
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
272 @@ -59,9 +59,15 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
273 #include <linux/netdevice.h>
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
274 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
275
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
276 + method init(Builtin::symbol dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
277 + {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
278 + ${self} = (${Ethernet::AbstractDevice} *)${dev};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
279 + }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
280 +
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
281 map
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
282 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
283 - netdev: ${self}->ndev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
284 + k_net_dev: ((struct net_device *)${self});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
285 + rtx_ether_ctx: netdev_priv((struct net_device *)${self});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
286 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
287 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
288
105
fb20f01ea997 Wip, note: the interrupt handler refactoring patch is broken, I have to find the fix from the abstract type notation patch
Louis Opter <louis@lse.epita.fr>
parents: 104
diff changeset
289 @@ -88,25 +94,33 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
290 #include <linux/etherdevice.h>
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
291 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
292
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
293 - method init(Ethernet::AbstractDevice net_dev, PCI::AbstractDevice pci_dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
294 + /* XXX: if the first arg is not called rtx_net_dev, it breaks. */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
295 + method init(Ethernet::AbstractDevice rtx_net_dev, PCI::AbstractDevice pci_dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
296 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
297 - ${self} = netdev_priv(&${net_dev.netdev});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
298 + ${self} = ${rtx_net_dev.rtx_ether_ctx};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
299 /*
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
300 * We can use -> because we know that ${self} will be always a
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
301 * pointer, but the ambiguity sucks.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
302 */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
303 ${self}->pci_dev = ${pci_dev};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
304 - ${self}->net_dev = ${net_dev};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
305 + ${self}->net_dev = ${rtx_net_dev};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
306 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
307
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
308 map
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
309 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
310 - device: ${self}->pci_dev->data.dev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
311 + /*
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
312 + * XXX: I'd like to be able to do things like:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
313 + * device: ${self.pci_dev.k_pci_dev}->dev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
314 + *
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
315 + * Also, using ${PCI::AbstractDevice} instead of directly struct
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
316 + * pci_dev doesn't work.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
317 + */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
318 + device: (&((struct pci_dev *)(${self})->pci_dev)->dev);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
319 pci_device: ${self}->pci_dev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
320 net_device: ${self}->net_dev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
321 - perm_addr: ${self}->net_dev->ndev.perm_addr;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
322 - dev_addr: ${self}->net_dev->ndev.dev_addr;
105
fb20f01ea997 Wip, note: the interrupt handler refactoring patch is broken, I have to find the fix from the abstract type notation patch
Louis Opter <louis@lse.epita.fr>
parents: 104
diff changeset
323 - irq: ${self}->pci_dev->data.irq;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
324 + perm_addr: ((struct net_device *)(${self})->net_dev)->perm_addr;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
325 + dev_addr: ((struct net_device *)(${self})->net_dev)->dev_addr;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
326 + irq: ((struct pci_dev *)(${self})->pci_dev)->irq;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
327 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
328 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
329
105
fb20f01ea997 Wip, note: the interrupt handler refactoring patch is broken, I have to find the fix from the abstract type notation patch
Louis Opter <louis@lse.epita.fr>
parents: 104
diff changeset
330 @@ -126,8 +140,17 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
331 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
332 static int rtx_ethernet_open(struct net_device *dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
333 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
334 - ${Ethernet::Device} *rtx_ether_ctx = netdev_priv(dev);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
335 + /*
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
336 + * XXX The casts are here because the compiler doesn't resolve
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
337 + * "enclosed" type (e.g: local.var.enclosed) correctly.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
338 + */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
339 + ${Ethernet::AbstractDevice} *rtx_net_dev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
340 + ${cast local.rtx_net_dev as Ethernet::AbstractDevice};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
341 + { /* XXX: I end up with a placeholder if I don't open a scope */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
342 + ${local.rtx_net_dev.init(local.dev)};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
343 + }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
344
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
345 + ${Ethernet::Device} *rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
346 ${cast local.rtx_ether_ctx as Ethernet::Device};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
347
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
348 int error;
105
fb20f01ea997 Wip, note: the interrupt handler refactoring patch is broken, I have to find the fix from the abstract type notation patch
Louis Opter <louis@lse.epita.fr>
parents: 104
diff changeset
349 @@ -187,8 +210,13 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
350 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
351 static int rtx_ethernet_close(struct net_device *dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
352 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
353 - ${Ethernet::Device} *rtx_ether_ctx = netdev_priv(dev);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
354 + ${Ethernet::AbstractDevice} *rtx_net_dev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
355 + ${cast local.rtx_net_dev as Ethernet::AbstractDevice};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
356 + { /* XXX: I end up with a placeholder if I don't open a scope */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
357 + ${local.rtx_net_dev.init(local.dev)};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
358 + }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
359
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
360 + ${Ethernet::Device} *rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
361 ${cast local.rtx_ether_ctx as Ethernet::Device};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
362
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
363 /* TODO: change this pointcut into a pointcut/adapter/callback: */
105
fb20f01ea997 Wip, note: the interrupt handler refactoring patch is broken, I have to find the fix from the abstract type notation patch
Louis Opter <louis@lse.epita.fr>
parents: 104
diff changeset
364 @@ -221,9 +249,13 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
365 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
366 static enum irqreturn rtx_ethernet_interrupt_handler(int irq, void *dev_id)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
367 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
368 - ${Ethernet::Device} *rtx_ether_ctx = dev_id;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
369 + ${Ethernet::AbstractDevice} *rtx_net_dev = dev_id;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
370 + ${cast local.rtx_net_dev as Ethernet::AbstractDevice};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
371
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
372 + ${Ethernet::Device} *rtx_ether_ctx;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
373 ${cast local.rtx_ether_ctx as Ethernet::Device};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
374 + rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
375 +
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
376 ${pointcut ::IMPLEMENTATION(local.rtx_ether_ctx)};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
377
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
378 return IRQ_NONE;
105
fb20f01ea997 Wip, note: the interrupt handler refactoring patch is broken, I have to find the fix from the abstract type notation patch
Louis Opter <louis@lse.epita.fr>
parents: 104
diff changeset
379 @@ -253,23 +285,26 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
380 */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
381 chunk PCI::pci_probe_hook(PCI::Device rtx_pci_dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
382 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
383 + ${Ethernet::AbstractDevice} *rtx_net_dev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
384 ${Ethernet::Device} *rtx_ether_ctx;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
385 - ${Ethernet::AbstractDevice} *net_dev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
386 - ${cast local.net_dev as Ethernet::AbstractDevice};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
387 + ${cast local.rtx_net_dev as Ethernet::AbstractDevice};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
388
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
389 - net_dev = (${Ethernet::AbstractDevice}*) alloc_etherdev(sizeof(*rtx_ether_ctx));
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
390 - if (!net_dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
391 + /* Cast the result back into our "transparent wrapper" type */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
392 + rtx_net_dev = (${Ethernet::AbstractDevice}*)alloc_etherdev(sizeof(*rtx_ether_ctx));
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
393 + if (!rtx_net_dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
394 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
395 ${Log::info("cannot allocate the ethernet device context")};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
396 error = -ENOMEM;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
397 goto fail;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
398 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
399 - SET_NETDEV_DEV(&${local.net_dev.netdev}, ${rtx_pci_dev.device});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
400 - strlcpy(${local.net_dev.netdev}.name, ${config.ifname}, sizeof(${local.net_dev.netdev}.name));
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
401 - ${local.net_dev.netdev}.irq = ${rtx_pci_dev.irq};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
402 - ${local.net_dev.netdev}.netdev_ops = &rtx_ether_ops;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
403 + SET_NETDEV_DEV(${local.rtx_net_dev.k_net_dev}, ${rtx_pci_dev.device});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
404 + strlcpy(${local.rtx_net_dev.k_net_dev}->name,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
405 + ${config.ifname},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
406 + sizeof(${local.rtx_net_dev.k_net_dev}->name));
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
407 + ${local.rtx_net_dev.k_net_dev}->irq = ${rtx_pci_dev.irq};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
408 + ${local.rtx_net_dev.k_net_dev}->netdev_ops = &rtx_ether_ops;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
409
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
410 - error = register_netdev(&${local.net_dev.netdev});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
411 + error = register_netdev(${local.rtx_net_dev.k_net_dev});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
412 if (error)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
413 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
414 ${Log::info("cannot register the driver in the net subsystem")};
105
fb20f01ea997 Wip, note: the interrupt handler refactoring patch is broken, I have to find the fix from the abstract type notation patch
Louis Opter <louis@lse.epita.fr>
parents: 104
diff changeset
415 @@ -281,14 +316,11 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
416 * XXX: the cast is here because the compiler resolve the
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
417 * type of rtx_pci_dev.pci_device to the type of
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
418 * rtx_pci_dev instead of the type of rtx_pci_dev.pci_device.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
419 - *
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
420 - * Also, I'm getting placeholder in the generated code if
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
421 - * I don't open a scope here.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
422 */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
423 - {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
424 - ${PCI::AbstractDevice} *rtx_pdev = ${rtx_pci_dev.pci_device};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
425 - ${cast local.rtx_pdev as PCI::AbstractDevice};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
426 - ${local.rtx_ether_ctx.init(local.net_dev, local.rtx_pdev)};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
427 + ${PCI::AbstractDevice} *workaround = ${rtx_pci_dev.pci_device};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
428 + ${cast local.workaround as PCI::AbstractDevice};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
429 + { /* XXX: I end up with a placeholder if I don't open a scope */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
430 + ${local.rtx_ether_ctx.init(local.rtx_net_dev, local.workaround)};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
431 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
432
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
433 /* Register ourselves in the parent context: */
105
fb20f01ea997 Wip, note: the interrupt handler refactoring patch is broken, I have to find the fix from the abstract type notation patch
Louis Opter <louis@lse.epita.fr>
parents: 104
diff changeset
434 @@ -310,7 +342,7 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
435 ${pointcut Ethernet::adapter_load_mac_address(local.rtx_ether_ctx)};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
436 memcpy(${local.rtx_ether_ctx.perm_addr},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
437 ${local.rtx_ether_ctx.dev_addr},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
438 - ${local.net_dev.netdev}.addr_len);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
439 + ${local.rtx_net_dev.k_net_dev}->addr_len);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
440 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
441
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
442 /* This chunk should be removed (see #26) */
105
fb20f01ea997 Wip, note: the interrupt handler refactoring patch is broken, I have to find the fix from the abstract type notation patch
Louis Opter <louis@lse.epita.fr>
parents: 104
diff changeset
443 @@ -327,15 +359,15 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
444 */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
445 chunk PCI::pci_remove_hook(PCI::Device rtx_pci_dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
446 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
447 - ${Ethernet::Device} *rtx_ether_ctx = ${rtx_pci_dev.context};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
448 - ${Ethernet::AbstractDevice} *rtx_ether_dev = (${Ethernet::AbstractDevice}*) ${local.rtx_ether_ctx.net_device};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
449 -
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
450 + ${Ethernet::Device} *rtx_ether_ctx = ${rtx_pci_dev.rtx_drv_context};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
451 + ${cast local.rtx_ether_ctx as Ethernet::Device}; /* XXX */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
452 BUG_ON(!rtx_ether_ctx);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
453
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
454 - ${cast local.rtx_ether_ctx as Ethernet::Device};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
455 - ${cast local.rtx_ether_dev as Ethernet::AbstractDevice};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
456 - unregister_netdev(&${local.rtx_ether_dev.netdev});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
457 - free_netdev(&${local.rtx_ether_dev.netdev});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
458 + ${Ethernet::AbstractDevice} *rtx_net_dev = ${local.rtx_ether_ctx.net_device};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
459 + ${cast local.rtx_net_dev as Ethernet::AbstractDevice}; /* XXX */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
460 +
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
461 + unregister_netdev(${local.rtx_net_dev.k_net_dev});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
462 + free_netdev(${local.rtx_net_dev.k_net_dev});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
463 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
464
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
465 /* This chunk should be removed (see #26) */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
466 diff --git a/rathaxes/samples/e1000/ethernet.rti b/rathaxes/samples/e1000/ethernet.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
467 --- a/rathaxes/samples/e1000/ethernet.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
468 +++ b/rathaxes/samples/e1000/ethernet.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
469 @@ -16,8 +16,15 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
470 provided type AbstractDevice
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
471 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
472 chunk LKM::includes();
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
473 + method init(Builtin::symbol);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
474 decl data_types();
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
475 - attribute Builtin::symbol netdev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
476 +
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
477 + attribute Builtin::symbol k_net_dev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
478 + /*
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
479 + * XXX: should be a Ethernet::Device, but that causes a circular
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
480 + * dependency.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
481 + */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
482 + attribute Builtin::symbol rtx_ether_ctx;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
483 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
484
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
485 provided type Device
105
fb20f01ea997 Wip, note: the interrupt handler refactoring patch is broken, I have to find the fix from the abstract type notation patch
Louis Opter <louis@lse.epita.fr>
parents: 104
diff changeset
486 @@ -34,9 +41,9 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
487 * I'd like to use better names here, but I'd like to understand the
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
488 * difference between the two first:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
489 */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
490 - attribute Builtin::symbol perm_addr;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
491 - attribute Builtin::symbol dev_addr;
105
fb20f01ea997 Wip, note: the interrupt handler refactoring patch is broken, I have to find the fix from the abstract type notation patch
Louis Opter <louis@lse.epita.fr>
parents: 104
diff changeset
492 - attribute Builtin::symbol irq;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
493 + attribute Builtin::symbol perm_addr;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
494 + attribute Builtin::symbol dev_addr;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
495 + attribute Builtin::symbol irq;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
496 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
497
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
498 required sequence open(Ethernet::Device)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
499 diff --git a/rathaxes/samples/e1000/pci.blt b/rathaxes/samples/e1000/pci.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
500 --- a/rathaxes/samples/e1000/pci.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
501 +++ b/rathaxes/samples/e1000/pci.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
502 @@ -16,15 +16,15 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
503 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
504 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
505
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
506 - method set_context(Builtin::symbol ctx)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
507 + method set_rtx_context(Builtin::symbol ctx)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
508 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
509 - pci_set_drvdata(&${self}->data, ${ctx});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
510 + pci_set_drvdata(${self.k_pci_dev}, ${ctx});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
511 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
512
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
513 map
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
514 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
515 - data: ${self}->data;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
516 - drv_data: pci_get_drvdata(&${self}->data);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
517 + k_pci_dev: ((struct pci_dev *)${self});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
518 + rtx_pci_ctx: pci_get_drvdata((struct pci_dev *)${self});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
519 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
520 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
521
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
522 @@ -52,13 +52,13 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
523 int error;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
524 ${PCI::AbstractDevice} *enable_pdev = self->pdev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
525 ${cast local.enable_pdev as PCI::AbstractDevice};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
526 - error = pci_enable_device(&${local.enable_pdev.data});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
527 + error = pci_enable_device(${local.enable_pdev.k_pci_dev});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
528 if (error)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
529 return error;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
530 - error = pci_request_selected_regions(&${local.enable_pdev.data}, self->bars, ${config.name});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
531 + error = pci_request_selected_regions(${local.enable_pdev.k_pci_dev}, self->bars, ${config.name});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
532 if (error)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
533 return error;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
534 - pci_set_master(&${local.enable_pdev.data});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
535 + pci_set_master(${local.enable_pdev.k_pci_dev});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
536 return 0;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
537 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
538
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
539 @@ -68,8 +68,8 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
540 ${cast local.disable_pdev as PCI::AbstractDevice};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
541 if (self->ioaddr)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
542 iounmap(self->ioaddr);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
543 - pci_release_selected_regions(&${local.disable_pdev.data}, self->bars);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
544 - pci_disable_device(&${local.disable_pdev.data});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
545 + pci_release_selected_regions(${local.disable_pdev.k_pci_dev}, self->bars);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
546 + pci_disable_device(${local.disable_pdev.k_pci_dev});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
547 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
548 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
549
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
550 @@ -78,7 +78,7 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
551 ${PCI::AbstractDevice} * workaround = (${PCI::AbstractDevice}*)pdev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
552 ${cast local.workaround as PCI::AbstractDevice};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
553 ${self}->pdev = ${pdev};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
554 - ${self}->bars = pci_select_bars(&${local.workaround.data}, IORESOURCE_MEM);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
555 + ${self}->bars = pci_select_bars(${local.workaround.k_pci_dev}, IORESOURCE_MEM);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
556 ${self}->ioaddr = NULL;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
557 ${self}->context = NULL;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
558 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
559 @@ -97,20 +97,20 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
560 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
561 ${PCI::AbstractDevice} *select_ioaddr_pdev = ${self}->pdev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
562 ${cast local.select_ioaddr_pdev as PCI::AbstractDevice};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
563 - ${self}->ioaddr = pci_ioremap_bar(&${local.select_ioaddr_pdev.data}, ${bar});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
564 + ${self}->ioaddr = pci_ioremap_bar(${local.select_ioaddr_pdev.k_pci_dev}, ${bar});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
565 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
566
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
567 - method set_context(Builtin::symbol ctx)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
568 + method set_rtx_drv_context(Builtin::symbol ctx)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
569 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
570 ${self}->context = ctx;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
571 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
572
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
573 map
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
574 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
575 - context: ${self}->context;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
576 - device: &${self}->pdev->data.dev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
577 + rtx_drv_context: ${self}->context;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
578 + device: &((struct pci_dev *)(${self})->pdev)->dev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
579 pci_device: ${self}->pdev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
580 - irq: ${self}->pdev->data.irq;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
581 + irq: ((struct pci_dev *)(${self})->pdev)->irq;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
582 bars: ${self}->bars;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
583 ioaddr: ${self}->ioaddr;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
584 BAR_0: 0;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
585 @@ -151,7 +151,7 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
586 ${local.rtx_pci_dev.init(local.rtx_pdev)};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
587 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
588
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
589 - /* ${local.pdev.set_context(local.rtx_pci_dev)}; */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
590 + /* ${local.pdev.set_rtx_context(local.rtx_pci_dev)}; */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
591 pci_set_drvdata(pdev, rtx_pci_dev);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
592
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
593 /* ${local.rtx_pci_dev.enable()}; */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
594 @@ -184,7 +184,7 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
595 return 0;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
596
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
597 fail:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
598 - /* ${local.pdev.set_context(NULL)}; */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
599 + /* ${local.pdev.set_rtx_drv_context(NULL)}; */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
600 pci_set_drvdata(pdev, NULL);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
601 kfree(rtx_pci_dev);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
602 return error;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
603 @@ -210,7 +210,7 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
604 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
605 ${PCI::AbstractDevice} *rtx_pdev = (${PCI::AbstractDevice}*)pdev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
606 ${cast local.rtx_pdev as PCI::AbstractDevice};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
607 - ${PCI::Device} *rtx_pci_dev = ${rtx_pdev.drv_data};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
608 + ${PCI::Device} *rtx_pci_dev = ${rtx_pdev.rtx_pci_ctx};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
609
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
610 BUG_ON(!rtx_pci_dev);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
611
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
612 diff --git a/rathaxes/samples/e1000/pci.rti b/rathaxes/samples/e1000/pci.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
613 --- a/rathaxes/samples/e1000/pci.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
614 +++ b/rathaxes/samples/e1000/pci.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
615 @@ -10,10 +10,15 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
616
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
617 chunk LKM::includes();
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
618 method init(PCI::AbstractDevice);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
619 - method set_context(Builtin::symbol);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
620 + /*
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
621 + * XXX: the argument should be a PCI::Device but that causes a circular
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
622 + * dependency:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
623 + */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
624 + method set_rtx_context(Builtin::symbol);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
625
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
626 - attribute Builtin::symbol data;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
627 - attribute Builtin::symbol drv_data;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
628 + attribute Builtin::symbol k_pci_dev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
629 + /* XXX: should be PCI::Device (see above point) */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
630 + attribute Builtin::symbol rtx_pci_ctx;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
631 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
632
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
633 provided type PCI::Device
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
634 @@ -27,9 +32,9 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
635 method enable();
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
636 method disable();
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
637 method select_ioaddr(Builtin::number);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
638 - method set_context(Builtin::symbol);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
639 + method set_rtx_drv_context(Builtin::symbol);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
640
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
641 - attribute Builtin::symbol context;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
642 + attribute Builtin::symbol rtx_drv_context;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
643 attribute Device::AbstractDevice device;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
644 attribute PCI::AbstractDevice pci_device;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
645 attribute Builtin::symbol ioaddr;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
646 diff --git a/rathaxes/samples/e1000/socket.blt b/rathaxes/samples/e1000/socket.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
647 --- a/rathaxes/samples/e1000/socket.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
648 +++ b/rathaxes/samples/e1000/socket.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
649 @@ -14,7 +14,7 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
650
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
651 map
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
652 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
653 - data: ${self}->data;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
654 + k_sk_buff: ((struct sk_buff *)${self});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
655 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
656 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
657
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
658 @@ -46,11 +46,12 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
659 */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
660 ${Socket::AbstractSKBuff} *skb = self->skbuff;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
661 ${cast local.skb as Socket::AbstractSKBuff};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
662 - ${Ethernet::ProtocolId} ethernet_proto = { .id = be16_to_cpu(${local.skb.data}.protocol) };
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
663 + ${Ethernet::ProtocolId} ethernet_proto = { .id = be16_to_cpu(${local.skb.k_sk_buff}->protocol) };
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
664 +
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
665 static const char * const ip_summed_values[] = {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
666 "none", "unnecessary", "complete", "partial"
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
667 };
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
668 - struct skb_shared_info *shinfo = skb_shinfo(&${local.skb.data});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
669 + struct skb_shared_info *shinfo = skb_shinfo(${local.skb.k_sk_buff});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
670
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
671 pr_info(
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
672 "\t protocol = %#-5x (%s) ip_summed = %d (%s)\n"
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
673 @@ -59,8 +60,8 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
674 "\t gso_size = %-5u gso_segs = %-5u gso_type = %-5u",
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
675 /* XXX: can't use ${local.ethernet_proto.id} here (issue #52): */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
676 ethernet_proto.id, ${local.ethernet_proto.str},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
677 - ${local.skb.data}.ip_summed, ip_summed_values[${local.skb.data}.ip_summed],
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
678 - ${local.skb.data}.len, ${local.skb.data}.data_len, skb_headlen(&${local.skb.data}),
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
679 + ${local.skb.k_sk_buff}->ip_summed, ip_summed_values[${local.skb.k_sk_buff}->ip_summed],
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
680 + ${local.skb.k_sk_buff}->len, ${local.skb.k_sk_buff}->data_len, skb_headlen(${local.skb.k_sk_buff}),
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
681 shinfo->nr_frags, shinfo->gso_size, shinfo->gso_segs, shinfo->gso_type
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
682 );
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
683 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
684 @@ -72,14 +73,13 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
685 ${Socket::AbstractSKBuff} *skb = self->skbuff;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
686 ${cast local.skb as Socket::AbstractSKBuff};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
687
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
688 - WARN_ON(!skb);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
689 - WARN_ON(!${local.skb.data}.data);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
690 + WARN_ON(!${local.skb.k_sk_buff});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
691 WARN_ON(self->dma_handle);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
692
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
693 self->dma_handle = dma_map_single(
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
694 dev,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
695 - &${local.skb.data}.data,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
696 - skb_headlen(&${local.skb.data}),
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
697 + ${local.skb.k_sk_buff},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
698 + skb_headlen(${local.skb.k_sk_buff}),
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
699 direction);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
700 int err = dma_mapping_error(dev, self->dma_handle);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
701 if (err)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
702 @@ -97,18 +97,17 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
703 ${Socket::AbstractSKBuff} *skb = self->skbuff;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
704 ${cast local.skb as Socket::AbstractSKBuff};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
705
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
706 - WARN_ON(!${local.skb});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
707 - WARN_ON(!${local.skb.data}.data);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
708 + WARN_ON(!${local.skb.k_sk_buff});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
709
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
710 if (self->dma_handle)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
711 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
712 dma_unmap_single(dev,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
713 self->dma_handle,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
714 - skb_headlen(&${local.skb.data}),
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
715 + skb_headlen(${local.skb.k_sk_buff}),
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
716 direction);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
717 self->dma_handle = 0;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
718 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
719 - dev_kfree_skb_any(&${local.skb.data});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
720 + dev_kfree_skb_any(${local.skb.k_sk_buff});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
721 self->skbuff = 0;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
722 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
723 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
724 @@ -131,22 +130,22 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
725
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
726 method map_to(Device::AbstractDevice dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
727 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
728 - rtx_socket_skbuff_map(${self}, &${dev.data}, DMA_TO_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
729 + rtx_socket_skbuff_map(${self}, ${dev.k_device}, DMA_TO_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
730 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
731
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
732 method map_from(Device::AbstractDevice dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
733 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
734 - rtx_socket_skbuff_map(${self}, &${dev.data}, DMA_FROM_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
735 + rtx_socket_skbuff_map(${self}, ${dev.k_device}, DMA_FROM_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
736 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
737
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
738 method unmap_to_and_free(Device::AbstractDevice dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
739 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
740 - rtx_socket_skbuff_unmap_and_free(${self}, &${dev.data}, DMA_TO_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
741 + rtx_socket_skbuff_unmap_and_free(${self}, ${dev.k_device}, DMA_TO_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
742 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
743
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
744 method unmap_from_and_free(Device::AbstractDevice dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
745 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
746 - rtx_socket_skbuff_unmap_and_free(${self}, &${dev.data}, DMA_FROM_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
747 + rtx_socket_skbuff_unmap_and_free(${self}, ${dev.k_device}, DMA_FROM_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
748 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
749
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
750 map
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
751 diff --git a/rathaxes/samples/e1000/socket.rti b/rathaxes/samples/e1000/socket.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
752 --- a/rathaxes/samples/e1000/socket.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
753 +++ b/rathaxes/samples/e1000/socket.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
754 @@ -5,7 +5,8 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
755 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
756 chunk LKM::includes();
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
757 decl data_types();
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
758 - attribute Builtin::symbol data;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
759 +
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
760 + attribute Builtin::symbol k_sk_buff;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
761 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
762
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
763 provided type SKBuff