annotate rathaxes_rewrite_create_and_destroy_device_in_the_e1000_sample.patch @ 97:ffdb018893e2

Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
author Louis Opter <louis@lse.epita.fr>
date Thu, 22 Nov 2012 15:37:46 -0800
parents 3e715b3e0ecd
children e2c237d6c37b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
1 # HG changeset patch
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
2 # Parent d65cd0228e5c25692e6f37d0524e61ae26102a33
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
3 rathaxes: rehaul the device initialization/destruction in the e1000 sample
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
4
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
5 - Add several chunks on the e1000::Context; these chunks perform
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
6 low-level, device-dependant operations and should be move in the
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
7 front-end at some point. They weave into pointcuts defined by the
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
8 Ethernet subsystem;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
9 - The e1000::{create,destroy}_device sequence templates are entirely
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
10 gone; they are replaced by the aforementioned chunks and more generic
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
11 code in the PCI and Ethernet subsystems;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
12 - The PCI::{probe,remove} chunks/pointcuts have been rehauled and are
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
13 centered on the new PCI::Device type template.
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
14
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
15 diff --git a/rathaxes/samples/e1000/e1000.blt b/rathaxes/samples/e1000/e1000.blt
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
16 --- a/rathaxes/samples/e1000/e1000.blt
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
17 +++ b/rathaxes/samples/e1000/e1000.blt
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
18 @@ -1,4 +1,4 @@
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
19 -with e1000, Ethernet, Socket, PCI, LKM, Log
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
20 +with e1000, Ethernet, Socket, PCI, LKM, Log, Builtin
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
21 {
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
22 template type e1000::RxDescriptor()
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
23 {
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
24 @@ -268,6 +268,22 @@
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
25
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
26 template type e1000::Context()
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
27 {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
28 + chunk ::decl()
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
29 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
30 + struct rtx_e1000_ctx
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
31 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
32 + int bars;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
33 + unsigned char /* __iomem */ *ioaddr;
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
34 + unsigned int irq;
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
35 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
36 + /* we can't use the Rathaxes type here (#8) */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
37 + //${e1000::RxRing} rx_ring;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
38 + //${e1000::TxRing} tx_ring;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
39 + struct rtx_e1000_rx_ring rx_ring;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
40 + struct rtx_e1000_tx_ring tx_ring;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
41 + };
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
42 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
43 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
44 chunk Ethernet::SubContext()
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
45 {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
46 /*
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
47 @@ -278,28 +294,58 @@
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
48 ${e1000::Context} hw_ctx;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
49 }
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
50
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
51 - chunk ::decl()
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
52 + chunk Ethernet::adapter_init_context(Ethernet::Device rtx_ether_ctx,
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
53 + Builtin::number bars,
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
54 + Builtin::symbol ioaddr,
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
55 + Builtin::number irq)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
56 {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
57 - /*
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
58 - * Yes, this typedef looks ugly but read the remark about
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
59 - * Ethernet::Device in ethernet.blt.
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
60 - */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
61 - struct rtx_e1000_ctx
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
62 {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
63 - int bars;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
64 - unsigned char /* __iomem */ *ioaddr;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
65 - int irq;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
66 -
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
67 - /* we can't use the Rathaxes type here (#8) */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
68 - //${e1000::RxRing} rx_ring;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
69 - //${e1000::TxRing} tx_ring;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
70 - struct rtx_e1000_rx_ring rx_ring;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
71 - struct rtx_e1000_tx_ring tx_ring;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
72 - };
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
73 + struct rtx_e1000_ctx *hw_ctx = &${rtx_ether_ctx}->hw_ctx;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
74 + hw_ctx->bars = ${bars};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
75 + hw_ctx->ioaddr = ${ioaddr};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
76 + hw_ctx->irq = ${irq};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
77 + }
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
78 }
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
79
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
80 - chunk ::init()
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
81 + chunk Ethernet::adapter_reset(Ethernet::Device rtx_ether_ctx)
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
82 {
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
83 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
84 + struct rtx_e1000_ctx *hw_ctx = &${rtx_ether_ctx}->hw_ctx;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
85 + rtx_e1000_register_write32(hw_ctx, E1000_CTRL, E1000_CMD_RST);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
86 + udelay(10);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
87 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
88 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
89 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
90 + chunk Ethernet::adapter_load_mac_address(Ethernet::Device rtx_ether_ctx)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
91 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
92 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
93 + struct rtx_e1000_ctx *hw_ctx = &${rtx_ether_ctx}->hw_ctx;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
94 + /* Shamelessly borrowed from Minix */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
95 + for (int i = 0; i < 3; ++i)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
96 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
97 + rtx_e1000_register_write32(hw_ctx, E1000_EEPROM_READ, (i << 8) | 1);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
98 + int value;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
99 + do
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
100 + value = rtx_e1000_register_read32(hw_ctx, E1000_EEPROM_READ);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
101 + while ((value & (1 << 4)) == 0);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
102 + value >>= 16;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
103 + /*
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
104 + * XXX: The net_dev manipulations here should take place in the
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
105 + * ethernet templates:
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
106 + * TODO: recevoir un Builtin::symbol avec le tableau ici pour
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
107 + * pouvoir les remonter directement.
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
108 + */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
109 + ${rtx_ether_ctx}->net_dev->dev_addr[i * 2] = value & 0xff;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
110 + ${rtx_ether_ctx}->net_dev->dev_addr[i * 2 + 1] = (value >> 8) & 0xff;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
111 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
112 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
113 + /* TODO: deplacer ça dans Ethernet (see above point): */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
114 + memcpy(${rtx_ether_ctx}->net_dev->perm_addr,
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
115 + ${rtx_ether_ctx}->net_dev->dev_addr,
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
116 + ${rtx_ether_ctx}->net_dev->addr_len);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
117 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
118 + ${Log::info("e1000::create: mac address loaded from the EEPROM")};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
119 + }
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
120 }
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
121
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
122 map
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
123 @@ -477,91 +523,6 @@
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
124 }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
125 }
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
126
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
127 - template sequence e1000::create_device()
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
128 - {
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
129 - chunk Ethernet::create_device(PCI::AbstractDevice pdev, Ethernet::Device rtx_ether_ctx)
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
130 - {
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
131 - /*
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
132 - * PCI init stuff:
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
133 - *
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
134 - * Some of that code should certainly be moved in the PCI/Ethernet
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
135 - * blts, also at some point maybe we could do that completely
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
136 - * automatically in the PCI/Ethernet blts.
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
137 - */
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
138 -
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
139 - /*
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
140 - * We could have used an init function here but since we can't init
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
141 - * all the fields at once (see, ioaddr) and cannot call a C
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
142 - * function within a placeholder (${}), it wasn't really worth it.
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
143 - */
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
144 - ${rtx_ether_ctx}->hw_ctx.bars = pci_select_bars(${pdev}, IORESOURCE_MEM);
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
145 - ${rtx_ether_ctx}->hw_ctx.irq = ${pdev}->irq;
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
146 -
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
147 - if (pci_enable_device_mem(${pdev}))
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
148 - ${Log::info("e1000::create: pci_enable_device_mem failed")};
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
149 - if (pci_request_selected_regions(${pdev}, ${rtx_ether_ctx}->hw_ctx.bars, ${config.name}))
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
150 - ${Log::info("e1000::create: pci_request_selected_regions failed")};
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
151 - if (${config.set_master})
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
152 - pci_set_master(${pdev});
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
153 -
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
154 - /* 0 here is for BAR_0: */
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
155 - ${rtx_ether_ctx}->hw_ctx.ioaddr = pci_ioremap_bar(${pdev}, 0);
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
156 - if (!${rtx_ether_ctx}->hw_ctx.ioaddr)
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
157 - ${Log::info("e1000::create: pci_ioremap_bar failed")};
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
158 -
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
159 - /*
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
160 - * The really device specific algorithm starts here (so it should
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
161 - * certainly be written in the frontend):
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
162 - */
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
163 -
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
164 - /* Reset the card */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
165 - rtx_e1000_register_write32(&${rtx_ether_ctx}->hw_ctx, E1000_CTRL, E1000_CMD_RST);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
166 - udelay(10);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
167 -
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
168 - /* Now we can load its mac address (thanks minix code) */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
169 - for (int i = 0; i < 3; ++i)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
170 - {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
171 - rtx_e1000_register_write32(&${rtx_ether_ctx}->hw_ctx, E1000_EEPROM_READ, (i << 8) | 1);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
172 -
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
173 - int value;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
174 - do
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
175 - value = rtx_e1000_register_read32(&${rtx_ether_ctx}->hw_ctx, E1000_EEPROM_READ);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
176 - while ((value & (1 << 4)) == 0);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
177 - value >>= 16;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
178 -
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
179 - ${rtx_ether_ctx}->net_dev->dev_addr[i * 2] = value & 0xff;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
180 - ${rtx_ether_ctx}->net_dev->dev_addr[i * 2 + 1] = (value >> 8) & 0xff;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
181 - }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
182 -
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
183 - memcpy(${rtx_ether_ctx}->net_dev->perm_addr,
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
184 - ${rtx_ether_ctx}->net_dev->dev_addr,
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
185 - ${rtx_ether_ctx}->net_dev->addr_len);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
186 -
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
187 - ${Log::info("e1000::create: mac address loaded from the EEPROM")};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
188 - }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
189 -
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
190 - chunk ::CALL()
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
191 - {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
192 - }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
193 - }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
194 -
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
195 - template sequence e1000::destroy_device()
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
196 - {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
197 - chunk Ethernet::destroy_device(PCI::AbstractDevice pdev, Ethernet::Device rtx_ether_ctx)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
198 - {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
199 - /*
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
200 - * Here, we should have some checks to avoid to free resources that
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
201 - * haven't been allocated. (e.g: in case of previous errors).
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
202 - */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
203 - iounmap(${rtx_ether_ctx}->hw_ctx.ioaddr);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
204 - pci_release_selected_regions(${pdev}, ${rtx_ether_ctx}->hw_ctx.bars);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
205 - }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
206 -
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
207 - chunk ::CALL()
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
208 - {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
209 - }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
210 - }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
211 -
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
212 /* TODO: make that a method of e1000::Context */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
213 template sequence e1000::print_status(Ethernet::Device ctx)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
214 {
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
215 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
216 --- a/rathaxes/samples/e1000/e1000.rti
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
217 +++ b/rathaxes/samples/e1000/e1000.rti
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
218 @@ -1,8 +1,5 @@
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
219 interface e1000 : Socket, Ethernet, PCI, LKM, Builtin
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
220 {
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
221 - /* XXX: This should be in pci.rti, also maybe we need a bool type */
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
222 - required variable Builtin::symbol set_master;
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
223 -
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
224 required variable Builtin::number rx_ring_size;
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
225 required variable Builtin::number tx_ring_size;
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
226 required variable Builtin::number rx_buffer_len;
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
227 @@ -10,9 +7,18 @@
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
228
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
229 provided type Context
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
230 {
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
231 + method decl();
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
232 +
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
233 chunk Ethernet::SubContext();
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
234 - method decl();
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
235 - method init();
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
236 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
237 + /* Callbacks/Hooks which should probably be in the front-end: */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
238 + chunk Ethernet::adapter_init_context(Ethernet::Device,
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
239 + Builtin::number,
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
240 + Builtin::symbol,
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
241 + Builtin::number);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
242 +// chunk Ethernet::adapter_init_context(Ethernet::Device);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
243 + chunk Ethernet::adapter_reset(Ethernet::Device);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
244 + chunk Ethernet::adapter_load_mac_address(Ethernet::Device);
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
245 }
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
246
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
247 provided type RxDescriptor
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
248 @@ -76,18 +82,6 @@
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
249 chunk ::decl();
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
250 }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
251
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
252 - provided sequence create_device()
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
253 - {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
254 - provided chunk Ethernet::create_device(PCI::AbstractDevice, Ethernet::Device);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
255 - provided chunk ::CALL();
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
256 - }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
257 -
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
258 - provided sequence destroy_device()
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
259 - {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
260 - provided chunk Ethernet::destroy_device(PCI::AbstractDevice, Ethernet::Device);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
261 - provided chunk ::CALL();
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
262 - }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
263 -
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
264 /*
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
265 * This should take an e1000::Context as the first argument but this was
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
266 * not working as wished.
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
267 diff --git a/rathaxes/samples/e1000/ethernet.blt b/rathaxes/samples/e1000/ethernet.blt
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
268 --- a/rathaxes/samples/e1000/ethernet.blt
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
269 +++ b/rathaxes/samples/e1000/ethernet.blt
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
270 @@ -113,6 +113,8 @@
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
271
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
272 map
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
273 {
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
274 + pci_device: ${self}->pci_dev;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
275 + net_device: ${self}->net_dev;
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
276 }
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
277 }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
278
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
279 @@ -210,48 +212,72 @@
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
280 };
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
281 }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
282
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
283 - /* For now the type is not handled, so we just omit it (see #17) */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
284 - chunk PCI::pci_probe_hook(PCI::AbstractDevice pdev)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
285 + /*
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
286 + * NOTE: for now, the error handling is leaking from PCI::probe(), but
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
287 + * it's better than doing it at all.
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
288 + *
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
289 + * XXX: the chunk argument isn't correctly expanded by the
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
290 + * compiler I have to use the same name as the actual C
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
291 + * variable:
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
292 + */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
293 + chunk PCI::pci_probe_hook(PCI::Device rtx_pci_dev)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
294 {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
295 - /*
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
296 - * This typedef is needed to workaround a bug in CNorm __std__
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
297 - * dialect.
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
298 - */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
299 ${Ethernet::Device} rtx_ether_ctx;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
300 - struct net_device *net_dev;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
301 - int error;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
302 + ${Ethernet::AbstractDevice} net_dev;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
303
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
304 - /* Initialize the net_device structure */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
305 net_dev = alloc_etherdev(sizeof(*rtx_ether_ctx));
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
306 - if (net_dev == 0)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
307 + if (!net_dev)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
308 {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
309 - ${Log::info("cannot allocate memory")};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
310 - /*
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
311 - * Again, the error should be "raised" in the parent context.
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
312 - *
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
313 - * Here we know that we can return ENOMEM because *we* wrote
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
314 - * the parent context.
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
315 - */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
316 - return -ENOMEM;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
317 + ${Log::info("cannot allocate the ethernet device context")};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
318 + error = -ENOMEM;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
319 + goto fail;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
320 }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
321 - SET_NETDEV_DEV(net_dev, &${pdev}->dev);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
322 + SET_NETDEV_DEV(net_dev, ${rtx_pci_dev.device});
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
323 strlcpy(net_dev->name, ${config.ifname}, sizeof(net_dev->name));
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
324 - net_dev->irq = ${pdev}->irq;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
325 + net_dev->irq = ${rtx_pci_dev.irq};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
326 net_dev->netdev_ops = &rtx_ether_ops;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
327
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
328 error = register_netdev(net_dev);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
329 if (error)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
330 {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
331 ${Log::info("cannot register the driver in the net subsystem")};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
332 - return error;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
333 + goto fail;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
334 }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
335
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
336 /* Initialize our context held by the net_device structure */
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
337 - ${rtx_ether_ctx.init(local.net_dev, pdev)};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
338 + /*
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
339 + * XXX: the cast is here because the compiler resolve the
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
340 + * type of rtx_pci_dev.pci_device to the type of
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
341 + * rtx_pci_dev instead of the type of rtx_pci_dev.pci_device.
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
342 + *
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
343 + * Also, I'm getting placeholder in the generated code if
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
344 + * I don't open a scope here.
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
345 + */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
346 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
347 + struct pci_dev *pci_device = ${rtx_pci_dev.pci_device};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
348 + ${cast local.pci_device as PCI::AbstractDevice};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
349 + ${local.rtx_ether_ctx.init(local.net_dev, local.pci_device)};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
350 + }
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
351
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
352 - pci_set_drvdata(${pdev}, net_dev);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
353 + /* Register ourselves in the parent context: */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
354 + /* ${rtx_pci_dev.set_context(local.rtx_ether_ctx)}; */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
355 + ${rtx_pci_dev}->context = rtx_ether_ctx;
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
356
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
357 - ${pointcut Ethernet::create_device(pdev, local.rtx_ether_ctx)};
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
358 + /*
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
359 + * XXX: the asssignments/casts are here to circumvent
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
360 + * typing issues in the compiler (see previous XXX).
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
361 + */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
362 + int bars = ${rtx_pci_dev.bars};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
363 + unsigned char /* __iomem */ *ioaddr = ${rtx_pci_dev.ioaddr};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
364 + int irq = ${rtx_pci_dev.irq};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
365 + ${cast local.bars as Builtin::number};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
366 + ${cast local.irq as Builtin::number};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
367 + ${pointcut Ethernet::adapter_init_context(local.rtx_ether_ctx,
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
368 + local.bars,
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
369 + local.ioaddr,
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
370 + local.irq)};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
371 + ${pointcut Ethernet::adapter_reset(local.rtx_ether_ctx)};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
372 + ${pointcut Ethernet::adapter_load_mac_address(local.rtx_ether_ctx)};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
373 }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
374
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
375 /* This chunk should be removed (see #26) */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
376 @@ -262,16 +288,18 @@
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
377
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
378 template sequence Ethernet::exit()
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
379 {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
380 - chunk PCI::pci_remove_hook(PCI::AbstractDevice pdev)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
381 + /*
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
382 + * XXX: We have to use the same name as the C variable for
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
383 + * the chunk argument...
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
384 + */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
385 + chunk PCI::pci_remove_hook(PCI::Device rtx_pci_dev)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
386 {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
387 - /* workaround for cnorm unstrict */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
388 - struct net_device *net_dev = pci_get_drvdata(${pdev});
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
389 - ${Ethernet::Device} rtx_ether_ctx = netdev_priv(net_dev);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
390 + ${Ethernet::Device} rtx_ether_ctx = ${rtx_pci_dev.context};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
391
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
392 - ${pointcut Ethernet::destroy_device(pdev, local.rtx_ether_ctx)};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
393 + BUG_ON(!rtx_ether_ctx);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
394
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
395 - unregister_netdev(net_dev);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
396 - free_netdev(net_dev);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
397 + unregister_netdev(${local.rtx_ether_ctx.net_device});
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
398 + free_netdev(${local.rtx_ether_ctx.net_device});
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
399 }
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
400
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
401 /* This chunk should be removed (see #26) */
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
402 diff --git a/rathaxes/samples/e1000/ethernet.rti b/rathaxes/samples/e1000/ethernet.rti
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
403 --- a/rathaxes/samples/e1000/ethernet.rti
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
404 +++ b/rathaxes/samples/e1000/ethernet.rti
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
405 @@ -1,4 +1,4 @@
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
406 -interface Ethernet : Socket, PCI, LKM
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
407 +interface Ethernet : Socket, PCI, LKM, Builtin
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
408 {
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
409 required variable Builtin::string ifname;
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
410
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
411 @@ -23,6 +23,9 @@
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
412 method decl();
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
413 method init(Ethernet::AbstractDevice, PCI::AbstractDevice);
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
414 pointcut Ethernet::SubContext();
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
415 +
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
416 + attribute PCI::AbstractDevice pci_device;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
417 + attribute Ethernet::AbstractDevice net_device;
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
418 }
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
419
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
420 required sequence open(Ethernet::Device)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
421 @@ -52,15 +55,18 @@
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
422 provided sequence init()
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
423 {
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
424 provided chunk LKM::data();
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
425 - provided chunk PCI::pci_probe_hook(PCI::AbstractDevice);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
426 + provided chunk PCI::pci_probe_hook(PCI::Device);
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
427
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
428 - provided pointcut Ethernet::create_device(PCI::AbstractDevice, Ethernet::Device);
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
429 + provided pointcut Ethernet::adapter_init_context(Ethernet::Device,
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
430 + Builtin::number,
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
431 + Builtin::symbol,
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
432 + Builtin::number);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
433 + provided pointcut Ethernet::adapter_reset(Ethernet::Device);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
434 + provided pointcut Ethernet::adapter_load_mac_address(Ethernet::Device);
96
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
435 }
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
436
3e715b3e0ecd Start a series to cleanup/refactor the e1000 sample a little bit
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
437 provided sequence exit()
97
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
438 {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
439 - provided chunk PCI::pci_remove_hook(PCI::AbstractDevice);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
440 -
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
441 - provided pointcut Ethernet::destroy_device(PCI::AbstractDevice, Ethernet::Device);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
442 + provided chunk PCI::pci_remove_hook(PCI::Device);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
443 }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
444 }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
445 diff --git a/rathaxes/samples/e1000/lkm.rtx b/rathaxes/samples/e1000/lkm.rtx
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
446 --- a/rathaxes/samples/e1000/lkm.rtx
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
447 +++ b/rathaxes/samples/e1000/lkm.rtx
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
448 @@ -74,7 +74,6 @@
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
449 */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
450 PCI::vendor_id = 0x8086;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
451 PCI::product_id = 0x100e;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
452 - PCI::set_master = true;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
453
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
454 Ethernet::ifname = "rtx%d";
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
455
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
456 diff --git a/rathaxes/samples/e1000/pci.blt b/rathaxes/samples/e1000/pci.blt
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
457 --- a/rathaxes/samples/e1000/pci.blt
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
458 +++ b/rathaxes/samples/e1000/pci.blt
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
459 @@ -12,12 +12,102 @@
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
460 struct pci_dev;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
461 }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
462
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
463 - chunk ::init(PCI::AbstractDevice)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
464 + chunk ::init(PCI::AbstractDevice)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
465 {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
466 }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
467
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
468 + chunk set_context(Builtin::symbol ctx)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
469 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
470 + pci_set_drvdata(${self}, ${ctx});
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
471 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
472 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
473 map
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
474 {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
475 + context: pci_get_drvdata(${self});
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
476 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
477 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
478 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
479 + template type PCI::Device()
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
480 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
481 + chunk ::decl()
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
482 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
483 + struct rtx_pci_dev
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
484 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
485 + struct pci_dev *pdev;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
486 + int bars;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
487 + /* It could be an array at some point: */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
488 + unsigned char /* __iomem */ *ioaddr;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
489 + void *context;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
490 + };
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
491 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
492 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
493 + chunk ::init(PCI::AbstractDevice pdev)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
494 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
495 + ${self}->pdev = ${pdev};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
496 + ${self}->bars = pci_select_bars(${pdev}, IORESOURCE_MEM);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
497 + ${self}->ioaddr = NULL;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
498 + ${self}->context = NULL;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
499 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
500 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
501 + chunk LKM::prototypes()
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
502 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
503 + static int rtx_pci_device_enable(struct rtx_pci_dev *);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
504 + static void rtx_pci_device_disable(struct rtx_pci_dev *);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
505 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
506 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
507 + chunk LKM::code()
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
508 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
509 + static int rtx_pci_device_enable(struct rtx_pci_dev *self)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
510 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
511 + int error;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
512 + error = pci_enable_device(self->pdev);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
513 + if (error)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
514 + return error;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
515 + error = pci_request_selected_regions(self->pdev, self->bars, ${config.name});
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
516 + if (error)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
517 + return error;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
518 + pci_set_master(self->pdev);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
519 + return 0;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
520 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
521 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
522 + static void rtx_pci_device_disable(struct rtx_pci_dev *self)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
523 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
524 + if (self->ioaddr)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
525 + iounmap(self->ioaddr);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
526 + pci_release_selected_regions(self->pdev, self->bars);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
527 + pci_disable_device(self->pdev);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
528 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
529 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
530 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
531 + chunk enable()
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
532 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
533 + rtx_pci_device_enable(${self});
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
534 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
535 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
536 + chunk disable()
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
537 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
538 + rtx_pci_device_disable(${self});
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
539 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
540 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
541 + chunk select_ioaddr(Builtin::number bar)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
542 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
543 + ${self}->ioaddr = pci_ioremap_bar(${self}->pdev, ${bar});
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
544 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
545 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
546 + chunk set_context(Builtin::symbol ctx)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
547 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
548 + ${self}->context = ctx;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
549 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
550 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
551 + map
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
552 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
553 + context: ${self}->context;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
554 + device: &${self}->pdev->dev;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
555 + pci_device: ${self}->pdev;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
556 + irq: ${self}->pdev->irq;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
557 + bars: ${self}->bars;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
558 + ioaddr: ${self}->ioaddr;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
559 + BAR_0: 0;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
560 }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
561 }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
562
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
563 @@ -34,24 +124,67 @@
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
564 static int /* __devinit */ rtx_pci_probe(struct pci_dev *pdev,
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
565 const struct pci_device_id *pdev_id)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
566 {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
567 - int err;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
568 + ${cast local.pdev as PCI::AbstractDevice};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
569 + int error;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
570 + ${PCI::Device} *rtx_pci_dev;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
571
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
572 - err = pci_enable_device(pdev);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
573 - if (err < 0)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
574 + rtx_pci_dev = kmalloc(sizeof(*rtx_pci_dev), GFP_KERNEL);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
575 + if (!rtx_pci_dev)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
576 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
577 + ${Log::info("cannot allocate the pci device context")};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
578 + error = -ENOMEM;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
579 goto fail;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
580 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
581
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
582 - /* Use local. to reference a local C variable: */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
583 - ${cast local.pdev as PCI::AbstractDevice};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
584 - ${pointcut PCI::pci_probe_hook(local.pdev)};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
585 + /*
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
586 + * XXX: I'm getting placeholder in the generated code if I don't
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
587 + * open a scope here:
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
588 + */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
589 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
590 + ${local.rtx_pci_dev.init(local.pdev)};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
591 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
592 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
593 + /* ${local.pdev.set_context(local.rtx_pci_dev)}; */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
594 + pci_set_drvdata(pdev, rtx_pci_dev);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
595 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
596 + /* ${local.rtx_pci_dev.enable()}; */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
597 + error = rtx_pci_device_enable(rtx_pci_dev);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
598 + if (error)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
599 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
600 + ${Log::info("rtx_pci_device_enable failed")};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
601 + goto fail;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
602 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
603 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
604 + /* ${local.rtx_pci_dev.select_ioaddr(local.rtx_pci_dev.BAR_0)}; */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
605 + rtx_pci_dev->ioaddr = pci_ioremap_bar(
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
606 + rtx_pci_dev->pdev, ${local.rtx_pci_dev.BAR_0}
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
607 + );
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
608 + if (!${local.rtx_pci_dev.ioaddr})
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
609 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
610 + ${Log::info("can't map the device address space")};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
611 + error = 1; /* XXX anything more approriate? */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
612 + goto fail;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
613 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
614 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
615 + /*
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
616 + * XXX: We have to cast here because the compiler is
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
617 + * confused by the fact that rtx_pci_dev is a
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
618 + * pointer.
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
619 + */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
620 + ${cast local.rtx_pci_dev as PCI::Device};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
621 + ${pointcut PCI::pci_probe_hook(local.rtx_pci_dev)};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
622
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
623 return 0;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
624
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
625 - fail:
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
626 - return err;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
627 + fail:
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
628 + /* ${local.pdev.set_context(NULL)}; */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
629 + pci_set_drvdata(pdev, NULL);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
630 + kfree(rtx_pci_dev);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
631 + return error;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
632 }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
633 }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
634
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
635 - /* This chunk should be remove (see #26) */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
636 + /* This chunk should be removed (see #26) */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
637 chunk ::CALL()
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
638 {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
639 }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
640 @@ -69,9 +202,16 @@
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
641 static void rtx_pci_remove(struct pci_dev *pdev)
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
642 {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
643 ${cast local.pdev as PCI::AbstractDevice};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
644 - ${pointcut PCI::pci_remove_hook(local.pdev)};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
645 + ${PCI::Device} *rtx_pci_dev = ${local.pdev.context};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
646
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
647 - pci_disable_device(pdev);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
648 + BUG_ON(!rtx_pci_dev);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
649 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
650 + /* XXX: compiler confused by the pointer type. */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
651 + ${cast local.rtx_pci_dev as PCI::Device};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
652 + ${pointcut PCI::pci_remove_hook(local.rtx_pci_dev)};
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
653 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
654 + /* ${local.rtx_pci_dev.disable()}; */
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
655 + rtx_pci_device_disable(rtx_pci_dev);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
656 }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
657 }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
658
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
659 diff --git a/rathaxes/samples/e1000/pci.rti b/rathaxes/samples/e1000/pci.rti
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
660 --- a/rathaxes/samples/e1000/pci.rti
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
661 +++ b/rathaxes/samples/e1000/pci.rti
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
662 @@ -1,14 +1,40 @@
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
663 -interface PCI : LKM
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
664 +interface PCI : LKM, Builtin, Device
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
665 {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
666 + required variable Builtin::string LKM::name;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
667 + required variable Builtin::number PCI::vendor_id;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
668 + required variable Builtin::number PCI::product_id;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
669 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
670 provided type PCI::AbstractDevice
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
671 {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
672 chunk LKM::includes();
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
673 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
674 method decl();
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
675 method init(PCI::AbstractDevice);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
676 + method set_context(Builtin::symbol);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
677 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
678 + attribute Builtin::symbol context;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
679 }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
680
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
681 - required variable Builtin::number PCI::vendor_id;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
682 - required variable Builtin::number PCI::product_id;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
683 + provided type PCI::Device
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
684 + {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
685 + chunk LKM::prototypes();
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
686 + chunk LKM::code();
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
687 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
688 + method decl();
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
689 + method init(PCI::AbstractDevice);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
690 + method enable();
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
691 + method disable();
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
692 + method select_ioaddr(Builtin::number);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
693 + method set_context(Builtin::symbol);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
694 +
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
695 + attribute Builtin::symbol context;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
696 + attribute Device::AbstractDevice device;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
697 + attribute PCI::AbstractDevice pci_device;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
698 + attribute Builtin::symbol ioaddr;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
699 + attribute Builtin::number BAR_0;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
700 + attribute Builtin::number irq;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
701 + attribute Builtin::number bars;
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
702 + }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
703
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
704 provided sequence register()
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
705 {
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
706 @@ -28,7 +54,7 @@
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
707 provided chunk LKM::prototypes();
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
708 provided chunk LKM::code();
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
709
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
710 - provided pointcut PCI::pci_probe_hook(PCI::AbstractDevice);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
711 + provided pointcut PCI::pci_probe_hook(PCI::Device);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
712 }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
713
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
714 provided sequence remove()
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
715 @@ -36,6 +62,6 @@
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
716 provided chunk LKM::prototypes();
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
717 provided chunk LKM::code();
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
718
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
719 - provided pointcut PCI::pci_remove_hook(PCI::AbstractDevice);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
720 + provided pointcut PCI::pci_remove_hook(PCI::Device);
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
721 }
ffdb018893e2 Finish the patch on the create/destroy_device rewrite in the e1000 sample and fix Builtin::symbol
Louis Opter <louis@lse.epita.fr>
parents: 96
diff changeset
722 }