Mercurial > archived > louis > epitech > mq > rathaxes
diff rathaxes_samples_e1000_add_a_dma_abstraction.patch @ 112:bfe10def90e3
Wip
author | Louis Opter <louis@lse.epita.fr> |
---|---|
date | Fri, 19 Jul 2013 19:12:10 -0700 |
parents | b072f682823d |
children | 5a663f8f0e54 |
line wrap: on
line diff
--- a/rathaxes_samples_e1000_add_a_dma_abstraction.patch Sun Jul 14 23:14:33 2013 -0700 +++ b/rathaxes_samples_e1000_add_a_dma_abstraction.patch Fri Jul 19 19:12:10 2013 -0700 @@ -9,12 +9,119 @@ This will be useful to remove Linux specific DMA code from e1000::set_up_device which should be only device independent code. - +diff --git a/rathaxes/samples/e1000/CMakeLists.txt b/rathaxes/samples/e1000/CMakeLists.txt +--- a/rathaxes/samples/e1000/CMakeLists.txt ++++ b/rathaxes/samples/e1000/CMakeLists.txt +@@ -5,6 +5,7 @@ + log.rti + lkm.rti + device.rti ++ dma.rti + pci.rti + socket.rti + ethernet.rti +@@ -12,8 +13,9 @@ + BLT + log.blt + lkm.blt ++ device.blt ++ dma.blt + pci.blt +- device.blt + socket.blt + e1000.blt + ethernet.blt) +diff --git a/rathaxes/samples/e1000/dma.blt b/rathaxes/samples/e1000/dma.blt +new file mode 100644 +--- /dev/null ++++ b/rathaxes/samples/e1000/dma.blt +@@ -0,0 +1,81 @@ ++with DMA, Builtin, LKM, Device ++{ ++ template type AbstractDMAHandle() ++ { ++ chunk LKM::includes() ++ { ++ #include <linux/dma-mapping.h> ++ } ++ ++ decl data_types() ++ { ++ dma_addr_t data; ++ } ++ ++ map ++ { ++ k_dma_handle: ((dma_addr_t *)${self}); ++ } ++ } ++ ++ template type AbstractDMADirection() ++ { ++ decl data_types() ++ { ++ enum dma_data_direction data; ++ } ++ ++ map ++ { ++ k_dma_direction: ((enum dma_data_direction)${self}); ++ } ++ } ++ ++ template type DMADirection() ++ { ++ decl data_types() ++ { ++ RTX_DMA_BIDIRECTIONAL = DMA_BIDIRECTIONAL, ++ RTX_DMA_TO_DEVICE = DMA_TO_DEVICE, ++ RTX_DMA_FROM_DEVICE = DMA_FROM_DEVICE ++ } ++ ++ map ++ { ++ /* XXX: we should use ${AbstractDMADirection} here: */ ++ dma_direction: ((enum dma_data_direction)${self}); ++ } ++ } ++ ++ template sequence map(Device::AbstractDevice dev, Builtin::symbol buf, Builtin::number size, DMADirection dir) ++ { ++ chunk ::CALL() ++ { ++ dma_map_single(${dev.k_device}, ${buf}, ${size}, ${dir.dma_direction}); ++ } ++ } ++ ++ template sequence unmap(Device::AbstractDevice dev, AbstractDMAHandle handle, Builtin::number size, DMADirection dir) ++ { ++ chunk ::CALL() ++ { ++ dma_unmap_single(${dev.k_device}, ${handle.k_dma_handle}, ${size}, ${dir.dma_direction}); ++ } ++ } ++ ++ template sequence alloc_coherent(Device::AbstractDevice dev, Builtin::number size, AbstractDMAHandle handle) ++ { ++ chunk ::CALL() ++ { ++ dma_alloc_coherent(${dev.k_device}, ${size}, ${handle.k_dma_handle}, GFP_KERNEL); ++ } ++ } ++ ++ template sequence free_coherent(Device::AbstractDevice dev, Builtin::number size, Builtin::symbol addr, AbstractDMAHandle handle) ++ { ++ chunk ::CALL() ++ { ++ dma_free_coherent(${dev.k_device}, ${size}, ${addr}, ${handle.k_dma_handle}); ++ } ++ } ++} diff --git a/rathaxes/samples/e1000/dma.rti b/rathaxes/samples/e1000/dma.rti new file mode 100644 --- /dev/null +++ b/rathaxes/samples/e1000/dma.rti -@@ -0,0 +1,34 @@ +@@ -0,0 +1,42 @@ +interface DMA : Builtin, LKM, Device +{ + provided type AbstractDMAHandle @@ -24,24 +131,32 @@ + attribute Builtin::symbol.scalar k_dma_handle; + } + -+ provided type Direction ++ provided type AbstractDMADirection + { -+ decl data_types(); ++ decl data_types(); ++ attribute Builtin::symbol.scalar k_dma_direction; + } + -+ provided sequence map(Device::AbstractDevice, Builtin::symbol, Builtin::number, Direction) ++ provided type DMADirection + { -+ provided chunk ::CALL(); /* -> AbstractDMAHandle */ ++ decl data_types(); ++ attribute AbstractDMADirection.scalar dma_direction; + } + -+ provided sequence unmap(Device::AbstractDevice, AbstractDMAHandle, Builtin::number, Direction) ++ provided sequence map(Device::AbstractDevice, Builtin::symbol, Builtin::number, DMADirection) ++ { ++ provided chunk ::CALL(); /* -> DMAHandle */ ++ } ++ ++ provided sequence unmap(Device::AbstractDevice, AbstractDMAHandle, Builtin::number, DMADirection) + { + provided chunk ::CALL(); + } + -+ provided sequence alloc_coherent(Device::AbstractDevice, Builtin::number, Builtin::symbol) ++ provided sequence alloc_coherent(Device::AbstractDevice, Builtin::number, AbstractDMAHandle) + { -+ provided chunk ::CALL(); /* -> AbstractDMAHandle + addr returned via the symbol */ ++ /* return the addr and the handle via the AbstractDMAHandle ptr: */ ++ provided chunk ::CALL(); + } + + provided sequence free_coherent(Device::AbstractDevice, Builtin::number, Builtin::symbol, AbstractDMAHandle)