FreeBSD/Linux Kernel Cross Reference
sys/sqt/misc.s
1 /*
2 * Mach Operating System
3 * Copyright (c) 1991 Carnegie Mellon University
4 * Copyright (c) 1991 Sequent Computer Systems
5 * All Rights Reserved.
6 *
7 * Permission to use, copy, modify and distribute this software and its
8 * documentation is hereby granted, provided that both the copyright
9 * notice and this permission notice appear in all copies of the
10 * software, derivative works or modified versions, and any portions
11 * thereof, and that both notices appear in supporting documentation.
12 *
13 * CARNEGIE MELLON AND SEQUENT COMPUTER SYSTEMS ALLOW FREE USE OF
14 * THIS SOFTWARE IN ITS "AS IS" CONDITION. CARNEGIE MELLON AND
15 * SEQUENT COMPUTER SYSTEMS DISCLAIM ANY LIABILITY OF ANY KIND FOR
16 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17 *
18 * Carnegie Mellon requests users of this software to return to
19 *
20 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
21 * School of Computer Science
22 * Carnegie Mellon University
23 * Pittsburgh PA 15213-3890
24 *
25 * any improvements or extensions that they make and grant Carnegie Mellon
26 * the rights to redistribute these changes.
27 */
28
29 /*
30 * HISTORY
31 * $Log: misc.s,v $
32 * Revision 2.3 91/07/31 18:02:35 dbg
33 * Changed copyright.
34 * [91/07/31 dbg]
35 *
36 * Revision 2.2 91/05/08 12:57:48 dbg
37 * Converted for pure kernel.
38 * [90/05/02 dbg]
39 *
40 */
41
42 /* $Copyright: $
43 * Copyright (c) 1984, 1985, 1986, 1987 Sequent Computer Systems, Inc.
44 * All rights reserved
45 *
46 * This software is furnished under a license and may be used
47 * only in accordance with the terms of that license and with the
48 * inclusion of the above copyright notice. This software may not
49 * be provided or otherwise made available to, or used by, any
50 * other person. No title to or ownership of the software is
51 * hereby transferred.
52 */
53
54 /*
55 * misc.s
56 * Miscellaneous Assembly routines.
57 */
58
59 #include <assym.s>
60 #include <machine/asm.h>
61 #include <sqt/asm_macros.h>
62
63 /*
64 * bit = ffs(mask)
65 * unsigned int mask;
66 *
67 * Return first found set bit position (1-32) or zero if none set.
68 */
69
70 ENTRY(ffs)
71 movl $-1, %eax # in case no bits set
72 bsfl S_ARG0, %eax # check all 32 bits of arg
73 incl %eax # incr by one for 0-32 (0 if S_ARG==0)
74 ret
75
76 /*
77 * enable_nmi: NMI's are enabled at the processor by
78 * an iret. This routine enables interrupts and does
79 * an iret back to the caller, thus enabling interrupts
80 * and NMI's. Only called by trap().
81 * On entry, stack looks like
82 * <return_eip>
83 * Change to (stack grows down)
84 * <flags>
85 * <kernel_cs>
86 * <return_eip>
87 * so the iret works
88 */
89
90 ENTRY(enable_nmi)
91 popl %eax # return addr
92 sti
93 pushfl
94 pushl $(KERNEL_CS)
95 pushl %eax
96 iret
97
98 /*
99 * Return logical processor ID
100 */
101
102 ENTRY(cpu_number)
103 CPU_NUMBER(%eax)
104 ret
Cache object: d1489705774eccd2980729f368ce078c
|