First try in keyboard driver
[incOS.git] / programs / include / cdi / dma.h
blob0edd1670d799ddb1409216beabb2b4ce833f2e10
1 /*
2 * Copyright (c) 2007 Antoine Kaufmann
4 * This program is free software. It comes without any warranty, to
5 * the extent permitted by applicable law. You can redistribute it
6 * and/or modify it under the terms of the Do What The Fuck You Want
7 * To Public License, Version 2, as published by Sam Hocevar. See
8 * http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9 */
11 #ifndef CDI_DMA_H_INCLUDED
12 #define CDI_DMA_H_INCLUDED
14 #include <stdint.h>
15 #include <stdio.h>
16 #include <cdi.h>
18 struct cdi_dma_handle
20 uint8_t channel;
21 size_t length;
22 uint8_t mode;
23 void *buffer;
25 // IncOS-specific
26 int file;
29 // Geraet => Speicher
30 #define CDI_DMA_MODE_READ (1 << 2)
31 // Speicher => Geraet
32 #define CDI_DMA_MODE_WRITE (2 << 2)
33 #define CDI_DMA_MODE_ON_DEMAND (0 << 6)
34 #define CDI_DMA_MODE_SINGLE (1 << 6)
35 #define CDI_DMA_MODE_BLOCK (2 << 6)
38 /**
39 * Initialisiert einen Transport per DMA
41 * @return 0 bei Erfolg, -1 im Fehlerfall
43 int cdi_dma_open(struct cdi_dma_handle* handle, uint8_t channel, uint8_t mode,
44 size_t length, void* buffer);
46 /**
47 * Liest Daten per DMA ein
49 * @return 0 bei Erfolg, -1 im Fehlerfall
51 int cdi_dma_read(struct cdi_dma_handle* handle);
53 /**
54 * Schreibt Daten per DMA
56 * @return 0 bei Erfolg, -1 im Fehlerfall
58 int cdi_dma_write(struct cdi_dma_handle* handle);
60 /**
61 * Schliesst das DMA-Handle wieder
63 * @return 0 bei Erfolg, -1 im Fehlerfall
65 int cdi_dma_close(struct cdi_dma_handle* handle);
67 #endif