cpufunc.h revision 66458
1/*-
2 * Copyright (c) 1998 Doug Rabson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/ia64/include/cpufunc.h 66458 2000-09-29 13:46:07Z dfr $
27 */
28
29#ifndef _MACHINE_CPUFUNC_H_
30#define _MACHINE_CPUFUNC_H_
31
32#ifdef _KERNEL
33
34#include <sys/types.h>
35
36#ifdef __GNUC__
37
38static __inline void
39breakpoint(void)
40{
41	__asm __volatile("break 0x80100"); /* XXX use linux value */
42}
43
44#endif
45
46static __inline u_int8_t
47inb(u_int port)
48{
49	return 0;		/* TODO: implement this */
50}
51
52static __inline u_int16_t
53inw(u_int port)
54{
55	return 0;		/* TODO: implement this */
56}
57
58static __inline u_int32_t
59inl(u_int port)
60{
61	return 0;		/* TODO: implement this */
62}
63
64static __inline void
65insb(u_int port, void *addr, size_t count)
66{
67	u_int8_t *p = addr;
68	while (count--)
69		*p++ = inb(port);
70}
71
72static __inline void
73insw(u_int port, void *addr, size_t count)
74{
75	u_int16_t *p = addr;
76	while (count--)
77		*p++ = inw(port);
78}
79
80static __inline void
81insl(u_int port, void *addr, size_t count)
82{
83	u_int32_t *p = addr;
84	while (count--)
85		*p++ = inl(port);
86}
87
88static __inline void
89outb(u_int port, u_int8_t data)
90{
91	return;			/* TODO: implement this */
92}
93
94static __inline void
95outw(u_int port, u_int16_t data)
96{
97	return;			/* TODO: implement this */
98}
99
100static __inline void
101outl(u_int port, u_int32_t data)
102{
103	return;			/* TODO: implement this */
104}
105
106static __inline void
107outsb(u_int port, const void *addr, size_t count)
108{
109	const u_int8_t *p = addr;
110	while (count--)
111		outb(port, *p++);
112}
113
114static __inline void
115outsw(u_int port, const void *addr, size_t count)
116{
117	const u_int16_t *p = addr;
118	while (count--)
119		outw(port, *p++);
120}
121
122static __inline void
123outsl(u_int port, const void *addr, size_t count)
124{
125	const u_int32_t *p = addr;
126	while (count--)
127		outl(port, *p++);
128}
129
130static __inline u_int8_t
131readb(u_int addr)
132{
133	return 0;		/* TODO: implement this */
134}
135
136static __inline u_int16_t
137readw(u_int addr)
138{
139	return 0;		/* TODO: implement this */
140}
141
142static __inline u_int32_t
143readl(u_int addr)
144{
145	return 0;		/* TODO: implement this */
146}
147
148static __inline void
149writeb(u_int addr, u_int8_t data)
150{
151	return;			/* TODO: implement this */
152}
153
154static __inline void
155writew(u_int addr, u_int16_t data)
156{
157	return;			/* TODO: implement this */
158}
159
160static __inline void
161writel(u_int addr, u_int32_t data)
162{
163	return;			/* TODO: implement this */
164}
165
166/*
167 * Bogus interrupt manipulation
168 */
169static __inline void
170disable_intr(void)
171{
172	__asm __volatile ("rsm psr.i;;");
173}
174
175static __inline void
176enable_intr(void)
177{
178	__asm __volatile (";; ssm psr.i;; srlz.d");
179}
180
181static __inline u_int
182save_intr(void)
183{
184	u_int psr;
185	__asm __volatile ("mov %0=psr;;" : "=r" (psr));
186	return psr;
187}
188
189static __inline void
190restore_intr(u_int psr)
191{
192	__asm __volatile ("mov psr.l=%0;; srlz.d" :: "r" (psr));
193}
194
195#endif /* _KERNEL */
196
197#endif /* !_MACHINE_CPUFUNC_H_ */
198