Home | History | Annotate | Line # | Download | only in include
aeabi.h revision 1.3
      1  1.3  matt /*	$NetBSD: aeabi.h,v 1.3 2013/01/24 10:14:17 matt Exp $	*/
      2  1.1  matt 
      3  1.1  matt /*-
      4  1.1  matt  * Copyright (c) 2012 The NetBSD Foundation, Inc.
      5  1.1  matt  * All rights reserved.
      6  1.1  matt  *
      7  1.1  matt  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1  matt  * by Matt Thomas of 3am Software Foundry.
      9  1.1  matt  *
     10  1.1  matt  * Redistribution and use in source and binary forms, with or without
     11  1.1  matt  * modification, are permitted provided that the following conditions
     12  1.1  matt  * are met:
     13  1.1  matt  * 1. Redistributions of source code must retain the above copyright
     14  1.1  matt  *    notice, this list of conditions and the following disclaimer.
     15  1.1  matt  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1  matt  *    notice, this list of conditions and the following disclaimer in the
     17  1.1  matt  *    documentation and/or other materials provided with the distribution.
     18  1.1  matt  *
     19  1.1  matt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.1  matt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.1  matt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.1  matt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.1  matt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.1  matt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.1  matt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.1  matt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.1  matt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.1  matt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.1  matt  * POSSIBILITY OF SUCH DAMAGE.
     30  1.1  matt  */
     31  1.1  matt #ifndef _ARM_AEABI_H_
     32  1.1  matt #define	_ARM_AEABI_H_
     33  1.1  matt 
     34  1.3  matt #ifdef _KERNEL
     35  1.3  matt #include <sys/types.h>
     36  1.3  matt #else
     37  1.2  matt #include <stddef.h>
     38  1.3  matt #endif
     39  1.2  matt 
     40  1.1  matt #define	__value_in_regs		/* nothing */
     41  1.1  matt 
     42  1.1  matt /*
     43  1.1  matt  * Standard double precision floating-point arithmetic helper functions
     44  1.1  matt  */
     45  1.1  matt double __aeabi_dadd(double, double);	// double-precision addition
     46  1.1  matt double __aeabi_ddiv(double n, double d);	// double-precision division, n / d
     47  1.1  matt double __aeabi_dmul(double, double);	// double-precision multiplication
     48  1.1  matt double __aeabi_drsub(double x, double y);	// double-precision reverse subtraction, y - x
     49  1.1  matt double __aeabi_dsub(double x, double y);	// double-precision subtraction, x - y
     50  1.1  matt double __aeabi_dneg(double);	// double-precision negation (obsolete, to be removed in r2.09)
     51  1.1  matt 
     52  1.1  matt /*
     53  1.1  matt  * Double precision floating-point comparison helper functions
     54  1.1  matt  */
     55  1.1  matt void __aeabi_cdcmpeq(double, double); // non-excepting equality comparison [1], result in PSR ZC flags
     56  1.1  matt void __aeabi_cdcmple(double, double); // 3-way (<, =, >) compare [1], result in PSR ZC flags
     57  1.1  matt void __aeabi_cdrcmple(double, double); // reversed 3-way (<, =, >) compare [1], result in PSR ZC flags
     58  1.1  matt int __aeabi_dcmpeq(double, double); // result (1, 0) denotes (=, <>) [2], use for C == and !=
     59  1.1  matt int __aeabi_dcmplt(double, double); // result (1, 0) denotes (<, >=) [2], use for C <
     60  1.1  matt int __aeabi_dcmple(double, double); // result (1, 0) denotes (<=, >) [2], use for C <=
     61  1.1  matt int __aeabi_dcmpge(double, double); // result (1, 0) denotes (>=, <) [2], use for C >=
     62  1.1  matt int __aeabi_dcmpgt(double, double); // result (1, 0) denotes (>, <=) [2], use for C >
     63  1.1  matt int __aeabi_dcmpun(double, double); // result (1, 0) denotes (?, <=>) [2], use for C99 isunordered()
     64  1.1  matt 
     65  1.1  matt /*
     66  1.1  matt  * Standard single precision floating-point arithmetic helper functions
     67  1.1  matt  */
     68  1.1  matt float __aeabi_fadd(float, float); // single-precision addition
     69  1.1  matt float __aeabi_fdiv(float n, float d); // single-precision division, n / d
     70  1.1  matt float __aeabi_fmul(float, float); // single-precision multiplication
     71  1.1  matt float __aeabi_frsub(float x, float y); // single-precision reverse subtraction, y - x
     72  1.1  matt float __aeabi_fsub(float x, float y); // single-precision subtraction, x - y
     73  1.1  matt float __aeabi_fneg(float); // single-precision negation (obsolete, to be removed in r2.09)
     74  1.1  matt 
     75  1.1  matt /*
     76  1.1  matt  * Standard single precision floating-point comparison helper functions
     77  1.1  matt  */
     78  1.1  matt void __aeabi_cfcmpeq(float, float); // non-excepting equality comparison [1], result in PSR ZC flags
     79  1.1  matt void __aeabi_cfcmple(float, float); // 3-way (<, =, ?>) compare [1], result in PSR ZC flags
     80  1.1  matt void __aeabi_cfrcmple(float, float); // reversed 3-way (<, =, ?>) compare [1], result in PSR ZC flags
     81  1.1  matt int __aeabi_fcmpeq(float, float); // result (1, 0) denotes (=, <>) [2], use for C == and !=
     82  1.1  matt int __aeabi_fcmplt(float, float); // result (1, 0) denotes (<, >=) [2], use for C <
     83  1.1  matt int __aeabi_fcmple(float, float); // result (1, 0) denotes (<=, >) [2], use for C <=
     84  1.1  matt int __aeabi_fcmpge(float, float); // result (1, 0) denotes (>=, <) [2], use for C >=
     85  1.1  matt int __aeabi_fcmpgt(float, float); // result (1, 0) denotes (>, <=) [2], use for C >
     86  1.1  matt int __aeabi_fcmpun(float, float); // result (1, 0) denotes (?, <=>) [2], use for C99 isunordered()
     87  1.1  matt 
     88  1.1  matt /*
     89  1.1  matt  * Standard conversions between floating types
     90  1.1  matt  */
     91  1.1  matt float __aeabi_d2f(double);	// double to float (single precision) conversion
     92  1.1  matt double __aeabi_f2d(float);	// float (single precision) to double conversion
     93  1.1  matt float __aeabi_h2f(short hf);	// IEEE 754 binary16 storage format (VFP half precision) to binary32 (float) conversion [4, 5]
     94  1.1  matt short __aeabi_f2h(float f);	// IEEE 754 binary32 (float) to binary16 storage format (VFP half precision) conversion [4, 6]
     95  1.1  matt float __aeabi_h2f_alt(short hf);	// __aeabi_h2f_alt converts from VFP alternative format [7].
     96  1.1  matt short __aeabi_f2h_alt(float f);	// __aeabi_f2h_alt converts to VFP alternative format [8].
     97  1.1  matt 
     98  1.1  matt /*
     99  1.1  matt  * Standard floating-point to integer conversions
    100  1.1  matt  */
    101  1.1  matt int __aeabi_d2iz(double);	// double to integer C-style conversion [3]
    102  1.1  matt unsigned __aeabi_d2uiz(double);	// double to unsigned C-style conversion [3]
    103  1.1  matt long long __aeabi_d2lz(double);	// double to long long C-style conversion [3]
    104  1.1  matt unsigned long long __aeabi_d2ulz(double);	// double to unsigned long long C-style conversion [3]
    105  1.1  matt int __aeabi_f2iz(float);	// float (single precision) to integer C-style conversion [3]
    106  1.1  matt unsigned __aeabi_f2uiz(float);	// float (single precision) to unsigned C-style conversion [3]
    107  1.1  matt long long __aeabi_f2lz(float);	// float (single precision) to long long C-style conversion [3]
    108  1.1  matt unsigned long long __aeabi_f2ulz(float);	// float to unsigned long long C-style conversion [3]
    109  1.1  matt 
    110  1.1  matt /*
    111  1.1  matt  * Standard integer to floating-point conversions
    112  1.1  matt  */
    113  1.1  matt double __aeabi_i2d(int);		// integer to double conversion
    114  1.1  matt double __aeabi_ui2d(unsigned);	// unsigned to double conversion
    115  1.1  matt double __aeabi_l2d(long long);	// long long to double conversion
    116  1.1  matt double __aeabi_ul2d(unsigned long long);	// unsigned long long to double conversion
    117  1.1  matt float __aeabi_i2f(int);	// integer to float (single precision) conversion
    118  1.1  matt float __aeabi_ui2f(unsigned);	// unsigned to float (single precision) conversion
    119  1.1  matt float __aeabi_l2f(long long);	// long long to float (single precision) conversion
    120  1.1  matt float __aeabi_ul2f(unsigned long long);	// unsigned long long to float (single precision) conversion
    121  1.1  matt 
    122  1.1  matt /*
    123  1.1  matt  * Long long functions
    124  1.1  matt  */
    125  1.1  matt long long __aeabi_lmul(long long, long long); // multiplication
    126  1.1  matt 
    127  1.1  matt /*
    128  1.1  matt  * A pair of (unsigned) long longs is returned in {{r0, r1}, {r2, r3}},
    129  1.1  matt  * the quotient in {r0, r1}, and the remainder in {r2, r3}.
    130  1.1  matt  */
    131  1.1  matt typedef struct { long long quot; long long rem; } lldiv_t;
    132  1.1  matt __value_in_regs lldiv_t __aeabi_ldivmod(long long n, long long d); // signed long long division and remainder, {q, r} = n / d [2]
    133  1.1  matt 
    134  1.1  matt typedef struct { unsigned long long quot; unsigned long long rem; } ulldiv_t;
    135  1.1  matt __value_in_regs ulldiv_t __aeabi_uldivmod(unsigned long long n, unsigned long long d); // unsigned signed ll division, remainder, {q, r} = n / d [2]
    136  1.1  matt 
    137  1.1  matt /*
    138  1.1  matt  * Because of 2's complement number representation, these functions work
    139  1.1  matt  * identically with long long replaced uniformly by unsigned long long.
    140  1.1  matt  * Each returns its result in {r0, r1}, as specified by the [AAPCS].
    141  1.1  matt  */
    142  1.1  matt long long __aeabi_llsl(long long, int); // logical shift left [1]
    143  1.1  matt long long __aeabi_llsr(long long, int); // logical shift right [1]
    144  1.1  matt long long __aeabi_lasr(long long, int); // arithmetic shift right [1]
    145  1.1  matt 
    146  1.1  matt /*
    147  1.1  matt  * The comparison functions return negative, zero, or a positive integer
    148  1.1  matt  * according to whether the comparison result is <, ==, or >, respectively
    149  1.1  matt  * (like strcmp).
    150  1.1  matt  */
    151  1.1  matt int __aeabi_lcmp(long long, long long); // signed long long comparison
    152  1.1  matt int __aeabi_ulcmp(unsigned long long, unsigned long long); // unsigned long long comparison
    153  1.1  matt 
    154  1.1  matt int __aeabi_idiv(int numerator, int denominator);
    155  1.1  matt unsigned __aeabi_uidiv(unsigned numerator, unsigned denominator);
    156  1.1  matt typedef struct { int quot, rem; } idiv_return;
    157  1.1  matt typedef struct { unsigned int quot, rem; } uidiv_return;
    158  1.1  matt __value_in_regs idiv_return __aeabi_idivmod(int, int);
    159  1.1  matt __value_in_regs uidiv_return __aeabi_uidivmod(unsigned int, unsigned int);
    160  1.1  matt 
    161  1.1  matt /*
    162  1.1  matt  * Division by zero
    163  1.1  matt  *
    164  1.1  matt  * If an integer or long long division helper function is called upon to
    165  1.1  matt  * divide by 0, it should return as quotient the value returned by a call
    166  1.1  matt  * to __aeabi_idiv0 or __aeabi_ldiv0, respectively. A *divmod helper should
    167  1.1  matt  * return as remainder either 0 or the original numerator.
    168  1.1  matt  */
    169  1.1  matt int __aeabi_idiv0(int);
    170  1.1  matt long long __aeabi_ldiv0(long long);
    171  1.1  matt 
    172  1.1  matt /*
    173  1.1  matt  * These functions read and write 4-byte and 8-byte values at arbitrarily
    174  1.1  matt  * aligned addresses.  Write functions return the value written,
    175  1.1  matt  * read functions the value read.
    176  1.1  matt  */
    177  1.1  matt int __aeabi_uread4(void *);
    178  1.1  matt int __aeabi_uwrite4(int, void *);
    179  1.1  matt long long __aeabi_uread8(void *);
    180  1.1  matt long long __aeabi_uwrite8(long long, void *);
    181  1.1  matt 
    182  1.1  matt /*
    183  1.1  matt  * Memory copying, clearing, and setting
    184  1.1  matt  */
    185  1.1  matt void __aeabi_memcpy8(void *, const void *, size_t);
    186  1.1  matt void __aeabi_memcpy4(void *, const void *, size_t);
    187  1.1  matt void __aeabi_memcpy(void *, const void *, size_t);
    188  1.1  matt void __aeabi_memmove8(void *, const void *, size_t);
    189  1.1  matt void __aeabi_memmove4(void *, const void *, size_t);
    190  1.1  matt void __aeabi_memmove(void *, const void *, size_t);
    191  1.1  matt 
    192  1.1  matt /*
    193  1.1  matt  * Memory clearing and setting
    194  1.1  matt  */
    195  1.1  matt void __aeabi_memset8(void *, size_t, int);
    196  1.1  matt void __aeabi_memset4(void *, size_t, int);
    197  1.1  matt void __aeabi_memset(void *, size_t, int);
    198  1.1  matt void __aeabi_memclr8(void *, size_t);
    199  1.1  matt void __aeabi_memclr4(void *, size_t);
    200  1.1  matt void __aeabi_memclr(void *, size_t);
    201  1.1  matt 
    202  1.1  matt void *__aeabi_read_tp(void); // return the value of $tp
    203  1.1  matt 
    204  1.1  matt #endif /* _ARM_AEABI_H_ */
    205