17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 23*bcbe9155Sjg * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _ASM_SUNDDI_H 287c478bd9Sstevel@tonic-gate #define _ASM_SUNDDI_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #include <sys/types.h> 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 357c478bd9Sstevel@tonic-gate extern "C" { 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #if !defined(__lint) && defined(__GNUC__) 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__amd64) 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate extern __inline__ uint8_t inb(int port) 437c478bd9Sstevel@tonic-gate { 447c478bd9Sstevel@tonic-gate uint16_t port16 = (uint16_t)port; 457c478bd9Sstevel@tonic-gate uint8_t value; 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate __asm__ __volatile__( 487c478bd9Sstevel@tonic-gate "inb (%1)" /* value in %al */ 497c478bd9Sstevel@tonic-gate : "=a" (value) 507c478bd9Sstevel@tonic-gate : "d" (port16)); 517c478bd9Sstevel@tonic-gate return (value); 527c478bd9Sstevel@tonic-gate } 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate extern __inline__ uint16_t inw(int port) 557c478bd9Sstevel@tonic-gate { 567c478bd9Sstevel@tonic-gate uint16_t port16 = (uint16_t)port; 577c478bd9Sstevel@tonic-gate uint16_t value; 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate __asm__ __volatile__( 607c478bd9Sstevel@tonic-gate "inw (%1)" /* value in %ax */ 617c478bd9Sstevel@tonic-gate : "=a" (value) 627c478bd9Sstevel@tonic-gate : "d" (port16)); 637c478bd9Sstevel@tonic-gate return (value); 647c478bd9Sstevel@tonic-gate } 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate extern __inline__ uint32_t inl(int port) 677c478bd9Sstevel@tonic-gate { 687c478bd9Sstevel@tonic-gate uint16_t port16 = (uint16_t)port; 697c478bd9Sstevel@tonic-gate uint32_t value; 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate __asm__ __volatile__( 727c478bd9Sstevel@tonic-gate "inl (%1)" /* value in %eax */ 737c478bd9Sstevel@tonic-gate : "=a" (value) 747c478bd9Sstevel@tonic-gate : "d" (port16)); 757c478bd9Sstevel@tonic-gate return (value); 767c478bd9Sstevel@tonic-gate } 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate extern __inline__ void outb(int port, uint8_t value) 797c478bd9Sstevel@tonic-gate { 807c478bd9Sstevel@tonic-gate uint16_t port16 = (uint16_t)port; 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate __asm__ __volatile__( 837c478bd9Sstevel@tonic-gate "outb (%1)" 847c478bd9Sstevel@tonic-gate : /* no output */ 857c478bd9Sstevel@tonic-gate : "a" (value), "d" (port16)); 867c478bd9Sstevel@tonic-gate } 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate extern __inline__ void outw(int port, uint16_t value) 897c478bd9Sstevel@tonic-gate { 907c478bd9Sstevel@tonic-gate uint16_t port16 = (uint16_t)port; 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate __asm__ __volatile__( 937c478bd9Sstevel@tonic-gate "outw (%1)" 947c478bd9Sstevel@tonic-gate : /* no output */ 957c478bd9Sstevel@tonic-gate : "a" (value), "d" (port16)); 967c478bd9Sstevel@tonic-gate } 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate extern __inline__ void outl(int port, uint32_t value) 997c478bd9Sstevel@tonic-gate { 1007c478bd9Sstevel@tonic-gate uint16_t port16 = (uint16_t)port; 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate __asm__ __volatile__( 1037c478bd9Sstevel@tonic-gate "outl (%1)" 1047c478bd9Sstevel@tonic-gate : /* no output */ 1057c478bd9Sstevel@tonic-gate : "a" (value), "d" (port16)); 1067c478bd9Sstevel@tonic-gate } 1077c478bd9Sstevel@tonic-gate 108*bcbe9155Sjg #if defined(_BOOT) 109*bcbe9155Sjg 110*bcbe9155Sjg extern __inline__ void sync_instruction_memory(caddr_t v, size_t len) 111*bcbe9155Sjg { 112*bcbe9155Sjg __asm__ __volatile__("nop"); 113*bcbe9155Sjg } 114*bcbe9155Sjg 115*bcbe9155Sjg #endif /* _BOOT */ 116*bcbe9155Sjg 1177c478bd9Sstevel@tonic-gate #endif /* __i386 || __amd64 */ 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate #endif /* !__lint && __GNUC__ */ 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1227c478bd9Sstevel@tonic-gate } 1237c478bd9Sstevel@tonic-gate #endif 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate #endif /* _ASM_SUNDDI_H */ 126