xref: /netbsd-src/sys/lib/libkern/arch/powerpc/gprsavrest.S (revision 63efa6113b355599986e6dc7c91f28fb696acad0)
1/*-
2 * Copyright (c) 2011 The NetBSD Foundation, Inc.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Matt Thomas of 3am Software Foundry.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#include <powerpc/asm.h>
31
32__RCSID("$NetBSD: gprsavrest.S,v 1.4 2011/10/28 02:00:50 christos Exp $")
33
34#ifndef RESTGPR
35# define RESTGPR(n)	RESTOREXGPR(_restgpr_,n,_x)
36# define RESTGPR_END(n)	RESTOREXGPR_END(_restgpr_,n,_x)
37# define SAVEGPR(n)	SAVEXGPR(_savegpr_,n,)
38# define SAVEGPR_END(n)	SAVEXGPR_END(_savegpr_,n,)
39#endif
40
41#define RESTOREXGPR(a,n,b) \
42	.hidden a##n##b; ENTRY_NOPROFILE(a##n##b); lwz	n,(-4*(32-n))(11)
43#define SAVEXGPR(a,n,b) \
44	.hidden a##n##b; ENTRY_NOPROFILE(a##n##b); stw	n,(-4*(32-n))(11)
45#ifdef _LP64
46# define SAVEXGPR_END(a,n,b)
47# define RESTOREXGPR_END(a,n,b)
48#else
49# define SAVEXGPR_END(a,n,b) \
50	.size a##n##b,.-a##n##b
51# define RESTOREXGPR_END(a,n,b) \
52	.size a##n##b,.-a##n##b
53#endif
54
55	RESTGPR(14)
56	RESTGPR(15)
57	RESTGPR(16)
58	RESTGPR(17)
59	RESTGPR(18)
60	RESTGPR(19)
61	RESTGPR(20)
62	RESTGPR(21)
63	RESTGPR(22)
64	RESTGPR(23)
65	RESTGPR(24)
66	RESTGPR(25)
67	RESTGPR(26)
68	RESTGPR(27)
69	RESTGPR(28)
70	RESTGPR(29)
71	RESTGPR(30)
72	RESTGPR(31)
73	lwz	0,4(11)
74	mtlr	0
75	mr	1,11
76	blr
77	RESTGPR_END(14)
78	RESTGPR_END(15)
79	RESTGPR_END(16)
80	RESTGPR_END(17)
81	RESTGPR_END(18)
82	RESTGPR_END(19)
83	RESTGPR_END(20)
84	RESTGPR_END(21)
85	RESTGPR_END(22)
86	RESTGPR_END(23)
87	RESTGPR_END(24)
88	RESTGPR_END(25)
89	RESTGPR_END(26)
90	RESTGPR_END(27)
91	RESTGPR_END(28)
92	RESTGPR_END(29)
93	RESTGPR_END(30)
94	RESTGPR_END(31)
95
96	SAVEGPR(14)
97	SAVEGPR(15)
98	SAVEGPR(16)
99	SAVEGPR(17)
100	SAVEGPR(18)
101	SAVEGPR(19)
102	SAVEGPR(20)
103	SAVEGPR(21)
104	SAVEGPR(22)
105	SAVEGPR(23)
106	SAVEGPR(24)
107	SAVEGPR(25)
108	SAVEGPR(26)
109	SAVEGPR(27)
110	SAVEGPR(28)
111	SAVEGPR(29)
112	SAVEGPR(30)
113	SAVEGPR(31)
114	blr
115	SAVEGPR_END(14)
116	SAVEGPR_END(15)
117	SAVEGPR_END(16)
118	SAVEGPR_END(17)
119	SAVEGPR_END(18)
120	SAVEGPR_END(19)
121	SAVEGPR_END(20)
122	SAVEGPR_END(21)
123	SAVEGPR_END(22)
124	SAVEGPR_END(23)
125	SAVEGPR_END(24)
126	SAVEGPR_END(25)
127	SAVEGPR_END(26)
128	SAVEGPR_END(27)
129	SAVEGPR_END(28)
130	SAVEGPR_END(29)
131	SAVEGPR_END(30)
132	SAVEGPR_END(31)
133