summaryrefslogtreecommitdiff
path: root/sys/arch/alpha/isa/isafcns_jensen.c
blob: 3b0971d7375bedd173a6b9e04173ce6849444c22 (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*	$OpenBSD: isafcns_jensen.c,v 1.7 2002/06/25 21:33:21 miod Exp $	*/
/*	$NetBSD: isafcns_jensen.c,v 1.4 1996/10/13 02:59:54 christos Exp $	*/

/*
 * Copyright (c) 1995, 1996 Carnegie-Mellon University.
 * All rights reserved.
 *
 * Author: Chris G. Demetriou
 *
 * Permission to use, copy, modify and distribute this software and
 * its documentation is hereby granted, provided that both the copyright
 * notice and this permission notice appear in all copies of the
 * software, derivative works or modified versions, and any portions
 * thereof, and that both notices appear in supporting documentation.
 *
 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
 *
 * Carnegie Mellon requests users of this software to return to
 *
 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
 *  School of Computer Science
 *  Carnegie Mellon University
 *  Pittsburgh PA 15213-3890
 *
 * any improvements or extensions that they make and grant Carnegie the
 * rights to redistribute these changes.
 */

#include <sys/types.h>
#include <machine/pio.h>
#include <machine/pte.h>

static u_int8_t		jensen_inb(int port);
/* static void		jensen_insb(int port, void *addr, int cnt); */
static u_int16_t	jensen_inw(int port);
/* static void		jensen_insw(int port, void *addr, int cnt); */
u_int32_t		jensen_inl(int port);
/* static void		jensen_insl(int port, void *addr, int cnt); */

static void		jensen_outb(int port, u_int8_t datum);
/* static void		jensen_outsb(int port, void *addr, int cnt); */
static void		jensen_outw(int port, u_int16_t datum);
/* static void		jensen_outsw(int port, void *addr, int cnt); */
static void		jensen_outl(int port, u_int32_t datum);
/* static void		jensen_outsl(int port, void *addr, int cnt); */

struct alpha_isafcndesc jensen_isafcns = {
	jensen_inb,	0 /* jensen_insb */,
	jensen_inw,	0 /* jensen_insw */,
	jensen_inl,	0 /* jensen_insl */,
	jensen_outb,	0 /* jensen_outsb */,
	jensen_outw,	0 /* jensen_outsw */,
	jensen_outl,	0 /* jensen_outsl */,
};

u_int8_t
jensen_inb(ioaddr)
	int ioaddr;
{
	u_int32_t *port, val;
	u_int8_t rval;
	int offset;

	offset = ioaddr & 3;
	port = (int32_t *)phystok0seg(0x300000000L | 0 << 5 | ioaddr << 7);
	val = *port;
	rval = ((val) >> (8 * offset)) & 0xff;
	rval = val & 0xff;

printf("inb(0x%x) => 0x%x @ %p => 0x%x\n", ioaddr, val, port, rval);

	return rval;
}

u_int16_t
jensen_inw(ioaddr)
	int ioaddr;
{
	u_int32_t *port, val;
	u_int16_t rval;
	int offset;

	offset = ioaddr & 3;
	port = (int32_t *)phystok0seg(0x300000000L | 1 << 5 | ioaddr << 7);
	val = *port;
	rval = ((val) >> (8 * offset)) & 0xffff;
	rval = val & 0xffff;

printf("inw(0x%x) => 0x%x @ %p => 0x%x", ioaddr, val, port, rval);

	return rval;
}

u_int32_t
jensen_inl(ioaddr)
	int ioaddr;
{
	u_int32_t *port, val;
	u_int32_t rval;
	int offset;

	offset = ioaddr & 3;
	port = (int32_t *)phystok0seg(0x300000000L | 3 << 5 | ioaddr << 7);
	val = *port;
	rval = ((val) >> (8 * offset)) & 0xffffffff;
	rval = val & 0xffffffff;

printf("inl(0x%x) => 0x%x @ %p => 0x%x\n", ioaddr, val, port, rval);

	return rval;
}

void
jensen_outb(ioaddr, val)
	int ioaddr;
	u_int8_t val;
{
	u_int32_t *port, nval;
	int offset;

	offset = ioaddr & 3;
	nval = val /*<< (8 * offset)*/;
	port = (int32_t *)phystok0seg(0x300000000L | 0 << 5 | ioaddr << 7);

printf("outb(0x%x, 0x%x) => 0x%x @ %p\n", ioaddr, val, nval, port);

	*port = nval;
}

void
jensen_outw(ioaddr, val)
	int ioaddr;
	u_int16_t val;
{
	u_int32_t *port, nval;
	int offset;

	offset = ioaddr & 3;
	nval = val /*<< (8 * offset)*/;
	port = (int32_t *)phystok0seg(0x300000000L | 1 << 5 | ioaddr << 7);

printf("outb(0x%x, 0x%x) => 0x%x @ %p\n", ioaddr, val, nval, port);

	*port = nval;
}

void
jensen_outl(ioaddr, val)
	int ioaddr;
	u_int32_t val;
{
	u_int32_t *port, nval;
	int offset;

	offset = ioaddr & 3;
	nval = val /*<< (8 * offset)*/;
	port = (int32_t *)phystok0seg(0x300000000L | 3 << 5 | ioaddr << 7);

printf("outb(0x%x, 0x%x) => 0x%x @ %p\n", ioaddr, val, nval, port);

	*port = nval;
}