summaryrefslogtreecommitdiffstats
path: root/driver/dma.c
blob: dc48de2ad2971fdf493c6127255fcc41b39c1f84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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);
}