Home | History | Annotate | Line # | Download | only in include
      1  1.7     matt /* $NetBSD: bwx.h,v 1.7 2012/02/06 02:14:13 matt Exp $ */
      2  1.1  thorpej 
      3  1.1  thorpej /*-
      4  1.1  thorpej  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      5  1.1  thorpej  * All rights reserved.
      6  1.1  thorpej  *
      7  1.1  thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1  thorpej  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  1.1  thorpej  * NASA Ames Research Center.
     10  1.1  thorpej  *
     11  1.1  thorpej  * Redistribution and use in source and binary forms, with or without
     12  1.1  thorpej  * modification, are permitted provided that the following conditions
     13  1.1  thorpej  * are met:
     14  1.1  thorpej  * 1. Redistributions of source code must retain the above copyright
     15  1.1  thorpej  *    notice, this list of conditions and the following disclaimer.
     16  1.1  thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.1  thorpej  *    notice, this list of conditions and the following disclaimer in the
     18  1.1  thorpej  *    documentation and/or other materials provided with the distribution.
     19  1.1  thorpej  *
     20  1.1  thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21  1.1  thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22  1.1  thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23  1.1  thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24  1.1  thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25  1.1  thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26  1.1  thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27  1.1  thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28  1.1  thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29  1.1  thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30  1.1  thorpej  * POSSIBILITY OF SUCH DAMAGE.
     31  1.1  thorpej  */
     32  1.1  thorpej 
     33  1.1  thorpej #ifndef _ALPHA_BWX_H_
     34  1.1  thorpej #define	_ALPHA_BWX_H_
     35  1.1  thorpej 
     36  1.1  thorpej /*
     37  1.1  thorpej  * Alpha Byte/Word Extension instructions.
     38  1.1  thorpej  *
     39  1.1  thorpej  * These instructions are available on EV56 (21164A) and later processors.
     40  1.1  thorpej  *
     41  1.1  thorpej  * See "Alpha Architecture Handbook, Version 3", DEC order number EC-QD2KB-TE.
     42  1.1  thorpej  */
     43  1.1  thorpej 
     44  1.7     matt static __inline uint8_t
     45  1.7     matt alpha_ldbu(volatile uint8_t *a0)
     46  1.1  thorpej {
     47  1.7     matt 	uint8_t v0;
     48  1.1  thorpej 
     49  1.4    perry 	__asm volatile("ldbu %0, %1"
     50  1.1  thorpej 		: "=r" (v0)
     51  1.1  thorpej 		: "m" (*a0));
     52  1.1  thorpej 
     53  1.1  thorpej 	return (v0);
     54  1.1  thorpej }
     55  1.1  thorpej 
     56  1.7     matt static __inline uint16_t
     57  1.7     matt alpha_ldwu(volatile uint16_t *a0)
     58  1.1  thorpej {
     59  1.7     matt 	uint16_t v0;
     60  1.1  thorpej 
     61  1.4    perry 	__asm volatile("ldwu %0, %1"
     62  1.1  thorpej 		: "=r" (v0)
     63  1.1  thorpej 		: "m" (*a0));
     64  1.1  thorpej 
     65  1.1  thorpej 	return (v0);
     66  1.1  thorpej }
     67  1.1  thorpej 
     68  1.5    perry static __inline void
     69  1.7     matt alpha_stb(volatile uint8_t *a0, uint8_t a1)
     70  1.1  thorpej {
     71  1.1  thorpej 
     72  1.4    perry 	__asm volatile("stb %1, %0"
     73  1.1  thorpej 		: "=m" (*a0)
     74  1.1  thorpej 		: "r" (a1));
     75  1.1  thorpej }
     76  1.1  thorpej 
     77  1.5    perry static __inline void
     78  1.7     matt alpha_stw(volatile uint16_t *a0, uint16_t a1)
     79  1.1  thorpej {
     80  1.1  thorpej 
     81  1.4    perry 	__asm volatile("stw %1, %0"
     82  1.1  thorpej 		: "=m" (*a0)
     83  1.1  thorpej 		: "r" (a1));
     84  1.1  thorpej }
     85  1.1  thorpej 
     86  1.7     matt static __inline uint8_t
     87  1.7     matt alpha_sextb(uint8_t a0)
     88  1.1  thorpej {
     89  1.7     matt 	uint8_t v0;
     90  1.1  thorpej 
     91  1.4    perry 	__asm volatile("sextb %1, %0"
     92  1.1  thorpej 		: "=r" (v0)
     93  1.1  thorpej 		: "r" (a0));
     94  1.1  thorpej 
     95  1.1  thorpej 	return (v0);
     96  1.1  thorpej }
     97  1.1  thorpej 
     98  1.7     matt static __inline uint16_t
     99  1.7     matt alpha_sextw(uint16_t a0)
    100  1.1  thorpej {
    101  1.7     matt 	uint16_t v0;
    102  1.1  thorpej 
    103  1.4    perry 	__asm volatile("sextw %1, %0"
    104  1.1  thorpej 		: "=r" (v0)
    105  1.1  thorpej 		: "r" (a0));
    106  1.1  thorpej 
    107  1.1  thorpej 	return (v0);
    108  1.1  thorpej }
    109  1.1  thorpej 
    110  1.1  thorpej #endif /* _ALPHA_BWX_H_ */
    111