annotate rathaxes_add_lkm_ethernet_sample.patch @ 45:bab559e0392b

rathaxes: enable irq + handle it
author Thomas Sanchez <thomas.sanchz@gmail.com>
date Mon, 09 Jan 2012 22:17:12 +0100
parents 258319759ba3
children cf7d541b9331
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
2 # Parent 6d6b478219da142368f4e458b8a348f4d87867d9
38
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
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
5 diff -r 6d6b478219da maintainers/CMakeScripts/UseRathaxes.cmake
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
6 --- a/maintainers/CMakeScripts/UseRathaxes.cmake Mon Jan 09 19:24:10 2012 +0100
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
7 +++ b/maintainers/CMakeScripts/UseRathaxes.cmake Mon Jan 09 22:16:54 2012 +0100
40
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:
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
17 diff -r 6d6b478219da rathaxes/samples/CMakeLists.txt
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
18 --- a/rathaxes/samples/CMakeLists.txt Mon Jan 09 19:24:10 2012 +0100
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
19 +++ b/rathaxes/samples/CMakeLists.txt Mon Jan 09 22:16:54 2012 +0100
10
44a25ffd5c8c Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
Louis Opter <louis@lse.epitech.net>
parents: 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)
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
24 diff -r 6d6b478219da rathaxes/samples/lkm/CMakeLists.txt
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
25 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
26 +++ b/rathaxes/samples/lkm/CMakeLists.txt Mon Jan 09 22:16:54 2012 +0100
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
27 @@ -0,0 +1,7 @@
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
28 +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
29 + 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
30 + 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
31 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
32 +# 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
33 +# 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
34 +ADD_RATHAXES_LKM(lkm lkm_src)
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
35 diff -r 6d6b478219da rathaxes/samples/lkm/e1000.blt
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
36 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
37 +++ b/rathaxes/samples/lkm/e1000.blt Mon Jan 09 22:16:54 2012 +0100
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
38 @@ -0,0 +1,435 @@
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
39 +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
40 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
41 + template type e1000::Context()
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 + chunk LKM::includes()
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 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
46 + * 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
47 + * 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
48 + * (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
49 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
50 + 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
51 + 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
52 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
53 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
54 + chunk ::decl()
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 + struct rtx_e1000_ctx
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 + int bars;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
59 + unsigned char /* __iomem */ *ioaddr;
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
60 + int irq;
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
61 + };
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 +
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
64 + chunk ::init(bars, ioaddr)
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
65 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
66 + ${self}.bars = ${bars};
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
67 + ${self}.ioaddr = ${ioaddr};
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
68 + }
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 + map
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
71 + {
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 + template type e1000::Register()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
76 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
77 + chunk LKM::includes()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
78 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
79 + typedef int ${e1000::Register};
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
80 + 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
81 + }
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 + chunk ::decl()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
84 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
85 + enum rtx_e1000_registers
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
86 + {
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
87 + E1000_CTRL = 0x00000, /* Device Control - RW */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
88 + 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
89 + E1000_STATUS = 0x00008, /* Device Status - RO */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
90 + 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
91 + 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
92 + 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
93 + E1000_FLA = 0x0001C, /* Flash Access - RW */
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
94 + E1000_MDIC = 0x00020, /* MDI Control - RW */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
95 + E1000_IMS = 0x000D0, /* Interrupt Mask Set */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
96 + E1000_IMC = 0x000D8, /* Interrupt Mask Clear */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
97 + E1000_ICR = 0x000C0 /* Interrupt Cause Read - R/clr */
39
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 + }
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 + chunk ::init(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 + ${self} = ${value};
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
104 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
105 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
106 + map
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 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
109 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
110 +
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
111 + template type e1000::Commands()
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 + chunk LKM::includes()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
114 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
115 + typedef int ${e1000::Commands};
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
116 + 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
117 + }
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 + chunk ::decl()
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 + enum rtx_e1000_commands
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
122 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
123 + 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
124 + 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
125 + 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
126 + 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
127 + 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
128 + 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
129 + 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
130 + 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
131 + 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
132 + 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
133 + 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
134 + 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
135 + 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
136 + 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
137 + 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
138 + E1000_CMD_FRCSPD = 0x00000800, /* Force Speed */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
139 + E1000_CMD_FRCDPX = 0x00001000, /* Force Duplex */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
140 + 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
141 + 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
142 + 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
143 + 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
144 + 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
145 + 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
146 + 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
147 + 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
148 + 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
149 + 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
150 + 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
151 + 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
152 + E1000_CMD_RST = 0x04000000, /* Global reset */
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
153 + 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
154 + 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
155 + 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
156 + 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
157 + E1000_CMD_PHY_RST = 0x80000000, /* PHY Reset */
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
158 + E1000_CMD_SW2FW_INT = 0x02000000, /* Initiate an interrupt to manageability engine */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
159 + E1000_INTR_TXDW = 0x00000001, /* Transmit desc written back */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
160 + E1000_INTR_TXQE = 0x00000002, /* Transmit Queue empty */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
161 + E1000_INTR_LSC = 0x00000004, /* Link Status Change */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
162 + E1000_INTR_RXSEQ = 0x00000008, /* rx sequence error */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
163 + E1000_INTR_RXDMT0 = 0x00000010, /* rx desc min. threshold (0) */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
164 + E1000_INTR_RXO = 0x00000040, /* rx overrun */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
165 + E1000_INTR_RXT0 = 0x00000080, /* rx timer intr (ring 0) */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
166 + E1000_INTR_MDAC = 0x00000200 /* MDIO access complete */
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
167 +
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
168 + };
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
169 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
170 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
171 + map
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
172 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
173 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
174 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
175 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
176 + template sequence e1000::create_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
177 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
178 + chunk Ethernet::create_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
179 + {
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
180 + rtx_ether_ctx->hw_ctx.irq = pdev->irq;
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
181 + 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
182 + 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
183 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
184 + ${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
185 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
186 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
187 + 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
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_request_selected_regions failed")};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
190 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
191 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
192 + if (${config.set_master})
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
193 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
194 + pci_set_master(pdev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
195 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
196 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
197 + /* 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
198 + 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
199 + 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
200 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
201 + ${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
202 + }
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
203 +
41
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
204 + /* Reset the card */
42
e0cd016d4fc5 Restore the reset code and print the mac address
Louis Opter <louis@lse.epitech.net>
parents: 41
diff changeset
205 + rtx_e1000_register_write32(&rtx_ether_ctx->hw_ctx, E1000_CTRL, E1000_CMD_RST);
41
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
206 + udelay(10);
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
207 +
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
208 + /* 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
209 + int i = 0;
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
210 + 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
211 + {
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
212 + 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
213 +
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
214 + int value;
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
215 + /* 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
216 + 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
217 + while ((value & (1 << 4)) == 0)
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
218 + value = rtx_e1000_register_read32(&rtx_ether_ctx->hw_ctx, E1000_EEPROM_READ);
43
4b51f5628787 Add a missing shift in the load mac address code
Louis Opter <louis@lse.epitech.net>
parents: 42
diff changeset
219 + value >>= 16;
41
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
220 +
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
221 + 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
222 + 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
223 + }
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
224 +
87704b867fb0 First attempt at loading the mac address
Louis Opter <louis@lse.epitech.net>
parents: 40
diff changeset
225 + 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
226 + 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
227 + rtx_ether_ctx->net_dev->addr_len);
42
e0cd016d4fc5 Restore the reset code and print the mac address
Louis Opter <louis@lse.epitech.net>
parents: 41
diff changeset
228 +
44
258319759ba3 Print something with Log::info when the mac address is loaded
Louis Opter <louis@lse.epitech.net>
parents: 43
diff changeset
229 + { /* < mais lol. */
258319759ba3 Print something with Log::info when the mac address is loaded
Louis Opter <louis@lse.epitech.net>
parents: 43
diff changeset
230 + ${Log::info("e1000::create: mac address loaded from the EEPROM")};
258319759ba3 Print something with Log::info when the mac address is loaded
Louis Opter <louis@lse.epitech.net>
parents: 43
diff changeset
231 + }
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
232 + }
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 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
235 + {
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
239 + template sequence e1000::destroy_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
240 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
241 + chunk Ethernet::destroy_device
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
242 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
243 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
244 + * 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
245 + * 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
246 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
247 + 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
248 + 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
249 + 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
250 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
251 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
252 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
253 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
254 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
255 + }
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
256 +
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
257 + template sequence e1000::print_status()
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 + chunk LKM::prototypes()
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 + 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
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 + chunk LKM::code()
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 + 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
267 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
268 + 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
269 + pr_info("rtx_e1000 status: \n");
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
270 + 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
271 + 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
272 + 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
273 + 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
274 + 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
275 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
276 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
277 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
278 + chunk ::CALL
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
279 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
280 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
281 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
282 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
283 + /*
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
284 + * 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
285 + * 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
286 + *
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
287 + * Ideally:
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
288 + * ${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
289 + *
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
290 + * 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
291 + * ${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
292 + *
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
293 + * "Acceptable":
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
294 + * 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
295 + * ${e1000::Register} reg_status;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
296 + * ${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
297 + * reg_status = E1000_STATUS;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
298 + * ${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
299 + */
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
300 + 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
301 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
302 + chunk LKM::prototypes()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
303 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
304 + 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
305 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
306 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
307 + chunk LKM::code()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
308 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
309 + 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
310 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
311 + 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
312 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
313 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
314 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
315 + chunk ::CALL()
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
316 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
317 + 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
318 + }
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
319 + }
40
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 + 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
322 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
323 + chunk LKM::prototypes()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
324 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
325 + 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
326 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
327 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
328 + chunk LKM::code()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
329 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
330 + 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
331 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
332 + iowrite32(value, ctx->ioaddr + reg_offset);
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
333 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
334 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
335 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
336 + chunk ::CALL()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
337 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
338 + 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
339 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
340 + }
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
341 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
342 + template sequence e1000::register_set32(e1000::Context ctx, e1000::Register reg_offset, ::number value)
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
343 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
344 + chunk LKM::prototypes()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
345 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
346 + static void rtx_e1000_register_set32(struct rtx_e1000_ctx *, unsigned int, unsigned int);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
347 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
348 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
349 + chunk LKM::code()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
350 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
351 + static void rtx_e1000_register_set32(struct rtx_e1000_ctx *ctx, unsigned int reg_offset, unsigned int value)
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
352 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
353 + iowrite32(rtx_e1000_register_read32(ctx, reg_offset) | value, ctx->ioaddr + reg_offset);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
354 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
355 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
356 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
357 + chunk ::CALL()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
358 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
359 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
360 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
361 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
362 + template sequence e1000::setup_interrupt_handler()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
363 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
364 + chunk LKM::includes()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
365 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
366 + #include <linux/interrupt.h>
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
367 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
368 + chunk LKM::prototypes()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
369 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
370 + static int e1000_setup_interrupt_handler(struct rtx_ethernet_dev *);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
371 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
372 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
373 + chunk LKM::code()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
374 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
375 + static int e1000_setup_interrupt_handler(struct rtx_ethernet_dev *ethernet_ctx)
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
376 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
377 + int error;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
378 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
379 + error = request_irq(ethernet_ctx->hw_ctx.irq,
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
380 + rtx_ethernet_interrupt_handler,
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
381 + IRQF_SHARED,
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
382 + ${config.name},
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
383 + ethernet_ctx);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
384 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
385 + if (error)
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
386 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
387 + ${Log::info("Cannot register the interruption")};
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
388 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
389 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
390 + return error;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
391 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
392 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
393 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
394 + chunk ::CALL()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
395 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
396 + // this is an hack for the scope
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
397 + (void)1;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
398 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
399 + int error;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
400 + error = e1000_setup_interrupt_handler(rtx_ether_dev);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
401 + if (error)
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
402 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
403 + return error;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
404 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
405 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
406 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
407 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
408 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
409 + template sequence e1000::free_interrupt_handler()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
410 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
411 + chunk LKM::prototypes()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
412 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
413 + static void e1000_free_interrupt_handler(struct rtx_ethernet_dev *ethernet_ctx);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
414 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
415 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
416 + chunk LKM::code()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
417 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
418 + static void e1000_free_interrupt_handler(struct rtx_ethernet_dev *ethernet_ctx)
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
419 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
420 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
421 + free_irq(ethernet_ctx->hw_ctx.irq, ethernet_ctx);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
422 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
423 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
424 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
425 + chunk ::CALL()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
426 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
427 + e1000_free_interrupt_handler(rtx_ether_dev);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
428 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
429 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
430 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
431 + template sequence e1000::activate_device_interruption()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
432 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
433 + chunk ::CALL()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
434 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
435 + rtx_e1000_register_write32(ctx, E1000_IMS,
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
436 + E1000_INTR_TXDW |
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
437 + E1000_INTR_TXQE |
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
438 + E1000_INTR_LSC |
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
439 + E1000_INTR_RXO |
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
440 + E1000_INTR_RXT0);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
441 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
442 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
443 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
444 + template sequence e1000::set_up_device()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
445 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
446 + chunk ::CALL()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
447 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
448 + rtx_e1000_register_set32(ctx, E1000_CTRL, E1000_CMD_ASDE
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
449 + | E1000_CMD_SLU
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
450 + | E1000_CMD_LRST
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
451 + | E1000_CMD_PHY_RST);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
452 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
453 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
454 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
455 + template sequence e1000::handle_intr()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
456 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
457 + chunk ::CALL()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
458 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
459 + int intr;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
460 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
461 + intr = rtx_e1000_register_read32(ctx, E1000_ICR);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
462 + if (intr & E1000_INTR_LSC)
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
463 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
464 + ${Log::info("Link status changed")};
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
465 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
466 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
467 + if (intr)
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
468 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
469 + return IRQ_HANDLED;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
470 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
471 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
472 + }
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
473 +}
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
474 diff -r 6d6b478219da rathaxes/samples/lkm/e1000.rti
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
475 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
476 +++ b/rathaxes/samples/lkm/e1000.rti Mon Jan 09 22:16:54 2012 +0100
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
477 @@ -0,0 +1,89 @@
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
478 +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
479 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
480 + provided type e1000::Context;
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
481 + provided type e1000::Register;
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
482 + provided type e1000::Commands;
38
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 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
485 + * 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
486 + * 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
487 + * the instrumented C 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 + * 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
490 + * 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
491 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
492 + provided sequence e1000::create_device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
493 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
494 + provided chunk Ethernet::create_device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
495 + provided chunk ::CALL;
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 + provided sequence e1000::destroy_device()
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 + provided chunk Ethernet::destroy_device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
501 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
502 + }
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
503 +
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
504 + /*
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
505 + * 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
506 + * not working as wished.
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
507 + */
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
508 + provided sequence e1000::print_status()
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
509 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
510 + provided chunk LKM::prototypes;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
511 + provided chunk LKM::code;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
512 + provided chunk ::CALL;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
513 + }
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
514 +
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
515 + provided sequence e1000::setup_interrupt_handler()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
516 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
517 + provided chunk LKM::includes; // work without this one
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
518 + provided chunk LKM::prototypes;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
519 + provided chunk LKM::code;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
520 + provided chunk ::CALL;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
521 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
522 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
523 + provided sequence e1000::free_interrupt_handler()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
524 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
525 + provided chunk LKM::prototypes;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
526 + provided chunk LKM::code;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
527 + provided chunk ::CALL;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
528 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
529 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
530 + provided sequence e1000::activate_device_interruption()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
531 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
532 + provided chunk ::CALL;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
533 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
534 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
535 + provided sequence e1000::set_up_device()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
536 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
537 + provided chunk ::CALL;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
538 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
539 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
540 + provided sequence e1000::handle_intr()
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
541 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
542 + provided chunk ::CALL;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
543 + }
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
544 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
545 +
39
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
546 + 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
547 + {
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
548 + provided chunk LKM::prototypes;
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
549 + provided chunk LKM::code;
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
550 + provided chunk ::CALL;
d761c8c625d3 Try to read a register on the card
Louis Opter <louis@lse.epitech.net>
parents: 38
diff changeset
551 + }
40
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
552 +
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
553 + 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
554 + {
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
555 + provided chunk LKM::prototypes;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
556 + provided chunk LKM::code;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
557 + provided chunk ::CALL;
0ff39df29c46 Add the code to reset the card
Louis Opter <louis@lse.epitech.net>
parents: 39
diff changeset
558 + }
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
559 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
560 + provided sequence e1000::register_set32(e1000::Context, e1000::Register, ::number)
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
561 + {
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
562 + provided chunk LKM::prototypes;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
563 + provided chunk LKM::code;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
564 + provided chunk ::CALL;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
565 + }
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
566 +}
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
567 diff -r 6d6b478219da rathaxes/samples/lkm/ethernet.blt
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
568 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
569 +++ b/rathaxes/samples/lkm/ethernet.blt Mon Jan 09 22:16:54 2012 +0100
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
570 @@ -0,0 +1,218 @@
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
571 +with Ethernet, PCI, LKM, Log
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 + template type Ethernet::Device()
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 + chunk LKM::includes()
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 + #include <linux/netdevice.h>
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
578 + #include <linux/etherdevice.h>
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
579 + }
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 + chunk ::decl()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
582 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
583 + struct rtx_ethernet_dev
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
584 + {
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 + * 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
587 + * 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
588 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
589 + struct pci_dev *pci_dev;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
590 + struct net_device *net_dev;
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 + /* while waiting on issue #8 */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
593 + 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
594 + };
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
595 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
596 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
597 + chunk ::init(net_dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
598 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
599 + ${self} = ${net_dev};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
600 + }
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 + map
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 + }
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
607 + 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
608 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
609 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
610 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
611 + 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
612 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
613 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
614 + chunk LKM::code()
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 + 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
617 + {
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
618 + struct rtx_ethernet_dev* rtx_ether_dev = netdev_priv(dev);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
619 + struct rtx_e1000_ctx* ctx = &rtx_ether_dev->hw_ctx;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
620 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
621 + ${pointcut ::IMPLEMENTATION};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
622 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
623 + return 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
624 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
625 + }
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 + 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
629 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
630 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
631 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
632 + 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
633 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
634 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
635 + chunk LKM::code()
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 + 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
638 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
639 + ${pointcut ::IMPLEMENTATION};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
640 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
641 + return 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
642 + }
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 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
645 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
646 + 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
647 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
648 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
649 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
650 + 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
651 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
652 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
653 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
654 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
655 + 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
656 + {
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
657 + struct rtx_ethernet_dev* rtx_ether_dev = netdev_priv(dev);
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
658 + struct rtx_e1000_ctx* ctx = &rtx_ether_dev->hw_ctx;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
659 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
660 + ${pointcut ::IMPLEMENTATION};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
661 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
662 + return 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
663 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
664 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
665 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
666 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
667 + 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
668 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
669 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
670 + * 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
671 + * it.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
672 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
673 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
674 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
675 + 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
676 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
677 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
678 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
679 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
680 + 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
681 + {
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
682 + struct rtx_ethernet_dev* rtx_ether_dev;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
683 + struct rtx_e1000_ctx* ctx;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
684 +
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
685 + rtx_ether_dev = dev_id;
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
686 + ctx = &rtx_ether_dev->hw_ctx;
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
687 + ${pointcut ::IMPLEMENTATION};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
688 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
689 + return IRQ_NONE;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
690 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
691 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
692 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
693 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
694 + 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
695 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
696 + chunk LKM::data()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
697 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
698 + 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
699 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
700 + .ndo_open = rtx_ethernet_open,
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
701 + .ndo_stop = rtx_ethernet_close,
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
702 + .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
703 + };
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
704 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
705 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
706 + chunk PCI::pci_probe_hook()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
707 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
708 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
709 + * 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
710 + * dialect.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
711 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
712 + typedef int ${Ethernet::Device};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
713 + ${Ethernet::Device} *rtx_ether_ctx;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
714 + struct net_device *net_dev;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
715 + int error;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
716 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
717 + error = 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
718 + 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
719 + if (net_dev == 0)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
720 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
721 + ${Log::info("Cannot allocate memory")};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
722 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
723 + * 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
724 + *
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
725 + * 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
726 + * the parent context.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
727 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
728 + return -ENOMEM;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
729 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
730 + 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
731 + net_dev->irq = pdev->irq;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
732 + // 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
733 + 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
734 + //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
735 + 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
736 + 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
737 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
738 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
739 + * 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
740 + * "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
741 + * "${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
742 + * placeholder, e.g: _1).
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 + * 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
745 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
746 + //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
747 + 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
748 + 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
749 + 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
750 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
751 + ${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
752 + return error;
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
755 + /* 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
756 + //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
757 + 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
758 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
759 + ${pointcut Ethernet::create_device};
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
762 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
763 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
764 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
765 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
766 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
767 + 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
768 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
769 + chunk PCI::pci_remove_hook()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
770 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
771 + 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
772 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
773 + ${pointcut Ethernet::destroy_device};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
774 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
775 + unregister_netdev(net_dev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
776 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
777 + * 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
778 + * 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
779 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
780 + free_netdev(net_dev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
781 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
782 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
783 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
784 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
785 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
786 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
787 +}
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
788 +
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
789 diff -r 6d6b478219da rathaxes/samples/lkm/ethernet.rti
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
790 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
791 +++ b/rathaxes/samples/lkm/ethernet.rti Mon Jan 09 22:16:54 2012 +0100
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
792 @@ -0,0 +1,47 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
793 +interface Ethernet : Socket, PCI, LKM
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
794 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
795 + provided type Ethernet::Device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
796 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
797 + required variable ::string Ethernet::ifname;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
798 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
799 + 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
800 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
801 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
802 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
803 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
804 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
805 + 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
806 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
807 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
808 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
809 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
810 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
811 + 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
812 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
813 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
814 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
815 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
816 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
817 + 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
818 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
819 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
820 + provided chunk LKM::code;
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
823 + 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
824 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
825 + provided chunk LKM::data;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
826 + 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
827 + provided chunk ::CALL;
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 + provided pointcut Ethernet::create_device;
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 + 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
833 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
834 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
835 + 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
836 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
837 + provided pointcut Ethernet::destroy_device;
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 +}
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
840 diff -r 6d6b478219da rathaxes/samples/lkm/lkm.blt
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
841 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
842 +++ b/rathaxes/samples/lkm/lkm.blt Mon Jan 09 22:16:54 2012 +0100
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
843 @@ -0,0 +1,55 @@
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
844 +with LKM
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
845 +{
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
846 + /* 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
847 + ${pointcut LKM::includes};
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
848 + ${pointcut LKM::prototypes};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
849 + ${pointcut LKM::data};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
850 + ${pointcut LKM::code};
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
851 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
852 + template sequence LKM::init()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
853 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
854 + chunk LKM::includes()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
855 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
856 + #include <linux/module.h>
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
857 + #include <linux/kernel.h>
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
858 + }
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
859 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
860 + chunk LKM::data()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
861 + {
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
862 + MODULE_DESCRIPTION(${config.description});
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
863 + MODULE_AUTHOR(${config.author});
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
864 + MODULE_LICENSE(${config.license});
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
865 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
866 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
867 + chunk LKM::code()
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
868 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
869 + /*
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
870 + * 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
871 + * or __exit.
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
872 + */
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
873 + 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
874 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
875 + ${pointcut ::IMPLEMENTATION};
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
876 + ${pointcut LKM::init_bus_hook};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
877 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
878 + return 0;
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
879 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
880 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
881 + module_init(rtx_module_init);
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
882 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
883 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
884 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
885 + template sequence LKM::exit()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
886 + {
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
887 + chunk LKM::code()
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
888 + {
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
889 + 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
890 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
891 + ${pointcut ::IMPLEMENTATION};
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
892 + ${pointcut LKM::deinit_bus_hook};
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
893 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
894 +
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
895 + module_exit(rtx_module_exit);
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
896 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
897 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
898 +}
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
899 diff -r 6d6b478219da rathaxes/samples/lkm/lkm.rti
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
900 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
901 +++ b/rathaxes/samples/lkm/lkm.rti Mon Jan 09 22:16:54 2012 +0100
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
902 @@ -0,0 +1,25 @@
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
903 +interface LKM
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
904 +{
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
905 + provided pointcut LKM::includes;
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
906 + /* 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
907 + provided pointcut LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
908 + provided pointcut LKM::data;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
909 + provided pointcut LKM::code;
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
910 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
911 + required variable ::string LKM::author;
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
912 + required variable ::string LKM::description;
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
913 + required variable ::string LKM::license;
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
914 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
915 + required sequence LKM::init()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
916 + {
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
917 + provided chunk LKM::includes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
918 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
919 + 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
920 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
921 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
922 + required sequence LKM::exit()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
923 + {
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
924 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
925 + 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
926 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
927 +}
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
928 diff -r 6d6b478219da rathaxes/samples/lkm/lkm.rtx
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
929 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
930 +++ b/rathaxes/samples/lkm/lkm.rtx Mon Jan 09 22:16:54 2012 +0100
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
931 @@ -0,0 +1,52 @@
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
932 +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
933 +{
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
934 + Ethernet::open(Ethernet::Device dev)
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 + Log::info("Open the device");
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
937 + e1000::setup_interrupt_handler();
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
938 + Log::info("Interrupt handler installed");
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
939 + e1000::set_up_device();
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
940 + e1000::activate_device_interruption();
38
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
943 + Ethernet::close(Ethernet::Device dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
944 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
945 + Log::info("Close the device");
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
946 + e1000::free_interrupt_handler();
38
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 + 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
950 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
951 + Log::info("Got an interruption");
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
952 + e1000::handle_intr();
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
953 + }
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 + 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
956 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
957 + 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
958 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
959 +
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
960 + LKM::init()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
961 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
962 + Log::info("Hello this is LKM");
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
963 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
964 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
965 + LKM::exit()
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
966 + {
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
967 + 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
968 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
969 +}
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
970 +
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
971 +configuration
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
972 +{
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
973 + LKM::name = "hello";
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
974 + LKM::author = "Rathaxes";
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
975 + 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
976 + LKM::license = "GPL";
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
977 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
978 + PCI::vendor_id = 0x8086;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
979 + PCI::product_id = 0x100f;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
980 + PCI::set_master = true;
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 + Ethernet::ifname = "rtx%d";
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
983 +}
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
984 diff -r 6d6b478219da rathaxes/samples/lkm/log.blt
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
985 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
986 +++ b/rathaxes/samples/lkm/log.blt Mon Jan 09 22:16:54 2012 +0100
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
987 @@ -0,0 +1,10 @@
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
988 +with Log
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
989 +{
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
990 + template sequence Log::info(::string msg)
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
991 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
992 + chunk ::CALL
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
993 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
994 + pr_info("%s\n", ${msg});
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
995 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
996 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
997 +}
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
998 diff -r 6d6b478219da rathaxes/samples/lkm/log.rti
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
999 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
1000 +++ b/rathaxes/samples/lkm/log.rti Mon Jan 09 22:16:54 2012 +0100
3
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1001 @@ -0,0 +1,7 @@
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1002 +interface Log
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1003 +{
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1004 + provided sequence Log::info(::string)
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1005 + {
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1006 + provided chunk ::CALL;
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1007 + }
2389c2bc501f Start to write a queue for the LKM
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1008 +}
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
1009 diff -r 6d6b478219da rathaxes/samples/lkm/pci.blt
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
1010 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
1011 +++ b/rathaxes/samples/lkm/pci.blt Mon Jan 09 22:16:54 2012 +0100
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1012 @@ -0,0 +1,143 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1013 +with PCI, LKM, Log
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 + template type PCI::Device()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1016 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1017 + chunk LKM::includes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1018 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1019 + #include <linux/pci.h>
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 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1022 + chunk ::decl()
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 + struct pci_dev;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1025 + }
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 + chunk ::init(pci_dev)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1028 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1029 + ${self} = ${pci_dev};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1030 + }
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 + map
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 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1035 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1036 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1037 + 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
1038 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1039 + chunk LKM::prototypes()
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 + 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
1042 + const struct pci_device_id *);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1043 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1044 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1045 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1046 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1047 + 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
1048 + 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
1049 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1050 + int err;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1051 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1052 + err = pci_enable_device(pdev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1053 + if (err < 0)
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1054 + goto fail;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1055 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1056 + ${pointcut PCI::pci_probe_hook};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1057 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1058 + return 0;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1059 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1060 + fail:
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1061 + return err;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1062 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1063 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1064 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1065 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1066 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1067 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1068 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1069 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1070 + 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
1071 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1072 + chunk LKM::prototypes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1073 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1074 + 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
1075 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1076 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1077 + chunk LKM::code()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1078 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1079 + 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
1080 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1081 + ${pointcut PCI::pci_remove_hook};
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1082 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1083 + pci_disable_device(pdev);
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1084 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1085 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1086 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1087 + chunk ::CALL()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1088 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1089 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1090 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1091 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1092 + template sequence PCI::register()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1093 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1094 + chunk LKM::data()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1095 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1096 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1097 + * 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
1098 + * 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
1099 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1100 + 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
1101 + { ${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
1102 + { 0, }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1103 + };
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1104 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1105 + 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
1106 + .name = ${config.name},
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1107 + .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
1108 + .probe = rtx_pci_probe,
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1109 + .remove = rtx_pci_remove
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1110 + };
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1111 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1112 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1113 + chunk LKM::init_bus_hook()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1114 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1115 + int error;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1116 + 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
1117 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1118 + ${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
1119 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1120 + * 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
1121 + * parent context?
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1122 + *
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1123 + * 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
1124 + * 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
1125 + * context).
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1126 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1127 + return error;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1128 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1129 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1130 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1131 + chunk ::CALL()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1132 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1133 + /*
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1134 + * 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
1135 + * actually not provided nor required.
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1136 + *
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1137 + * 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
1138 + * 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
1139 + * 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
1140 + */
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1141 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1142 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1143 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1144 + template sequence PCI::unregister()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1145 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1146 + chunk LKM::deinit_bus_hook()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1147 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1148 + 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
1149 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1150 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1151 + chunk ::CALL
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1152 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1153 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1154 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1155 +}
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
1156 diff -r 6d6b478219da rathaxes/samples/lkm/pci.rti
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
1157 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
1158 +++ b/rathaxes/samples/lkm/pci.rti Mon Jan 09 22:16:54 2012 +0100
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1159 @@ -0,0 +1,36 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1160 +interface PCI : LKM
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1161 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1162 + provided type PCI::Device;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1163 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1164 + 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
1165 + 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
1166 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1167 + provided sequence PCI::register()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1168 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1169 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1170 + provided chunk LKM::data;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1171 + 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
1172 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1173 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1174 + provided sequence PCI::unregister()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1175 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1176 + provided chunk ::CALL;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1177 + 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
1178 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1179 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1180 + 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
1181 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1182 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1183 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1184 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1185 + 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
1186 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1187 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1188 + 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
1189 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1190 + provided chunk LKM::prototypes;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1191 + provided chunk LKM::code;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1192 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1193 + 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
1194 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1195 +}
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
1196 diff -r 6d6b478219da rathaxes/samples/lkm/socket.blt
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
1197 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
1198 +++ b/rathaxes/samples/lkm/socket.blt Mon Jan 09 22:16:54 2012 +0100
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1199 @@ -0,0 +1,27 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1200 +with Socket, LKM
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1201 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1202 + template type Socket::SKBuff()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1203 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1204 + chunk LKM::includes()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1205 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1206 + #include <linux/skbuff.h>
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1207 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1208 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1209 + chunk ::decl()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1210 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1211 + struct sk_buff;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1212 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1213 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1214 + chunk ::init()
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1215 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1216 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1217 +
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1218 + map
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1219 + {
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1220 + // 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
1221 + // 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
1222 + // 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
1223 + // 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
1224 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1225 + }
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1226 +}
45
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
1227 diff -r 6d6b478219da rathaxes/samples/lkm/socket.rti
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
1228 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
bab559e0392b rathaxes: enable irq + handle it
Thomas Sanchez <thomas.sanchz@gmail.com>
parents: 44
diff changeset
1229 +++ b/rathaxes/samples/lkm/socket.rti Mon Jan 09 22:16:54 2012 +0100
38
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1230 @@ -0,0 +1,4 @@
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1231 +interface Socket : LKM
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1232 +{
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1233 + provided type Socket::SKBuff;
f43900ad7e66 Fold All The Patches on the LKM Sample
Louis Opter <louis@lse.epitech.net>
parents: 10
diff changeset
1234 +}