summaryrefslogtreecommitdiff
path: root/sys/arch/mvme88k/stand/libsa/dvma.c
blob: 11526106c2affe76d8d7b8bb3ffa71c5ddff8e10 (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

/*
 * The easiest way to deal with the need for DVMA mappings is
 * to just map the first four megabytes of RAM into DVMA space.
 * That way, dvma_mapin can just compute the DVMA alias address,
 * and dvma_mapout does nothing.
 */

#include <sys/param.h>

#define	DVMA_BASE 0x00000000
#define	DVMA_MASK 0x00ffFFff
#define DVMA_MAPLEN 0x400000	/* 4 MB */

void
dvma_init()
{
#if 0
	int segva, sme;

	for (segva = 0; segva < DVMA_MAPLEN; segva += NBSG) {
		sme = get_segmap(segva);
		set_segmap((DVMA_BASE | segva), sme);
	}
#endif
}

/* Convert a local address to a DVMA address. */
char *
dvma_mapin(char *addr, int len)
{
	int va = (int)addr;

	va |= DVMA_BASE;
	return ((char *) va);
}

/* Convert a DVMA address to a local address. */
char *
dvma_mapout(char *dmabuf, int len)
{
	if (dmabuf < (char*)DVMA_BASE)
		panic("dvma_mapout");
	return (dmabuf - DVMA_BASE);
}

extern char *alloc(int len);
char *
dvma_alloc(int len)
{
	char *mem;

	mem = alloc(len);
	if (!mem)
		return(mem);
	return(dvma_mapin(mem, len));
}

extern void free(void *ptr, int len);
void
dvma_free(char *dvma, int len)
{
	char *mem;

	mem = dvma_mapout(dvma, len);
	if (mem)
		free(mem, len);
}