Home | History | Annotate | Line # | Download | only in include
pio.h revision 1.1.2.1
      1  1.1.2.1  mellon /*	$NetBSD: pio.h,v 1.1.2.1 1997/11/28 19:43:56 mellon Exp $ */
      2  1.1.2.1  mellon /*	$OpenBSD: pio.h,v 1.1 1997/10/13 10:53:47 pefo Exp $ */
      3  1.1.2.1  mellon 
      4  1.1.2.1  mellon /*
      5  1.1.2.1  mellon  * Copyright (c) 1997 Per Fogelstrom, Opsycon AB and RTMX Inc, USA.
      6  1.1.2.1  mellon  *
      7  1.1.2.1  mellon  * Redistribution and use in source and binary forms, with or without
      8  1.1.2.1  mellon  * modification, are permitted provided that the following conditions
      9  1.1.2.1  mellon  * are met:
     10  1.1.2.1  mellon  * 1. Redistributions of source code must retain the above copyright
     11  1.1.2.1  mellon  *    notice, this list of conditions and the following disclaimer.
     12  1.1.2.1  mellon  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1.2.1  mellon  *    notice, this list of conditions and the following disclaimer in the
     14  1.1.2.1  mellon  *    documentation and/or other materials provided with the distribution.
     15  1.1.2.1  mellon  * 3. All advertising materials mentioning features or use of this software
     16  1.1.2.1  mellon  *    must display the following acknowledgement:
     17  1.1.2.1  mellon  *	This product includes software developed under OpenBSD by
     18  1.1.2.1  mellon  *	Per Fogelstrom Opsycon AB for RTMX Inc, North Carolina, USA.
     19  1.1.2.1  mellon  * 4. The name of the author may not be used to endorse or promote products
     20  1.1.2.1  mellon  *    derived from this software without specific prior written permission.
     21  1.1.2.1  mellon  *
     22  1.1.2.1  mellon  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
     23  1.1.2.1  mellon  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     24  1.1.2.1  mellon  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25  1.1.2.1  mellon  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
     26  1.1.2.1  mellon  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27  1.1.2.1  mellon  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28  1.1.2.1  mellon  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29  1.1.2.1  mellon  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30  1.1.2.1  mellon  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31  1.1.2.1  mellon  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32  1.1.2.1  mellon  * SUCH DAMAGE.
     33  1.1.2.1  mellon  *
     34  1.1.2.1  mellon  */
     35  1.1.2.1  mellon 
     36  1.1.2.1  mellon #ifndef _MACHINE_PIO_H_
     37  1.1.2.1  mellon #define _MACHINE_PIO_H_
     38  1.1.2.1  mellon /*
     39  1.1.2.1  mellon  * I/O macros.
     40  1.1.2.1  mellon  */
     41  1.1.2.1  mellon 
     42  1.1.2.1  mellon static __inline void
     43  1.1.2.1  mellon __outb(a,v)
     44  1.1.2.1  mellon 	volatile u_int8_t *a;
     45  1.1.2.1  mellon 	int v;
     46  1.1.2.1  mellon {
     47  1.1.2.1  mellon 	*a = v;
     48  1.1.2.1  mellon 	__asm__ volatile("eieio; sync");
     49  1.1.2.1  mellon }
     50  1.1.2.1  mellon 
     51  1.1.2.1  mellon static __inline void
     52  1.1.2.1  mellon __outw(a,v)
     53  1.1.2.1  mellon 	volatile u_int16_t *a;
     54  1.1.2.1  mellon 	u_int16_t v;
     55  1.1.2.1  mellon {
     56  1.1.2.1  mellon 	*a = v;
     57  1.1.2.1  mellon 	__asm__ volatile("eieio; sync");
     58  1.1.2.1  mellon }
     59  1.1.2.1  mellon 
     60  1.1.2.1  mellon static __inline void
     61  1.1.2.1  mellon __outl(a,v)
     62  1.1.2.1  mellon 	volatile u_int32_t *a;
     63  1.1.2.1  mellon 	int v;
     64  1.1.2.1  mellon {
     65  1.1.2.1  mellon 	*a = v;
     66  1.1.2.1  mellon 	__asm__ volatile("eieio; sync");
     67  1.1.2.1  mellon }
     68  1.1.2.1  mellon 
     69  1.1.2.1  mellon static __inline void
     70  1.1.2.1  mellon __outwrb(a,v)
     71  1.1.2.1  mellon 	volatile u_int16_t *a;
     72  1.1.2.1  mellon 	u_int16_t v;
     73  1.1.2.1  mellon {
     74  1.1.2.1  mellon 	u_int32_t _p_ = (u_int32_t)a;
     75  1.1.2.1  mellon 
     76  1.1.2.1  mellon 	__asm__ volatile("sthbrx %0, 0, %1" :: "r"(v), "r"(_p_));
     77  1.1.2.1  mellon 	__asm__ volatile("eieio; sync");
     78  1.1.2.1  mellon }
     79  1.1.2.1  mellon 
     80  1.1.2.1  mellon static __inline void
     81  1.1.2.1  mellon __outlrb(a,v)
     82  1.1.2.1  mellon 	volatile u_int32_t *a;
     83  1.1.2.1  mellon 	u_int32_t v;
     84  1.1.2.1  mellon {
     85  1.1.2.1  mellon 	u_int32_t _p_ = (u_int32_t)a;
     86  1.1.2.1  mellon 
     87  1.1.2.1  mellon 	__asm__ volatile("stwbrx %0, 0, %1" :: "r"(v), "r"(_p_));
     88  1.1.2.1  mellon 	__asm__ volatile("eieio; sync");
     89  1.1.2.1  mellon }
     90  1.1.2.1  mellon 
     91  1.1.2.1  mellon static __inline u_int8_t
     92  1.1.2.1  mellon __inb(a)
     93  1.1.2.1  mellon 	volatile u_int8_t *a;
     94  1.1.2.1  mellon {
     95  1.1.2.1  mellon 	u_int8_t _v_;
     96  1.1.2.1  mellon 
     97  1.1.2.1  mellon 	_v_ = *a;
     98  1.1.2.1  mellon 	__asm__ volatile("eieio; sync");
     99  1.1.2.1  mellon 	return _v_;
    100  1.1.2.1  mellon }
    101  1.1.2.1  mellon 
    102  1.1.2.1  mellon static __inline u_int16_t
    103  1.1.2.1  mellon __inw(a)
    104  1.1.2.1  mellon 	volatile u_int16_t *a;
    105  1.1.2.1  mellon {
    106  1.1.2.1  mellon 	u_int16_t _v_;
    107  1.1.2.1  mellon 
    108  1.1.2.1  mellon 	_v_ = *a;
    109  1.1.2.1  mellon 	__asm__ volatile("eieio; sync");
    110  1.1.2.1  mellon 	return _v_;
    111  1.1.2.1  mellon }
    112  1.1.2.1  mellon 
    113  1.1.2.1  mellon static __inline u_int32_t
    114  1.1.2.1  mellon __inl(a)
    115  1.1.2.1  mellon 	volatile u_int32_t *a;
    116  1.1.2.1  mellon {
    117  1.1.2.1  mellon 	u_int32_t _v_;
    118  1.1.2.1  mellon 
    119  1.1.2.1  mellon 	_v_ = *a;
    120  1.1.2.1  mellon 	__asm__ volatile("eieio; sync");
    121  1.1.2.1  mellon 	return _v_;
    122  1.1.2.1  mellon }
    123  1.1.2.1  mellon 
    124  1.1.2.1  mellon static __inline u_int16_t
    125  1.1.2.1  mellon __inwrb(a)
    126  1.1.2.1  mellon 	volatile u_int16_t *a;
    127  1.1.2.1  mellon {
    128  1.1.2.1  mellon 	u_int16_t _v_;
    129  1.1.2.1  mellon 	u_int32_t _p_ = (u_int32_t)a;
    130  1.1.2.1  mellon 
    131  1.1.2.1  mellon 	__asm__ volatile("lhbrx %0, 0, %1" : "=r"(_v_) : "r"(_p_));
    132  1.1.2.1  mellon 	__asm__ volatile("eieio; sync");
    133  1.1.2.1  mellon 	return _v_;
    134  1.1.2.1  mellon }
    135  1.1.2.1  mellon 
    136  1.1.2.1  mellon static __inline u_int32_t
    137  1.1.2.1  mellon __inlrb(a)
    138  1.1.2.1  mellon 	volatile u_int32_t *a;
    139  1.1.2.1  mellon {
    140  1.1.2.1  mellon 	u_int32_t _v_;
    141  1.1.2.1  mellon 	u_int32_t _p_ = (u_int32_t)a;
    142  1.1.2.1  mellon 
    143  1.1.2.1  mellon 	__asm__ volatile("lwbrx %0, 0, %1" : "=r"(_v_) : "r"(_p_));
    144  1.1.2.1  mellon 	__asm__ volatile("eieio; sync");
    145  1.1.2.1  mellon 	return _v_;
    146  1.1.2.1  mellon }
    147  1.1.2.1  mellon 
    148  1.1.2.1  mellon 
    149  1.1.2.1  mellon #define	outb(a,v)	(__outb((volatile u_int8_t *)(a), v))
    150  1.1.2.1  mellon #define	out8(a,v)	outb(a,v)
    151  1.1.2.1  mellon #define	outw(a,v)	(__outw((volatile u_int16_t *)(a), v))
    152  1.1.2.1  mellon #define	out16(a,v)	outw(a,v)
    153  1.1.2.1  mellon #define	outl(a,v)	(__outl((volatile u_int32_t *)(a), v))
    154  1.1.2.1  mellon #define	out32(a,v)	outl(a,v)
    155  1.1.2.1  mellon #define	inb(a)		(__inb((volatile u_int8_t *)(a)))
    156  1.1.2.1  mellon #define	in8(a)		inb(a)
    157  1.1.2.1  mellon #define	inw(a)		(__inw((volatile u_int16_t *)(a)))
    158  1.1.2.1  mellon #define	in16(a)		inw(a)
    159  1.1.2.1  mellon #define	inl(a)		(__inl((volatile u_int32_t *)(a)))
    160  1.1.2.1  mellon #define	in32(a)		inl(a)
    161  1.1.2.1  mellon 
    162  1.1.2.1  mellon #define	out8rb(a,v)	outb(a,v)
    163  1.1.2.1  mellon #define	outwrb(a,v)	(__outwrb((volatile u_int16_t *)(a), v))
    164  1.1.2.1  mellon #define	out16rb(a,v)	outwrb(a,v)
    165  1.1.2.1  mellon #define	outlrb(a,v)	(__outlrb((volatile u_int32_t *)(a), v))
    166  1.1.2.1  mellon #define	out32rb(a,v)	outlrb(a,v)
    167  1.1.2.1  mellon #define	in8rb(a)	inb(a)
    168  1.1.2.1  mellon #define	inwrb(a)	(__inwrb((volatile u_int16_t *)(a)))
    169  1.1.2.1  mellon #define	in16rb(a)	inwrb(a)
    170  1.1.2.1  mellon #define	inlrb(a)	(__inlrb((volatile u_int32_t *)(a)))
    171  1.1.2.1  mellon #define	in32rb(a)	inlrb(a)
    172  1.1.2.1  mellon 
    173  1.1.2.1  mellon #endif /*_MACHINE_PIO_H_*/
    174