2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #pragma ident "%Z%%M% %I% %E% SMI"
27
28 /
29 / In-line functions for amd64 kernels.
30 /
31
32 /
33 / return current thread pointer
34 /
35 / NOTE: the "0x18" should be replaced by the computed value of the
36 / offset of "cpu_thread" from the beginning of the struct cpu.
37 / Including "assym.h" does not work, however, since that stuff
38 / is PSM-specific and is only visible to the 'unix' build anyway.
39 / Same with current cpu pointer, where "0xc" should be replaced
40 / by the computed value of the offset of "cpu_self".
41 / Ugh -- what a disaster.
42 /
43 .inline threadp,0
44 movq %gs:0x18, %rax
45 .end
46
47 /
61 /
62 / convert ipl to spl. This is the identity function for i86
63 /
64 .inline ipltospl,0
65 movq %rdi, %rax
66 .end
67
68 /
69 / find the low order bit in a word
70 /
71 .inline lowbit,4
72 movq $-1, %rax
73 bsfq %rdi, %rax
74 incq %rax
75 .end
76
77 /
78 / Networking byte order functions (too bad, Intel has the wrong byte order)
79 /
80
81 .inline htonl,4
82 movl %edi, %eax
83 bswap %eax
84 .end
85
86 .inline ntohl,4
87 movl %edi, %eax
88 bswap %eax
89 .end
90
91 .inline htons,4
92 movl %edi, %eax
93 bswap %eax
94 shrl $16, %eax
95 .end
96
97 .inline ntohs,4
98 movl %edi, %eax
99 bswap %eax
100 shrl $16, %eax
|
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /
27 / In-line functions for amd64 kernels.
28 /
29
30 /
31 / return current thread pointer
32 /
33 / NOTE: the "0x18" should be replaced by the computed value of the
34 / offset of "cpu_thread" from the beginning of the struct cpu.
35 / Including "assym.h" does not work, however, since that stuff
36 / is PSM-specific and is only visible to the 'unix' build anyway.
37 / Same with current cpu pointer, where "0xc" should be replaced
38 / by the computed value of the offset of "cpu_self".
39 / Ugh -- what a disaster.
40 /
41 .inline threadp,0
42 movq %gs:0x18, %rax
43 .end
44
45 /
59 /
60 / convert ipl to spl. This is the identity function for i86
61 /
62 .inline ipltospl,0
63 movq %rdi, %rax
64 .end
65
66 /
67 / find the low order bit in a word
68 /
69 .inline lowbit,4
70 movq $-1, %rax
71 bsfq %rdi, %rax
72 incq %rax
73 .end
74
75 /
76 / Networking byte order functions (too bad, Intel has the wrong byte order)
77 /
78
79 .inline htonll,4
80 movq %rdi, %rax
81 bswapq %rax
82 .end
83
84 .inline ntohll,4
85 movq %rdi, %rax
86 bswapq %rax
87 .end
88
89 .inline htonl,4
90 movl %edi, %eax
91 bswap %eax
92 .end
93
94 .inline ntohl,4
95 movl %edi, %eax
96 bswap %eax
97 .end
98
99 .inline htons,4
100 movl %edi, %eax
101 bswap %eax
102 shrl $16, %eax
103 .end
104
105 .inline ntohs,4
106 movl %edi, %eax
107 bswap %eax
108 shrl $16, %eax
|