diff options
Diffstat (limited to 'driver/dma.c')
-rw-r--r-- | driver/dma.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/driver/dma.c b/driver/dma.c new file mode 100644 index 0000000..dc48de2 --- /dev/null +++ b/driver/dma.c @@ -0,0 +1,31 @@ +/* dma.c - DMA functions */ + +#include <system.h> +#include <dma.h> + +void dma_enable(unsigned char dma_nr) { + OUT_PORT(dma_nr & 3, PORT_DMA_MASK); +} + +void dma_disable(unsigned char dma_nr) { + OUT_PORT((dma_nr & 3) | 4, PORT_DMA_MASK); +} + +void dma_set_base_addr(unsigned char dma_nr, void *addr) { + OUT_PORT((unsigned long)addr & 0xFF, (dma_nr & 3)*2); + OUT_PORT(((unsigned long)addr >> 8) & 0xFF, (dma_nr & 3)*2); + OUT_PORT(((unsigned long)addr >> 16) & 0xFF, dma_page_ports[dma_nr & 3]); +} + +void dma_set_word_count(unsigned char dma_nr, unsigned short words) { + OUT_PORT(words & 0xFF, ((dma_nr & 3)*2)+1); + OUT_PORT((words >> 8) & 0xFF, ((dma_nr & 3)*2)+1); +} + +void dma_set_mode(unsigned char dma_nr, unsigned char mode) { + OUT_PORT(mode | (dma_nr & 3), PORT_DMA_MODE); +} + +void dma_clear_ff() { + OUT_PORT(0, PORT_DMA_FF); +} |