Mercurial > archived > louis > epitech > mq > rathaxes
view rathaxes_call_pci_register_unregister_in_the_pci_lkm_sample.patch @ 8:7089717b63b7
WIP on the PCI LKM
author | Louis Opter <louis@lse.epitech.net> |
---|---|
date | Fri, 06 Jan 2012 12:48:22 +0100 |
parents | |
children | 7d51609a0ff1 |
line wrap: on
line source
# HG changeset patch # Parent 3c5e2af745189313fab89aa2674afc3153744f7b rathaxes: add the pci_{register,unregister}_device calls in the PCI LKM sample diff --git a/rathaxes/samples/lkm/lkm.rtx b/rathaxes/samples/lkm/lkm.rtx --- a/rathaxes/samples/lkm/lkm.rtx +++ b/rathaxes/samples/lkm/lkm.rtx @@ -13,10 +13,12 @@ LKM::init() { Log::info("Hello this is LKM"); + PCI::register(); } LKM::exit() { + PCI::unregister(); } } diff --git a/rathaxes/samples/lkm/pci.blt b/rathaxes/samples/lkm/pci.blt --- a/rathaxes/samples/lkm/pci.blt +++ b/rathaxes/samples/lkm/pci.blt @@ -35,25 +35,6 @@ const struct pci_device_id *); } - chunk LKM::data() - { - /* - * CNorm doesn't seem to like "dynamic" arrays (i.e: you always - * have to specify the exact size). - */ - static struct pci_device_id rtx_pci_device_table[2] = { - { ${config.vendor_id}, ${config.product_id}, 0, PCI_ANY_ID, PCI_ANY_ID }, - { 0, } - }; - - static struct pci_driver rtx_pci_driver = { - .name = ${config.name}, - .id_table = rtx_pci_device_table, - .probe = rtx_pci_probe, - .remove = rtx_pci_remove - }; - } - chunk LKM::code() { static int /* __devinit */ rtx_pci_probe(struct pci_dev *pdev, @@ -98,4 +79,39 @@ } } } + + template sequence PCI::register() + { + chunk LKM::data() + { + /* + * CNorm doesn't seem to like "dynamic" arrays (i.e: you always + * have to specify the exact size). + */ + static struct pci_device_id rtx_pci_device_table[2] = { + { ${config.vendor_id}, ${config.product_id}, 0, PCI_ANY_ID, PCI_ANY_ID }, + { 0, } + }; + + static struct pci_driver rtx_pci_driver = { + .name = ${config.name}, + .id_table = rtx_pci_device_table, + .probe = rtx_pci_probe, + .remove = rtx_pci_remove + }; + } + + chunk ::CALL + { + pci_register_driver(&rtx_pci_device); + } + } + + template sequence PCI::unregister() + { + chunk ::CALL + { + pci_unregister_driver(&rtx_pci_device); + } + } } diff --git a/rathaxes/samples/lkm/pci.rti b/rathaxes/samples/lkm/pci.rti --- a/rathaxes/samples/lkm/pci.rti +++ b/rathaxes/samples/lkm/pci.rti @@ -8,12 +8,17 @@ provided sequence PCI::register() { provided chunk ::CALL; + provided chunk LKM::data; + } + + provided sequence PCI::unregister() + { + provided chunk ::CALL; } required sequence PCI::probe(PCI::Device) { provided chunk LKM::prototypes; - provided chunk LKM::data; provided chunk LKM::code; }