Mercurial > archived > louis > epitech > mq > rathaxes
annotate rathaxes_add_lkm_ethernet_sample.patch @ 41:87704b867fb0
First attempt at loading the mac address
author | Louis Opter <louis@lse.epitech.net> |
---|---|
date | Sun, 08 Jan 2012 16:49:38 +0100 |
parents | 0ff39df29c46 |
children | e0cd016d4fc5 |
rev | line source |
---|---|
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
1 # HG changeset patch |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
2 # Parent b995d8934956b83383c144303178f3eb383d0acf |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
3 rathaxes: add the PCI/Ethernet part of a Linux Intel e1000 network card driver |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
4 |
40
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
5 diff --git a/maintainers/CMakeScripts/UseRathaxes.cmake b/maintainers/CMakeScripts/UseRathaxes.cmake |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
6 --- a/maintainers/CMakeScripts/UseRathaxes.cmake |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
7 +++ b/maintainers/CMakeScripts/UseRathaxes.cmake |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
8 @@ -193,6 +193,8 @@ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
9 |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
10 SET(KERNEL_OBJECT_NAME "${RATHAXES_SOURCE}_${SYSTEM}.ko") |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
11 ADD_CUSTOM_COMMAND(OUTPUT "${KERNEL_OBJECT_NAME}" |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
12 + # … |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
13 + COMMAND "sed" "-i" "/TARTE/ d" "${RATHAXES_SOURCE}_${SYSTEM}.c" |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
14 # The linux Makefile to build kernel module is quite |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
15 # picky about file location and its own name. Let's |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
16 # copy our source side by side with the Makefile: |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
17 diff --git a/rathaxes/samples/CMakeLists.txt b/rathaxes/samples/CMakeLists.txt |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
18 --- a/rathaxes/samples/CMakeLists.txt |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
19 +++ b/rathaxes/samples/CMakeLists.txt |
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:
3
diff
changeset
|
20 @@ -1,2 +1,3 @@ |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
21 ADD_SUBDIRECTORY(helloworld) |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
22 +ADD_SUBDIRECTORY(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:
3
diff
changeset
|
23 ADD_SUBDIRECTORY(syntax) |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
24 diff --git a/rathaxes/samples/lkm/CMakeLists.txt b/rathaxes/samples/lkm/CMakeLists.txt |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
25 new file mode 100644 |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
26 --- /dev/null |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
27 +++ b/rathaxes/samples/lkm/CMakeLists.txt |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
28 @@ -0,0 +1,7 @@ |
39
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
29 +ADD_RATHAXES_SOURCES(lkm_src lkm.rtx |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
30 + RTI log.rti lkm.rti pci.rti socket.rti ethernet.rti e1000.rti |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
31 + BLT log.blt lkm.blt pci.blt socket.blt ethernet.blt e1000.blt) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
32 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
33 +# We can't name lkm since it's already used as the target name to generate the |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
34 +# source (with ADD_RATHAXES_SOURCES). |
39
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
35 +ADD_RATHAXES_LKM(lkm lkm_src) |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
36 diff --git a/rathaxes/samples/lkm/e1000.blt b/rathaxes/samples/lkm/e1000.blt |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
37 new file mode 100644 |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
38 --- /dev/null |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
39 +++ b/rathaxes/samples/lkm/e1000.blt |
41
87704b867fb0
First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents:
40
diff
changeset
|
40 @@ -0,0 +1,284 @@ |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
41 +with e1000, Ethernet, Socket, PCI, LKM, Log |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
42 +{ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
43 + template type e1000::Context() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
44 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
45 + chunk LKM::includes() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
46 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
47 + /* |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
48 + * Force the generation of the structure in the "headers" part, we |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
49 + * have to do this since we do not use the structure in this blt |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
50 + * (we hacked a bit and used it in ethernet.blt directly). |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
51 + */ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
52 + typedef int ${e1000::Context}; /* CNorm __std__ workaround */ |
39
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
53 + static const ${e1000::Context} force_struct_rtx_10000_ctx_decl; |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
54 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
55 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
56 + chunk ::decl() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
57 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
58 + struct rtx_e1000_ctx |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
59 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
60 + int bars; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
61 + unsigned char /* __iomem */ *ioaddr; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
62 + }; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
63 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
64 + |
39
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
65 + chunk ::init(bars, ioaddr) |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
66 + { |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
67 + ${self}.bars = ${bars}; |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
68 + ${self}.ioaddr = ${ioaddr}; |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
69 + } |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
70 + |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
71 + map |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
72 + { |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
73 + } |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
74 + } |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
75 + |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
76 + template type e1000::Register() |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
77 + { |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
78 + chunk LKM::includes() |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
79 + { |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
80 + typedef int ${e1000::Register}; |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
81 + static const ${e1000::Register} force_enum_rtx_e1000_registers_decl; |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
82 + } |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
83 + |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
84 + chunk ::decl() |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
85 + { |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
86 + enum rtx_e1000_registers |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
87 + { |
40
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
88 + E1000_CTRL = 0x00000, /* Device Control - RW */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
89 + E1000_CTRL_DUP = 0x00004, /* Device Control Duplicate (Shadow) - RW */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
90 + E1000_STATUS = 0x00008, /* Device Status - RO */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
91 + E1000_EEPROM_FLASH = 0x00010, /* EEPROM/Flash Control - RW */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
92 + E1000_EEPROM_READ = 0x00014, /* EEPROM Read - RW */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
93 + E1000_CTRL_EXT = 0x00018, /* Extended Device Control - RW */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
94 + E1000_FLA = 0x0001C, /* Flash Access - RW */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
95 + E1000_MDIC = 0x00020 /* MDI Control - RW */ |
39
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
96 + }; |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
97 + } |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
98 + |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
99 + chunk ::init(value) |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
100 + { |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
101 + ${self} = ${value}; |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
102 + } |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
103 + |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
104 + map |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
105 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
106 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
107 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
108 + |
40
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
109 + template type e1000::Commands() |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
110 + { |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
111 + chunk LKM::includes() |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
112 + { |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
113 + typedef int ${e1000::Commands}; |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
114 + static const ${e1000::Commands} force_enum_rtx_e1000_commands_decls; |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
115 + } |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
116 + |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
117 + chunk ::decl() |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
118 + { |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
119 + enum rtx_e1000_commands |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
120 + { |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
121 + E1000_CMD_FD = 0x00000001, /* Full duplex.0=half; 1=full */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
122 + E1000_CMD_BEM = 0x00000002, /* Endian Mode.0=little,1=big */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
123 + E1000_CMD_PRIOR = 0x00000004, /* Priority on PCI. 0=rx,1=fair */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
124 + E1000_CMD_GIO_MASTER_DISABLE = 0x00000004, /* Blocks new Master requests */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
125 + E1000_CMD_LRST = 0x00000008, /* Link reset. 0=normal,1=reset */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
126 + E1000_CMD_TME = 0x00000010, /* Test mode. 0=normal,1=test */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
127 + E1000_CMD_SLE = 0x00000020, /* Serial Link on 0=dis,1=en */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
128 + E1000_CMD_ASDE = 0x00000020, /* Auto-speed detect enable */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
129 + E1000_CMD_SLU = 0x00000040, /* Set link up (Force Link) */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
130 + E1000_CMD_ILOS = 0x00000080, /* Invert Loss-Of Signal */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
131 + E1000_CMD_SPD_SEL = 0x00000300, /* Speed Select Mask */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
132 + E1000_CMD_SPD_10 = 0x00000000, /* Force 10Mb */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
133 + E1000_CMD_SPD_100 = 0x00000100, /* Force 100Mb */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
134 + E1000_CMD_SPD_1000 = 0x00000200, /* Force 1Gb */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
135 + E1000_CMD_BEM32 = 0x00000400, /* Big Endian 32 mode */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
136 + E1000_CMD_FRCSPD = 0x00000800, /* Force Speed */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
137 + E1000_CMD_FRCDPX = 0x00001000, /* Force Duplex */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
138 + E1000_CMD_D_UD_EN = 0x00002000, /* Dock/Undock enable */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
139 + E1000_CMD_D_UD_POLARITY = 0x00004000, /* Defined polarity of Dock/Undock indication in SDP[0] */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
140 + E1000_CMD_FORCE_PHY_RESET = 0x00008000, /* Reset both PHY ports, through PHYRST_N pin */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
141 + E1000_CMD_EXT_LINK_EN = 0x00010000, /* enable link status from external LINK_0 and LINK_1 pins */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
142 + E1000_CMD_SWDPIN0 = 0x00040000, /* SWDPIN 0 value */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
143 + E1000_CMD_SWDPIN1 = 0x00080000, /* SWDPIN 1 value */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
144 + E1000_CMD_SWDPIN2 = 0x00100000, /* SWDPIN 2 value */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
145 + E1000_CMD_SWDPIN3 = 0x00200000, /* SWDPIN 3 value */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
146 + E1000_CMD_SWDPIO0 = 0x00400000, /* SWDPIN 0 Input or output */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
147 + E1000_CMD_SWDPIO1 = 0x00800000, /* SWDPIN 1 input or output */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
148 + E1000_CMD_SWDPIO2 = 0x01000000, /* SWDPIN 2 input or output */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
149 + E1000_CMD_SWDPIO3 = 0x02000000, /* SWDPIN 3 input or output */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
150 + E1000_CMD_RST = 0x04000000, /* Global reset */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
151 + E1000_CMD_RFCE = 0x08000000, /* Receive Flow Control enable */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
152 + E1000_CMD_TFCE = 0x10000000, /* Transmit flow control enable */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
153 + E1000_CMD_RTE = 0x20000000, /* Routing tag enable */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
154 + E1000_CMD_VME = 0x40000000, /* IEEE VLAN mode enable */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
155 + E1000_CMD_PHY_RST = 0x80000000, /* PHY Reset */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
156 + E1000_CMD_SW2FW_INT = 0x02000000 /* Initiate an interrupt to manageability engine */ |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
157 + }; |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
158 + } |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
159 + |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
160 + map |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
161 + { |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
162 + } |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
163 + } |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
164 + |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
165 + template sequence e1000::create_device() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
166 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
167 + chunk Ethernet::create_device() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
168 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
169 + rtx_ether_ctx->hw_ctx.bars = pci_select_bars(pdev, IORESOURCE_MEM); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
170 + if (pci_enable_device_mem(pdev)) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
171 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
172 + ${Log::info("e1000::create: pci_enable_device_mem failed")}; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
173 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
174 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
175 + if (pci_request_selected_regions(pdev, rtx_ether_ctx->hw_ctx.bars, ${config.name})) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
176 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
177 + ${Log::info("e1000::create: pci_request_selected_regions failed")}; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
178 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
179 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
180 + if (${config.set_master}) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
181 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
182 + pci_set_master(pdev); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
183 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
184 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
185 + /* 0 here is for BAR_0: */ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
186 + rtx_ether_ctx->hw_ctx.ioaddr = pci_ioremap_bar(pdev, 0); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
187 + if (!rtx_ether_ctx->hw_ctx.ioaddr) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
188 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
189 + ${Log::info("e1000::create: pci_ioremap_bar failed")}; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
190 + } |
39
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
191 + |
41
87704b867fb0
First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents:
40
diff
changeset
|
192 + /* Reset the card */ |
40
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
193 + rtx_e1000_print_status(&rtx_ether_ctx->hw_ctx); |
41
87704b867fb0
First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents:
40
diff
changeset
|
194 + udelay(10); |
39
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
195 + |
40
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
196 + /* Now we can load its mac address */ |
41
87704b867fb0
First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents:
40
diff
changeset
|
197 + int i = 0; |
87704b867fb0
First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents:
40
diff
changeset
|
198 + for (i = 0 /* < this is not generated! */; i < 3; ++i) |
87704b867fb0
First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents:
40
diff
changeset
|
199 + { |
87704b867fb0
First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents:
40
diff
changeset
|
200 + rtx_e1000_register_write32(&rtx_ether_ctx->hw_ctx, E1000_EEPROM_READ, (i << 8) | 1); |
87704b867fb0
First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents:
40
diff
changeset
|
201 + |
87704b867fb0
First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents:
40
diff
changeset
|
202 + int value; |
87704b867fb0
First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents:
40
diff
changeset
|
203 + /* Should be a do { } while(); but the compiler doesn't do { } while(); yet. */ |
87704b867fb0
First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents:
40
diff
changeset
|
204 + value = rtx_e1000_register_read32(&rtx_ether_ctx->hw_ctx, E1000_EEPROM_READ); |
87704b867fb0
First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents:
40
diff
changeset
|
205 + while ((value & (1 << 4)) == 0) |
87704b867fb0
First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents:
40
diff
changeset
|
206 + value = rtx_e1000_register_read32(&rtx_ether_ctx->hw_ctx, E1000_EEPROM_READ); |
87704b867fb0
First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents:
40
diff
changeset
|
207 + |
87704b867fb0
First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents:
40
diff
changeset
|
208 + rtx_ether_ctx->net_dev->dev_addr[i * 2] = value & 0xff; |
87704b867fb0
First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents:
40
diff
changeset
|
209 + rtx_ether_ctx->net_dev->dev_addr[i * 2 + 1] = (value >> 8) & 0xff; |
87704b867fb0
First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents:
40
diff
changeset
|
210 + } |
87704b867fb0
First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents:
40
diff
changeset
|
211 + |
87704b867fb0
First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents:
40
diff
changeset
|
212 + memcpy(rtx_ether_ctx->net_dev->perm_addr, |
87704b867fb0
First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents:
40
diff
changeset
|
213 + rtx_ether_ctx->net_dev->dev_addr, |
87704b867fb0
First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents:
40
diff
changeset
|
214 + rtx_ether_ctx->net_dev->addr_len); |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
215 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
216 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
217 + chunk ::CALL |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
218 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
219 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
220 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
221 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
222 + template sequence e1000::destroy_device() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
223 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
224 + chunk Ethernet::destroy_device |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
225 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
226 + /* |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
227 + * Here, we should have some checks to avoid to free resources that |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
228 + * haven't been allocated. (e.g: in case of previous errors). |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
229 + */ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
230 + struct rtx_ethernet_dev* rtx_ether_ctx = netdev_priv(net_dev); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
231 + iounmap(rtx_ether_ctx->hw_ctx.ioaddr); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
232 + pci_release_selected_regions(pdev, rtx_ether_ctx->hw_ctx.bars); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
233 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
234 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
235 + chunk ::CALL |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
236 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
237 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
238 + } |
39
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
239 + |
40
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
240 + template sequence e1000::print_status() |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
241 + { |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
242 + chunk LKM::prototypes() |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
243 + { |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
244 + static void rtx_e1000_print_status(struct rtx_e1000_ctx *); |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
245 + } |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
246 + |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
247 + chunk LKM::code() |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
248 + { |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
249 + static void rtx_e1000_print_status(struct rtx_e1000_ctx *ctx) |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
250 + { |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
251 + unsigned int status = rtx_e1000_register_read32(ctx, E1000_STATUS); |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
252 + pr_info("rtx_e1000 status: \n"); |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
253 + pr_info("\tRegister value: 0x%x\n", status); |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
254 + pr_info("\tMode: %s\n", (status & 1) ? "Full": "Half"); |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
255 + pr_info("\tLink: %s\n", (status & 2) ? "Up" : "Down"); |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
256 + pr_info("\tTransmission: %s\n", (status & 4) ? "Paused" : "Ok"); |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
257 + pr_info("\tInterface: %s\n", (status & 3) == 3 ? "Up" : "Down"); |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
258 + } |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
259 + } |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
260 + |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
261 + chunk ::CALL |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
262 + { |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
263 + } |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
264 + } |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
265 + |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
266 + /* |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
267 + * We should have been able to do something along those lines, but |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
268 + * it didn't work so we made the call manually. |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
269 + * |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
270 + * Ideally: |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
271 + * ${e1000::register_read32(rtx_ether_ctx->hw_ctx, E1000_STATUS)}; |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
272 + * |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
273 + * Ideally2, not sure about the syntax on the register parameter: |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
274 + * ${e1000::register_read32(rtx_ether_ctx->hw_ctx, ${e1000::Register.E1000_STATUS})}; |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
275 + * |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
276 + * "Acceptable": |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
277 + * typedef int ${e1000::Register}; // cnorm __std__ workaround |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
278 + * ${e1000::Register} reg_status; |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
279 + * ${e1000.init(E1000_STATUS); // didn't work, so we used the next line |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
280 + * reg_status = E1000_STATUS; |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
281 + * ${e1000::register_read32(rtx_ether_ctx->hw_ctx, reg_status)}; |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
282 + */ |
39
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
283 + template sequence e1000::register_read32(e1000::Context ctx, e1000::Register reg_offset) |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
284 + { |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
285 + chunk LKM::prototypes() |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
286 + { |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
287 + static unsigned int rtx_e1000_register_read32(struct rtx_e1000_ctx *, unsigned int); |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
288 + } |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
289 + |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
290 + chunk LKM::code() |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
291 + { |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
292 + static unsigned int rtx_e1000_register_read32(struct rtx_e1000_ctx *ctx, unsigned int reg_offset) |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
293 + { |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
294 + return ioread32(ctx->ioaddr + reg_offset); |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
295 + } |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
296 + } |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
297 + |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
298 + chunk ::CALL() |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
299 + { |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
300 + rtx_e1000_register_read32(&${ctx}, ${reg_offset}); |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
301 + } |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
302 + } |
40
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
303 + |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
304 + template sequence e1000::register_write32(e1000::Context ctx, e1000::Register reg_offset, ::number value) |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
305 + { |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
306 + chunk LKM::prototypes() |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
307 + { |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
308 + static void rtx_e1000_register_write32(struct rtx_e1000_ctx *, unsigned int, unsigned int); |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
309 + } |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
310 + |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
311 + chunk LKM::code() |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
312 + { |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
313 + static void rtx_e1000_register_write32(struct rtx_e1000_ctx *ctx, unsigned int reg_offset, unsigned int value) |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
314 + { |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
315 + iowrite32(value, ctx->ioaddr + reg_offset); |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
316 + } |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
317 + } |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
318 + |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
319 + chunk ::CALL() |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
320 + { |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
321 + rtx_e1000_register_write32(&${ctx}, ${reg_offset}); |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
322 + } |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
323 + } |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
324 +} |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
325 diff --git a/rathaxes/samples/lkm/e1000.rti b/rathaxes/samples/lkm/e1000.rti |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
326 new file mode 100644 |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
327 --- /dev/null |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
328 +++ b/rathaxes/samples/lkm/e1000.rti |
40
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
329 @@ -0,0 +1,51 @@ |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
330 +interface e1000 : Socket, Ethernet, PCI, LKM |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
331 +{ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
332 + provided type e1000::Context; |
39
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
333 + provided type e1000::Register; |
40
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
334 + provided type e1000::Commands; |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
335 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
336 + /* |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
337 + * This sequence should receive an argument like Ethernet::Device, but it is |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
338 + * unclear about how this argument should be bound to a variable/argument in |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
339 + * the instrumented C code. |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
340 + * |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
341 + * Here again, we rely on the fact that *we* wrote the parent context and |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
342 + * named the C variables we need/use with the same name everywhere. |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
343 + */ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
344 + provided sequence e1000::create_device() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
345 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
346 + provided chunk Ethernet::create_device; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
347 + provided chunk ::CALL; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
348 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
349 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
350 + provided sequence e1000::destroy_device() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
351 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
352 + provided chunk Ethernet::destroy_device; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
353 + provided chunk ::CALL; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
354 + } |
39
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
355 + |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
356 + /* |
40
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
357 + * This should take an e1000::Context as the first argument but this was |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
358 + * not working as wished. |
39
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
359 + */ |
40
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
360 + provided sequence e1000::print_status() |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
361 + { |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
362 + provided chunk LKM::prototypes; |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
363 + provided chunk LKM::code; |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
364 + provided chunk ::CALL; |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
365 + } |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
366 + |
39
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
367 + provided sequence e1000::register_read32(e1000::Context, e1000::Register) |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
368 + { |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
369 + provided chunk LKM::prototypes; |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
370 + provided chunk LKM::code; |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
371 + provided chunk ::CALL; |
d761c8c625d3
Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents:
38
diff
changeset
|
372 + } |
40
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
373 + |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
374 + provided sequence e1000::register_write32(e1000::Context, e1000::Register, ::number) |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
375 + { |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
376 + provided chunk LKM::prototypes; |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
377 + provided chunk LKM::code; |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
378 + provided chunk ::CALL; |
0ff39df29c46
Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents:
39
diff
changeset
|
379 + } |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
380 +} |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
381 diff --git a/rathaxes/samples/lkm/ethernet.blt b/rathaxes/samples/lkm/ethernet.blt |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
382 new file mode 100644 |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
383 --- /dev/null |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
384 +++ b/rathaxes/samples/lkm/ethernet.blt |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
385 @@ -0,0 +1,207 @@ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
386 +with Ethernet, PCI, LKM, Log |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
387 +{ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
388 + template type Ethernet::Device() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
389 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
390 + chunk LKM::includes() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
391 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
392 + #include <linux/netdevice.h> |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
393 + #include <linux/etherdevice.h> |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
394 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
395 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
396 + chunk ::decl() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
397 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
398 + struct rtx_ethernet_dev |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
399 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
400 + /* |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
401 + * I think it's useless to use the ${PCI::Device} "abstraction" |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
402 + * here, since we are already in a Linux specific context here. |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
403 + */ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
404 + struct pci_dev *pci_dev; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
405 + struct net_device *net_dev; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
406 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
407 + /* while waiting on issue #8 */ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
408 + struct rtx_e1000_ctx hw_ctx; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
409 + }; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
410 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
411 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
412 + chunk ::init(net_dev) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
413 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
414 + ${self} = ${net_dev}; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
415 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
416 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
417 + map |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
418 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
419 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
420 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
421 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
422 + template sequence Ethernet::open(Ethernet::Device dev) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
423 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
424 + chunk LKM::prototypes() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
425 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
426 + static int rtx_ethernet_open(struct net_device *); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
427 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
428 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
429 + chunk LKM::code() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
430 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
431 + static int rtx_ethernet_open(struct net_device *dev) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
432 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
433 + ${pointcut ::IMPLEMENTATION}; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
434 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
435 + return 0; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
436 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
437 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
438 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
439 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
440 + template sequence Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
441 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
442 + chunk LKM::prototypes() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
443 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
444 + static int rtx_ethernet_xmit(struct sk_buff* skb, struct net_device *dev); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
445 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
446 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
447 + chunk LKM::code() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
448 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
449 + static int rtx_ethernet_xmit(struct sk_buff* skb, struct net_device *dev) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
450 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
451 + ${pointcut ::IMPLEMENTATION}; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
452 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
453 + return 0; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
454 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
455 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
456 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
457 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
458 + template sequence Ethernet::close(Ethernet::Device dev) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
459 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
460 + chunk LKM::prototypes() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
461 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
462 + static int rtx_ethernet_close(struct net_device *); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
463 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
464 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
465 + chunk LKM::code() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
466 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
467 + static int rtx_ethernet_close(struct net_device *dev) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
468 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
469 + ${pointcut ::IMPLEMENTATION}; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
470 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
471 + return 0; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
472 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
473 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
474 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
475 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
476 + template sequence Ethernet::interrupt_handler(Ethernet::Device dev) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
477 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
478 + /* |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
479 + * We can't use the irqreturn_t type here because CNornm doesn't know |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
480 + * it. |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
481 + */ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
482 + chunk LKM::prototypes() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
483 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
484 + static enum irqreturn rtx_ethernet_interrupt_handler(int, void *); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
485 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
486 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
487 + chunk LKM::code() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
488 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
489 + static enum irqreturn rtx_ethernet_interrupt_handler(int irq, void *dev_id) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
490 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
491 + ${pointcut ::IMPLEMENTATION}; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
492 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
493 + return IRQ_NONE; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
494 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
495 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
496 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
497 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
498 + template sequence Ethernet::init(PCI::Device pdev) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
499 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
500 + chunk LKM::data() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
501 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
502 + static const struct net_device_ops rtx_ether_ops = |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
503 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
504 + .ndo_open = rtx_ethernet_open, |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
505 + .ndo_stop = rtx_ethernet_close, |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
506 + .ndo_start_xmit = rtx_ethernet_xmit, |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
507 + }; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
508 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
509 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
510 + chunk PCI::pci_probe_hook() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
511 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
512 + /* |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
513 + * This typedef is needed to workaround a bug in CNorm __std__ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
514 + * dialect. |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
515 + */ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
516 + typedef int ${Ethernet::Device}; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
517 + ${Ethernet::Device} *rtx_ether_ctx; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
518 + struct net_device *net_dev; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
519 + int error; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
520 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
521 + error = 0; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
522 + net_dev = alloc_etherdev(sizeof(*rtx_ether_ctx)); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
523 + if (net_dev == 0) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
524 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
525 + ${Log::info("Cannot allocate memory")}; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
526 + /* |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
527 + * Again, the error should be "raised" in the parent context. |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
528 + * |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
529 + * Here we know that we should return ENOMEM because *we* wrote |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
530 + * the parent context. |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
531 + */ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
532 + return -ENOMEM; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
533 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
534 + strlcpy(net_dev->name, ${config.ifname}, sizeof(net_dev->name)); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
535 + net_dev->irq = pdev->irq; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
536 + // Maybe we should try ${rtx_ether_ctx.init()} here: |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
537 + rtx_ether_ctx = netdev_priv(net_dev); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
538 + //rtx_ether_ctx->pci_dev = ${pdev}; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
539 + rtx_ether_ctx->pci_dev = pdev; // In the meantime do it directly |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
540 + rtx_ether_ctx->net_dev = net_dev; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
541 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
542 + /* |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
543 + * The substitution of ${pdev} fails here. I also tried to add a |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
544 + * "substitute method" to the PCI::Device that was just doing |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
545 + * "${self}" but it didn't work either (it was subsituted by a |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
546 + * placeholder, e.g: _1). |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
547 + * |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
548 + * That's why we cheated a bit and named all the arguments pdev. |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
549 + */ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
550 + //SET_NETDEV_DEV(net_dev, &${pdev}->dev); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
551 + SET_NETDEV_DEV(net_dev, &pdev->dev); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
552 + net_dev->netdev_ops = &rtx_ether_ops; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
553 + if ((error = register_netdev(net_dev))) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
554 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
555 + ${Log::info("Cannot register the driver")}; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
556 + return error; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
557 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
558 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
559 + /* same problem as above with ${pdev} */ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
560 + //pci_set_drvdata(${pdev}, net_dev); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
561 + pci_set_drvdata(pdev, net_dev); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
562 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
563 + ${pointcut Ethernet::create_device}; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
564 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
565 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
566 + chunk ::CALL |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
567 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
568 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
569 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
570 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
571 + template sequence Ethernet::exit(PCI::Device pdev) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
572 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
573 + chunk PCI::pci_remove_hook() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
574 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
575 + struct net_device *net_dev = pci_get_drvdata(pdev); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
576 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
577 + ${pointcut Ethernet::destroy_device}; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
578 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
579 + unregister_netdev(net_dev); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
580 + /* |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
581 + * If we had some cleanup todo with struct rtx_ether_ctx we would |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
582 + * do a netdev_priv(net_dev) here and do it. |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
583 + */ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
584 + free_netdev(net_dev); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
585 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
586 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
587 + chunk ::CALL |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
588 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
589 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
590 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
591 +} |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
592 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
593 diff --git a/rathaxes/samples/lkm/ethernet.rti b/rathaxes/samples/lkm/ethernet.rti |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
594 new file mode 100644 |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
595 --- /dev/null |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
596 +++ b/rathaxes/samples/lkm/ethernet.rti |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
597 @@ -0,0 +1,47 @@ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
598 +interface Ethernet : Socket, PCI, LKM |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
599 +{ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
600 + provided type Ethernet::Device; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
601 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
602 + required variable ::string Ethernet::ifname; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
603 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
604 + required sequence Ethernet::open(Ethernet::Device) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
605 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
606 + provided chunk LKM::prototypes; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
607 + provided chunk LKM::code; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
608 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
609 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
610 + required sequence Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
611 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
612 + provided chunk LKM::prototypes; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
613 + provided chunk LKM::code; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
614 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
615 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
616 + required sequence Ethernet::close(Ethernet::Device) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
617 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
618 + provided chunk LKM::prototypes; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
619 + provided chunk LKM::code; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
620 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
621 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
622 + required sequence Ethernet::interrupt_handler(Ethernet::Device) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
623 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
624 + provided chunk LKM::prototypes; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
625 + provided chunk LKM::code; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
626 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
627 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
628 + provided sequence Ethernet::init(PCI::Device) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
629 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
630 + provided chunk LKM::data; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
631 + provided chunk PCI::pci_probe_hook; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
632 + provided chunk ::CALL; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
633 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
634 + provided pointcut Ethernet::create_device; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
635 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
636 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
637 + provided sequence Ethernet::exit(PCI::Device) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
638 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
639 + provided chunk ::CALL; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
640 + provided chunk PCI::pci_remove_hook; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
641 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
642 + provided pointcut Ethernet::destroy_device; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
643 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
644 +} |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
645 diff --git a/rathaxes/samples/lkm/lkm.blt b/rathaxes/samples/lkm/lkm.blt |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
646 new file mode 100644 |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
647 --- /dev/null |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
648 +++ b/rathaxes/samples/lkm/lkm.blt |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
649 @@ -0,0 +1,55 @@ |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
650 +with LKM |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
651 +{ |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
652 + /* Skel of the generated C file: */ |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
653 + ${pointcut LKM::includes}; |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
654 + ${pointcut LKM::prototypes}; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
655 + ${pointcut LKM::data}; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
656 + ${pointcut LKM::code}; |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
657 + |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
658 + template sequence LKM::init() |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
659 + { |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
660 + chunk LKM::includes() |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
661 + { |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
662 + #include <linux/module.h> |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
663 + #include <linux/kernel.h> |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
664 + } |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
665 + |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
666 + chunk LKM::data() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
667 + { |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
668 + MODULE_DESCRIPTION(${config.description}); |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
669 + MODULE_AUTHOR(${config.author}); |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
670 + MODULE_LICENSE(${config.license}); |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
671 + } |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
672 + |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
673 + chunk LKM::code() |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
674 + { |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
675 + /* |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
676 + * Rathaxes doesn't yet support arbitrary "decorators" like __init |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
677 + * or __exit. |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
678 + */ |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
679 + static int __attribute__((__section__(".init.text"))) rtx_module_init(void) |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
680 + { |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
681 + ${pointcut ::IMPLEMENTATION}; |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
682 + ${pointcut LKM::init_bus_hook}; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
683 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
684 + return 0; |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
685 + } |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
686 + |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
687 + module_init(rtx_module_init); |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
688 + } |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
689 + } |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
690 + |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
691 + template sequence LKM::exit() |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
692 + { |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
693 + chunk LKM::code() |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
694 + { |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
695 + static void __attribute__((__section__(".exit.text"))) rtx_module_exit(void) |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
696 + { |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
697 + ${pointcut ::IMPLEMENTATION}; |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
698 + ${pointcut LKM::deinit_bus_hook}; |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
699 + } |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
700 + |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
701 + module_exit(rtx_module_exit); |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
702 + } |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
703 + } |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
704 +} |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
705 diff --git a/rathaxes/samples/lkm/lkm.rti b/rathaxes/samples/lkm/lkm.rti |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
706 new file mode 100644 |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
707 --- /dev/null |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
708 +++ b/rathaxes/samples/lkm/lkm.rti |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
709 @@ -0,0 +1,25 @@ |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
710 +interface LKM |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
711 +{ |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
712 + provided pointcut LKM::includes; |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
713 + /* maybe it should be possible to use chunk ::decl in sequence templates? */ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
714 + provided pointcut LKM::prototypes; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
715 + provided pointcut LKM::data; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
716 + provided pointcut LKM::code; |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
717 + |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
718 + required variable ::string LKM::author; |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
719 + required variable ::string LKM::description; |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
720 + required variable ::string LKM::license; |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
721 + |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
722 + required sequence LKM::init() |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
723 + { |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
724 + provided chunk LKM::includes; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
725 + provided chunk LKM::code; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
726 + provided pointcut LKM::init_bus_hook; |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
727 + } |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
728 + |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
729 + required sequence LKM::exit() |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
730 + { |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
731 + provided chunk LKM::code; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
732 + provided pointcut LKM::deinit_bus_hook; |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
733 + } |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
734 +} |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
735 diff --git a/rathaxes/samples/lkm/lkm.rtx b/rathaxes/samples/lkm/lkm.rtx |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
736 new file mode 100644 |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
737 --- /dev/null |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
738 +++ b/rathaxes/samples/lkm/lkm.rtx |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
739 @@ -0,0 +1,46 @@ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
740 +device LKM use LKM, PCI, Ethernet, Log |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
741 +{ |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
742 + Ethernet::open(Ethernet::Device dev) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
743 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
744 + Log::info("Open the device"); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
745 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
746 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
747 + Ethernet::close(Ethernet::Device dev) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
748 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
749 + Log::info("Close the device"); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
750 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
751 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
752 + Ethernet::interrupt_handler(Ethernet::Device dev) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
753 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
754 + Log::info("Got an interruption"); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
755 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
756 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
757 + Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
758 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
759 + Log::info("We have one packet to transmit!"); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
760 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
761 + |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
762 + LKM::init() |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
763 + { |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
764 + Log::info("Hello this is LKM"); |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
765 + } |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
766 + |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
767 + LKM::exit() |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
768 + { |
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:
3
diff
changeset
|
769 + Log::info("Good bye this was LKM"); |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
770 + } |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
771 +} |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
772 + |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
773 +configuration |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
774 +{ |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
775 + LKM::name = "hello"; |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
776 + LKM::author = "Rathaxes"; |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
777 + LKM::description = "Hello World Loadable Kernel Module (LKM)"; |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
778 + LKM::license = "GPL"; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
779 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
780 + PCI::vendor_id = 0x8086; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
781 + PCI::product_id = 0x100f; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
782 + PCI::set_master = true; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
783 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
784 + Ethernet::ifname = "rtx%d"; |
3
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
785 +} |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
786 diff --git a/rathaxes/samples/lkm/log.blt b/rathaxes/samples/lkm/log.blt |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
787 new file mode 100644 |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
788 --- /dev/null |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
789 +++ b/rathaxes/samples/lkm/log.blt |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
790 @@ -0,0 +1,10 @@ |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
791 +with Log |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
792 +{ |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
793 + template sequence Log::info(::string msg) |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
794 + { |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
795 + chunk ::CALL |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
796 + { |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
797 + pr_info("%s\n", ${msg}); |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
798 + } |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
799 + } |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
800 +} |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
801 diff --git a/rathaxes/samples/lkm/log.rti b/rathaxes/samples/lkm/log.rti |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
802 new file mode 100644 |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
803 --- /dev/null |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
804 +++ b/rathaxes/samples/lkm/log.rti |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
805 @@ -0,0 +1,7 @@ |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
806 +interface Log |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
807 +{ |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
808 + provided sequence Log::info(::string) |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
809 + { |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
810 + provided chunk ::CALL; |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
811 + } |
2389c2bc501f
Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff
changeset
|
812 +} |
38
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
813 diff --git a/rathaxes/samples/lkm/pci.blt b/rathaxes/samples/lkm/pci.blt |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
814 new file mode 100644 |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
815 --- /dev/null |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
816 +++ b/rathaxes/samples/lkm/pci.blt |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
817 @@ -0,0 +1,143 @@ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
818 +with PCI, LKM, Log |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
819 +{ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
820 + template type PCI::Device() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
821 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
822 + chunk LKM::includes() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
823 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
824 + #include <linux/pci.h> |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
825 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
826 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
827 + chunk ::decl() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
828 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
829 + struct pci_dev; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
830 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
831 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
832 + chunk ::init(pci_dev) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
833 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
834 + ${self} = ${pci_dev}; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
835 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
836 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
837 + map |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
838 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
839 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
840 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
841 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
842 + template sequence PCI::probe(PCI::Device pdev) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
843 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
844 + chunk LKM::prototypes() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
845 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
846 + static int /* __devinit */ rtx_pci_probe(struct pci_dev *, |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
847 + const struct pci_device_id *); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
848 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
849 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
850 + chunk LKM::code() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
851 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
852 + static int /* __devinit */ rtx_pci_probe(struct pci_dev *pdev, |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
853 + const struct pci_device_id *pdev_id) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
854 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
855 + int err; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
856 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
857 + err = pci_enable_device(pdev); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
858 + if (err < 0) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
859 + goto fail; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
860 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
861 + ${pointcut PCI::pci_probe_hook}; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
862 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
863 + return 0; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
864 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
865 + fail: |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
866 + return err; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
867 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
868 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
869 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
870 + chunk ::CALL |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
871 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
872 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
873 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
874 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
875 + template sequence PCI::remove(PCI::Device pdev) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
876 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
877 + chunk LKM::prototypes() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
878 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
879 + static void rtx_pci_remove(struct pci_dev *); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
880 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
881 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
882 + chunk LKM::code() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
883 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
884 + static void rtx_pci_remove(struct pci_dev *pdev) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
885 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
886 + ${pointcut PCI::pci_remove_hook}; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
887 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
888 + pci_disable_device(pdev); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
889 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
890 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
891 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
892 + chunk ::CALL() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
893 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
894 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
895 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
896 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
897 + template sequence PCI::register() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
898 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
899 + chunk LKM::data() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
900 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
901 + /* |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
902 + * CNorm doesn't seem to like "dynamic" arrays (i.e: you always |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
903 + * have to specify the exact size). |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
904 + */ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
905 + static struct pci_device_id rtx_pci_device_table[2] = { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
906 + { ${config.vendor_id}, ${config.product_id}, PCI_ANY_ID, PCI_ANY_ID }, |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
907 + { 0, } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
908 + }; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
909 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
910 + static struct pci_driver rtx_pci_driver = { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
911 + .name = ${config.name}, |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
912 + .id_table = rtx_pci_device_table, |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
913 + .probe = rtx_pci_probe, |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
914 + .remove = rtx_pci_remove |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
915 + }; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
916 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
917 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
918 + chunk LKM::init_bus_hook() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
919 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
920 + int error; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
921 + if ((error = pci_register_driver(&rtx_pci_driver))) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
922 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
923 + ${Log::info("Cannot register pci driver")}; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
924 + /* |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
925 + * So we catched the error but how do we return it to the |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
926 + * parent context? |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
927 + * |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
928 + * Here we know that we can just return error, but that's just |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
929 + * a coincidence (and, in this case, *we* wrote the parent |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
930 + * context). |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
931 + */ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
932 + return error; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
933 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
934 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
935 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
936 + chunk ::CALL() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
937 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
938 + /* |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
939 + * The implementation of ::CALL is empty. This template sequence is |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
940 + * actually not provided nor required. |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
941 + * |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
942 + * This sequence is just "intermediate" code that will just inject |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
943 + * itself in the hook LKM::init_bus_hook for which this sequence |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
944 + * has a chunk (see above chunk). |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
945 + */ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
946 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
947 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
948 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
949 + template sequence PCI::unregister() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
950 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
951 + chunk LKM::deinit_bus_hook() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
952 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
953 + pci_unregister_driver(&rtx_pci_driver); |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
954 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
955 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
956 + chunk ::CALL |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
957 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
958 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
959 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
960 +} |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
961 diff --git a/rathaxes/samples/lkm/pci.rti b/rathaxes/samples/lkm/pci.rti |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
962 new file mode 100644 |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
963 --- /dev/null |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
964 +++ b/rathaxes/samples/lkm/pci.rti |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
965 @@ -0,0 +1,36 @@ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
966 +interface PCI : LKM |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
967 +{ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
968 + provided type PCI::Device; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
969 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
970 + required variable ::number PCI::vendor_id; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
971 + required variable ::number PCI::product_id; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
972 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
973 + provided sequence PCI::register() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
974 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
975 + provided chunk ::CALL; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
976 + provided chunk LKM::data; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
977 + provided chunk LKM::init_bus_hook; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
978 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
979 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
980 + provided sequence PCI::unregister() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
981 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
982 + provided chunk ::CALL; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
983 + provided chunk LKM::deinit_bus_hook; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
984 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
985 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
986 + provided sequence PCI::probe(PCI::Device) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
987 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
988 + provided chunk LKM::prototypes; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
989 + provided chunk LKM::code; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
990 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
991 + provided pointcut PCI::pci_probe_hook; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
992 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
993 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
994 + provided sequence PCI::remove(PCI::Device) |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
995 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
996 + provided chunk LKM::prototypes; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
997 + provided chunk LKM::code; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
998 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
999 + provided pointcut PCI::pci_remove_hook; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1000 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1001 +} |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1002 diff --git a/rathaxes/samples/lkm/socket.blt b/rathaxes/samples/lkm/socket.blt |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1003 new file mode 100644 |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1004 --- /dev/null |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1005 +++ b/rathaxes/samples/lkm/socket.blt |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1006 @@ -0,0 +1,27 @@ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1007 +with Socket, LKM |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1008 +{ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1009 + template type Socket::SKBuff() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1010 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1011 + chunk LKM::includes() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1012 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1013 + #include <linux/skbuff.h> |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1014 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1015 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1016 + chunk ::decl() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1017 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1018 + struct sk_buff; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1019 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1020 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1021 + chunk ::init() |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1022 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1023 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1024 + |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1025 + map |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1026 + { |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1027 + // some work may have to be done here in order |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1028 + // to access to some field of the sk_buff. |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1029 + // We should determine if all the sk_buff managment |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1030 + // can be abstracted from the user. |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1031 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1032 + } |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1033 +} |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1034 diff --git a/rathaxes/samples/lkm/socket.rti b/rathaxes/samples/lkm/socket.rti |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1035 new file mode 100644 |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1036 --- /dev/null |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1037 +++ b/rathaxes/samples/lkm/socket.rti |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1038 @@ -0,0 +1,4 @@ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1039 +interface Socket : LKM |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1040 +{ |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1041 + provided type Socket::SKBuff; |
f43900ad7e66
Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents:
10
diff
changeset
|
1042 +} |