summaryrefslogtreecommitdiff
path: root/usr/src/uts/i86pc/ml/ia32.il
blob: 44354b8bca6dac8bd880c82d4b9f8dd29c1c5896 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/
/ Inline functions specific to the i86pc kernel running on bare metal.
/

/
/ return value of cr3 register
/
	.inline	getcr3,0
	movl	%cr3, %eax
	.end

/
/ reload cr3 register with its current value
/
	.inline	reload_cr3,0
	movl	%cr3, %eax
	movl	%eax, %cr3
	.end

/*
 * Put a new value into cr3 (page table base register
 *	void setcr3(void *value)
 */
	.inline	setcr3,4
	movl	(%esp), %eax
	movl	%eax, %cr3
	.end

/
/ enable interrupts
/
	.inline	sti,0
	sti
	.end

/
/ disable interrupts
/
	.inline cli,0
	cli
	.end

/
/ disable interrupts and return value describing if interrupts were enabled
/
	.inline	clear_int_flag,0
	pushfl
	cli
	popl	%eax
	.end

	.inline	intr_clear,0
	pushfl
	cli
	popl	%eax
	.end

/
/ return the flags register
/
	.inline getflags,0
	pushfl
	popl	%eax
	.end

/
/ restore interrupt enable flag to value returned from 'clear_int_flag' above
/
	.inline restore_int_flag,4
	testl	$0x200, (%esp)
	jz	1f
	sti
1:
	.end

	.inline intr_restore,4
	testl	$0x200, (%esp)
	jz	1f
	sti
1:
	.end

/
/ in and out
/
	.inline	inb,4
	movl	(%esp), %edx
	xorl    %eax, %eax
	inb	(%dx)
	.end

	.inline	inw,4
	movl	(%esp), %edx
	xorl    %eax, %eax
	inw	(%dx)
	.end

	.inline	inl,4
	movl	(%esp), %edx
	xorl    %eax, %eax
	inl	(%dx)
	.end

	.inline	outb,8
	movl	(%esp), %edx
	movl    4(%esp), %eax
	outb	(%dx)
	.end

	.inline	outw,8
	movl	(%esp), %edx
	movl    4(%esp), %eax
	outw	(%dx)
	.end

	.inline	outl,8
	movl	(%esp), %edx
	movl    4(%esp), %eax
	outl	(%dx)
	.end

/*
 * Invalidate TLB translation to 1 page.
 *	void mmu_tlbflush_entry(void *addr)
 */
	.inline	mmu_tlbflush_entry,4
	movl	(%esp), %eax
	invlpg	(%eax)
	.end

/*
 * Call the halt instruction. This will put the CPU to sleep until
 * it is again awoken via an interrupt.
 * This function should be called with interrupts already disabled
 * for the CPU.
 * Note that "sti" will only enable interrupts at the end of the
 * subsequent instruction...in this case: "hlt".
 */
	.inline i86_halt,0
	sti
	hlt
	.end

/*
 * execute the bsrw instruction
 *	int bsrw_insn(uint16_t)
 */
	.inline	bsrw_insn,4
	xorl	%eax, %eax
	movw	(%esp), %cx
	bsrw	%cx, %ax
	.end