1*d09bd0a9Srin/* $NetBSD: spl.S,v 1.11 2021/10/11 07:26:17 rin Exp $ */ 227f96e84Schris 327f96e84Schris/* 427f96e84Schris * Copyright (c) 1996-1998 Mark Brinicombe. 527f96e84Schris * Copyright (c) Brini. 627f96e84Schris * All rights reserved. 727f96e84Schris * 827f96e84Schris * Redistribution and use in source and binary forms, with or without 927f96e84Schris * modification, are permitted provided that the following conditions 1027f96e84Schris * are met: 1127f96e84Schris * 1. Redistributions of source code must retain the above copyright 1227f96e84Schris * notice, this list of conditions and the following disclaimer. 1327f96e84Schris * 2. Redistributions in binary form must reproduce the above copyright 1427f96e84Schris * notice, this list of conditions and the following disclaimer in the 1527f96e84Schris * documentation and/or other materials provided with the distribution. 1627f96e84Schris * 3. All advertising materials mentioning features or use of this software 1727f96e84Schris * must display the following acknowledgement: 1827f96e84Schris * This product includes software developed by Mark Brinicombe 1927f96e84Schris * for the NetBSD Project. 2027f96e84Schris * 4. The name of the company nor the name of the author may be used to 2127f96e84Schris * endorse or promote products derived from this software without specific 2227f96e84Schris * prior written permission. 2327f96e84Schris * 2427f96e84Schris * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 2527f96e84Schris * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 2627f96e84Schris * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2727f96e84Schris * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 2827f96e84Schris * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 2927f96e84Schris * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 3027f96e84Schris * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3127f96e84Schris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3227f96e84Schris * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3327f96e84Schris * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3427f96e84Schris * SUCH DAMAGE. 3527f96e84Schris * 3627f96e84Schris * spl routines 3727f96e84Schris * 3827f96e84Schris * Created : 01/03/96 3927f96e84Schris */ 4027f96e84Schris 4127f96e84Schris#include "assym.h" 42ab152917Smatt#include <arm/asm.h> 43ab152917Smatt#include <arm/locore.h> 440ca43a5fSthorpej#include <arm/arm32/psl.h> 45825088edSmatt 46*d09bd0a9Srin RCSID("$NetBSD: spl.S,v 1.11 2021/10/11 07:26:17 rin Exp $") 4727f96e84Schris 4827f96e84Schris .text 4927f96e84Schris .align 0 5027f96e84Schris 51825088edSmatt.Lcpu_info_store: 52825088edSmatt .word _C_LABEL(cpu_info_store) 5327f96e84Schris 5427f96e84SchrisENTRY(raisespl) 5527f96e84Schris mov r3, r0 /* Save the new value */ 56825088edSmatt ldr r1, .Lcpu_info_store /* Get the current spl level */ 57825088edSmatt ldr r0, [r1, #CI_CPL] 5827f96e84Schris cmp r3, r0 59825088edSmatt RETc(le) 6027f96e84Schris 61825088edSmatt stmfd sp!, {r0, r1, r4, lr} /* Preserve registers */ 6227f96e84Schris 63825088edSmatt /* Disable interrupts */ 648b058f85Sjoerg mrs r4, cpsr 65825088edSmatt orr r2, r4, #(I32_bit) 66825088edSmatt msr cpsr_c, r2 67825088edSmatt 68825088edSmatt str r3, [r1, #CI_CPL] /* Store the new spl level */ 6927f96e84Schris bl _C_LABEL(irq_setmasks) /* Update the actual masks */ 70825088edSmatt msr cpsr_c, r4 /* Restore interrupts */ 71825088edSmatt 72825088edSmatt ldmfd sp!, {r0, r1, r4, pc} /* Restore registers */ 7327f96e84Schris 7427f96e84SchrisENTRY(lowerspl) 7527f96e84Schris mov r3, r0 /* Save the new value */ 76825088edSmatt ldr r1, .Lcpu_info_store /* Get the current spl level */ 77825088edSmatt ldr r0, [r1, #CI_CPL] 7827f96e84Schris cmp r3, r0 79825088edSmatt RETc(ge) 8027f96e84Schris 81825088edSmatt stmfd sp!, {r0, r1, r4, lr} /* Preserve registers */ 8227f96e84Schris 83825088edSmatt /* Disable interrupts */ 848b058f85Sjoerg mrs r4, cpsr 85825088edSmatt orr r2, r4, #(I32_bit) 86825088edSmatt msr cpsr_c, r2 87825088edSmatt 88825088edSmatt str r3, [r1, #CI_CPL] /* Store the new spl level */ 89825088edSmatt 9027f96e84Schris bl _C_LABEL(irq_setmasks) /* Update the actual masks */ 91825088edSmatt msr cpsr_all, r4 924b293a84Sad#ifdef __HAVE_FAST_SOFTINTS 9327f96e84Schris bl _C_LABEL(dosoftints) /* Process any pending soft ints */ 944b293a84Sad#endif 95825088edSmatt ldmfd sp!, {r0, r1, r4, pc} /* restore registers */ 9627f96e84Schris 9727f96e84SchrisENTRY(splx) 98fa742cdeSchris mov r3, r0 /* Save the new value */ 99825088edSmatt ldr r1, .Lcpu_info_store /* Get the current spl level */ 100825088edSmatt ldr r0, [r1, #CI_CPL] 10127f96e84Schris cmp r3, r0 102825088edSmatt RETc(eq) 10327f96e84Schris 104825088edSmatt stmfd sp!, {r0, r1, r4, lr} 10527f96e84Schris 106825088edSmatt /* Disable interrupts */ 1078b058f85Sjoerg mrs r4, cpsr 108825088edSmatt orr r2, r4, #(I32_bit) 109825088edSmatt msr cpsr_c, r2 110825088edSmatt 111825088edSmatt str r3, [r1, #CI_CPL] /* Store the new spl level */ 11227f96e84Schris 11327f96e84Schris bl _C_LABEL(irq_setmasks) /* Update the actual masks */ 114*d09bd0a9Srin msr cpsr_c, r4 1154b293a84Sad#ifdef __HAVE_FAST_SOFTINTS 11627f96e84Schris bl _C_LABEL(dosoftints) /* Process any pending soft ints */ 1174b293a84Sad#endif 118825088edSmatt ldmfd sp!, {r0, r1, r4, pc} 119