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