Deleted Added
full compact
cpufunc.h (108730) cpufunc.h (114208)
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 unchanged lines hidden (view full) ---

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 *
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 unchanged lines hidden (view full) ---

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 108730 2003-01-05 21:40:45Z marcel $
26 * $FreeBSD: head/sys/ia64/include/cpufunc.h 114208 2003-04-29 09:50:03Z marcel $
27 */
28
29#ifndef _MACHINE_CPUFUNC_H_
30#define _MACHINE_CPUFUNC_H_
31
32#ifdef _KERNEL
33
34#include <sys/types.h>

--- 7 unchanged lines hidden (view full) ---

42static __inline void
43breakpoint(void)
44{
45 __asm __volatile("break 0x80100"); /* XXX use linux value */
46}
47
48#endif
49
27 */
28
29#ifndef _MACHINE_CPUFUNC_H_
30#define _MACHINE_CPUFUNC_H_
31
32#ifdef _KERNEL
33
34#include <sys/types.h>

--- 7 unchanged lines hidden (view full) ---

42static __inline void
43breakpoint(void)
44{
45 __asm __volatile("break 0x80100"); /* XXX use linux value */
46}
47
48#endif
49
50extern u_int64_t ia64_port_base;
50extern uint64_t ia64_port_base;
51#define __MEMIO_ADDR(x) (__volatile void*)(IA64_PHYS_TO_RR6(x))
52#define __PIO_ADDR(x) (__volatile void*)(ia64_port_base | \
53 (((x) & 0xFFFC) << 10) | ((x) & 0xFFF))
51
54
52static __inline volatile void *
53ia64_port_address(u_int port)
55/*
56 * I/O port reads with ia32 semantics.
57 */
58static __inline uint8_t
59inb(unsigned int port)
54{
60{
55 return (volatile void *)(ia64_port_base
56 | ((port >> 2) << 12)
57 | (port & ((1 << 12) - 1)));
58}
59
60static __inline volatile void *
61ia64_memory_address(u_int64_t addr)
62{
63 return (volatile void *) IA64_PHYS_TO_RR6(addr);
64}
65
66static __inline u_int8_t
67inb(u_int port)
68{
69 volatile u_int8_t *p = ia64_port_address(port);
70 u_int8_t v = *p;
61 __volatile uint8_t *p;
62 uint8_t v;
63 p = __PIO_ADDR(port);
71 ia64_mf();
64 ia64_mf();
72 return v;
73}
74
75static __inline u_int16_t
76inw(u_int port)
77{
78 volatile u_int16_t *p = ia64_port_address(port);
79 u_int16_t v = *p;
65 v = *p;
66 ia64_mf_a();
80 ia64_mf();
67 ia64_mf();
81 return v;
68 return (v);
82}
83
69}
70
84static __inline u_int32_t
85inl(u_int port)
71static __inline uint16_t
72inw(unsigned int port)
86{
73{
87 volatile u_int32_t *p = ia64_port_address(port);
88 u_int32_t v = *p;
74 __volatile uint16_t *p;
75 uint16_t v;
76 p = __PIO_ADDR(port);
89 ia64_mf();
77 ia64_mf();
90 return v;
91}
92
93static __inline void
94insb(u_int port, void *addr, size_t count)
95{
96 u_int8_t *p = addr;
97 while (count--)
98 *p++ = inb(port);
99}
100
101static __inline void
102insw(u_int port, void *addr, size_t count)
103{
104 u_int16_t *p = addr;
105 while (count--)
106 *p++ = inw(port);
107}
108
109static __inline void
110insl(u_int port, void *addr, size_t count)
111{
112 u_int32_t *p = addr;
113 while (count--)
114 *p++ = inl(port);
115}
116
117static __inline void
118outb(u_int port, u_int8_t data)
119{
120 volatile u_int8_t *p = ia64_port_address(port);
121 *p = data;
78 v = *p;
79 ia64_mf_a();
122 ia64_mf();
80 ia64_mf();
81 return (v);
123}
124
82}
83
125static __inline void
126outw(u_int port, u_int16_t data)
84static __inline uint32_t
85inl(unsigned int port)
127{
86{
128 volatile u_int16_t *p = ia64_port_address(port);
129 *p = data;
87 volatile uint32_t *p;
88 uint32_t v;
89 p = __PIO_ADDR(port);
130 ia64_mf();
90 ia64_mf();
131}
132
133static __inline void
134outl(u_int port, u_int32_t data)
135{
136 volatile u_int32_t *p = ia64_port_address(port);
137 *p = data;
91 v = *p;
92 ia64_mf_a();
138 ia64_mf();
93 ia64_mf();
94 return (v);
139}
140
141static __inline void
95}
96
97static __inline void
142outsb(u_int port, const void *addr, size_t count)
98insb(unsigned int port, void *addr, size_t count)
143{
99{
144 const u_int8_t *p = addr;
100 uint8_t *buf = addr;
145 while (count--)
101 while (count--)
146 outb(port, *p++);
102 *buf++ = inb(port);
147}
148
149static __inline void
103}
104
105static __inline void
150outsw(u_int port, const void *addr, size_t count)
106insw(unsigned int port, void *addr, size_t count)
151{
107{
152 const u_int16_t *p = addr;
108 uint16_t *buf = addr;
153 while (count--)
109 while (count--)
154 outw(port, *p++);
110 *buf++ = inw(port);
155}
156
157static __inline void
111}
112
113static __inline void
158outsl(u_int port, const void *addr, size_t count)
114insl(unsigned int port, void *addr, size_t count)
159{
115{
160 const u_int32_t *p = addr;
116 uint32_t *buf = addr;
161 while (count--)
117 while (count--)
162 outl(port, *p++);
118 *buf++ = inl(port);
163}
164
119}
120
165static __inline u_int8_t
166readb(u_int64_t addr)
167{
168 volatile u_int8_t *p = ia64_memory_address(addr);
169 u_int8_t v = *p;
170 ia64_mf();
171 return v;
172}
173
174static __inline u_int16_t
175readw(u_int64_t addr)
176{
177 volatile u_int16_t *p = ia64_memory_address(addr);
178 u_int16_t v = *p;
179 ia64_mf();
180 return v;
181}
182
183static __inline u_int32_t
184readl(u_int64_t addr)
185{
186 volatile u_int32_t *p = ia64_memory_address(addr);
187 u_int32_t v = *p;
188 ia64_mf();
189 return v;
190}
191
192static __inline void
121static __inline void
193writeb(u_int64_t addr, u_int8_t data)
122outb(unsigned int port, uint8_t data)
194{
123{
195 volatile u_int8_t *p = ia64_memory_address(addr);
124 volatile uint8_t *p;
125 p = __PIO_ADDR(port);
126 ia64_mf();
196 *p = data;
127 *p = data;
128 ia64_mf_a();
197 ia64_mf();
198}
199
200static __inline void
129 ia64_mf();
130}
131
132static __inline void
201writew(u_int64_t addr, u_int16_t data)
133outw(unsigned int port, uint16_t data)
202{
134{
203 volatile u_int16_t *p = ia64_memory_address(addr);
135 volatile uint16_t *p;
136 p = __PIO_ADDR(port);
137 ia64_mf();
204 *p = data;
138 *p = data;
139 ia64_mf_a();
205 ia64_mf();
206}
207
208static __inline void
140 ia64_mf();
141}
142
143static __inline void
209writel(u_int64_t addr, u_int32_t data)
144outl(unsigned int port, uint32_t data)
210{
145{
211 volatile u_int32_t *p = ia64_memory_address(addr);
146 volatile uint32_t *p;
147 p = __PIO_ADDR(port);
148 ia64_mf();
212 *p = data;
149 *p = data;
150 ia64_mf_a();
213 ia64_mf();
214}
215
216static __inline void
151 ia64_mf();
152}
153
154static __inline void
217memcpy_fromio(u_int8_t *addr, u_int64_t ofs, size_t count)
155outsb(unsigned int port, const void *addr, size_t count)
218{
156{
219 volatile u_int8_t *p = ia64_memory_address(ofs);
157 const uint8_t *buf = addr;
220 while (count--)
158 while (count--)
221 *addr++ = *p++;
159 outb(port, *buf++);
222}
223
224static __inline void
160}
161
162static __inline void
225memcpy_io(u_int64_t dst, u_int64_t src, size_t count)
163outsw(unsigned int port, const void *addr, size_t count)
226{
164{
227 volatile u_int8_t *dp = ia64_memory_address(dst);
228 volatile u_int8_t *sp = ia64_memory_address(src);
165 const uint16_t *buf = addr;
229 while (count--)
166 while (count--)
230 *dp++ = *sp++;
167 outw(port, *buf++);
231}
232
233static __inline void
168}
169
170static __inline void
234memcpy_toio(u_int64_t ofs, u_int8_t *addr, size_t count)
171outsl(unsigned int port, const void *addr, size_t count)
235{
172{
236 volatile u_int8_t *p = ia64_memory_address(ofs);
173 const uint32_t *buf = addr;
237 while (count--)
174 while (count--)
238 *p++ = *addr++;
175 outl(port, *buf++);
239}
240
241static __inline void
176}
177
178static __inline void
242memset_io(u_int64_t ofs, u_int8_t value, size_t count)
243{
244 volatile u_int8_t *p = ia64_memory_address(ofs);
245 while (count--)
246 *p++ = value;
247}
248
249static __inline void
250memsetw(u_int16_t *addr, int val, size_t size)
251{
252 while (size--)
253 *addr++ = val;
254}
255
256static __inline void
257memsetw_io(u_int64_t ofs, u_int16_t value, size_t count)
258{
259 volatile u_int16_t *p = ia64_memory_address(ofs);
260 while (count--)
261 *p++ = value;
262}
263
264static __inline void
265disable_intr(void)
266{
179disable_intr(void)
180{
267 __asm __volatile ("rsm psr.i;;");
181 __asm __volatile ("rsm psr.i");
268}
269
270static __inline void
271enable_intr(void)
272{
182}
183
184static __inline void
185enable_intr(void)
186{
273 __asm __volatile (";; ssm psr.i;; srlz.d");
187 __asm __volatile ("ssm psr.i;; srlz.d");
274}
275
276static __inline register_t
277intr_disable(void)
278{
279 register_t psr;
188}
189
190static __inline register_t
191intr_disable(void)
192{
193 register_t psr;
280
281 __asm __volatile ("mov %0=psr;;" : "=r" (psr));
194 __asm __volatile ("mov %0=psr;;" : "=r"(psr));
282 disable_intr();
283 return (psr);
284}
285
286static __inline void
287intr_restore(critical_t psr)
288{
195 disable_intr();
196 return (psr);
197}
198
199static __inline void
200intr_restore(critical_t psr)
201{
289 __asm __volatile ("mov psr.l=%0;; srlz.d" :: "r" (psr));
202 __asm __volatile ("mov psr.l=%0;; srlz.d" :: "r"(psr));
290}
291
292#endif /* _KERNEL */
293
294#endif /* !_MACHINE_CPUFUNC_H_ */
203}
204
205#endif /* _KERNEL */
206
207#endif /* !_MACHINE_CPUFUNC_H_ */