vmod/vmodttl: fixed bug related to luns not ordered and/or not starting from zero.
[ht-drivers.git] / cdcm / cdcmPciDmaLynx.c
blob83e675a4bde450136fdf6bc8a87ba2221c34e15b
1 /**
2 * @file cdcmPciDmaLynx.c
4 * @brief CDCM PCI DMA implementation for LynxOS
6 * @author Copyright (C) 2009 CERN CO/HT Emilio G. Cota
7 * <emilio.garcia.cota@cern.ch>
9 * @section license_sec License
10 * Released under the GPL v2. (and only v2, not any later version)
12 #ifdef __Lynx__
14 #include "cdcmPciDma.h"
15 #include <kernel.h>
17 cdcm_dma_t cdcm_pci_map(void *handle, void *addr, size_t size, int write)
19 unsigned long ptr;
20 ptr = (unsigned long)addr;
21 if (ptr < PHYSBASE)
22 ptr = (unsigned long)get_phys((kaddr_t)addr);
23 return (cdcm_dma_t)(ptr - PHYSBASE);
26 void cdcm_pci_unmap(void *handle, cdcm_dma_t dma_addr, int size, int write)
28 return;
31 int cdcm_pci_mmchain_lock(void *handle, struct cdcm_dmabuf *dma, int write,
32 int pid, void *buf, unsigned long size,
33 struct dmachain *out)
35 int err;
36 int i;
37 dma->user_buf = (char *)buf;
38 dma->size = size;
39 err = mem_lock(pid, dma->user_buf, dma->size);
40 if (err < 0) return SYSERR;
41 err = mmchain(out, dma->user_buf, dma->size);
42 for (i=0; i < err; i++) {
43 /* get_phys here would be redundant */
44 out[i].address -= PHYSBASE;
46 return err;
49 int cdcm_pci_mem_unlock(void *handle, struct cdcm_dmabuf *dma, int pid,
50 int dirty)
52 return mem_unlock(pid, dma->user_buf, dma->size, dirty);
55 #endif /* __Lynx__ */