xref: /netbsd-src/sys/lib/libkern/arch/powerpc/gprsavrest.S (revision 9aa0541bdf64142d9a27c2cf274394d60182818f)
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.3 2011/08/12 14:48:00 matt 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 RESTOREXGPR_END(a,n,b) \
44	.size a##n##b,.-a##n##b
45#define SAVEXGPR(a,n,b) \
46	.hidden a##n##b; ENTRY_NOPROFILE(a##n##b); stw	n,(-4*(32-n))(11)
47#define SAVEXGPR_END(a,n,b) \
48	.size a##n##b,.-a##n##b
49
50	RESTGPR(14)
51	RESTGPR(15)
52	RESTGPR(16)
53	RESTGPR(17)
54	RESTGPR(18)
55	RESTGPR(19)
56	RESTGPR(20)
57	RESTGPR(21)
58	RESTGPR(22)
59	RESTGPR(23)
60	RESTGPR(24)
61	RESTGPR(25)
62	RESTGPR(26)
63	RESTGPR(27)
64	RESTGPR(28)
65	RESTGPR(29)
66	RESTGPR(30)
67	RESTGPR(31)
68	lwz	0,4(11)
69	mtlr	0
70	mr	1,11
71	blr
72	RESTGPR_END(14)
73	RESTGPR_END(15)
74	RESTGPR_END(16)
75	RESTGPR_END(17)
76	RESTGPR_END(18)
77	RESTGPR_END(19)
78	RESTGPR_END(20)
79	RESTGPR_END(21)
80	RESTGPR_END(22)
81	RESTGPR_END(23)
82	RESTGPR_END(24)
83	RESTGPR_END(25)
84	RESTGPR_END(26)
85	RESTGPR_END(27)
86	RESTGPR_END(28)
87	RESTGPR_END(29)
88	RESTGPR_END(30)
89	RESTGPR_END(31)
90
91	SAVEGPR(14)
92	SAVEGPR(15)
93	SAVEGPR(16)
94	SAVEGPR(17)
95	SAVEGPR(18)
96	SAVEGPR(19)
97	SAVEGPR(20)
98	SAVEGPR(21)
99	SAVEGPR(22)
100	SAVEGPR(23)
101	SAVEGPR(24)
102	SAVEGPR(25)
103	SAVEGPR(26)
104	SAVEGPR(27)
105	SAVEGPR(28)
106	SAVEGPR(29)
107	SAVEGPR(30)
108	SAVEGPR(31)
109	blr
110	SAVEGPR_END(14)
111	SAVEGPR_END(15)
112	SAVEGPR_END(16)
113	SAVEGPR_END(17)
114	SAVEGPR_END(18)
115	SAVEGPR_END(19)
116	SAVEGPR_END(20)
117	SAVEGPR_END(21)
118	SAVEGPR_END(22)
119	SAVEGPR_END(23)
120	SAVEGPR_END(24)
121	SAVEGPR_END(25)
122	SAVEGPR_END(26)
123	SAVEGPR_END(27)
124	SAVEGPR_END(28)
125	SAVEGPR_END(29)
126	SAVEGPR_END(30)
127	SAVEGPR_END(31)
128