File: /usr/src/linux/include/asm-sparc/asmmacro.h

1     /* asmmacro.h: Assembler macros.
2      *
3      * Copyright (C) 1996 David S. Miller (davem@caipfs.rutgers.edu)
4      */
5     
6     #ifndef _SPARC_ASMMACRO_H
7     #define _SPARC_ASMMACRO_H
8     
9     #include <linux/config.h>
10     #include <asm/btfixup.h>
11     #include <asm/asi.h>
12     
13     #define GET_PROCESSOR4M_ID(reg) \
14     	rd	%tbr, %reg; \
15     	srl	%reg, 12, %reg; \
16     	and	%reg, 3, %reg;
17     
18     #define GET_PROCESSOR4D_ID(reg) \
19     	lda	[%g0] ASI_M_VIKING_TMP1, %reg;
20     
21     /* Blackbox */
22     #define GET_PROCESSOR_ID(reg) \
23     	sethi	%hi(___b_smp_processor_id), %reg; \
24     	sethi	%hi(boot_cpu_id), %reg; \
25     	ldub	[%reg + %lo(boot_cpu_id)], %reg;
26     
27     #define GET_PROCESSOR_MID(reg, tmp) \
28     	rd	%tbr, %reg; \
29     	sethi	%hi(C_LABEL(mid_xlate)), %tmp; \
30     	srl	%reg, 12, %reg; \
31     	or	%tmp, %lo(C_LABEL(mid_xlate)), %tmp; \
32     	and	%reg, 3, %reg; \
33     	ldub	[%tmp + %reg], %reg;
34     
35     #define GET_PROCESSOR_OFFSET(reg, tmp) \
36     	GET_PROCESSOR_ID(reg) \
37     	sethi	%hi(C_LABEL(cpu_offset)), %tmp; \
38     	sll	%reg, 2, %reg; \
39     	or	%tmp, %lo(C_LABEL(cpu_offset)), %tmp; \
40     	ld	[%tmp + %reg], %reg;
41     
42     /* All trap entry points _must_ begin with this macro or else you
43      * lose.  It makes sure the kernel has a proper window so that
44      * c-code can be called.
45      */
46     #define SAVE_ALL_HEAD \
47     	sethi	%hi(trap_setup), %l4; \
48     	jmpl	%l4 + %lo(trap_setup), %l6;
49     #define SAVE_ALL \
50     	SAVE_ALL_HEAD \
51     	 nop;
52     
53     /* All traps low-level code here must end with this macro. */
54     #define RESTORE_ALL b ret_trap_entry; clr %l6;
55     
56     /* sun4 probably wants half word accesses to ASI_SEGMAP, while sun4c+
57        likes byte accesses. These are to avoid ifdef mania. */
58     
59     #ifdef CONFIG_SUN4
60     #define lduXa	lduha
61     #define stXa	stha
62     #else
63     #define lduXa	lduba
64     #define stXa	stba
65     #endif
66     
67     #endif /* !(_SPARC_ASMMACRO_H) */
68