xref: /titanic_50/usr/src/uts/intel/io/acpica/osl_ml.s (revision ae115bc77f6fcde83175c75b4206dc2e50747966)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License").  You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
23 * Copyright 2005 Sun Microsystems, Inc.
24 * Use is subject to license terms.
25 * All rights reserved.
26 */
27#pragma ident	"%Z%%M%	%I%	%E% SMI"
28
29#include <sys/asm_linkage.h>
30#include <sys/asm_misc.h>
31
32#if defined(lint) || defined(__lint)
33#include <sys/types.h>
34#include "acpi.h"
35#endif	/* lint */
36
37/*
38 * Implementation as specific by ACPI 3.0 specification
39 * section 5.2.10.1
40 *
41 * Global Lock Structure within the FACS
42 *
43 * |-----------------------------------------------------------------------|
44 * |  Field  | Bit Length | Bit Offset |           Description             |
45 * |---------|------------|------------|-----------------------------------|
46 * | Pending |     1      |     0      | Non-zero indicates that a request |
47 * |         |            |            | for ownership of the global lock  |
48 * |         |            |            | is pending.                       |
49 * |---------|------------|------------|-----------------------------------|
50 * | Owned   |     1      |     1      | Non-zero indicates that the Global|
51 * |         |            |            | lock is owned.                    |
52 * |---------|------------|------------|-----------------------------------|
53 * | Reserved|     30     |     2      | Reserved for future use           |
54 * |---------|------------|------------|-----------------------------------|
55 */
56
57
58#if defined(lint) || defined(__lint)
59
60/* ARGSUSED */
61UINT32
62__acpi_acquire_global_lock(UINT32 *glp)
63{ return (0); }
64
65#else	/* lint */
66
67#if defined(__amd64)
68	ENTRY(__acpi_acquire_global_lock)
69	movq	%rdi, %rcx		/ %ecx - glp
70__acpi_acquire_global_lock_000:
71	movl	(%rdi), %eax		/ get current value of Global Lock
72	movl	%eax, %edx
73	andl	$0xFFFFFFFE, %edx	/ Clear pending bit
74	btsl	$1, %edx		/ Check and set owner bit
75	adcl	$0, %edx		/ If owned, set pending bit
76	lock
77	cmpxchgl %edx, (%rdi)		/ Attempt to set new value
78	jnz	__acpi_acquire_global_lock_000 / If not set, try again
79	cmpb	$3, %dl			/ Was it acquired or marked pending?
80	sbbq	%rax, %rax		/ acquired = -1, pending = 0
81	ret
82	SET_SIZE(__acpi_acquire_global_lock)
83
84#elif defined(__i386)
85
86	ENTRY(__acpi_acquire_global_lock)
87	movl	4(%esp), %ecx		/ %ecx - glp
88__acpi_acquire_global_lock_000:
89	movl	(%ecx), %eax
90	movl	%eax, %edx
91	andl	$0xFFFFFFFE, %edx
92	btsl	$1, %edx
93	adcl	$0, %edx
94	lock
95	cmpxchgl %edx, (%ecx)
96	jnz	__acpi_acquire_global_lock_000
97	cmpb	$3, %dl
98	sbbl	%eax, %eax
99	ret
100	SET_SIZE(__acpi_acquire_global_lock)
101
102#endif	/* i386 */
103
104#endif	/* lint */
105
106
107#if defined(lint) || defined(__lint)
108
109/* ARGSUSED */
110UINT32
111__acpi_release_global_lock(UINT32 *glp)
112{ return (0); }
113
114#else	/* lint */
115
116#if defined(__amd64)
117	ENTRY(__acpi_release_global_lock)
118	movq	%rdi, %rcx
119__acpi_release_global_lock_000:
120	movl	(%rdi), %eax
121	movl	%eax, %edx
122	andl	$0xFFFFFFFC, %edx
123	lock
124	cmpxchgl %edx, (%rdi)
125	jnz	__acpi_release_global_lock_000
126	andq	$1, %Rax
127	ret
128	SET_SIZE(__acpi_release_global_lock)
129
130#elif defined(__i386)
131
132	ENTRY(__acpi_release_global_lock)
133	movl	4(%esp), %ecx
134__acpi_release_global_lock_000:
135	movl	(%ecx), %eax
136	movl	%eax, %edx
137	andl	$0xFFFFFFFC, %edx
138	lock
139	cmpxchgl %edx, (%ecx)
140	jnz	__acpi_release_global_lock_000
141	andl	$1, %eax
142	ret
143	SET_SIZE(__acpi_release_global_lock)
144
145#endif	/* i386 */
146
147#endif	/* lint */
148
149
150/*
151 * execute WBINVD instruction
152 */
153
154#if defined(lint) || defined(__lint)
155
156/* ARGSUSED */
157void
158__acpi_wbinvd(void)
159{ }
160
161#else	/* lint */
162
163	ENTRY(__acpi_wbinvd)
164	wbinvd
165	ret
166	SET_SIZE(__acpi_wbinvd)
167
168#endif	/* lint */
169
170