xref: /netbsd/lib/csu/arch/mips/crti.S (revision f105efc6)
1*f105efc6Smatt/* $NetBSD: crti.S,v 1.3 2015/05/01 21:35:56 matt Exp $ */
2c97b5950Smatt
3c97b5950Smatt/*-
4c97b5950Smatt * Copyright (c) 2011 The NetBSD Foundation, Inc.
5c97b5950Smatt * All rights reserved.
6c97b5950Smatt *
7c97b5950Smatt * This code is derived from software contributed to The NetBSD Foundation
8c97b5950Smatt * by Matt Thomas of 3am Software Foundry.
9c97b5950Smatt *
10c97b5950Smatt * Redistribution and use in source and binary forms, with or without
11c97b5950Smatt * modification, are permitted provided that the following conditions
12c97b5950Smatt * are met:
13c97b5950Smatt * 1. Redistributions of source code must retain the above copyright
14c97b5950Smatt *    notice, this list of conditions and the following disclaimer.
15c97b5950Smatt * 2. Redistributions in binary form must reproduce the above copyright
16c97b5950Smatt *    notice, this list of conditions and the following disclaimer in the
17c97b5950Smatt *    documentation and/or other materials provided with the distribution.
18c97b5950Smatt *
19c97b5950Smatt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20c97b5950Smatt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21c97b5950Smatt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22c97b5950Smatt * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23c97b5950Smatt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24c97b5950Smatt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25c97b5950Smatt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26c97b5950Smatt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27c97b5950Smatt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28c97b5950Smatt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29c97b5950Smatt * POSSIBILITY OF SUCH DAMAGE.
30c97b5950Smatt */
31c97b5950Smatt
32c97b5950Smatt#include <mips/asm.h>
33c97b5950Smatt
34*f105efc6SmattRCSID("$NetBSD: crti.S,v 1.3 2015/05/01 21:35:56 matt Exp $")
35c97b5950Smatt
36c97b5950Smatt#include "sysident.S"
37c97b5950Smatt
38c97b5950Smatt	.section ".init", "ax", @progbits
39*f105efc6Smatt	.p2align 2
40c97b5950SmattNESTED_NOPROFILE(_init, CALLFRAME_SIZ, ra)
41c97b5950Smatt        SETUP_GP
42c97b5950Smatt        PTR_SUBU sp, sp, CALLFRAME_SIZ	# allocate stack frame
43c97b5950Smatt	REG_S	ra, CALLFRAME_RA(sp)	# save RA
44077ca921Smatt#ifdef __mips_o32
45077ca921Smatt	REG_S	s0, CALLFRAME_S0(sp)	# save s0
46077ca921Smatt	move	s0, gp
47077ca921Smatt#endif
48077ca921Smatt        SETUP_GP64(CALLFRAME_GP, _init)
49c97b5950SmattEND(_init)
50c97b5950Smatt
51c97b5950Smatt	.section ".fini", "ax", @progbits
52*f105efc6Smatt	.p2align 2
53c97b5950SmattNESTED_NOPROFILE(_fini, CALLFRAME_SIZ, ra)
54c97b5950Smatt        SETUP_GP
55c97b5950Smatt        PTR_SUBU sp, sp, CALLFRAME_SIZ	# allocate stack frame
56c97b5950Smatt	REG_S	ra, CALLFRAME_RA(sp)	# save RA
57077ca921Smatt#ifdef __mips_o32
58077ca921Smatt	REG_S	s0, CALLFRAME_S0(sp)	# save s0
59077ca921Smatt	move	s0, gp
60077ca921Smatt#endif
61077ca921Smatt        SETUP_GP64(CALLFRAME_GP, _fini)
62c97b5950SmattEND(_fini)
63