Mercurial > archived > louis > epitech > mq > rathaxes
annotate rathaxes_start_to_implement_pci_stuff_in_the_lkm.patch @ 12:80cfe40c1136
WIP on the LKM sample, add a patch to work on the Ethernet subsystem
author | Louis Opter <louis@lse.epitech.net> |
---|---|
date | Fri, 06 Jan 2012 17:33:00 +0100 |
parents | efee5f0249e2 |
children | 052f9209ca09 |
rev | line source |
---|---|
4 | 1 # HG changeset patch |
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
|
2 # Parent 873b66890128280637d97a24221258bb297a1ac8 |
4 | 3 rathaxes: start to implement the PCI registration part in the LKM sample |
4 | |
5 diff --git a/rathaxes/samples/lkm/CMakeLists.txt b/rathaxes/samples/lkm/CMakeLists.txt | |
6 --- a/rathaxes/samples/lkm/CMakeLists.txt | |
7 +++ b/rathaxes/samples/lkm/CMakeLists.txt | |
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) |
4 | 18 diff --git a/rathaxes/samples/lkm/lkm.blt b/rathaxes/samples/lkm/lkm.blt |
19 --- a/rathaxes/samples/lkm/lkm.blt | |
20 +++ b/rathaxes/samples/lkm/lkm.blt | |
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 } |
4 | 85 diff --git a/rathaxes/samples/lkm/lkm.rti b/rathaxes/samples/lkm/lkm.rti |
86 --- a/rathaxes/samples/lkm/lkm.rti | |
87 +++ b/rathaxes/samples/lkm/lkm.rti | |
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 } | |
115 diff --git a/rathaxes/samples/lkm/lkm.rtx b/rathaxes/samples/lkm/lkm.rtx | |
116 --- a/rathaxes/samples/lkm/lkm.rtx | |
117 +++ b/rathaxes/samples/lkm/lkm.rtx | |
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 } |
4 | 155 diff --git a/rathaxes/samples/lkm/pci.blt b/rathaxes/samples/lkm/pci.blt |
156 new file mode 100644 | |
157 --- /dev/null | |
158 +++ b/rathaxes/samples/lkm/pci.blt | |
12
80cfe40c1136
WIP on the LKM sample, add a patch to work on the Ethernet subsystem
Louis Opter <louis@lse.epitech.net>
parents:
11
diff
changeset
|
159 @@ -0,0 +1,129 @@ |
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
|
160 +with PCI, LKM, Log |
4 | 161 +{ |
162 + template type PCI::Device() | |
163 + { | |
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
|
164 + 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
|
165 + { |
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 + #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
|
167 + |
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 + 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
|
169 + } |
4 | 170 + |
171 + chunk ::decl() | |
172 + { | |
173 + struct rtx_pci_device | |
174 + { | |
175 + struct pci_dev *pci_dev; | |
176 + }; | |
177 + } | |
178 + | |
179 + chunk ::init(pci_dev) | |
180 + { | |
181 + ${self}.pci_dev = pci_dev; | |
182 + } | |
183 + | |
184 + map | |
185 + { | |
186 + } | |
187 + } | |
188 + | |
189 + template sequence PCI::probe(PCI::Device dev) | |
190 + { | |
5 | 191 + chunk LKM::prototypes() |
192 + { | |
193 + static int /* __devinit */ rtx_pci_probe(struct pci_dev *, | |
194 + const struct pci_device_id *); | |
195 + } | |
196 + | |
4 | 197 + chunk LKM::code() |
198 + { | |
199 + static int /* __devinit */ rtx_pci_probe(struct pci_dev *pdev, | |
200 + const struct pci_device_id *pdev_id) | |
201 + { | |
202 + /* workaround for CNorm __std__ dialect, shouldn't be here */ | |
203 + typedef int ${PCI::Device}; | |
204 + | |
205 + 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
|
206 + ${PCI::Device} *dev = NULL; |
4 | 207 + |
208 + err = pci_enable_device(pdev); | |
209 +// if (err < 0) /* `if' doesn't work */ | |
210 +// goto fail; | |
211 + | |
212 + ${pointcut ::IMPLEMENTATION}; | |
213 + | |
214 + pci_set_drvdata(pdev, dev); | |
215 + | |
216 + return 0; | |
217 + | |
218 + fail: | |
219 + return err; | |
220 + } | |
221 + } | |
222 + } | |
223 + | |
224 + template sequence PCI::remove(PCI::Device dev) | |
225 + { | |
5 | 226 + chunk LKM::prototypes() |
227 + { | |
228 + static void rtx_pci_remove(struct pci_dev *); | |
229 + } | |
230 + | |
4 | 231 + chunk LKM::code() |
232 + { | |
233 + static void rtx_pci_remove(struct pci_dev *pdev) | |
234 + { | |
235 + pci_disable_device(pdev); | |
236 + | |
237 + ${pointcut ::IMPLEMENTATION}; | |
238 + } | |
239 + } | |
240 + } | |
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
|
241 + |
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 + 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
|
243 + { |
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 + 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
|
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 + /* |
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 + * 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
|
248 + * 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
|
249 + */ |
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 + static struct pci_device_id rtx_pci_device_table[2] = { |
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 + { ${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
|
252 + { 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
|
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 + |
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 + 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
|
256 + .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
|
257 + .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
|
258 + .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
|
259 + .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
|
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 + |
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 + 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
|
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 + /* |
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 + * 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
|
267 + */ |
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
|
268 + pci_register_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
|
269 + /* |
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
|
270 + * if (pci_register_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
|
271 + * { |
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
|
272 + * `if' still doesn't work. |
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
|
273 + * |
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
|
274 + * Also, can I call the Log interface from here? |
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 + * ${Log::info("Message")}; doesn't seem to work. |
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 + } |
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 + |
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 + 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
|
282 + { |
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 + 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
|
284 + { |
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
|
285 + 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
|
286 + } |
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
|
287 + } |
4 | 288 +} |
289 diff --git a/rathaxes/samples/lkm/pci.rti b/rathaxes/samples/lkm/pci.rti | |
290 new file mode 100644 | |
291 --- /dev/null | |
292 +++ b/rathaxes/samples/lkm/pci.rti | |
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
|
293 @@ -0,0 +1,30 @@ |
4 | 294 +interface PCI : LKM |
295 +{ | |
296 + provided type PCI::Device; | |
297 + | |
5 | 298 + required variable ::number PCI::vendor_id; |
299 + required variable ::number PCI::product_id; | |
300 + | |
4 | 301 + provided sequence PCI::register() |
302 + { | |
303 + 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
|
304 + 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
|
305 + } |
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
|
306 + |
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
|
307 + 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
|
308 + { |
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
|
309 + provided chunk ::CALL; |
4 | 310 + } |
311 + | |
312 + required sequence PCI::probe(PCI::Device) | |
313 + { | |
5 | 314 + provided chunk LKM::prototypes; |
4 | 315 + provided chunk LKM::code; |
316 + } | |
317 + | |
318 + required sequence PCI::remove(PCI::Device) | |
319 + { | |
5 | 320 + provided chunk LKM::prototypes; |
4 | 321 + provided chunk LKM::code; |
322 + } | |
323 +} |