[BACK]Return to pio.h CVS log [TXT][DIR] Up to [local] / sys / arch / mips64 / include

Annotation of sys/arch/mips64/include/pio.h, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: pio.h,v 1.3 2004/08/10 20:28:13 deraadt Exp $ */
        !             2:
        !             3: /*
        !             4:  * Copyright (c) 2001-2003 Opsycon AB  (www.opsycon.se / www.opsycon.com)
        !             5:  *
        !             6:  * Redistribution and use in source and binary forms, with or without
        !             7:  * modification, are permitted provided that the following conditions
        !             8:  * are met:
        !             9:  * 1. Redistributions of source code must retain the above copyright
        !            10:  *    notice, this list of conditions and the following disclaimer.
        !            11:  * 2. Redistributions in binary form must reproduce the above copyright
        !            12:  *    notice, this list of conditions and the following disclaimer in the
        !            13:  *    documentation and/or other materials provided with the distribution.
        !            14:  *
        !            15:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
        !            16:  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
        !            17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            18:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
        !            19:  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            20:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            21:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            22:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            23:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            24:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            25:  * SUCH DAMAGE.
        !            26:  *
        !            27:  */
        !            28:
        !            29: #ifndef _MIPS_PIO_H_
        !            30: #define _MIPS_PIO_H_
        !            31:
        !            32: /*
        !            33:  * I/O macros.
        !            34:  */
        !            35:
        !            36: #define        outb(a,v)       (*(volatile unsigned char*)(a) = (v))
        !            37: #define        out8(a,v)       (*(volatile unsigned char*)(a) = (v))
        !            38: #define        outw(a,v)       (*(volatile unsigned short*)(a) = (v))
        !            39: #define        out16(a,v)      outw(a,v)
        !            40: #define        outl(a,v)       (*(volatile unsigned int*)(a) = (v))
        !            41: #define        out32(a,v)      outl(a,v)
        !            42: #define        inb(a)          (*(volatile unsigned char*)(a))
        !            43: #define        in8(a)          (*(volatile unsigned char*)(a))
        !            44: #define        inw(a)          (*(volatile unsigned short*)(a))
        !            45: #define        in16(a)         inw(a)
        !            46: #define        inl(a)          (*(volatile unsigned int*)(a))
        !            47: #define        in32(a)         inl(a)
        !            48:
        !            49: #define        out8rb(a,v)     (*(volatile unsigned char*)(a) = (v))
        !            50: #define out16rb(a,v)   (__out16rb((volatile u_int16_t *)(a), v))
        !            51: #define out32rb(a,v)   (__out32rb((volatile u_int32_t *)(a), v))
        !            52: #define        in8rb(a)        (*(volatile unsigned char*)(a))
        !            53: #define in16rb(a)      (__in16rb((volatile u_int16_t *)(a)))
        !            54: #define in32rb(a)      (__in32rb((volatile u_int32_t *)(a)))
        !            55:
        !            56: #define        _swap_(x) \
        !            57:        (((x) >> 24) | ((x) << 24) | \
        !            58:        (((x) >> 8) & 0xff00) | (((x) & 0xff00) << 8))
        !            59:
        !            60: static __inline void __out32rb(volatile u_int32_t *, u_int32_t);
        !            61: static __inline void __out16rb(volatile u_int16_t *, u_int16_t);
        !            62: static __inline u_int32_t __in32rb(volatile u_int32_t *);
        !            63: static __inline u_int16_t __in16rb(volatile u_int16_t *);
        !            64:
        !            65: static __inline void
        !            66: __out32rb(a,v)
        !            67:        volatile u_int32_t *a;
        !            68:        u_int32_t v;
        !            69: {
        !            70:        u_int32_t _v_ = v;
        !            71:
        !            72:        _v_ = _swap_(_v_);
        !            73:        out32(a, _v_);
        !            74: }
        !            75:
        !            76: static __inline void
        !            77: __out16rb(a,v)
        !            78:         volatile u_int16_t *a;
        !            79:         u_int16_t v;
        !            80: {
        !            81:         u_int16_t _v_;
        !            82:
        !            83:        _v_ = ((v >> 8) & 0xff) | (v << 8);
        !            84:        out16(a, _v_);
        !            85: }
        !            86:
        !            87: static __inline u_int32_t
        !            88: __in32rb(a)
        !            89:         volatile u_int32_t *a;
        !            90: {
        !            91:         u_int32_t _v_;
        !            92:
        !            93:        _v_ = in32(a);
        !            94:        _v_ = _swap_(_v_);
        !            95:         return _v_;
        !            96: }
        !            97:
        !            98: static __inline u_int16_t
        !            99: __in16rb(a)
        !           100:         volatile u_int16_t *a;
        !           101: {
        !           102:         u_int16_t _v_;
        !           103:
        !           104:        _v_ = in16(a);
        !           105:        _v_ = ((_v_ >> 8) & 0xff) | (_v_ << 8);
        !           106:         return _v_;
        !           107: }
        !           108:
        !           109: void insb(u_int8_t *, u_int8_t *,int);
        !           110: void insw(u_int16_t *, u_int16_t *,int);
        !           111: void insl(u_int32_t *, u_int32_t *,int);
        !           112: void outsb(u_int8_t *, const u_int8_t *,int);
        !           113: void outsw(u_int16_t *, const u_int16_t *,int);
        !           114: void outsl(u_int32_t *, const u_int32_t *,int);
        !           115:
        !           116: /* Helper function to access bus 64 bit at at time in LP32 mode */
        !           117: u_int64_t lp32_read8(u_int64_t *);
        !           118: void lp32_write8(u_int64_t *, u_int64_t);
        !           119:
        !           120: #endif /* !_MIPS_PIO_H_ */

CVSweb