summaryrefslogtreecommitdiff
path: root/minix/drivers/audio/trident/io.h
blob: aacf26223da8872b1f1b79219cf474cb97a5107d (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef _IO_H
#define _IO_H

#include <sys/types.h>
#include <minix/syslib.h>
#include "trident.h"

/* I/O function */
static u8_t my_inb(u32_t port) {
	u32_t value;
	int r;
#ifdef DMA_BASE_IOMAP
	value = *(volatile u8_t *)(port);
#else
	if ((r = sys_inb(port, &value)) != OK)
		printf("SDR: sys_inb failed: %d\n", r);
#endif
	return (u8_t)value;
}
#define sdr_in8(port, offset) (my_inb((port) + (offset)))

static u16_t my_inw(u32_t port) {
	u32_t value;
	int r;
#ifdef DMA_BASE_IOMAP
	value = *(volatile u16_t *)(port);
#else
	if ((r = sys_inw(port, &value)) != OK)
		printf("SDR: sys_inw failed: %d\n", r);
#endif
	return (u16_t)value;
}
#define sdr_in16(port, offset) (my_inw((port) + (offset)))

static u32_t my_inl(u32_t port) {
	u32_t value;
	int r;
#ifdef DMA_BASE_IOMAP
	value = *(volatile u32_t *)(port);
#else
	if ((r = sys_inl(port, &value)) != OK)
		printf("SDR: sys_inl failed: %d\n", r);
#endif
	return value;
}
#define sdr_in32(port, offset) (my_inl((port) + (offset)))

static void my_outb(u32_t port, u32_t value) {
	int r;
#ifdef DMA_BASE_IOMAP
	*(volatile u8_t *)(port) = value;
#else
	if ((r = sys_outb(port, (u8_t)value)) != OK)
		printf("SDR: sys_outb failed: %d\n", r);
#endif
}
#define sdr_out8(port, offset, value) \
				(my_outb(((port) + (offset)), (value)))

static void my_outw(u32_t port, u32_t value) {
	int r;
#ifdef DMA_BASE_IOMAP
	*(volatile u16_t *)(port) = value;
#else
	if ((r = sys_outw(port, (u16_t)value)) != OK)
		printf("SDR: sys_outw failed: %d\n", r);
#endif
}
#define sdr_out16(port, offset, value) \
				(my_outw(((port) + (offset)), (value)))

static void my_outl(u32_t port, u32_t value) {
	int r;
#ifdef DMA_BASE_IOMAP
	*(volatile u32_t *)(port) = value;
#else
	if ((r = sys_outl(port, value)) != OK)
		printf("SDR: sys_outl failed: %d\n", r);
#endif
}
#define sdr_out32(port, offset, value) \
				(my_outl(((port) + (offset)), (value)))

#endif