Home | History | Annotate | Line # | Download | only in include
asm.h revision 1.12.2.2
      1  1.12.2.1    skrll /*	$NetBSD: asm.h,v 1.12.2.2 2004/09/18 14:39:11 skrll Exp $	*/
      2       1.1       ws 
      3       1.1       ws /*
      4       1.1       ws  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
      5       1.1       ws  * Copyright (C) 1995, 1996 TooLs GmbH.
      6       1.1       ws  * All rights reserved.
      7       1.1       ws  *
      8       1.1       ws  * Redistribution and use in source and binary forms, with or without
      9       1.1       ws  * modification, are permitted provided that the following conditions
     10       1.1       ws  * are met:
     11       1.1       ws  * 1. Redistributions of source code must retain the above copyright
     12       1.1       ws  *    notice, this list of conditions and the following disclaimer.
     13       1.1       ws  * 2. Redistributions in binary form must reproduce the above copyright
     14       1.1       ws  *    notice, this list of conditions and the following disclaimer in the
     15       1.1       ws  *    documentation and/or other materials provided with the distribution.
     16       1.1       ws  * 3. All advertising materials mentioning features or use of this software
     17       1.1       ws  *    must display the following acknowledgement:
     18       1.1       ws  *	This product includes software developed by TooLs GmbH.
     19       1.1       ws  * 4. The name of TooLs GmbH may not be used to endorse or promote products
     20       1.1       ws  *    derived from this software without specific prior written permission.
     21       1.1       ws  *
     22       1.1       ws  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
     23       1.1       ws  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24       1.1       ws  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25       1.1       ws  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     26       1.1       ws  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     27       1.1       ws  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     28       1.1       ws  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     29       1.1       ws  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     30       1.1       ws  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     31       1.1       ws  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32       1.1       ws  */
     33       1.1       ws 
     34       1.1       ws #ifndef _PPC_ASM_H_
     35       1.1       ws #define _PPC_ASM_H_
     36       1.1       ws 
     37       1.1       ws #ifdef PIC
     38       1.1       ws #define PIC_PROLOGUE	XXX
     39       1.1       ws #define PIC_EPILOGUE	XXX
     40       1.4   tsubai #define PIC_PLT(x)	x@plt
     41       1.1       ws #ifdef	__STDC__
     42       1.1       ws #define PIC_GOT(x)	XXX
     43       1.1       ws #define PIC_GOTOFF(x)	XXX
     44       1.1       ws #else	/* not __STDC__ */
     45       1.1       ws #define PIC_GOT(x)	XXX
     46       1.1       ws #define PIC_GOTOFF(x)	XXX
     47       1.1       ws #endif	/* __STDC__ */
     48       1.1       ws #else
     49       1.1       ws #define PIC_PROLOGUE
     50       1.1       ws #define PIC_EPILOGUE
     51       1.1       ws #define PIC_PLT(x)	x
     52       1.1       ws #define PIC_GOT(x)	x
     53       1.1       ws #define PIC_GOTOFF(x)	x
     54       1.1       ws #endif
     55       1.1       ws 
     56       1.3  thorpej #define	_C_LABEL(x)	x
     57       1.1       ws #define	_ASM_LABEL(x)	x
     58       1.1       ws 
     59       1.3  thorpej #define	_GLOBAL(x) \
     60       1.3  thorpej 	.data; .align 2; .globl x; x:
     61       1.3  thorpej 
     62       1.1       ws #define _ENTRY(x) \
     63       1.1       ws 	.text; .align 2; .globl x; .type x,@function; x:
     64       1.1       ws 
     65       1.2      jtc #ifdef GPROF
     66       1.6   tsubai # define _PROF_PROLOGUE	mflr 0; stw 0,4(1); bl _mcount
     67       1.1       ws #else
     68       1.1       ws # define _PROF_PROLOGUE
     69       1.1       ws #endif
     70       1.1       ws 
     71       1.1       ws #define	ENTRY(y)	_ENTRY(_C_LABEL(y)); _PROF_PROLOGUE
     72       1.9  thorpej #define	ENTRY_NOPROFILE(y) _ENTRY(_C_LABEL(y))
     73       1.9  thorpej 
     74       1.1       ws #define	ASENTRY(y)	_ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE
     75       1.3  thorpej #define	GLOBAL(y)	_GLOBAL(_C_LABEL(y))
     76       1.1       ws 
     77       1.1       ws #define	ASMSTR		.asciz
     78       1.1       ws 
     79       1.1       ws #define RCSID(x)	.text; .asciz x
     80       1.7   kleink 
     81       1.7   kleink #ifdef __ELF__
     82       1.7   kleink #define	WEAK_ALIAS(alias,sym)						\
     83       1.7   kleink 	.weak alias;							\
     84       1.7   kleink 	alias = sym
     85       1.7   kleink #endif
     86       1.5  thorpej 
     87       1.5  thorpej #ifdef __STDC__
     88       1.5  thorpej #define	WARN_REFERENCES(_sym,_msg)				\
     89       1.5  thorpej 	.section .gnu.warning. ## _sym ; .ascii _msg ; .text
     90       1.5  thorpej #else
     91       1.5  thorpej #define	WARN_REFERENCES(_sym,_msg)				\
     92       1.5  thorpej 	.section .gnu.warning./**/_sym ; .ascii _msg ; .text
     93       1.5  thorpej #endif /* __STDC__ */
     94      1.12     matt 
     95      1.12     matt #ifdef _KERNEL
     96      1.12     matt /*
     97      1.12     matt  * Get cpu_info pointer for current processor.  Always in SPRG0. *ALWAYS*
     98      1.12     matt  */
     99      1.12     matt #define	GET_CPUINFO(r)		mfsprg r,0
    100      1.12     matt /*
    101      1.12     matt  * IN:
    102      1.12     matt  *	R4[er] = first free byte beyond end/esym.
    103      1.12     matt  *
    104      1.12     matt  * OUT:
    105      1.12     matt  *	R1[sp] = new kernel stack
    106      1.12     matt  *	R4[er] = kernelend
    107      1.12     matt  */
    108      1.12     matt 
    109      1.12     matt #define	INIT_CPUINFO(er,sp,tmp1,tmp2) 					\
    110      1.12     matt 	li	tmp1,PGOFSET;						\
    111      1.12     matt 	add	er,er,tmp1;						\
    112      1.12     matt 	andc	er,er,tmp1;		/* page align */		\
    113      1.12     matt 	lis	tmp1,_C_LABEL(cpu_info)@ha;				\
    114      1.12     matt 	addi	tmp1,tmp1,_C_LABEL(cpu_info)@l;				\
    115  1.12.2.1    skrll 	mtsprg0	tmp1;			/* save for later use */	\
    116      1.12     matt 	addi	er,er,INTSTK;						\
    117  1.12.2.1    skrll 	stptr	er,CI_INTSTK(tmp1);					\
    118  1.12.2.1    skrll 	stptr	er,CI_IDLE_PCB(tmp1);					\
    119      1.12     matt 	addi	er,er,USPACE;		/* space for idle_u */		\
    120      1.12     matt 	li	tmp2,-1;						\
    121  1.12.2.1    skrll 	stint	tmp2,CI_INTRDEPTH(tmp1);				\
    122      1.12     matt 	li	tmp2,0;							\
    123  1.12.2.1    skrll 	stptr	tmp2,-CALLFRAMELEN(er);	/* terminate idle stack chain */\
    124      1.12     matt 	lis	tmp1,_C_LABEL(proc0paddr)@ha;				\
    125  1.12.2.1    skrll 	stptr	er,_C_LABEL(proc0paddr)@l(tmp1);			\
    126      1.12     matt 	addi	er,er,USPACE;		/* stackpointer for proc0 */	\
    127      1.12     matt 	addi	sp,er,-FRAMELEN;	/* stackpointer for proc0 */	\
    128      1.12     matt 		/* er = end of mem reserved for kernel */		\
    129  1.12.2.1    skrll 	stptru	tmp2,-CALLFRAMELEN(sp)	/* end of stack chain */
    130      1.12     matt 
    131      1.12     matt #endif
    132       1.8   simonb 
    133       1.8   simonb /* Condition Register Bit Fields */
    134       1.8   simonb 
    135      1.11     matt #if !defined(_NOREGNAMES)
    136      1.10     matt #if defined(_KERNEL) || defined(_STANDALONE)
    137       1.8   simonb #define cr0     0
    138       1.8   simonb #define cr1     1
    139       1.8   simonb #define cr2     2
    140       1.8   simonb #define cr3     3
    141       1.8   simonb #define cr4     4
    142       1.8   simonb #define cr5     5
    143       1.8   simonb #define cr6     6
    144       1.8   simonb #define cr7     7
    145      1.10     matt #endif
    146       1.8   simonb 
    147       1.8   simonb /* General Purpose Registers (GPRs) */
    148       1.8   simonb 
    149      1.10     matt #if defined(_KERNEL) || defined(_STANDALONE)
    150       1.8   simonb #define r0      0
    151       1.8   simonb #define r1      1
    152       1.8   simonb #define r2      2
    153       1.8   simonb #define r3      3
    154       1.8   simonb #define r4      4
    155       1.8   simonb #define r5      5
    156       1.8   simonb #define r6      6
    157       1.8   simonb #define r7      7
    158       1.8   simonb #define r8      8
    159       1.8   simonb #define r9      9
    160       1.8   simonb #define r10     10
    161       1.8   simonb #define r11     11
    162       1.8   simonb #define r12     12
    163       1.8   simonb #define r13     13
    164       1.8   simonb #define r14     14
    165       1.8   simonb #define r15     15
    166       1.8   simonb #define r16     16
    167       1.8   simonb #define r17     17
    168       1.8   simonb #define r18     18
    169       1.8   simonb #define r19     19
    170       1.8   simonb #define r20     20
    171       1.8   simonb #define r21     21
    172       1.8   simonb #define r22     22
    173       1.8   simonb #define r23     23
    174       1.8   simonb #define r24     24
    175       1.8   simonb #define r25     25
    176       1.8   simonb #define r26     26
    177       1.8   simonb #define r27     27
    178       1.8   simonb #define r28     28
    179       1.8   simonb #define r29     29
    180       1.8   simonb #define r30     30
    181       1.8   simonb #define r31     31
    182      1.10     matt #endif
    183       1.8   simonb 
    184       1.8   simonb /* Floating Point Registers (FPRs) */
    185       1.8   simonb 
    186      1.10     matt #if defined(_KERNEL) || defined(_STANDALONE)
    187       1.8   simonb #define fr0     0
    188       1.8   simonb #define fr1     1
    189       1.8   simonb #define fr2     2
    190       1.8   simonb #define fr3     3
    191       1.8   simonb #define fr4     4
    192       1.8   simonb #define fr5     5
    193       1.8   simonb #define fr6     6
    194       1.8   simonb #define fr7     7
    195       1.8   simonb #define fr8     8
    196       1.8   simonb #define fr9     9
    197       1.8   simonb #define fr10    10
    198       1.8   simonb #define fr11    11
    199       1.8   simonb #define fr12    12
    200       1.8   simonb #define fr13    13
    201       1.8   simonb #define fr14    14
    202       1.8   simonb #define fr15    15
    203       1.8   simonb #define fr16    16
    204       1.8   simonb #define fr17    17
    205       1.8   simonb #define fr18    18
    206       1.8   simonb #define fr19    19
    207       1.8   simonb #define fr20    20
    208       1.8   simonb #define fr21    21
    209       1.8   simonb #define fr22    22
    210       1.8   simonb #define fr23    23
    211       1.8   simonb #define fr24    24
    212       1.8   simonb #define fr25    25
    213       1.8   simonb #define fr26    26
    214       1.8   simonb #define fr27    27
    215       1.8   simonb #define fr28    28
    216       1.8   simonb #define fr29    29
    217       1.8   simonb #define fr30    30
    218       1.8   simonb #define fr31    31
    219      1.10     matt #endif
    220      1.11     matt #endif /* !_NOREGNAMES */
    221       1.1       ws 
    222  1.12.2.1    skrll /*
    223  1.12.2.1    skrll  * Add some psuedo instructions to made sharing of assembly versions of
    224  1.12.2.1    skrll  * ILP32 and LP64 code possible.
    225  1.12.2.1    skrll  */
    226  1.12.2.1    skrll #define ldint	lwz		/* not needed but for completeness */
    227  1.12.2.1    skrll #define ldintu	lwzu		/* not needed but for completeness */
    228  1.12.2.1    skrll #define stint	stw		/* not needed but for completeness */
    229  1.12.2.1    skrll #define stintu	stwu		/* not needed but for completeness */
    230  1.12.2.1    skrll #ifndef _LP64
    231  1.12.2.1    skrll #define ldlong	lwz		/* load "C" long */
    232  1.12.2.1    skrll #define ldlongu	lwzu		/* load "C" long with udpate */
    233  1.12.2.1    skrll #define stlong	stw		/* load "C" long */
    234  1.12.2.1    skrll #define stlongu	stwu		/* load "C" long with udpate */
    235  1.12.2.1    skrll #define ldptr	lwz		/* load "C" pointer */
    236  1.12.2.1    skrll #define ldptru	lwzu		/* load "C" pointer with udpate */
    237  1.12.2.1    skrll #define stptr	stw		/* load "C" pointer */
    238  1.12.2.1    skrll #define stptru	stwu		/* load "C" pointer with udpate */
    239  1.12.2.1    skrll #define	ldreg	lwz		/* load PPC general register */
    240  1.12.2.1    skrll #define	ldregu	lwzu		/* load PPC general register with udpate */
    241  1.12.2.1    skrll #define	streg	stw		/* load PPC general register */
    242  1.12.2.1    skrll #define	stregu	stwu		/* load PPC general register with udpate */
    243  1.12.2.1    skrll #define	SZREG	4		/* 4 byte registers */
    244  1.12.2.1    skrll #else
    245  1.12.2.1    skrll #define ldlong	ld		/* load "C" long */
    246  1.12.2.1    skrll #define ldlongu	ldu		/* load "C" long with update */
    247  1.12.2.1    skrll #define stlong	std		/* store "C" long */
    248  1.12.2.1    skrll #define stlongu	stdu		/* store "C" long with update */
    249  1.12.2.1    skrll #define ldptr	ld		/* load "C" pointer */
    250  1.12.2.1    skrll #define ldptru	ldu		/* load "C" pointer with update */
    251  1.12.2.1    skrll #define stptr	std		/* store "C" pointer */
    252  1.12.2.1    skrll #define stptru	stdu		/* store "C" pointer with update */
    253  1.12.2.1    skrll #define	ldreg	ld		/* load PPC general register */
    254  1.12.2.1    skrll #define	ldregu	ldu		/* load PPC general register with update */
    255  1.12.2.1    skrll #define	streg	std		/* store PPC general register */
    256  1.12.2.1    skrll #define	stregu	stdu		/* store PPC general register with update */
    257  1.12.2.1    skrll /* redefined this to force an error on PPC64 to catch their use.  */
    258  1.12.2.1    skrll #define	lmw	lmd		/* load multiple PPC general registers */
    259  1.12.2.1    skrll #define	stmw	stmd		/* store multiple PPC general registers */
    260  1.12.2.1    skrll #define	SZREG	8		/* 8 byte registers */
    261  1.12.2.1    skrll #endif
    262  1.12.2.1    skrll 
    263       1.1       ws #endif /* !_PPC_ASM_H_ */
    264