Mercurial > archived > louis > epitech > mq > rathaxes
comparison rathaxes_start_to_implement_pci_stuff_in_the_lkm.patch @ 21:052f9209ca09
rathaxes:: add the ifs
author | Thomas Sanchez <thomas.sanchz@gmail.com> |
---|---|
date | Sat, 07 Jan 2012 18:30:20 +0100 |
parents | 80cfe40c1136 |
children | 65523c345b40 |
comparison
equal
deleted
inserted
replaced
20:ecf2a0e61fff | 21:052f9209ca09 |
---|---|
1 # HG changeset patch | 1 # HG changeset patch |
2 # Parent 873b66890128280637d97a24221258bb297a1ac8 | 2 # Parent c08fffb84a93af26c6155c9776c5628fd556064b |
3 rathaxes: start to implement the PCI registration part in the LKM sample | 3 rathaxes: start to implement the PCI registration part in the LKM sample |
4 | 4 |
5 diff --git a/rathaxes/samples/lkm/CMakeLists.txt b/rathaxes/samples/lkm/CMakeLists.txt | 5 diff -r c08fffb84a93 rathaxes/samples/lkm/CMakeLists.txt |
6 --- a/rathaxes/samples/lkm/CMakeLists.txt | 6 --- a/rathaxes/samples/lkm/CMakeLists.txt Sat Jan 07 18:10:31 2012 +0100 |
7 +++ b/rathaxes/samples/lkm/CMakeLists.txt | 7 +++ b/rathaxes/samples/lkm/CMakeLists.txt Sat Jan 07 18:13:48 2012 +0100 |
8 @@ -1,3 +1,7 @@ | 8 @@ -1,3 +1,7 @@ |
9 ADD_RATHAXES_SOURCES(lkm lkm.rtx | 9 ADD_RATHAXES_SOURCES(lkm lkm.rtx |
10 - RTI log.rti lkm.rti | 10 - RTI log.rti lkm.rti |
11 - BLT log.blt lkm.blt) | 11 - BLT log.blt lkm.blt) |
12 + RTI log.rti lkm.rti pci.rti | 12 + RTI log.rti lkm.rti pci.rti |
13 + BLT log.blt lkm.blt pci.blt) | 13 + BLT log.blt lkm.blt pci.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 +ADD_RATHAXES_LKM(lkm_hello lkm) | 17 +ADD_RATHAXES_LKM(lkm_hello lkm) |
18 diff --git a/rathaxes/samples/lkm/lkm.blt b/rathaxes/samples/lkm/lkm.blt | 18 diff -r c08fffb84a93 rathaxes/samples/lkm/lkm.blt |
19 --- a/rathaxes/samples/lkm/lkm.blt | 19 --- a/rathaxes/samples/lkm/lkm.blt Sat Jan 07 18:10:31 2012 +0100 |
20 +++ b/rathaxes/samples/lkm/lkm.blt | 20 +++ b/rathaxes/samples/lkm/lkm.blt Sat Jan 07 18:13:48 2012 +0100 |
21 @@ -1,8 +1,10 @@ | 21 @@ -1,8 +1,10 @@ |
22 with LKM | 22 with LKM |
23 { | 23 { |
24 + /* Skel of the generated C file: */ | 24 + /* Skel of the generated C file: */ |
25 ${pointcut LKM::includes}; | 25 ${pointcut LKM::includes}; |
80 - module_exit(rtx_module_init); | 80 - module_exit(rtx_module_init); |
81 + module_exit(rtx_module_exit); | 81 + module_exit(rtx_module_exit); |
82 } | 82 } |
83 } | 83 } |
84 } | 84 } |
85 diff --git a/rathaxes/samples/lkm/lkm.rti b/rathaxes/samples/lkm/lkm.rti | 85 diff -r c08fffb84a93 rathaxes/samples/lkm/lkm.rti |
86 --- a/rathaxes/samples/lkm/lkm.rti | 86 --- a/rathaxes/samples/lkm/lkm.rti Sat Jan 07 18:10:31 2012 +0100 |
87 +++ b/rathaxes/samples/lkm/lkm.rti | 87 +++ b/rathaxes/samples/lkm/lkm.rti Sat Jan 07 18:13:48 2012 +0100 |
88 @@ -1,8 +1,10 @@ | 88 @@ -1,8 +1,10 @@ |
89 interface LKM | 89 interface LKM |
90 { | 90 { |
91 provided pointcut LKM::includes; | 91 provided pointcut LKM::includes; |
92 - provided pointcut LKM::init; | 92 - provided pointcut LKM::init; |
110 { | 110 { |
111 - provided chunk LKM::exit; | 111 - provided chunk LKM::exit; |
112 + provided chunk LKM::code; | 112 + provided chunk LKM::code; |
113 } | 113 } |
114 } | 114 } |
115 diff --git a/rathaxes/samples/lkm/lkm.rtx b/rathaxes/samples/lkm/lkm.rtx | 115 diff -r c08fffb84a93 rathaxes/samples/lkm/lkm.rtx |
116 --- a/rathaxes/samples/lkm/lkm.rtx | 116 --- a/rathaxes/samples/lkm/lkm.rtx Sat Jan 07 18:10:31 2012 +0100 |
117 +++ b/rathaxes/samples/lkm/lkm.rtx | 117 +++ b/rathaxes/samples/lkm/lkm.rtx Sat Jan 07 18:13:48 2012 +0100 |
118 @@ -1,19 +1,35 @@ | 118 @@ -1,19 +1,35 @@ |
119 -device LKM use LKM, Log | 119 -device LKM use LKM, Log |
120 +device LKM use LKM, PCI, Log | 120 +device LKM use LKM, PCI, Log |
121 { | 121 { |
122 + PCI::probe(PCI::Device dev) | 122 + PCI::probe(PCI::Device dev) |
150 LKM::license = "BSD"; | 150 LKM::license = "BSD"; |
151 + | 151 + |
152 + PCI::vendor_id = 0x8086; | 152 + PCI::vendor_id = 0x8086; |
153 + PCI::product_id = 0x100f; | 153 + PCI::product_id = 0x100f; |
154 } | 154 } |
155 diff --git a/rathaxes/samples/lkm/pci.blt b/rathaxes/samples/lkm/pci.blt | 155 diff -r c08fffb84a93 rathaxes/samples/lkm/pci.blt |
156 new file mode 100644 | 156 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
157 --- /dev/null | 157 +++ b/rathaxes/samples/lkm/pci.blt Sat Jan 07 18:13:48 2012 +0100 |
158 +++ b/rathaxes/samples/lkm/pci.blt | 158 @@ -0,0 +1,124 @@ |
159 @@ -0,0 +1,129 @@ | |
160 +with PCI, LKM, Log | 159 +with PCI, LKM, Log |
161 +{ | 160 +{ |
162 + template type PCI::Device() | 161 + template type PCI::Device() |
163 + { | 162 + { |
164 + chunk LKM::includes() | 163 + chunk LKM::includes() |
204 + | 203 + |
205 + int err; | 204 + int err; |
206 + ${PCI::Device} *dev = NULL; | 205 + ${PCI::Device} *dev = NULL; |
207 + | 206 + |
208 + err = pci_enable_device(pdev); | 207 + err = pci_enable_device(pdev); |
209 +// if (err < 0) /* `if' doesn't work */ | 208 + if (err < 0) |
210 +// goto fail; | 209 + goto fail; |
211 + | 210 + |
212 + ${pointcut ::IMPLEMENTATION}; | 211 + ${pointcut ::IMPLEMENTATION}; |
213 + | 212 + |
214 + pci_set_drvdata(pdev, dev); | 213 + pci_set_drvdata(pdev, dev); |
215 + | 214 + |
264 + { | 263 + { |
265 + /* | 264 + /* |
266 + * So how do we use the return value in the parent context? | 265 + * So how do we use the return value in the parent context? |
267 + */ | 266 + */ |
268 + pci_register_driver(&rtx_pci_driver); | 267 + pci_register_driver(&rtx_pci_driver); |
269 + /* | 268 + if (pci_register_driver(&rtx_pci_driver)) |
270 + * if (pci_register_driver(&rtx_pci_driver)) | 269 + { |
271 + * { | 270 + ${Log::info("Message")}; |
272 + * `if' still doesn't work. | 271 + } |
273 + * | |
274 + * Also, can I call the Log interface from here? | |
275 + * ${Log::info("Message")}; doesn't seem to work. | |
276 + * } | |
277 + */ | |
278 + } | 272 + } |
279 + } | 273 + } |
280 + | 274 + |
281 + template sequence PCI::unregister() | 275 + template sequence PCI::unregister() |
282 + { | 276 + { |
284 + { | 278 + { |
285 + pci_unregister_driver(&rtx_pci_driver); | 279 + pci_unregister_driver(&rtx_pci_driver); |
286 + } | 280 + } |
287 + } | 281 + } |
288 +} | 282 +} |
289 diff --git a/rathaxes/samples/lkm/pci.rti b/rathaxes/samples/lkm/pci.rti | 283 diff -r c08fffb84a93 rathaxes/samples/lkm/pci.rti |
290 new file mode 100644 | 284 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
291 --- /dev/null | 285 +++ b/rathaxes/samples/lkm/pci.rti Sat Jan 07 18:13:48 2012 +0100 |
292 +++ b/rathaxes/samples/lkm/pci.rti | |
293 @@ -0,0 +1,30 @@ | 286 @@ -0,0 +1,30 @@ |
294 +interface PCI : LKM | 287 +interface PCI : LKM |
295 +{ | 288 +{ |
296 + provided type PCI::Device; | 289 + provided type PCI::Device; |
297 + | 290 + |