11.2Suwe/*	$NetBSD: signalsphandler.S,v 1.2 2025/04/26 23:49:55 uwe Exp $	*/
21.1Suwe
31.1Suwe/*-
41.1Suwe * Copyright (c) 2025 The NetBSD Foundation, Inc.
51.1Suwe * All rights reserved.
61.1Suwe *
71.1Suwe * Redistribution and use in source and binary forms, with or without
81.1Suwe * modification, are permitted provided that the following conditions
91.1Suwe * are met:
101.1Suwe * 1. Redistributions of source code must retain the above copyright
111.1Suwe *    notice, this list of conditions and the following disclaimer.
121.1Suwe * 2. Redistributions in binary form must reproduce the above copyright
131.1Suwe *    notice, this list of conditions and the following disclaimer in the
141.1Suwe *    documentation and/or other materials provided with the distribution.
151.1Suwe *
161.1Suwe * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
171.1Suwe * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
181.1Suwe * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
191.1Suwe * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
201.1Suwe * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
211.1Suwe * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
221.1Suwe * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
231.1Suwe * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
241.1Suwe * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
251.1Suwe * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
261.1Suwe * POSSIBILITY OF SUCH DAMAGE.
271.1Suwe */
281.1Suwe
291.1Suwe#include "asm.h"
301.2SuweRCSID("$NetBSD: signalsphandler.S,v 1.2 2025/04/26 23:49:55 uwe Exp $")
311.1Suwe
321.1Suwe
331.1Suwe/*
341.1Suwe * void signalsphandler(int signo)
351.1Suwe *
361.1Suwe *	Signal handler.  Store the stack pointer on entry at the global
371.1Suwe *	variable signalsp and return.
381.1Suwe */
391.1SuweENTRY(signalsphandler)
401.1Suwe	mov	sp, r1
411.2Suwe#ifdef __PIC__
421.2Suwe	// PR kern/59327: don't touch stack as SP may be misaligned
431.2Suwe	// and as SuperH is a strict alignment architecture, we will
441.2Suwe	// get SIGBUS if we try to save registers on the stack
451.2Suwe	mov	r12, r2
461.2Suwe#endif
471.2Suwe	PIC_PROLOGUE_NOSAVE(.L_GOT)
481.1Suwe
491.1Suwe	MOVL_VAR(.L_signalsp, r0)
501.1Suwe	mov.l	r1, @r0
511.1Suwe
521.2Suwe#ifdef __PIC__
531.2Suwe	mov	r2, r12
541.2Suwe#endif
551.1Suwe	rts
561.2Suwe	 nop
571.1Suwe
581.1Suwe	.p2align 2
591.1Suwe.L_GOT:		PIC_GOT_DATUM
601.1Suwe.L_signalsp:	VAR_DATUM(signalsp)
611.1Suwe	SET_ENTRY_SIZE(signalsphandler)
62