xref: /titanic_41/usr/src/uts/i86pc/dboot/dboot_asm.s (revision 8475e04352e630e4bd0f59a283286ee2475a14ce)
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 (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/*
23 * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
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)
33
34#include "dboot_asm.h"
35
36/* ARGSUSED */
37uint32_t
38get_cpuid_edx(uint32_t *eax)
39{ return (0); }
40
41/* ARGSUSED */
42void
43outb(int port, uint8_t value)
44{}
45
46/* ARGSUSED */
47uint8_t
48inb(int port)
49{ return (0); }
50
51#else /* __lint */
52
53#if defined(__amd64)
54
55	/*
56	 * do a cpuid instruction, returning the eax/edx values
57	 *
58	 * uint32_t get_cpuid_edx(uint32_t *eax)
59	 */
60	ENTRY_NP(get_cpuid_edx)
61	pushq	%rbx
62	movl	(%rdi), %eax
63	cpuid
64	movl	%eax, (%rdi)
65	movl	%edx, %eax
66	popq	%rbx
67	ret
68	SET_SIZE(get_cpuid_edx)
69
70	/*
71	 * void outb(int port, uint8_t value)
72	 */
73	ENTRY(outb)
74	movw	%di, %dx
75	movb	%sil, %al
76	outb	(%dx)
77	ret
78	SET_SIZE(outb)
79
80	/*
81	 * uint8_t inb(int port)
82	 */
83	ENTRY(inb)
84	xorl	%eax, %eax
85	movw	%di, %dx
86	inb	(%dx)
87	ret
88	SET_SIZE(inb)
89
90#elif defined(__i386)
91
92	.code32
93
94	/*
95	 * do a cpuid instruction, returning the eax/edx values
96	 *
97	 * uint32_t get_cpuid_edx(uint32_t *eax)
98	 */
99	ENTRY_NP(get_cpuid_edx)
100	movl	4(%esp), %ecx
101	movl	(%ecx), %eax
102	pushl	%ebx
103	cpuid
104	popl	%ebx
105	movl	4(%esp), %ecx
106	movl	%eax, (%ecx)
107	movl	%edx, %eax
108	ret
109	SET_SIZE(get_cpuid_edx)
110
111	/*
112	 * void outb(int port, uint8_t value)
113	 */
114	ENTRY_NP(outb)
115	movl	4(%esp), %edx
116	movl	8(%esp), %eax
117	outb	(%dx)
118	ret
119	SET_SIZE(outb)
120
121	/*
122	 * uint8_t inb(int port)
123	 */
124	ENTRY_NP(inb)
125	movl	4(%esp), %edx
126	inb	(%dx)
127	andl	$0xff, %eax
128	ret
129	SET_SIZE(inb)
130
131#endif	/* __i386 */
132
133#endif /* __lint */
134