Mercurial > archived > louis > epitech > mq > rathaxes
diff rathaxes_rewrite_create_and_destroy_device_in_the_e1000_sample.patch @ 99:e2c237d6c37b
Update patches against David's new decl system
author | Louis Opter <louis@lse.epita.fr> |
---|---|
date | Thu, 22 Nov 2012 22:47:25 -0800 |
parents | ffdb018893e2 |
children |
line wrap: on
line diff
--- a/rathaxes_rewrite_create_and_destroy_device_in_the_e1000_sample.patch Thu Nov 22 16:41:18 2012 -0800 +++ b/rathaxes_rewrite_create_and_destroy_device_in_the_e1000_sample.patch Thu Nov 22 22:47:25 2012 -0800 @@ -1,5 +1,5 @@ # HG changeset patch -# Parent d65cd0228e5c25692e6f37d0524e61ae26102a33 +# Parent 23c454cb9c1efef0cdcb239505343e893bcd6303 rathaxes: rehaul the device initialization/destruction in the e1000 sample - Add several chunks on the e1000::Context; these chunks perform @@ -21,65 +21,59 @@ { template type e1000::RxDescriptor() { -@@ -268,6 +268,22 @@ +@@ -251,22 +251,8 @@ template type e1000::Context() { -+ chunk ::decl() -+ { -+ struct rtx_e1000_ctx -+ { -+ int bars; -+ unsigned char /* __iomem */ *ioaddr; -+ unsigned int irq; -+ -+ /* we can't use the Rathaxes type here (#8) */ -+ //${e1000::RxRing} rx_ring; -+ //${e1000::TxRing} tx_ring; -+ struct rtx_e1000_rx_ring rx_ring; -+ struct rtx_e1000_tx_ring tx_ring; -+ }; -+ } -+ - chunk Ethernet::SubContext() - { - /* -@@ -278,28 +294,58 @@ - ${e1000::Context} hw_ctx; - } - -- chunk ::decl() -+ chunk Ethernet::adapter_init_context(Ethernet::Device rtx_ether_ctx, -+ Builtin::number bars, -+ Builtin::symbol ioaddr, -+ Builtin::number irq) +- chunk Ethernet::SubContext() +- { +- /* +- * Force the generation of the structure in the "headers" part, we +- * have to do this since we do not use the structure in this blt +- * (we hacked a bit and used it in ethernet.blt directly). +- */ +- ${e1000::Context} hw_ctx; +- } +- + decl data_types() { - /* - * Yes, this typedef looks ugly but read the remark about - * Ethernet::Device in ethernet.blt. - */ -- struct rtx_e1000_ctx + struct rtx_e1000_ctx { -- int bars; -- unsigned char /* __iomem */ *ioaddr; -- int irq; -- -- /* we can't use the Rathaxes type here (#8) */ -- //${e1000::RxRing} rx_ring; -- //${e1000::TxRing} tx_ring; -- struct rtx_e1000_rx_ring rx_ring; -- struct rtx_e1000_tx_ring tx_ring; -- }; + int bars; +@@ -281,8 +267,68 @@ + }; + } + +- method init() ++ chunk Ethernet::SubContext() + { ++ /* ++ * Force the generation of the structure in the "headers" part, we ++ * have to do this since we do not use the structure in this blt ++ * (we hacked a bit and used it in ethernet.blt directly). ++ */ ++ ${e1000::Context} hw_ctx; ++ } ++ ++ chunk Ethernet::adapter_init_context(Ethernet::Device rtx_ether_ctx, ++ Builtin::number bars, ++ Builtin::symbol ioaddr, ++ Builtin::number irq) ++ { ++ { + struct rtx_e1000_ctx *hw_ctx = &${rtx_ether_ctx}->hw_ctx; + hw_ctx->bars = ${bars}; + hw_ctx->ioaddr = ${ioaddr}; + hw_ctx->irq = ${irq}; + } - } - -- chunk ::init() ++ } ++ + chunk Ethernet::adapter_reset(Ethernet::Device rtx_ether_ctx) - { ++ { + { + struct rtx_e1000_ctx *hw_ctx = &${rtx_ether_ctx}->hw_ctx; + rtx_e1000_register_write32(hw_ctx, E1000_CTRL, E1000_CMD_RST); @@ -120,7 +114,7 @@ } map -@@ -477,91 +523,6 @@ +@@ -445,91 +491,6 @@ } } @@ -224,29 +218,23 @@ required variable Builtin::number rx_ring_size; required variable Builtin::number tx_ring_size; required variable Builtin::number rx_buffer_len; -@@ -10,9 +7,18 @@ - - provided type Context - { -+ method decl(); -+ +@@ -13,6 +10,14 @@ chunk Ethernet::SubContext(); -- method decl(); -- method init(); + decl data_types(); + method init(); + + /* Callbacks/Hooks which should probably be in the front-end: */ + chunk Ethernet::adapter_init_context(Ethernet::Device, + Builtin::number, + Builtin::symbol, + Builtin::number); -+// chunk Ethernet::adapter_init_context(Ethernet::Device); + chunk Ethernet::adapter_reset(Ethernet::Device); + chunk Ethernet::adapter_load_mac_address(Ethernet::Device); } provided type RxDescriptor -@@ -76,18 +82,6 @@ - chunk ::decl(); +@@ -70,18 +75,6 @@ + decl data_types(); } - provided sequence create_device() @@ -409,7 +397,7 @@ required variable Builtin::string ifname; @@ -23,6 +23,9 @@ - method decl(); + decl data_types(); method init(Ethernet::AbstractDevice, PCI::AbstractDevice); pointcut Ethernet::SubContext(); + @@ -456,16 +444,16 @@ diff --git a/rathaxes/samples/e1000/pci.blt b/rathaxes/samples/e1000/pci.blt --- a/rathaxes/samples/e1000/pci.blt +++ b/rathaxes/samples/e1000/pci.blt -@@ -12,12 +12,102 @@ +@@ -12,15 +12,105 @@ struct pci_dev; } -- chunk ::init(PCI::AbstractDevice) -+ chunk ::init(PCI::AbstractDevice) +- method init(PCI::AbstractDevice) ++ method init(PCI::AbstractDevice) { } -+ chunk set_context(Builtin::symbol ctx) ++ method set_context(Builtin::symbol ctx) + { + pci_set_drvdata(${self}, ${ctx}); + } @@ -473,12 +461,12 @@ map { + context: pci_get_drvdata(${self}); -+ } -+ } -+ + } + } + + template type PCI::Device() + { -+ chunk ::decl() ++ decl data_types() + { + struct rtx_pci_dev + { @@ -490,7 +478,7 @@ + }; + } + -+ chunk ::init(PCI::AbstractDevice pdev) ++ method init(PCI::AbstractDevice pdev) + { + ${self}->pdev = ${pdev}; + ${self}->bars = pci_select_bars(${pdev}, IORESOURCE_MEM); @@ -528,22 +516,22 @@ + } + } + -+ chunk enable() ++ method enable() + { + rtx_pci_device_enable(${self}); + } + -+ chunk disable() ++ method disable() + { + rtx_pci_device_disable(${self}); + } + -+ chunk select_ioaddr(Builtin::number bar) ++ method select_ioaddr(Builtin::number bar) + { + ${self}->ioaddr = pci_ioremap_bar(${self}->pdev, ${bar}); + } + -+ chunk set_context(Builtin::symbol ctx) ++ method set_context(Builtin::symbol ctx) + { + ${self}->context = ctx; + } @@ -557,9 +545,12 @@ + bars: ${self}->bars; + ioaddr: ${self}->ioaddr; + BAR_0: 0; - } - } - ++ } ++ } ++ + template sequence probe() + { + chunk LKM::prototypes() @@ -34,24 +124,67 @@ static int /* __devinit */ rtx_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pdev_id) @@ -659,7 +650,7 @@ diff --git a/rathaxes/samples/e1000/pci.rti b/rathaxes/samples/e1000/pci.rti --- a/rathaxes/samples/e1000/pci.rti +++ b/rathaxes/samples/e1000/pci.rti -@@ -1,14 +1,40 @@ +@@ -1,14 +1,41 @@ -interface PCI : LKM +interface PCI : LKM, Builtin, Device { @@ -669,9 +660,10 @@ + provided type PCI::AbstractDevice { - chunk LKM::includes(); ++ decl data_types(); + - method decl(); + chunk LKM::includes(); +- decl data_types(); method init(PCI::AbstractDevice); + method set_context(Builtin::symbol); + @@ -682,10 +674,11 @@ - required variable Builtin::number PCI::product_id; + provided type PCI::Device + { ++ decl data_types(); ++ + chunk LKM::prototypes(); + chunk LKM::code(); + -+ method decl(); + method init(PCI::AbstractDevice); + method enable(); + method disable(); @@ -703,7 +696,7 @@ provided sequence register() { -@@ -28,7 +54,7 @@ +@@ -28,7 +55,7 @@ provided chunk LKM::prototypes(); provided chunk LKM::code(); @@ -712,7 +705,7 @@ } provided sequence remove() -@@ -36,6 +62,6 @@ +@@ -36,6 +63,6 @@ provided chunk LKM::prototypes(); provided chunk LKM::code();