# HG changeset patch # User Louis Opter # Date 1325781449 -3600 # Node ID d102c9be499c36d1ee762431c76bf291746d6764 # Parent 2389c2bc501faf00195d7c69e865da3ab7f3db32 WIP on the PCI LKM diff -r 2389c2bc501f -r d102c9be499c rathaxes_start_to_implement_pci_stuff_in_the_lkm.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rathaxes_start_to_implement_pci_stuff_in_the_lkm.patch Thu Jan 05 17:37:29 2012 +0100 @@ -0,0 +1,203 @@ +# HG changeset patch +# Parent e6e856bbde57d16b41e73cec8026d485ed722ab4 +rathaxes: start to implement the PCI registration part in the LKM sample + +diff --git a/rathaxes/samples/lkm/CMakeLists.txt b/rathaxes/samples/lkm/CMakeLists.txt +--- a/rathaxes/samples/lkm/CMakeLists.txt ++++ b/rathaxes/samples/lkm/CMakeLists.txt +@@ -1,3 +1,3 @@ + ADD_RATHAXES_SOURCES(lkm lkm.rtx +- RTI log.rti lkm.rti +- BLT log.blt lkm.blt) ++ RTI log.rti lkm.rti pci.rti ++ BLT log.blt lkm.blt pci.blt) +diff --git a/rathaxes/samples/lkm/lkm.blt b/rathaxes/samples/lkm/lkm.blt +--- a/rathaxes/samples/lkm/lkm.blt ++++ b/rathaxes/samples/lkm/lkm.blt +@@ -1,8 +1,8 @@ + with LKM + { + ${pointcut LKM::includes}; +- ${pointcut LKM::init}; +- ${pointcut LKM::exit}; ++ ${pointcut LKM::data}; ++ ${pointcut LKM::code}; + + template sequence LKM::init() + { +@@ -17,7 +17,7 @@ + MODULE_LICENSE(${config.license}); + } + +- chunk LKM::init() ++ chunk LKM::code() + { + /* + * Rathaxes doesn't yet support arbitrary "decorators" like __init +@@ -34,7 +34,7 @@ + + template sequence LKM::exit() + { +- chunk LKM::exit ++ chunk LKM::code() + { + static void __attribute((__section__(.exit.text))) rtx_module_exit(void) + { +diff --git a/rathaxes/samples/lkm/lkm.rti b/rathaxes/samples/lkm/lkm.rti +--- a/rathaxes/samples/lkm/lkm.rti ++++ b/rathaxes/samples/lkm/lkm.rti +@@ -1,8 +1,8 @@ + interface LKM + { + provided pointcut LKM::includes; +- provided pointcut LKM::init; +- provided pointcut LKM::exit; ++ provided pointcut LKM::data; ++ provided pointcut LKM::code; + + required variable ::string LKM::author; + required variable ::string LKM::description; +@@ -11,11 +11,11 @@ + required sequence LKM::init() + { + provided chunk LKM::includes; +- provided chunk LKM::init; ++ provided chunk LKM::code; + } + + required sequence LKM::exit() + { +- provided chunk LKM::exit; ++ provided chunk LKM::code; + } + } +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 +@@ -1,5 +1,15 @@ +-device LKM use LKM, Log ++device LKM use LKM, PCI, Log + { ++ PCI::probe(PCI::Device dev) ++ { ++ ++ } ++ ++ PCI::remove(PCI::Device dev) ++ { ++ ++ } ++ + LKM::init() + { + Log::info("Hello this is LKM"); +@@ -12,6 +22,7 @@ + + configuration + { ++ LKM::name = "hello"; + LKM::author = "Rathaxes"; + LKM::description = "Hello World Loadable Kernel Module (LKM)"; + LKM::license = "BSD"; +diff --git a/rathaxes/samples/lkm/pci.blt b/rathaxes/samples/lkm/pci.blt +new file mode 100644 +--- /dev/null ++++ b/rathaxes/samples/lkm/pci.blt +@@ -0,0 +1,73 @@ ++with PCI, LKM ++{ ++ template type PCI::Device() ++ { ++ /* ++ * chunk LKM::includes() ++ * { ++ * #include ++ * ++ * typedef int include_linux_pci_stamp; ++ * } ++ */ ++ ++ chunk ::decl() ++ { ++ struct rtx_pci_device ++ { ++ struct pci_dev *pci_dev; ++ }; ++ } ++ ++ chunk ::init(pci_dev) ++ { ++ ${self}.pci_dev = pci_dev; ++ } ++ ++ map ++ { ++ } ++ } ++ ++ template sequence PCI::probe(PCI::Device dev) ++ { ++ chunk LKM::code() ++ { ++ static int /* __devinit */ rtx_pci_probe(struct pci_dev *pdev, ++ const struct pci_device_id *pdev_id) ++ { ++ /* workaround for CNorm __std__ dialect, shouldn't be here */ ++ typedef int ${PCI::Device}; ++ ++ int err; ++ ${PCI::Device} dev = NULL; /* Doesn't work with a pointer */ ++ ++ err = pci_enable_device(pdev); ++// if (err < 0) /* `if' doesn't work */ ++// goto fail; ++ ++ ${pointcut ::IMPLEMENTATION}; ++ ++ pci_set_drvdata(pdev, dev); ++ ++ return 0; ++ ++ fail: ++ return err; ++ } ++ } ++ } ++ ++ template sequence PCI::remove(PCI::Device dev) ++ { ++ chunk LKM::code() ++ { ++ static void rtx_pci_remove(struct pci_dev *pdev) ++ { ++ pci_disable_device(pdev); ++ ++ ${pointcut ::IMPLEMENTATION}; ++ } ++ } ++ } ++} +diff --git a/rathaxes/samples/lkm/pci.rti b/rathaxes/samples/lkm/pci.rti +new file mode 100644 +--- /dev/null ++++ b/rathaxes/samples/lkm/pci.rti +@@ -0,0 +1,19 @@ ++interface PCI : LKM ++{ ++ provided type PCI::Device; ++ ++ provided sequence PCI::register() ++ { ++ provided chunk ::CALL; ++ } ++ ++ required sequence PCI::probe(PCI::Device) ++ { ++ provided chunk LKM::code; ++ } ++ ++ required sequence PCI::remove(PCI::Device) ++ { ++ provided chunk LKM::code; ++ } ++} diff -r 2389c2bc501f -r d102c9be499c series --- a/series Thu Jan 05 15:10:21 2012 +0100 +++ b/series Thu Jan 05 17:37:29 2012 +0100 @@ -1,1 +1,2 @@ rathaxes_add_a_linux_lkm.patch +rathaxes_start_to_implement_pci_stuff_in_the_lkm.patch