annotate rathaxes_start_to_implement_the_ethernet_subsystem_in_the_lkm.patch @ 30:b4ca25b88690

Finish patches on the CMake library and on #includes
author Louis Opter <louis@lse.epitech.net>
date Sat, 07 Jan 2012 21:11:13 +0100
parents 65523c345b40
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1 # HG changeset patch
22
65523c345b40 rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 21
diff changeset
2 # Parent 53c073d05449cc4cd6130bd79eb02c07239dd8d8
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
3 rathaxes: start to implement the Ethernet subsystem in linux LKM sample
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
4
22
65523c345b40 rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 21
diff changeset
5 diff -r 53c073d05449 rathaxes/samples/lkm/CMakeLists.txt
65523c345b40 rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 21
diff changeset
6 --- a/rathaxes/samples/lkm/CMakeLists.txt Sat Jan 07 19:10:21 2012 +0100
65523c345b40 rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 21
diff changeset
7 +++ b/rathaxes/samples/lkm/CMakeLists.txt Sat Jan 07 19:18:24 2012 +0100
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
8 @@ -1,6 +1,6 @@
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
9 ADD_RATHAXES_SOURCES(lkm lkm.rtx
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
10 - RTI log.rti lkm.rti pci.rti
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
11 - BLT log.blt lkm.blt pci.blt)
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
12 + RTI log.rti lkm.rti pci.rti ethernet.rti
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
13 + BLT log.blt lkm.blt pci.blt ethernet.blt)
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
14
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
15 # We can't name lkm since it's already used as the target name to generate the
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
16 # source (with ADD_RATHAXES_SOURCES).
22
65523c345b40 rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 21
diff changeset
17 diff -r 53c073d05449 rathaxes/samples/lkm/ethernet.blt
17
efe054f0989b Fix typo
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 16
diff changeset
18 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
22
65523c345b40 rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 21
diff changeset
19 +++ b/rathaxes/samples/lkm/ethernet.blt Sat Jan 07 19:18:24 2012 +0100
21
052f9209ca09 rathaxes:: add the ifs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 19
diff changeset
20 @@ -0,0 +1,173 @@
22
65523c345b40 rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 21
diff changeset
21 +with Ethernet, PCI, LKM, Log
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
22 +{
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
23 + template type Ethernet::Device()
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
24 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
25 + chunk LKM::includes()
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
26 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
27 + #include <linux/netdevice.h>
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
28 + #include <linux/etherdevice.h>
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
29 +
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
30 + typedef int include_linux_net_system_stamp;
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
31 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
32 +
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
33 + chunk ::decl()
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
34 + {
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
35 + struct rtx_ethernet_dev
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
36 + {
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
37 + /*
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
38 + * I think it's useless to use the ${PCI::Device} "abstraction"
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
39 + * here, since we are already in a Linux specific context here.
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
40 + */
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
41 + struct pci_dev *pci_dev;
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
42 + struct net_device *net_dev;
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
43 + };
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
44 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
45 +
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
46 + chunk ::init(net_dev)
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
47 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
48 + ${self} = ${net_dev};
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
49 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
50 +
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
51 + map
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
52 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
53 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
54 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
55 +
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
56 + template sequence Ethernet::open(Ethernet::Device dev)
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
57 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
58 + chunk LKM::prototypes()
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
59 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
60 + static int rtx_ethernet_open(struct net_device *);
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
61 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
62 +
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
63 + chunk LKM::code()
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
64 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
65 + static int rtx_ethernet_open(struct net_device *dev)
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
66 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
67 + ${pointcut ::IMPLEMENTATION};
14
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
68 +
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
69 + return 0;
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
70 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
71 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
72 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
73 +
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
74 + template sequence Ethernet::close(Ethernet::Device dev)
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
75 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
76 + chunk LKM::prototypes()
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
77 + {
14
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
78 + static int rtx_ethernet_close(struct net_device *);
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
79 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
80 +
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
81 + chunk LKM::code()
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
82 + {
14
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
83 + static int rtx_ethernet_close(struct net_device *dev)
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
84 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
85 + ${pointcut ::IMPLEMENTATION};
14
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
86 +
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
87 + return 0;
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
88 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
89 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
90 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
91 +
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
92 + template sequence Ethernet::interrupt_handler(Ethernet::Device dev)
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
93 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
94 + /*
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
95 + * Why we can't use irqreturn_t here? (we are forced to use enum
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
96 + * irqreturn, which is the real type).
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
97 + */
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
98 +
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
99 + chunk LKM::prototypes()
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
100 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
101 + static enum irqreturn rtx_ethernet_interrupt_handler(int, void *);
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
102 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
103 +
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
104 + chunk LKM::code()
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
105 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
106 + static enum irqreturn rtx_ethernet_interrupt_handler(int irq, void *dev_id)
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
107 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
108 + ${pointcut ::IMPLEMENTATION};
14
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
109 +
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
110 + return IRQ_NONE;
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
111 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
112 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
113 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
114 +
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
115 + template sequence Ethernet::init(PCI::Device pdev)
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
116 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
117 + chunk LKM::data()
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
118 + {
14
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
119 + static const struct net_device_ops rtx_ether_ops =
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
120 + {
13
d00a5829811d rathaxes: add net_dev_ops + register netdev device, but still a bug, see the diff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 12
diff changeset
121 + .ndo_open = rtx_ethernet_open,
d00a5829811d rathaxes: add net_dev_ops + register netdev device, but still a bug, see the diff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 12
diff changeset
122 + .ndo_stop = rtx_ethernet_close,
14
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
123 + .ndo_start_xmit = NULL,
13
d00a5829811d rathaxes: add net_dev_ops + register netdev device, but still a bug, see the diff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 12
diff changeset
124 + };
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
125 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
126 +
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
127 + chunk ::CALL
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
128 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
129 + /*
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
130 + * This typedef is needed to workaround a bug in CNorm __std__
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
131 + * dialect.
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
132 + */
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
133 + typedef int ${Ethernet::Device};
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
134 + ${Ethernet::Device} *rtx_ether_ctx;
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
135 + struct net_device *net_dev;
21
052f9209ca09 rathaxes:: add the ifs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 19
diff changeset
136 + int error;
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
137 +
21
052f9209ca09 rathaxes:: add the ifs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 19
diff changeset
138 + error = 0;
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
139 + net_dev = alloc_etherdev(sizeof(*rtx_ether_ctx));
21
052f9209ca09 rathaxes:: add the ifs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 19
diff changeset
140 + if (net_dev == 0)
052f9209ca09 rathaxes:: add the ifs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 19
diff changeset
141 + {
22
65523c345b40 rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 21
diff changeset
142 + ${Log::info("Cannot allocate memory")};
21
052f9209ca09 rathaxes:: add the ifs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 19
diff changeset
143 + // is it the thing to do?
052f9209ca09 rathaxes:: add the ifs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 19
diff changeset
144 + return -ENOMEM;
052f9209ca09 rathaxes:: add the ifs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 19
diff changeset
145 + }
16
41a434b0676b WIP on the ethernet part of the LKM sample: set ifname + the irq in the net_device struct
Louis Opter <louis@lse.epitech.net>
parents: 15
diff changeset
146 + strlcpy(net_dev->name, ${config.ifname}, sizeof(net_dev->name));
17
efe054f0989b Fix typo
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 16
diff changeset
147 + net_dev->irq = pdev->irq;
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
148 + // Maybe we should try ${rtx_ether_ctx.init()} here:
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
149 + rtx_ether_ctx = netdev_priv(net_dev);
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
150 + //rtx_ether_ctx->pci_dev = ${pdev};
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
151 + rtx_ether_ctx->pci_dev = pdev; // In the meantime do it directly
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
152 + rtx_ether_ctx->net_dev = net_dev;
13
d00a5829811d rathaxes: add net_dev_ops + register netdev device, but still a bug, see the diff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 12
diff changeset
153 +
d00a5829811d rathaxes: add net_dev_ops + register netdev device, but still a bug, see the diff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 12
diff changeset
154 + /*
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
155 + * The substitution of ${pdev} fails here. I also tried to add a
14
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
156 + * "substitute method" to the PCI::Device that was just doing
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
157 + * "${self}" but it didn't work either (it was subsituted by a
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
158 + * placeholder, e.g: _1).
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
159 + *
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
160 + * That's why we cheated a bit and named all the arguments pdev.
13
d00a5829811d rathaxes: add net_dev_ops + register netdev device, but still a bug, see the diff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 12
diff changeset
161 + */
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
162 + //SET_NETDEV_DEV(net_dev, &${pdev}->dev);
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
163 + SET_NETDEV_DEV(net_dev, &pdev->dev);
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
164 + net_dev->netdev_ops = &rtx_ether_ops;
21
052f9209ca09 rathaxes:: add the ifs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 19
diff changeset
165 + if ((error = register_netdev(net_dev)))
052f9209ca09 rathaxes:: add the ifs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 19
diff changeset
166 + {
22
65523c345b40 rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 21
diff changeset
167 + ${Log::info("Cannot register the driver")};
21
052f9209ca09 rathaxes:: add the ifs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 19
diff changeset
168 + // is it the thing to do?
052f9209ca09 rathaxes:: add the ifs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 19
diff changeset
169 + return error;
052f9209ca09 rathaxes:: add the ifs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 19
diff changeset
170 + }
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
171 +
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
172 + /* same problem as above with ${pdev} */
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
173 + //pci_set_drvdata(${pdev}, net_dev);
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
174 + pci_set_drvdata(pdev, net_dev);
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
175 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
176 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
177 +
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
178 + template sequence Ethernet::exit(PCI::Device pdev)
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
179 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
180 + chunk ::CALL
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
181 + {
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
182 + struct net_device *net_dev;
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
183 +
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
184 + net_dev = pci_get_drvdata(pdev); // should be ${pdev}, see above
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
185 + unregister_netdev(net_dev);
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
186 + /*
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
187 + * If we had some cleanup todo with struct rtx_ether_ctx we would
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
188 + * do a netdev_priv(net_dev) here and do it.
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
189 + */
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
190 + free_netdev(net_dev);
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
191 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
192 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
193 +}
22
65523c345b40 rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 21
diff changeset
194 diff -r 53c073d05449 rathaxes/samples/lkm/ethernet.rti
17
efe054f0989b Fix typo
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 16
diff changeset
195 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
22
65523c345b40 rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 21
diff changeset
196 +++ b/rathaxes/samples/lkm/ethernet.rti Sat Jan 07 19:18:24 2012 +0100
16
41a434b0676b WIP on the ethernet part of the LKM sample: set ifname + the irq in the net_device struct
Louis Opter <louis@lse.epitech.net>
parents: 15
diff changeset
197 @@ -0,0 +1,37 @@
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
198 +interface Ethernet : PCI, LKM
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
199 +{
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
200 + provided type Ethernet::Device;
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
201 +
16
41a434b0676b WIP on the ethernet part of the LKM sample: set ifname + the irq in the net_device struct
Louis Opter <louis@lse.epitech.net>
parents: 15
diff changeset
202 + required variable ::string Ethernet::ifname;
41a434b0676b WIP on the ethernet part of the LKM sample: set ifname + the irq in the net_device struct
Louis Opter <louis@lse.epitech.net>
parents: 15
diff changeset
203 +
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
204 + required sequence Ethernet::open(Ethernet::Device)
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
205 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
206 + provided chunk LKM::prototypes;
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
207 + provided chunk LKM::code;
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
208 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
209 +
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
210 + required sequence Ethernet::close(Ethernet::Device)
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
211 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
212 + provided chunk LKM::prototypes;
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
213 + provided chunk LKM::code;
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
214 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
215 +
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
216 + required sequence Ethernet::interrupt_handler(Ethernet::Device)
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
217 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
218 + provided chunk LKM::prototypes;
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
219 + provided chunk LKM::code;
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
220 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
221 +
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
222 + /* Kinda extends PCI::probe */
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
223 + provided sequence Ethernet::init(PCI::Device)
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
224 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
225 + provided chunk LKM::data;
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
226 + provided chunk ::CALL;
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
227 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
228 +
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
229 + /* Likely extends PCI::remove */
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
230 + provided sequence Ethernet::exit(PCI::Device)
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
231 + {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
232 + provided chunk ::CALL;
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
233 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
234 +}
22
65523c345b40 rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 21
diff changeset
235 diff -r 53c073d05449 rathaxes/samples/lkm/lkm.rtx
65523c345b40 rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 21
diff changeset
236 --- a/rathaxes/samples/lkm/lkm.rtx Sat Jan 07 19:10:21 2012 +0100
65523c345b40 rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 21
diff changeset
237 +++ b/rathaxes/samples/lkm/lkm.rtx Sat Jan 07 19:18:24 2012 +0100
19
670925d566c7 rathaxes: Add debug
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 18
diff changeset
238 @@ -1,13 +1,30 @@
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
239 device LKM use LKM, PCI, Log
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
240 {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
241 + Ethernet::open(Ethernet::Device dev)
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
242 + {
19
670925d566c7 rathaxes: Add debug
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 18
diff changeset
243 + Log::info("Open the device");
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
244 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
245 +
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
246 + Ethernet::close(Ethernet::Device dev)
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
247 + {
19
670925d566c7 rathaxes: Add debug
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 18
diff changeset
248 + Log::info("Close the device");
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
249 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
250 +
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
251 + Ethernet::interrupt_handler(Ethernet::Device dev)
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
252 + {
19
670925d566c7 rathaxes: Add debug
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 18
diff changeset
253 + Log::info("Got an interruption");
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
254 + }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
255 +
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
256 PCI::probe(PCI::Device dev)
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
257 {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
258 -
19
670925d566c7 rathaxes: Add debug
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 18
diff changeset
259 + Log::info("Probe the device");
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
260 + Ethernet::init(dev);
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
261 }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
262
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
263 PCI::remove(PCI::Device dev)
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
264 {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
265 -
19
670925d566c7 rathaxes: Add debug
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 18
diff changeset
266 + Log::info("Remove the pci device");
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
267 + Ethernet::exit(dev);
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
268 }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
269
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
270 LKM::init()
19
670925d566c7 rathaxes: Add debug
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 18
diff changeset
271 @@ -32,4 +49,6 @@
16
41a434b0676b WIP on the ethernet part of the LKM sample: set ifname + the irq in the net_device struct
Louis Opter <louis@lse.epitech.net>
parents: 15
diff changeset
272
41a434b0676b WIP on the ethernet part of the LKM sample: set ifname + the irq in the net_device struct
Louis Opter <louis@lse.epitech.net>
parents: 15
diff changeset
273 PCI::vendor_id = 0x8086;
41a434b0676b WIP on the ethernet part of the LKM sample: set ifname + the irq in the net_device struct
Louis Opter <louis@lse.epitech.net>
parents: 15
diff changeset
274 PCI::product_id = 0x100f;
41a434b0676b WIP on the ethernet part of the LKM sample: set ifname + the irq in the net_device struct
Louis Opter <louis@lse.epitech.net>
parents: 15
diff changeset
275 +
18
01f7686e4a33 rathaxes: update the interface name to add the number of the device
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 17
diff changeset
276 + Ethernet::ifname = "rtx%d";
16
41a434b0676b WIP on the ethernet part of the LKM sample: set ifname + the irq in the net_device struct
Louis Opter <louis@lse.epitech.net>
parents: 15
diff changeset
277 }
22
65523c345b40 rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 21
diff changeset
278 diff -r 53c073d05449 rathaxes/samples/lkm/pci.blt
65523c345b40 rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 21
diff changeset
279 --- a/rathaxes/samples/lkm/pci.blt Sat Jan 07 19:10:21 2012 +0100
65523c345b40 rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 21
diff changeset
280 +++ b/rathaxes/samples/lkm/pci.blt Sat Jan 07 19:18:24 2012 +0100
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
281 @@ -11,15 +11,12 @@
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
282
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
283 chunk ::decl()
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
284 {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
285 - struct rtx_pci_device
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
286 - {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
287 - struct pci_dev *pci_dev;
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
288 - };
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
289 + struct pci_dev;
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
290 }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
291
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
292 chunk ::init(pci_dev)
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
293 {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
294 - ${self}.pci_dev = pci_dev;
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
295 + ${self} = ${pci_dev};
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
296 }
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
297
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
298 map
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
299 @@ -27,7 +24,17 @@
14
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
300 }
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
301 }
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
302
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
303 - template sequence PCI::probe(PCI::Device dev)
14
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
304 + /*
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
305 + * The PCI::probe sequence is a "required" sequence which means that its
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
306 + * implementation will be done in the .rtx. Here we just define the context
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
307 + * were this implementation will be inserted. The implementation should be
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
308 + * able to access to the struct pci_dev (here marked as the "argument"
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
309 + * PCI::Device). How do we bind this PCI::Device argument with the pdev
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
310 + * struct pci_dev pointer defined in the LKM::code chunk?
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
311 + *
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
312 + * The only thing I can imagine is: ${pointcut ::IMPLEMENTATION(pdev)};
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
313 + */
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
314 + template sequence PCI::probe(PCI::Device pdev)
14
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
315 {
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
316 chunk LKM::prototypes()
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
317 {
14
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
318 @@ -40,11 +47,7 @@
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
319 static int /* __devinit */ rtx_pci_probe(struct pci_dev *pdev,
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
320 const struct pci_device_id *pdev_id)
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
321 {
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
322 - /* workaround for CNorm __std__ dialect, shouldn't be here */
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
323 - typedef int ${PCI::Device};
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
324 -
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
325 int err;
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
326 - ${PCI::Device} *dev = NULL;
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
327
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
328 err = pci_enable_device(pdev);
21
052f9209ca09 rathaxes:: add the ifs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 19
diff changeset
329 if (err < 0)
14
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
330 @@ -52,8 +55,6 @@
12
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
331
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
332 ${pointcut ::IMPLEMENTATION};
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
333
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
334 - pci_set_drvdata(pdev, dev);
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
335 -
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
336 return 0;
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
337
80cfe40c1136 WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
338 fail:
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
339 @@ -62,7 +63,7 @@
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
340 }
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
341 }
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
342
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
343 - template sequence PCI::remove(PCI::Device dev)
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
344 + template sequence PCI::remove(PCI::Device pdev)
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
345 {
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
346 chunk LKM::prototypes()
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
347 {
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
348 @@ -73,9 +74,9 @@
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
349 {
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
350 static void rtx_pci_remove(struct pci_dev *pdev)
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
351 {
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
352 + ${pointcut ::IMPLEMENTATION};
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
353 +
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
354 pci_disable_device(pdev);
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
355 -
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
356 - ${pointcut ::IMPLEMENTATION};
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
357 }
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
358 }
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 14
diff changeset
359 }
22
65523c345b40 rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 21
diff changeset
360 @@ -89,7 +90,7 @@
14
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
361 * have to specify the exact size).
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
362 */
22
65523c345b40 rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 21
diff changeset
363 static struct pci_device_id rtx_pci_device_table[2] = {
14
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
364 - { ${config.vendor_id}, ${config.product_id}, 0, PCI_ANY_ID, PCI_ANY_ID },
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
365 + { ${config.vendor_id}, ${config.product_id}, PCI_ANY_ID, PCI_ANY_ID },
22
65523c345b40 rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 21
diff changeset
366 { 0, }
14
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
367 };
4aac69287060 Fixes + comment in the Ethernet part
Louis Opter <louis@lse.epitech.net>
parents: 13
diff changeset
368