diff --git a/dma/dma.py b/dma/dma.py deleted file mode 100755 index 07283d5..0000000 --- a/dma/dma.py +++ /dev/null @@ -1,44 +0,0 @@ -from dmadefs import * - -lib = ffi.dlopen("/home/xpp/dma/libdma.so") - -class DMA(): - - def __init__(self,address): - # Pick a random direction - self.info = ffi.new("axi_dma_simple_info_t *") - global device_id - self.info.device_id = device_id - device_id = device_id + 1 - self.info.phys_base_addr = address - self.info.addr_range = 0x10000 - self.info.dir = DMA_TO_DEV - self.channel = ffi.new("axi_dma_simple_channel_info_t *") - self.channel.dma_info = self.info - self.channel. in_use = 0 - self.channel.needs_cache_flush_invalidate = 0 - self.num_recd = ffi.new("int *") - self.sent_data = 0 - - def dma_register(self): - lib.custom_dma_register(self.info.device_id) - - def dma_unregister(self): - lib.custom_dma_unregister(self.info.device_id) - - def dma_open(self): - lib.custom_dma_open(self.channel, self.info.device_id) - - def dma_close(self): - lib.custom_dma_close(self.channel, self.info.device_id) - - def dma_send(self,buf,length): - lib.custom_dma_send_i(self.channel,buf,length,self.info.device_id) - - def dma_recv(self,buf,length): - self.info.dir = DMA_FROM_DEV - self.sent_data = length - lib.custom_dma_recv_i(self.channel,buf,length,self.num_recd,self.info.device_id) - - def dma_wait(self): - lib.custom_dma_wait(self.info.device_id) \ No newline at end of file diff --git a/dma/dmadefs.py b/dma/dmadefs.py deleted file mode 100755 index c4072f4..0000000 --- a/dma/dmadefs.py +++ /dev/null @@ -1,64 +0,0 @@ -import cffi -ffi = cffi.FFI() -#wa = ffi.new_handle("struct test") - -DMA_TO_DEV = 0 -DMA_FROM_DEV = 1 -device_id = 0 - -ffi.cdef(""" -typedef struct axi_dma_simple_info_struct { - int device_id; - int phys_base_addr; - int addr_range; - int virt_base_addr; - int dir; // either DMA_TO_DEV or DMA_FROM_DEV -} axi_dma_simple_info_t; -""") - -ffi.cdef(""" -typedef struct axi_dma_simple_channel_info_struct { - axi_dma_simple_info_t *dma_info; - int in_use; - int needs_cache_flush_invalidate; -} axi_dma_simple_channel_info_t; -""") - -ffi.cdef(""" -void custom_dma_register(int id); -""") - -ffi.cdef(""" -void custom_dma_unregister(int id); -""") - -ffi.cdef(""" -int custom_dma_open( - axi_dma_simple_channel_info_t dstruct, int id - ); -""") - -ffi.cdef(""" -int custom_dma_close( - axi_dma_simple_channel_info_t dstruct, int id - ); -""") - -ffi.cdef(""" -int custom_dma_send_i( - axi_dma_simple_channel_info_t dstruct, - void *buf, int len,int id - ); - -""") - -ffi.cdef(""" -int custom_dma_recv_i( - axi_dma_simple_channel_info_t dstruct, - void *buf, int len,int *num_recd,int id - ); -""") - -ffi.cdef(""" -void custom_dma_wait(int id); -""") \ No newline at end of file