cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

comedi_isadma.h (2835B)


      1/* SPDX-License-Identifier: GPL-2.0+ */
      2/*
      3 * COMEDI ISA DMA support functions
      4 * Copyright (c) 2014 H Hartley Sweeten <hsweeten@visionengravers.com>
      5 */
      6
      7#ifndef _COMEDI_ISADMA_H
      8#define _COMEDI_ISADMA_H
      9
     10#include <linux/types.h>
     11
     12struct comedi_device;
     13struct device;
     14
     15/*
     16 * These are used to avoid issues when <asm/dma.h> and the DMA_MODE_
     17 * defines are not available.
     18 */
     19#define COMEDI_ISADMA_READ	0
     20#define COMEDI_ISADMA_WRITE	1
     21
     22/**
     23 * struct comedi_isadma_desc - cookie for ISA DMA
     24 * @virt_addr:	virtual address of buffer
     25 * @hw_addr:	hardware (bus) address of buffer
     26 * @chan:	DMA channel
     27 * @maxsize:	allocated size of buffer (in bytes)
     28 * @size:	transfer size (in bytes)
     29 * @mode:	DMA_MODE_READ or DMA_MODE_WRITE
     30 */
     31struct comedi_isadma_desc {
     32	void *virt_addr;
     33	dma_addr_t hw_addr;
     34	unsigned int chan;
     35	unsigned int maxsize;
     36	unsigned int size;
     37	char mode;
     38};
     39
     40/**
     41 * struct comedi_isadma - ISA DMA data
     42 * @dev:	device to allocate non-coherent memory for
     43 * @desc:	cookie for each DMA buffer
     44 * @n_desc:	the number of cookies
     45 * @cur_dma:	the current cookie in use
     46 * @chan:	the first DMA channel requested
     47 * @chan2:	the second DMA channel requested
     48 */
     49struct comedi_isadma {
     50	struct device *dev;
     51	struct comedi_isadma_desc *desc;
     52	int n_desc;
     53	int cur_dma;
     54	unsigned int chan;
     55	unsigned int chan2;
     56};
     57
     58#if IS_ENABLED(CONFIG_ISA_DMA_API)
     59
     60void comedi_isadma_program(struct comedi_isadma_desc *desc);
     61unsigned int comedi_isadma_disable(unsigned int dma_chan);
     62unsigned int comedi_isadma_disable_on_sample(unsigned int dma_chan,
     63					     unsigned int size);
     64unsigned int comedi_isadma_poll(struct comedi_isadma *dma);
     65void comedi_isadma_set_mode(struct comedi_isadma_desc *desc, char dma_dir);
     66
     67struct comedi_isadma *comedi_isadma_alloc(struct comedi_device *dev,
     68					  int n_desc, unsigned int dma_chan1,
     69					  unsigned int dma_chan2,
     70					  unsigned int maxsize, char dma_dir);
     71void comedi_isadma_free(struct comedi_isadma *dma);
     72
     73#else	/* !IS_ENABLED(CONFIG_ISA_DMA_API) */
     74
     75static inline void comedi_isadma_program(struct comedi_isadma_desc *desc)
     76{
     77}
     78
     79static inline unsigned int comedi_isadma_disable(unsigned int dma_chan)
     80{
     81	return 0;
     82}
     83
     84static inline unsigned int
     85comedi_isadma_disable_on_sample(unsigned int dma_chan, unsigned int size)
     86{
     87	return 0;
     88}
     89
     90static inline unsigned int comedi_isadma_poll(struct comedi_isadma *dma)
     91{
     92	return 0;
     93}
     94
     95static inline void comedi_isadma_set_mode(struct comedi_isadma_desc *desc,
     96					  char dma_dir)
     97{
     98}
     99
    100static inline struct comedi_isadma *
    101comedi_isadma_alloc(struct comedi_device *dev, int n_desc,
    102		    unsigned int dma_chan1, unsigned int dma_chan2,
    103		    unsigned int maxsize, char dma_dir)
    104{
    105	return NULL;
    106}
    107
    108static inline void comedi_isadma_free(struct comedi_isadma *dma)
    109{
    110}
    111
    112#endif	/* !IS_ENABLED(CONFIG_ISA_DMA_API) */
    113
    114#endif	/* #ifndef _COMEDI_ISADMA_H */