Mercurial > archived > louis > epitech > mq > rathaxes
annotate rathaxes_start_to_implement_pci_stuff_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 |
rev | line source |
---|---|
4 | 1 # HG changeset patch |
22
65523c345b40
rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
21
diff
changeset
|
2 # Parent 6e00628ccba9fd82577a8a30fe4e730bc982e987 |
4 | 3 rathaxes: start to implement the PCI registration part in the LKM sample |
4 | |
22
65523c345b40
rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
21
diff
changeset
|
5 diff -r 6e00628ccba9 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:07:39 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:10:21 2012 +0100 |
6
5b128dbd2c17
WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
5
diff
changeset
|
8 @@ -1,3 +1,7 @@ |
4 | 9 ADD_RATHAXES_SOURCES(lkm lkm.rtx |
10 - RTI log.rti lkm.rti | |
11 - BLT log.blt lkm.blt) | |
12 + RTI log.rti lkm.rti pci.rti | |
13 + BLT log.blt lkm.blt pci.blt) | |
6
5b128dbd2c17
WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
5
diff
changeset
|
14 + |
5b128dbd2c17
WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
5
diff
changeset
|
15 +# We can't name lkm since it's already used as the target name to generate the |
5b128dbd2c17
WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
5
diff
changeset
|
16 +# source (with ADD_RATHAXES_SOURCES). |
5b128dbd2c17
WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
5
diff
changeset
|
17 +ADD_RATHAXES_LKM(lkm_hello lkm) |
22
65523c345b40
rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
21
diff
changeset
|
18 diff -r 6e00628ccba9 rathaxes/samples/lkm/lkm.blt |
65523c345b40
rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
21
diff
changeset
|
19 --- a/rathaxes/samples/lkm/lkm.blt Sat Jan 07 19:07:39 2012 +0100 |
65523c345b40
rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
21
diff
changeset
|
20 +++ b/rathaxes/samples/lkm/lkm.blt Sat Jan 07 19:10:21 2012 +0100 |
5 | 21 @@ -1,8 +1,10 @@ |
4 | 22 with LKM |
23 { | |
5 | 24 + /* Skel of the generated C file: */ |
4 | 25 ${pointcut LKM::includes}; |
26 - ${pointcut LKM::init}; | |
27 - ${pointcut LKM::exit}; | |
5 | 28 + ${pointcut LKM::prototypes}; |
4 | 29 + ${pointcut LKM::data}; |
30 + ${pointcut LKM::code}; | |
31 | |
32 template sequence LKM::init() | |
33 { | |
10
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
34 @@ -10,22 +12,29 @@ |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
35 { |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
36 #include <linux/module.h> |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
37 #include <linux/kernel.h> |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
38 - typedef int lkm_headers_include_stamp; |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
39 |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
40 + typedef int include_linux_module_stamp; |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
41 + typedef int include_linux_kernel_stamp; |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
42 + } |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
43 + |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
44 + chunk LKM::data() |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
45 + { |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
46 MODULE_DESCRIPTION(${config.description}); |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
47 MODULE_AUTHOR(${config.author}); |
4 | 48 MODULE_LICENSE(${config.license}); |
49 } | |
50 | |
51 - chunk LKM::init() | |
52 + chunk LKM::code() | |
53 { | |
54 /* | |
55 * Rathaxes doesn't yet support arbitrary "decorators" like __init | |
10
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
56 * or __exit. |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
57 */ |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
58 - static int __attribute__((__section__(.init.text))) rtx_module_init(void) |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
59 + static int __attribute__((__section__(".init.text"))) rtx_module_init(void) |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
60 { |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
61 ${pointcut ::IMPLEMENTATION}; |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
62 + |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
63 + return 0; |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
64 } |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
65 |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
66 module_init(rtx_module_init); |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
67 @@ -34,14 +43,14 @@ |
4 | 68 |
69 template sequence LKM::exit() | |
70 { | |
71 - chunk LKM::exit | |
72 + chunk LKM::code() | |
73 { | |
10
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
74 - static void __attribute((__section__(.exit.text))) rtx_module_exit(void) |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
75 + static void __attribute__((__section__(".exit.text"))) rtx_module_exit(void) |
4 | 76 { |
10
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
77 ${pointcut ::IMPLEMENTATION}; |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
78 } |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
79 |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
80 - module_exit(rtx_module_init); |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
81 + module_exit(rtx_module_exit); |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
82 } |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
83 } |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
84 } |
22
65523c345b40
rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
21
diff
changeset
|
85 diff -r 6e00628ccba9 rathaxes/samples/lkm/lkm.rti |
65523c345b40
rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
21
diff
changeset
|
86 --- a/rathaxes/samples/lkm/lkm.rti Sat Jan 07 19:07:39 2012 +0100 |
65523c345b40
rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
21
diff
changeset
|
87 +++ b/rathaxes/samples/lkm/lkm.rti Sat Jan 07 19:10:21 2012 +0100 |
6
5b128dbd2c17
WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
5
diff
changeset
|
88 @@ -1,8 +1,10 @@ |
4 | 89 interface LKM |
90 { | |
91 provided pointcut LKM::includes; | |
92 - provided pointcut LKM::init; | |
93 - provided pointcut LKM::exit; | |
6
5b128dbd2c17
WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
5
diff
changeset
|
94 + /* maybe it should be possible to use chunk ::decl in sequence templates? */ |
5 | 95 + provided pointcut LKM::prototypes; |
4 | 96 + provided pointcut LKM::data; |
97 + provided pointcut LKM::code; | |
98 | |
99 required variable ::string LKM::author; | |
100 required variable ::string LKM::description; | |
6
5b128dbd2c17
WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
5
diff
changeset
|
101 @@ -11,11 +13,11 @@ |
4 | 102 required sequence LKM::init() |
103 { | |
104 provided chunk LKM::includes; | |
105 - provided chunk LKM::init; | |
106 + provided chunk LKM::code; | |
107 } | |
108 | |
109 required sequence LKM::exit() | |
110 { | |
111 - provided chunk LKM::exit; | |
112 + provided chunk LKM::code; | |
113 } | |
114 } | |
22
65523c345b40
rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
21
diff
changeset
|
115 diff -r 6e00628ccba9 rathaxes/samples/lkm/lkm.rtx |
65523c345b40
rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
21
diff
changeset
|
116 --- a/rathaxes/samples/lkm/lkm.rtx Sat Jan 07 19:07:39 2012 +0100 |
65523c345b40
rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
21
diff
changeset
|
117 +++ b/rathaxes/samples/lkm/lkm.rtx Sat Jan 07 19:10:21 2012 +0100 |
10
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
118 @@ -1,19 +1,35 @@ |
4 | 119 -device LKM use LKM, Log |
120 +device LKM use LKM, PCI, Log | |
121 { | |
122 + PCI::probe(PCI::Device dev) | |
123 + { | |
124 + | |
125 + } | |
126 + | |
127 + PCI::remove(PCI::Device dev) | |
128 + { | |
129 + | |
130 + } | |
131 + | |
132 LKM::init() | |
133 { | |
134 Log::info("Hello this is LKM"); | |
10
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
135 + PCI::register(); |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
136 } |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
137 |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
138 LKM::exit() |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
139 { |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
140 Log::info("Good bye this was LKM"); |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
141 + PCI::unregister(); |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
142 } |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
143 } |
4 | 144 |
145 configuration | |
146 { | |
147 + LKM::name = "hello"; | |
148 LKM::author = "Rathaxes"; | |
149 LKM::description = "Hello World Loadable Kernel Module (LKM)"; | |
150 LKM::license = "BSD"; | |
5 | 151 + |
10
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
152 + PCI::vendor_id = 0x8086; |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
153 + PCI::product_id = 0x100f; |
5 | 154 } |
22
65523c345b40
rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
21
diff
changeset
|
155 diff -r 6e00628ccba9 rathaxes/samples/lkm/pci.blt |
21
052f9209ca09
rathaxes:: add the ifs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
12
diff
changeset
|
156 --- /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
|
157 +++ b/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
|
158 @@ -0,0 +1,127 @@ |
10
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
159 +with PCI, LKM, Log |
4 | 160 +{ |
161 + template type PCI::Device() | |
162 + { | |
10
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
163 + chunk LKM::includes() |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
164 + { |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
165 + #include <linux/pci.h> |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
166 + |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
167 + typedef int include_linux_pci_stamp; |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
168 + } |
4 | 169 + |
170 + chunk ::decl() | |
171 + { | |
172 + struct rtx_pci_device | |
173 + { | |
174 + struct pci_dev *pci_dev; | |
175 + }; | |
176 + } | |
177 + | |
178 + chunk ::init(pci_dev) | |
179 + { | |
180 + ${self}.pci_dev = pci_dev; | |
181 + } | |
182 + | |
183 + map | |
184 + { | |
185 + } | |
186 + } | |
187 + | |
188 + template sequence PCI::probe(PCI::Device dev) | |
189 + { | |
5 | 190 + chunk LKM::prototypes() |
191 + { | |
192 + static int /* __devinit */ rtx_pci_probe(struct pci_dev *, | |
193 + const struct pci_device_id *); | |
194 + } | |
195 + | |
4 | 196 + chunk LKM::code() |
197 + { | |
198 + static int /* __devinit */ rtx_pci_probe(struct pci_dev *pdev, | |
199 + const struct pci_device_id *pdev_id) | |
200 + { | |
201 + /* workaround for CNorm __std__ dialect, shouldn't be here */ | |
202 + typedef int ${PCI::Device}; | |
203 + | |
204 + int err; | |
10
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
205 + ${PCI::Device} *dev = NULL; |
4 | 206 + |
207 + err = pci_enable_device(pdev); | |
21
052f9209ca09
rathaxes:: add the ifs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
12
diff
changeset
|
208 + if (err < 0) |
052f9209ca09
rathaxes:: add the ifs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
12
diff
changeset
|
209 + goto fail; |
4 | 210 + |
211 + ${pointcut ::IMPLEMENTATION}; | |
212 + | |
213 + pci_set_drvdata(pdev, dev); | |
214 + | |
215 + return 0; | |
216 + | |
217 + fail: | |
218 + return err; | |
219 + } | |
220 + } | |
221 + } | |
222 + | |
223 + template sequence PCI::remove(PCI::Device dev) | |
224 + { | |
5 | 225 + chunk LKM::prototypes() |
226 + { | |
227 + static void rtx_pci_remove(struct pci_dev *); | |
228 + } | |
229 + | |
4 | 230 + chunk LKM::code() |
231 + { | |
232 + static void rtx_pci_remove(struct pci_dev *pdev) | |
233 + { | |
234 + pci_disable_device(pdev); | |
235 + | |
236 + ${pointcut ::IMPLEMENTATION}; | |
237 + } | |
238 + } | |
239 + } | |
10
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
240 + |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
241 + template sequence PCI::register() |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
242 + { |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
243 + chunk LKM::data() |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
244 + { |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
245 + /* |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
246 + * CNorm doesn't seem to like "dynamic" arrays (i.e: you always |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
247 + * have to specify the exact size). |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
248 + */ |
22
65523c345b40
rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
21
diff
changeset
|
249 + static struct pci_device_id rtx_pci_device_table[2] = { |
10
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
250 + { ${config.vendor_id}, ${config.product_id}, 0, PCI_ANY_ID, PCI_ANY_ID }, |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
251 + { 0, } |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
252 + }; |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
253 + |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
254 + static struct pci_driver rtx_pci_driver = { |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
255 + .name = ${config.name}, |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
256 + .id_table = rtx_pci_device_table, |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
257 + .probe = rtx_pci_probe, |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
258 + .remove = rtx_pci_remove |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
259 + }; |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
260 + } |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
261 + |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
262 + chunk ::CALL |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
263 + { |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
264 + /* |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
265 + * So how do we use the return value in the parent context? |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
266 + */ |
22
65523c345b40
rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
21
diff
changeset
|
267 + int error; |
65523c345b40
rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
21
diff
changeset
|
268 + if ((error = pci_register_driver(&rtx_pci_driver))) |
21
052f9209ca09
rathaxes:: add the ifs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
12
diff
changeset
|
269 + { |
22
65523c345b40
rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
21
diff
changeset
|
270 + ${Log::info("Cannot register pci driver")}; |
65523c345b40
rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
21
diff
changeset
|
271 + // should we return here. |
65523c345b40
rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
21
diff
changeset
|
272 + // error managmement procedure has to be determined ASAP. |
65523c345b40
rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
21
diff
changeset
|
273 + return error; |
21
052f9209ca09
rathaxes:: add the ifs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
12
diff
changeset
|
274 + } |
10
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
275 + } |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
276 + } |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
277 + |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
278 + template sequence PCI::unregister() |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
279 + { |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
280 + chunk ::CALL |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
281 + { |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
282 + pci_unregister_driver(&rtx_pci_driver); |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
283 + } |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
284 + } |
4 | 285 +} |
22
65523c345b40
rathaxes:: add logs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
21
diff
changeset
|
286 diff -r 6e00628ccba9 rathaxes/samples/lkm/pci.rti |
21
052f9209ca09
rathaxes:: add the ifs
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
12
diff
changeset
|
287 --- /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
|
288 +++ b/rathaxes/samples/lkm/pci.rti Sat Jan 07 19:10:21 2012 +0100 |
10
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
289 @@ -0,0 +1,30 @@ |
4 | 290 +interface PCI : LKM |
291 +{ | |
292 + provided type PCI::Device; | |
293 + | |
5 | 294 + required variable ::number PCI::vendor_id; |
295 + required variable ::number PCI::product_id; | |
296 + | |
4 | 297 + provided sequence PCI::register() |
298 + { | |
299 + provided chunk ::CALL; | |
10
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
300 + provided chunk LKM::data; |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
301 + } |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
302 + |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
303 + provided sequence PCI::unregister() |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
304 + { |
44a25ffd5c8c
Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents:
6
diff
changeset
|
305 + provided chunk ::CALL; |
4 | 306 + } |
307 + | |
308 + required sequence PCI::probe(PCI::Device) | |
309 + { | |
5 | 310 + provided chunk LKM::prototypes; |
4 | 311 + provided chunk LKM::code; |
312 + } | |
313 + | |
314 + required sequence PCI::remove(PCI::Device) | |
315 + { | |
5 | 316 + provided chunk LKM::prototypes; |
4 | 317 + provided chunk LKM::code; |
318 + } | |
319 +} |