xref: /titanic_51/usr/src/uts/i86pc/ml/ia32.il (revision a563a037ee1e9e7c39304f3775eb7327ab86b914)
1ae115bc7Smrj/*
2ae115bc7Smrj * CDDL HEADER START
3ae115bc7Smrj *
4ae115bc7Smrj * The contents of this file are subject to the terms of the
5ae115bc7Smrj * Common Development and Distribution License (the "License").
6ae115bc7Smrj * You may not use this file except in compliance with the License.
7ae115bc7Smrj *
8ae115bc7Smrj * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9ae115bc7Smrj * or http://www.opensolaris.org/os/licensing.
10ae115bc7Smrj * See the License for the specific language governing permissions
11ae115bc7Smrj * and limitations under the License.
12ae115bc7Smrj *
13ae115bc7Smrj * When distributing Covered Code, include this CDDL HEADER in each
14ae115bc7Smrj * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15ae115bc7Smrj * If applicable, add the following below this CDDL HEADER, with the
16ae115bc7Smrj * fields enclosed by brackets "[]" replaced with your own identifying
17ae115bc7Smrj * information: Portions Copyright [yyyy] [name of copyright owner]
18ae115bc7Smrj *
19ae115bc7Smrj * CDDL HEADER END
20ae115bc7Smrj */
21ae115bc7Smrj
22ae115bc7Smrj/*
23*a563a037Sbholler * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24ae115bc7Smrj * Use is subject to license terms.
25ae115bc7Smrj */
26ae115bc7Smrj
27ae115bc7Smrj#pragma ident	"%Z%%M%	%I%	%E% SMI"
28ae115bc7Smrj
29ae115bc7Smrj/
30ae115bc7Smrj/ Inline functions specific to the i86pc kernel running on bare metal.
31ae115bc7Smrj/
32ae115bc7Smrj
33ae115bc7Smrj/
34ae115bc7Smrj/ return value of cr3 register
35ae115bc7Smrj/
36ae115bc7Smrj	.inline	getcr3,0
37ae115bc7Smrj	movl	%cr3, %eax
38ae115bc7Smrj	.end
39ae115bc7Smrj
40ae115bc7Smrj/
41ae115bc7Smrj/ reload cr3 register with its current value
42ae115bc7Smrj/
43ae115bc7Smrj	.inline	reload_cr3,0
44ae115bc7Smrj	movl	%cr3, %eax
45ae115bc7Smrj	movl	%eax, %cr3
46ae115bc7Smrj	.end
47ae115bc7Smrj
48ae115bc7Smrj/*
49ae115bc7Smrj * Put a new value into cr3 (page table base register
50ae115bc7Smrj *	void setcr3(void *value)
51ae115bc7Smrj */
52ae115bc7Smrj	.inline	setcr3,4
53ae115bc7Smrj	movl	(%esp), %eax
54ae115bc7Smrj	movl	%eax, %cr3
55ae115bc7Smrj	.end
56ae115bc7Smrj
57ae115bc7Smrj/
58ae115bc7Smrj/ enable interrupts
59ae115bc7Smrj/
60ae115bc7Smrj	.inline	sti,0
61ae115bc7Smrj	sti
62ae115bc7Smrj	.end
63ae115bc7Smrj
64ae115bc7Smrj/
65ae115bc7Smrj/ disable interrupts
66ae115bc7Smrj/
67ae115bc7Smrj	.inline cli,0
68ae115bc7Smrj	cli
69ae115bc7Smrj	.end
70ae115bc7Smrj
71ae115bc7Smrj/
72ae115bc7Smrj/ disable interrupts and return value describing if interrupts were enabled
73ae115bc7Smrj/
74ae115bc7Smrj	.inline	clear_int_flag,0
75ae115bc7Smrj	pushfl
76ae115bc7Smrj	cli
77ae115bc7Smrj	popl	%eax
78ae115bc7Smrj	.end
79ae115bc7Smrj
80ae115bc7Smrj	.inline	intr_clear,0
81ae115bc7Smrj	pushfl
82ae115bc7Smrj	cli
83ae115bc7Smrj	popl	%eax
84ae115bc7Smrj	.end
85ae115bc7Smrj
86ae115bc7Smrj/
87ae115bc7Smrj/ return the flags register
88ae115bc7Smrj/
89ae115bc7Smrj	.inline getflags,0
90ae115bc7Smrj	pushfl
91ae115bc7Smrj	popl	%eax
92ae115bc7Smrj	.end
93ae115bc7Smrj
94ae115bc7Smrj/
95ae115bc7Smrj/ restore interrupt enable flag to value returned from 'clear_int_flag' above
96ae115bc7Smrj/
97ae115bc7Smrj	.inline restore_int_flag,4
98*a563a037Sbholler	testl	$0x200, (%esp)
99*a563a037Sbholler	jz	1f
100*a563a037Sbholler	sti
101*a563a037Sbholler1:
102ae115bc7Smrj	.end
103ae115bc7Smrj
104ae115bc7Smrj	.inline intr_restore,4
105*a563a037Sbholler	testl	$0x200, (%esp)
106*a563a037Sbholler	jz	1f
107*a563a037Sbholler	sti
108*a563a037Sbholler1:
109ae115bc7Smrj	.end
110ae115bc7Smrj
111ae115bc7Smrj/
112ae115bc7Smrj/ in and out
113ae115bc7Smrj/
114ae115bc7Smrj	.inline	inb,4
115ae115bc7Smrj	movl	(%esp), %edx
116ae115bc7Smrj	xorl    %eax, %eax
117ae115bc7Smrj	inb	(%dx)
118ae115bc7Smrj	.end
119ae115bc7Smrj
120ae115bc7Smrj	.inline	inw,4
121ae115bc7Smrj	movl	(%esp), %edx
122ae115bc7Smrj	xorl    %eax, %eax
123ae115bc7Smrj	inw	(%dx)
124ae115bc7Smrj	.end
125ae115bc7Smrj
126ae115bc7Smrj	.inline	inl,4
127ae115bc7Smrj	movl	(%esp), %edx
128ae115bc7Smrj	xorl    %eax, %eax
129ae115bc7Smrj	inl	(%dx)
130ae115bc7Smrj	.end
131ae115bc7Smrj
132ae115bc7Smrj	.inline	outb,8
133ae115bc7Smrj	movl	(%esp), %edx
134ae115bc7Smrj	movl    4(%esp), %eax
135ae115bc7Smrj	outb	(%dx)
136ae115bc7Smrj	.end
137ae115bc7Smrj
138ae115bc7Smrj	.inline	outw,8
139ae115bc7Smrj	movl	(%esp), %edx
140ae115bc7Smrj	movl    4(%esp), %eax
141ae115bc7Smrj	outw	(%dx)
142ae115bc7Smrj	.end
143ae115bc7Smrj
144ae115bc7Smrj	.inline	outl,8
145ae115bc7Smrj	movl	(%esp), %edx
146ae115bc7Smrj	movl    4(%esp), %eax
147ae115bc7Smrj	outl	(%dx)
148ae115bc7Smrj	.end
149ae115bc7Smrj
150ae115bc7Smrj/*
151ae115bc7Smrj * Invalidate TLB translation to 1 page.
152ae115bc7Smrj *	void mmu_tlbflush_entry(void *addr)
153ae115bc7Smrj */
154ae115bc7Smrj	.inline	mmu_tlbflush_entry,4
155ae115bc7Smrj	movl	(%esp), %eax
156ae115bc7Smrj	invlpg	(%eax)
157ae115bc7Smrj	.end
158ae115bc7Smrj
159ae115bc7Smrj/*
160ae115bc7Smrj * Call the halt instruction. This will put the CPU to sleep until
161ae115bc7Smrj * it is again awoken via an interrupt.
162ae115bc7Smrj * This function should be called with interrupts already disabled
163ae115bc7Smrj * for the CPU.
164ae115bc7Smrj * Note that "sti" will only enable interrupts at the end of the
165ae115bc7Smrj * subsequent instruction...in this case: "hlt".
166ae115bc7Smrj */
167ae115bc7Smrj	.inline i86_halt,0
168ae115bc7Smrj	sti
169ae115bc7Smrj	hlt
170ae115bc7Smrj	.end
171ae115bc7Smrj
172ae115bc7Smrj/*
173ae115bc7Smrj * execute the bsrw instruction
174ae115bc7Smrj *	int bsrw_insn(uint16_t)
175ae115bc7Smrj */
176ae115bc7Smrj	.inline	bsrw_insn,4
177ae115bc7Smrj	xorl	%eax, %eax
178ae115bc7Smrj	movw	(%esp), %cx
179ae115bc7Smrj	bsrw	%cx, %ax
180ae115bc7Smrj	.end
181