xref: /original-bsd/sys/sparc/sparc/asm.h (revision 3705696b)
1 /*
2  * Copyright (c) 1992, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This software was developed by the Computer Systems Engineering group
6  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7  * contributed to Berkeley.
8  *
9  * All advertising materials mentioning features or use of this software
10  * must display the following acknowledgement:
11  *	This product includes software developed by the University of
12  *	California, Lawrence Berkeley Laboratory.
13  *
14  * %sccs.include.redist.c%
15  *
16  *	@(#)asm.h	8.1 (Berkeley) 06/11/93
17  *
18  * from: $Header: asm.h,v 1.5 92/11/26 03:04:42 torek Exp $
19  */
20 
21 /*
22  * GCC __asm constructs for doing assembly stuff.
23  */
24 
25 /*
26  * ``Routines'' to load and store from/to alternate address space.
27  * The location can be a variable, the asi value (address space indicator)
28  * must be a constant.
29  *
30  * N.B.: You can put as many special functions here as you like, since
31  * they cost no kernel space or time if they are not used.
32  *
33  * These were static inline functions, but gcc screws up the constraints
34  * on the address space identifiers (the "n"umeric value part) because
35  * it inlines too late, so we have to use the funny valued-macro syntax.
36  */
37 
38 /* load byte from alternate address space */
39 #define	lduba(loc, asi) ({ \
40 	register int _lduba_v; \
41 	__asm __volatile("lduba [%1]%2,%0" : "=r" (_lduba_v) : \
42 	    "r" ((int)(loc)), "n" (asi)); \
43 	_lduba_v; \
44 })
45 
46 /* load int from alternate address space */
47 #define	lda(loc, asi) ({ \
48 	register int _lda_v; \
49 	__asm __volatile("lda [%1]%2,%0" : "=r" (_lda_v) : \
50 	    "r" ((int)(loc)), "n" (asi)); \
51 	_lda_v; \
52 })
53 
54 /* store byte to alternate address space */
55 #define	stba(loc, asi, value) ({ \
56 	__asm __volatile("stba %0,[%1]%2" : : \
57 	    "r" ((int)(value)), "r" ((int)(loc)), "n" (asi)); \
58 })
59 
60 /* store int to alternate address space */
61 #define	sta(loc, asi, value) ({ \
62 	__asm __volatile("sta %0,[%1]%2" : : \
63 	    "r" ((int)(value)), "r" ((int)(loc)), "n" (asi)); \
64 })
65