summaryrefslogtreecommitdiffstats
path: root/qemu/roms/openbios/include/arch/ppc/asmdefs.h
blob: 3b3cad434dd5223efc2619df316d79de2d469960 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*   -*- asm -*-
 *
 *   Creation Date: <2001/02/03 19:38:07 samuel>
 *   Time-stamp: <2003/07/08 18:55:50 samuel>
 *
 *	<asmdefs.h>
 *
 *	Common assembly definitions
 *
 *   Copyright (C) 2001, 2002, 2003 Samuel Rydh (samuel@ibrium.se)
 *
 *   This program is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU General Public License
 *   as published by the Free Software Foundation
 *
 */

#ifndef _H_ASMDEFS
#define _H_ASMDEFS

/************************************************************************/
/*	High/low halfword compatibility macros				*/
/************************************************************************/

#ifndef __darwin__
#define 	ha16( v )	(v)##@ha
#define 	hi16( v )	(v)##@h
#define 	lo16( v )	(v)##@l
#endif
#define		HA(v)		ha16(v)
#define		HI(v)		hi16(v)
#define		LO(v)		lo16(v)

/* from Linux: include/asm-powerpc/ppc_asm.h */
/*
 * Copyright (C) 1995-1999 Gary Thomas, Paul Mackerras, Cort Dougan.
 */

/* General Purpose Registers (GPRs) */

#define	r0	0
#define	r1	1
#define	r2	2
#define	r3	3
#define	r4	4
#define	r5	5
#define	r6	6
#define	r7	7
#define	r8	8
#define	r9	9
#define	r10	10
#define	r11	11
#define	r12	12
#define	r13	13
#define	r14	14
#define	r15	15
#define	r16	16
#define	r17	17
#define	r18	18
#define	r19	19
#define	r20	20
#define	r21	21
#define	r22	22
#define	r23	23
#define	r24	24
#define	r25	25
#define	r26	26
#define	r27	27
#define	r28	28
#define	r29	29
#define	r30	30
#define	r31	31

/************************************************************************/
/*	MISC								*/
/************************************************************************/

#ifdef __powerpc64__

#define LOAD_REG_IMMEDIATE(D, x) \
	lis  (D),      (x)@highest ; \
	ori  (D), (D), (x)@higher ; \
	sldi (D), (D), 32 ; \
	oris (D), (D), (x)@h ; \
	ori  (D), (D), (x)@l

#define LOAD_REG_FUNC(D, x) \
    LOAD_REG_IMMEDIATE((D), (x)) ; \
    ld (D), 0(D)

#else

#define LOAD_REG_IMMEDIATE(D, x) \
	lis  (D),      HA(x) ; \
	addi (D), (D), LO(x)

#define LOAD_REG_FUNC(D, x) \
    LOAD_REG_IMMEDIATE((D), (x))

#endif

#ifdef __powerpc64__
#define PPC_LL   ld
#define PPC_STL  std
#define PPC_STLU stdu
#define RFI rfid
#define MTMSRD(r) mtmsrd r
#define DATA_LONG(x) .quad x
#define BRANCH_LABEL(name) . ## name
#define PPC_LR_STKOFF 16
#else
#define PPC_LL   lwz
#define PPC_STL  stw
#define PPC_STLU stwu
#define RFI rfi
#define MTMSRD(r) mtmsr  r
#define DATA_LONG(x) .long x
#define BRANCH_LABEL(name) name
#define PPC_LR_STKOFF 4
#endif

#ifndef __darwin__
#define GLOBL( name )		.globl name ; name
#define EXTERN( name )		name
#else
/* an underscore is needed on Darwin */
#define GLOBL( name )		.globl _##name ; name: ; _##name
#define EXTERN( name )		_##name
#endif

#if defined(__powerpc64__) && !defined(__darwin__)
#define _GLOBAL(name) \
        .align 2 ; \
        .section ".opd", "aw" ; \
        .globl name ; \
        .globl .##name ; \
    name: \
        .quad .##name ; \
        .quad .TOC.@tocbase ; \
        .quad 0 ; \
        .previous ; \
        .type .##name, @function ; \
    .##name
#else
#define _GLOBAL(name) \
    GLOBL(name)
#endif

#define	BIT(n)		(1<<(31-(n)))

#endif   /* _H_ASMDEFS */