spl.S revision 1.5.2.2 1 1.5.2.2 matt /* $NetBSD: spl.S,v 1.5.2.2 2008/01/09 01:45:13 matt Exp $ */
2 1.1 chris
3 1.1 chris /*
4 1.1 chris * Copyright (c) 1996-1998 Mark Brinicombe.
5 1.1 chris * Copyright (c) Brini.
6 1.1 chris * All rights reserved.
7 1.1 chris *
8 1.1 chris * Redistribution and use in source and binary forms, with or without
9 1.1 chris * modification, are permitted provided that the following conditions
10 1.1 chris * are met:
11 1.1 chris * 1. Redistributions of source code must retain the above copyright
12 1.1 chris * notice, this list of conditions and the following disclaimer.
13 1.1 chris * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 chris * notice, this list of conditions and the following disclaimer in the
15 1.1 chris * documentation and/or other materials provided with the distribution.
16 1.1 chris * 3. All advertising materials mentioning features or use of this software
17 1.1 chris * must display the following acknowledgement:
18 1.1 chris * This product includes software developed by Mark Brinicombe
19 1.1 chris * for the NetBSD Project.
20 1.1 chris * 4. The name of the company nor the name of the author may be used to
21 1.1 chris * endorse or promote products derived from this software without specific
22 1.1 chris * prior written permission.
23 1.1 chris *
24 1.1 chris * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
25 1.1 chris * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 1.1 chris * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 1.1 chris * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
28 1.1 chris * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 1.1 chris * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 1.1 chris * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 1.1 chris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 1.1 chris * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 1.1 chris * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 1.1 chris * SUCH DAMAGE.
35 1.1 chris *
36 1.1 chris * spl routines
37 1.1 chris *
38 1.1 chris * Created : 01/03/96
39 1.1 chris */
40 1.1 chris
41 1.1 chris #include "assym.h"
42 1.3 thorpej #include <arm/arm32/psl.h>
43 1.1 chris #include <machine/asm.h>
44 1.5.2.2 matt #include <machine/cpu.h>
45 1.1 chris
46 1.1 chris .text
47 1.1 chris .align 0
48 1.1 chris
49 1.5.2.1 matt .Lcpu_info_store:
50 1.5.2.1 matt .word _C_LABEL(cpu_info_store)
51 1.1 chris
52 1.1 chris ENTRY(raisespl)
53 1.1 chris mov r3, r0 /* Save the new value */
54 1.5.2.1 matt ldr r1, .Lcpu_info_store /* Get the current spl level */
55 1.5.2.1 matt ldr r0, [r1, #CI_CPL]
56 1.1 chris cmp r3, r0
57 1.5.2.2 matt RETc(le)
58 1.1 chris
59 1.5.2.2 matt stmfd sp!, {r0, r1, r4, lr} /* Preserve registers */
60 1.5.2.2 matt
61 1.5.2.2 matt /* Disable interrupts */
62 1.5.2.2 matt mrs r4, cpsr_all
63 1.5.2.2 matt orr r2, r4, #(I32_bit)
64 1.5.2.2 matt msr cpsr_all, r2
65 1.1 chris
66 1.5.2.2 matt str r3, [r1, #CI_CPL] /* Store the new spl level */
67 1.1 chris bl _C_LABEL(irq_setmasks) /* Update the actual masks */
68 1.5.2.2 matt msr cpsr_all, r4 /* Restore interrupts */
69 1.5.2.2 matt
70 1.5.2.2 matt ldmfd sp!, {r0, r1, r4, pc} /* Restore registers */
71 1.1 chris
72 1.1 chris ENTRY(lowerspl)
73 1.1 chris mov r3, r0 /* Save the new value */
74 1.5.2.1 matt ldr r1, .Lcpu_info_store /* Get the current spl level */
75 1.5.2.1 matt ldr r0, [r1, #CI_CPL]
76 1.1 chris cmp r3, r0
77 1.5.2.2 matt RETc(ge)
78 1.5.2.2 matt
79 1.5.2.2 matt stmfd sp!, {r0, r1, r4, lr} /* Preserve registers */
80 1.5.2.2 matt
81 1.5.2.2 matt /* Disable interrupts */
82 1.5.2.2 matt mrs r4, cpsr_all
83 1.5.2.2 matt orr r2, r4, #(I32_bit)
84 1.5.2.2 matt msr cpsr_all, r2
85 1.1 chris
86 1.5.2.1 matt str r3, [r1, #CI_CPL] /* Store the new spl level */
87 1.1 chris
88 1.1 chris bl _C_LABEL(irq_setmasks) /* Update the actual masks */
89 1.5.2.2 matt msr cpsr_all, r4
90 1.5.2.2 matt #ifdef __HAVE_FAST_SOFTINTS
91 1.1 chris bl _C_LABEL(dosoftints) /* Process any pending soft ints */
92 1.5.2.2 matt #endif
93 1.5.2.2 matt ldmfd sp!, {r0, r1, r4, pc} /* restore registers */
94 1.1 chris
95 1.1 chris ENTRY(splx)
96 1.1 chris mov r3, r0 /* Save the new value */
97 1.5.2.2 matt ldr r1, .Lcpu_info_store /* Get the current spl level */
98 1.5.2.1 matt ldr r0, [r1, #CI_CPL]
99 1.1 chris cmp r3, r0
100 1.5.2.2 matt RETc(eq)
101 1.1 chris
102 1.5.2.2 matt stmfd sp!, {r0, r1, r4, lr}
103 1.5.2.2 matt /* Disable interrupts */
104 1.5.2.2 matt mrs r4, cpsr_all
105 1.5.2.2 matt orr r2, r4, #(I32_bit)
106 1.5.2.2 matt msr cpsr_all, r2
107 1.1 chris
108 1.5.2.2 matt str r3, [r1, #CI_CPL] /* Store the new spl level */
109 1.1 chris
110 1.1 chris bl _C_LABEL(irq_setmasks) /* Update the actual masks */
111 1.5.2.2 matt msr cpsr_all, r4
112 1.5.2.2 matt #ifdef __HAVE_FAST_SOFTINTS
113 1.1 chris bl _C_LABEL(dosoftints) /* Process any pending soft ints */
114 1.5.2.2 matt #endif
115 1.5.2.2 matt ldmfd sp!, {r0, r1, r4, pc}
116