xref: /onnv-gate/usr/src/uts/intel/asm/sunddi.h (revision 231:fbcbedccbc5a)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
220Sstevel@tonic-gate /*
23*231Sjg  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef _ASM_SUNDDI_H
280Sstevel@tonic-gate #define	_ASM_SUNDDI_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #include <sys/types.h>
330Sstevel@tonic-gate 
340Sstevel@tonic-gate #ifdef	__cplusplus
350Sstevel@tonic-gate extern "C" {
360Sstevel@tonic-gate #endif
370Sstevel@tonic-gate 
380Sstevel@tonic-gate #if !defined(__lint) && defined(__GNUC__)
390Sstevel@tonic-gate 
400Sstevel@tonic-gate #if defined(__i386) || defined(__amd64)
410Sstevel@tonic-gate 
inb(int port)420Sstevel@tonic-gate extern __inline__ uint8_t inb(int port)
430Sstevel@tonic-gate {
440Sstevel@tonic-gate 	uint16_t port16 = (uint16_t)port;
450Sstevel@tonic-gate 	uint8_t value;
460Sstevel@tonic-gate 
470Sstevel@tonic-gate 	__asm__ __volatile__(
480Sstevel@tonic-gate 		"inb (%1)"		/* value in %al */
490Sstevel@tonic-gate 		: "=a" (value)
500Sstevel@tonic-gate 		: "d" (port16));
510Sstevel@tonic-gate 	return (value);
520Sstevel@tonic-gate }
530Sstevel@tonic-gate 
inw(int port)540Sstevel@tonic-gate extern __inline__ uint16_t inw(int port)
550Sstevel@tonic-gate {
560Sstevel@tonic-gate 	uint16_t port16 = (uint16_t)port;
570Sstevel@tonic-gate 	uint16_t value;
580Sstevel@tonic-gate 
590Sstevel@tonic-gate 	__asm__ __volatile__(
600Sstevel@tonic-gate 		"inw (%1)"		/* value in %ax */
610Sstevel@tonic-gate 		: "=a" (value)
620Sstevel@tonic-gate 		: "d" (port16));
630Sstevel@tonic-gate 	return (value);
640Sstevel@tonic-gate }
650Sstevel@tonic-gate 
inl(int port)660Sstevel@tonic-gate extern __inline__ uint32_t inl(int port)
670Sstevel@tonic-gate {
680Sstevel@tonic-gate 	uint16_t port16 = (uint16_t)port;
690Sstevel@tonic-gate 	uint32_t value;
700Sstevel@tonic-gate 
710Sstevel@tonic-gate 	__asm__ __volatile__(
720Sstevel@tonic-gate 		"inl (%1)"		/* value in %eax */
730Sstevel@tonic-gate 		: "=a" (value)
740Sstevel@tonic-gate 		: "d" (port16));
750Sstevel@tonic-gate 	return (value);
760Sstevel@tonic-gate }
770Sstevel@tonic-gate 
outb(int port,uint8_t value)780Sstevel@tonic-gate extern __inline__ void outb(int port, uint8_t value)
790Sstevel@tonic-gate {
800Sstevel@tonic-gate 	uint16_t port16 = (uint16_t)port;
810Sstevel@tonic-gate 
820Sstevel@tonic-gate 	__asm__ __volatile__(
830Sstevel@tonic-gate 		"outb (%1)"
840Sstevel@tonic-gate 		: /* no output */
850Sstevel@tonic-gate 		: "a" (value), "d" (port16));
860Sstevel@tonic-gate }
870Sstevel@tonic-gate 
outw(int port,uint16_t value)880Sstevel@tonic-gate extern __inline__ void outw(int port, uint16_t value)
890Sstevel@tonic-gate {
900Sstevel@tonic-gate 	uint16_t port16 = (uint16_t)port;
910Sstevel@tonic-gate 
920Sstevel@tonic-gate 	__asm__ __volatile__(
930Sstevel@tonic-gate 		"outw (%1)"
940Sstevel@tonic-gate 		: /* no output */
950Sstevel@tonic-gate 		: "a" (value), "d" (port16));
960Sstevel@tonic-gate }
970Sstevel@tonic-gate 
outl(int port,uint32_t value)980Sstevel@tonic-gate extern __inline__ void outl(int port, uint32_t value)
990Sstevel@tonic-gate {
1000Sstevel@tonic-gate 	uint16_t port16 = (uint16_t)port;
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate 	__asm__ __volatile__(
1030Sstevel@tonic-gate 		"outl (%1)"
1040Sstevel@tonic-gate 		: /* no output */
1050Sstevel@tonic-gate 		: "a" (value), "d" (port16));
1060Sstevel@tonic-gate }
1070Sstevel@tonic-gate 
108*231Sjg #if defined(_BOOT)
109*231Sjg 
sync_instruction_memory(caddr_t v,size_t len)110*231Sjg extern __inline__ void sync_instruction_memory(caddr_t v, size_t len)
111*231Sjg {
112*231Sjg 	__asm__ __volatile__("nop");
113*231Sjg }
114*231Sjg 
115*231Sjg #endif /* _BOOT */
116*231Sjg 
1170Sstevel@tonic-gate #endif /* __i386 || __amd64 */
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate #endif /* !__lint && __GNUC__ */
1200Sstevel@tonic-gate 
1210Sstevel@tonic-gate #ifdef __cplusplus
1220Sstevel@tonic-gate }
1230Sstevel@tonic-gate #endif
1240Sstevel@tonic-gate 
1250Sstevel@tonic-gate #endif	/* _ASM_SUNDDI_H */
126