comparison rathaxes_start_to_implement_the_ethernet_subsystem_in_the_lkm.patch @ 13:d00a5829811d

rathaxes: add net_dev_ops + register netdev device, but still a bug, see the diff
author Thomas Sanchez <thomas.sanchz@gmail.com>
date Fri, 06 Jan 2012 18:08:41 +0100
parents 80cfe40c1136
children 4aac69287060
comparison
equal deleted inserted replaced
12:80cfe40c1136 13:d00a5829811d
1 # HG changeset patch 1 # HG changeset patch
2 # Parent 44a4871708b167b49df10fc6153a73730f08287a 2 # Parent 6d15ec109487b733721b6dbe84c27841f441e196
3 rathaxes: start to implement the Ethernet subsystem in linux LKM sample 3 rathaxes: start to implement the Ethernet subsystem in linux LKM sample
4 4
5 diff --git a/rathaxes/samples/lkm/CMakeLists.txt b/rathaxes/samples/lkm/CMakeLists.txt 5 diff -r 6d15ec109487 rathaxes/samples/lkm/CMakeLists.txt
6 --- a/rathaxes/samples/lkm/CMakeLists.txt 6 --- a/rathaxes/samples/lkm/CMakeLists.txt Fri Jan 06 17:34:47 2012 +0100
7 +++ b/rathaxes/samples/lkm/CMakeLists.txt 7 +++ b/rathaxes/samples/lkm/CMakeLists.txt Fri Jan 06 18:06:48 2012 +0100
8 @@ -1,6 +1,6 @@ 8 @@ -1,6 +1,6 @@
9 ADD_RATHAXES_SOURCES(lkm lkm.rtx 9 ADD_RATHAXES_SOURCES(lkm lkm.rtx
10 - RTI log.rti lkm.rti pci.rti 10 - RTI log.rti lkm.rti pci.rti
11 - BLT log.blt lkm.blt pci.blt) 11 - BLT log.blt lkm.blt pci.blt)
12 + RTI log.rti lkm.rti pci.rti ethernet.rti 12 + RTI log.rti lkm.rti pci.rti ethernet.rti
13 + BLT log.blt lkm.blt pci.blt ethernet.blt) 13 + BLT log.blt lkm.blt pci.blt ethernet.blt)
14 14
15 # We can't name lkm since it's already used as the target name to generate the 15 # We can't name lkm since it's already used as the target name to generate the
16 # source (with ADD_RATHAXES_SOURCES). 16 # source (with ADD_RATHAXES_SOURCES).
17 diff --git a/rathaxes/samples/lkm/ethernet.blt b/rathaxes/samples/lkm/ethernet.blt 17 diff -r 6d15ec109487 rathaxes/samples/lkm/ethernet.blt
18 new file mode 100644 18 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
19 --- /dev/null 19 +++ b/rathaxes/samples/lkm/ethernet.blt Fri Jan 06 18:06:48 2012 +0100
20 +++ b/rathaxes/samples/lkm/ethernet.blt 20 @@ -0,0 +1,135 @@
21 @@ -0,0 +1,116 @@
22 +with Ethernet, PCI, LKM 21 +with Ethernet, PCI, LKM
23 +{ 22 +{
24 + template type Ethernet::Device() 23 + template type Ethernet::Device()
25 + { 24 + {
26 + chunk LKM::includes() 25 + chunk LKM::includes()
108 + * dialect. 107 + * dialect.
109 + */ 108 + */
110 + typedef int ${Ethernet::Device}; 109 + typedef int ${Ethernet::Device};
111 + 110 +
112 + static ${Ethernet::Device} *rtx_net_dev = NULL; 111 + static ${Ethernet::Device} *rtx_net_dev = NULL;
112 + static const struct net_device_ops rtx_ether_ops= {
113 + .ndo_open = rtx_ethernet_open,
114 + .ndo_stop = rtx_ethernet_close,
115 + .ndo_start_xmit = NULL, // XXX:
116 + };
117 +
113 + } 118 + }
114 + 119 +
115 + chunk ::CALL 120 + chunk ::CALL
116 + { 121 + {
117 + /* 122 + /*
123 + * if (rtx_net_dev == NULL) 128 + * if (rtx_net_dev == NULL)
124 + * { 129 + * {
125 + * // What can we do here? 130 + * // What can we do here?
126 + * } 131 + * }
127 + */ 132 + */
133 +
134 + /*
135 + * Does not work atm
136 + */
137 + // -> this is the problem, dev cannot be resolved ${dev} = 0;
138 + // SET_NETDEV_DEV(rtx_net_dev, &${dev}->dev);
139 + rtx_net_dev->netdev_ops = rtx_ether_ops;
140 +
141 + /* if (*/register_netdev(rtx_net_dev);/*)*/
142 + /* {
143 + * XXX: handle the error
144 + * }
145 + */
128 + } 146 + }
129 + } 147 + }
130 + 148 +
131 + template sequence Ethernet::exit(PCI::Device dev) 149 + template sequence Ethernet::exit(PCI::Device dev)
132 + { 150 + {
133 + chunk ::CALL 151 + chunk ::CALL
134 + { 152 + {
135 + } 153 + }
136 + } 154 + }
137 +} 155 +}
138 diff --git a/rathaxes/samples/lkm/ethernet.rti b/rathaxes/samples/lkm/ethernet.rti 156 diff -r 6d15ec109487 rathaxes/samples/lkm/ethernet.rti
139 new file mode 100644 157 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
140 --- /dev/null 158 +++ b/rathaxes/samples/lkm/ethernet.rti Fri Jan 06 18:06:48 2012 +0100
141 +++ b/rathaxes/samples/lkm/ethernet.rti
142 @@ -0,0 +1,33 @@ 159 @@ -0,0 +1,33 @@
143 +interface Ethernet : PCI, LKM 160 +interface Ethernet : PCI, LKM
144 +{ 161 +{
145 + provided type Ethernet::Device; 162 + provided type Ethernet::Device;
146 + 163 +
171 + provided sequence Ethernet::exit(PCI::Device) 188 + provided sequence Ethernet::exit(PCI::Device)
172 + { 189 + {
173 + provided chunk ::CALL; 190 + provided chunk ::CALL;
174 + } 191 + }
175 +} 192 +}
176 diff --git a/rathaxes/samples/lkm/lkm.rtx b/rathaxes/samples/lkm/lkm.rtx 193 diff -r 6d15ec109487 rathaxes/samples/lkm/lkm.rtx
177 --- a/rathaxes/samples/lkm/lkm.rtx 194 --- a/rathaxes/samples/lkm/lkm.rtx Fri Jan 06 17:34:47 2012 +0100
178 +++ b/rathaxes/samples/lkm/lkm.rtx 195 +++ b/rathaxes/samples/lkm/lkm.rtx Fri Jan 06 18:06:48 2012 +0100
179 @@ -1,13 +1,24 @@ 196 @@ -1,13 +1,24 @@
180 device LKM use LKM, PCI, Log 197 device LKM use LKM, PCI, Log
181 { 198 {
182 + Ethernet::open(Ethernet::Device dev) 199 + Ethernet::open(Ethernet::Device dev)
183 + { 200 + {
201 { 218 {
202 - 219 -
203 } 220 }
204 221
205 LKM::init() 222 LKM::init()
206 diff --git a/rathaxes/samples/lkm/pci.blt b/rathaxes/samples/lkm/pci.blt 223 diff -r 6d15ec109487 rathaxes/samples/lkm/pci.blt
207 --- a/rathaxes/samples/lkm/pci.blt 224 --- a/rathaxes/samples/lkm/pci.blt Fri Jan 06 17:34:47 2012 +0100
208 +++ b/rathaxes/samples/lkm/pci.blt 225 +++ b/rathaxes/samples/lkm/pci.blt Fri Jan 06 18:06:48 2012 +0100
209 @@ -11,15 +11,12 @@ 226 @@ -11,15 +11,12 @@
210 227
211 chunk ::decl() 228 chunk ::decl()
212 { 229 {
213 - struct rtx_pci_device 230 - struct rtx_pci_device