bwx.h revision 1.2 1 /* $NetBSD: bwx.h,v 1.2 2000/03/05 18:46:15 thorpej Exp $ */
2
3 /*-
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the NetBSD
22 * Foundation, Inc. and its contributors.
23 * 4. Neither the name of The NetBSD Foundation nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40 #ifndef _ALPHA_BWX_H_
41 #define _ALPHA_BWX_H_
42
43 /*
44 * Alpha Byte/Word Extension instructions.
45 *
46 * These instructions are available on EV56 (21164A) and later processors.
47 *
48 * See "Alpha Architecture Handbook, Version 3", DEC order number EC-QD2KB-TE.
49 */
50
51 static __inline u_int8_t alpha_ldbu __P((__volatile u_int8_t *))
52 __attribute__((__unused__));
53 static __inline u_int16_t alpha_ldwu __P((__volatile u_int16_t *))
54 __attribute__((__unused__));
55 static __inline void alpha_stb __P((__volatile u_int8_t *, u_int8_t))
56 __attribute__((__unused__));
57 static __inline void alpha_stw __P((__volatile u_int16_t *, u_int16_t))
58 __attribute__((__unused__));
59 static __inline u_int8_t alpha_sextb __P((u_int8_t))
60 __attribute__((__unused__));
61 static __inline u_int16_t alpha_sextw __P((u_int16_t))
62 __attribute__((__unused__));
63
64 static __inline u_int8_t
65 alpha_ldbu(__volatile u_int8_t *a0)
66 {
67 u_int8_t v0;
68
69 __asm __volatile("ldbu %0, %1"
70 : "=r" (v0)
71 : "m" (*a0));
72
73 return (v0);
74 }
75
76 static __inline u_int16_t
77 alpha_ldwu(__volatile u_int16_t *a0)
78 {
79 u_int16_t v0;
80
81 __asm __volatile("ldwu %0, %1"
82 : "=r" (v0)
83 : "m" (*a0));
84
85 return (v0);
86 }
87
88 static __inline void
89 alpha_stb(__volatile u_int8_t *a0, u_int8_t a1)
90 {
91
92 __asm __volatile("stb %1, %0"
93 : "=m" (*a0)
94 : "r" (a1));
95 }
96
97 static __inline void
98 alpha_stw(__volatile u_int16_t *a0, u_int16_t a1)
99 {
100
101 __asm __volatile("stw %1, %0"
102 : "=m" (*a0)
103 : "r" (a1));
104 }
105
106 static __inline u_int8_t
107 alpha_sextb(u_int8_t a0)
108 {
109 u_int8_t v0;
110
111 __asm __volatile("sextb %1, %0"
112 : "=r" (v0)
113 : "r" (a0));
114
115 return (v0);
116 }
117
118 static __inline u_int16_t
119 alpha_sextw(u_int16_t a0)
120 {
121 u_int16_t v0;
122
123 __asm __volatile("sextw %1, %0"
124 : "=r" (v0)
125 : "r" (a0));
126
127 return (v0);
128 }
129
130 #endif /* _ALPHA_BWX_H_ */
131