Fixed MTP to work with TWRP

This commit is contained in:
awab228 2018-06-19 23:16:04 +02:00
commit f6dfaef42e
50820 changed files with 20846062 additions and 0 deletions

View file

@ -0,0 +1,481 @@
/*
*
* (C) COPYRIGHT ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*
* A copy of the licence is included with the program, and can also be obtained
* from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
/**
* @addtogroup malisw
* @{
*/
/* ============================================================================
Description
============================================================================ */
/**
* @defgroup arm_cstd_coding_standard ARM C standard types and constants
* The common files are a set of standard headers which are used by all parts
* of this development, describing types, and generic constants.
*
* Files in group:
* - arm_cstd.h
* - arm_cstd_compilers.h
* - arm_cstd_types.h
* - arm_cstd_types_rvct.h
* - arm_cstd_types_gcc.h
* - arm_cstd_types_msvc.h
* - arm_cstd_pack_push.h
* - arm_cstd_pack_pop.h
*/
/**
* @addtogroup arm_cstd_coding_standard
* @{
*/
#ifndef _ARM_CSTD_
#define _ARM_CSTD_
/* ============================================================================
Import standard C99 types
============================================================================ */
#include "arm_cstd_compilers.h"
#include "arm_cstd_types.h"
/* ============================================================================
Min and Max Values
============================================================================ */
#if !defined(INT8_MAX)
#define INT8_MAX ((int8_t) 0x7F)
#endif
#if !defined(INT8_MIN)
#define INT8_MIN (-INT8_MAX - 1)
#endif
#if !defined(INT16_MAX)
#define INT16_MAX ((int16_t)0x7FFF)
#endif
#if !defined(INT16_MIN)
#define INT16_MIN (-INT16_MAX - 1)
#endif
#if !defined(INT32_MAX)
#define INT32_MAX ((int32_t)0x7FFFFFFF)
#endif
#if !defined(INT32_MIN)
#define INT32_MIN (-INT32_MAX - 1)
#endif
#if !defined(INT64_MAX)
#define INT64_MAX ((int64_t)0x7FFFFFFFFFFFFFFFLL)
#endif
#if !defined(INT64_MIN)
#define INT64_MIN (-INT64_MAX - 1)
#endif
#if !defined(UINT8_MAX)
#define UINT8_MAX ((uint8_t) 0xFF)
#endif
#if !defined(UINT16_MAX)
#define UINT16_MAX ((uint16_t)0xFFFF)
#endif
#if !defined(UINT32_MAX)
#define UINT32_MAX ((uint32_t)0xFFFFFFFF)
#endif
#if !defined(UINT64_MAX)
#define UINT64_MAX ((uint64_t)0xFFFFFFFFFFFFFFFFULL)
#endif
/* fallbacks if limits.h wasn't available */
#if !defined(UCHAR_MAX)
#define UCHAR_MAX ((unsigned char)~0U)
#endif
#if !defined(SCHAR_MAX)
#define SCHAR_MAX ((signed char)(UCHAR_MAX >> 1))
#endif
#if !defined(SCHAR_MIN)
#define SCHAR_MIN ((signed char)(-SCHAR_MAX - 1))
#endif
#if !defined(USHRT_MAX)
#define USHRT_MAX ((unsigned short)~0U)
#endif
#if !defined(SHRT_MAX)
#define SHRT_MAX ((signed short)(USHRT_MAX >> 1))
#endif
#if !defined(SHRT_MIN)
#define SHRT_MIN ((signed short)(-SHRT_MAX - 1))
#endif
#if !defined(UINT_MAX)
#define UINT_MAX ((unsigned int)~0U)
#endif
#if !defined(INT_MAX)
#define INT_MAX ((signed int)(UINT_MAX >> 1))
#endif
#if !defined(INT_MIN)
#define INT_MIN ((signed int)(-INT_MAX - 1))
#endif
#if !defined(ULONG_MAX)
#define ULONG_MAX ((unsigned long)~0UL)
#endif
#if !defined(LONG_MAX)
#define LONG_MAX ((signed long)(ULONG_MAX >> 1))
#endif
#if !defined(LONG_MIN)
#define LONG_MIN ((signed long)(-LONG_MAX - 1))
#endif
#if !defined(ULLONG_MAX)
#define ULLONG_MAX ((unsigned long long)~0ULL)
#endif
#if !defined(LLONG_MAX)
#define LLONG_MAX ((signed long long)(ULLONG_MAX >> 1))
#endif
#if !defined(LLONG_MIN)
#define LLONG_MIN ((signed long long)(-LLONG_MAX - 1))
#endif
#if !defined(SIZE_MAX)
#if 1 == CSTD_CPU_32BIT
#define SIZE_MAX UINT32_MAX
#elif 1 == CSTD_CPU_64BIT
#define SIZE_MAX UINT64_MAX
#endif
#endif
/* ============================================================================
Keywords
============================================================================ */
/* Portable keywords. */
#if !defined(CONST)
/**
* @hideinitializer
* Variable is a C @c const, which can be made non-const for testing purposes.
*/
#define CONST const
#endif
#if !defined(STATIC)
/**
* @hideinitializer
* Variable is a C @c static, which can be made non-static for testing
* purposes.
*/
#define STATIC static
#endif
/**
* Specifies a function as being exported outside of a logical module.
*/
#define PUBLIC
/**
* @def PROTECTED
* Specifies a a function which is internal to an logical module, but which
* should not be used outside of that module. This cannot be enforced by the
* compiler, as a module is typically more than one translation unit.
*/
#define PROTECTED
/**
* Specifies a function as being internal to a translation unit. Private
* functions would typically be declared as STATIC, unless they are being
* exported for unit test purposes.
*/
#define PRIVATE STATIC
/**
* Specify an assertion value which is evaluated at compile time. Recommended
* usage is specification of a @c static @c INLINE function containing all of
* the assertions thus:
*
* @code
* static INLINE [module]_compile_time_assertions( void )
* {
* COMPILE_TIME_ASSERT( sizeof(uintptr_t) == sizeof(intptr_t) );
* }
* @endcode
*
* @note Use @c static not @c STATIC. We never want to turn off this @c static
* specification for testing purposes.
*/
#define CSTD_COMPILE_TIME_ASSERT( expr ) \
do { switch(0){case 0: case (expr):;} } while( FALSE )
/**
* @hideinitializer
* @deprecated Prefered form is @c CSTD_UNUSED
* Function-like macro for suppressing unused variable warnings. Where possible
* such variables should be removed; this macro is present for cases where we
* much support API backwards compatibility.
*/
#define UNUSED( x ) ((void)(x))
/**
* @hideinitializer
* Function-like macro for suppressing unused variable warnings. Where possible
* such variables should be removed; this macro is present for cases where we
* much support API backwards compatibility.
*/
#define CSTD_UNUSED( x ) ((void)(x))
/**
* @hideinitializer
* Function-like macro for use where "no behavior" is desired. This is useful
* when compile time macros turn a function-like macro in to a no-op, but
* where having no statement is otherwise invalid.
*/
#define CSTD_NOP( ... ) ((void)#__VA_ARGS__)
/**
* @hideinitializer
* Function-like macro for converting a pointer in to a u64 for storing into
* an external data structure. This is commonly used when pairing a 32-bit
* CPU with a 64-bit peripheral, such as a Midgard GPU. C's type promotion
* is complex and a straight cast does not work reliably as pointers are
* often considered as signed.
*/
#define CSTD_PTR_TO_U64( x ) ((uint64_t)((uintptr_t)(x)))
/**
* @hideinitializer
* Function-like macro for stringizing a single level macro.
* @code
* #define MY_MACRO 32
* CSTD_STR1( MY_MACRO )
* > "MY_MACRO"
* @endcode
*/
#define CSTD_STR1( x ) #x
/**
* @hideinitializer
* Function-like macro for stringizing a macro's value. This should not be used
* if the macro is defined in a way which may have no value; use the
* alternative @c CSTD_STR2N macro should be used instead.
* @code
* #define MY_MACRO 32
* CSTD_STR2( MY_MACRO )
* > "32"
* @endcode
*/
#define CSTD_STR2( x ) CSTD_STR1( x )
/**
* @hideinitializer
* Utility function for stripping the first character off a string.
*/
static INLINE char* arm_cstd_strstrip( char * string )
{
return ++string;
}
/**
* @hideinitializer
* Function-like macro for stringizing a single level macro where the macro
* itself may not have a value. Parameter @c a should be set to any single
* character which is then stripped by the macro via an inline function. This
* should only be used via the @c CSTD_STR2N macro; for printing a single
* macro only the @c CSTD_STR1 macro is a better alternative.
*
* This macro requires run-time code to handle the case where the macro has
* no value (you can't concat empty strings in the preprocessor).
*/
#define CSTD_STR1N( a, x ) arm_cstd_strstrip( CSTD_STR1( a##x ) )
/**
* @hideinitializer
* Function-like macro for stringizing a two level macro where the macro itself
* may not have a value.
* @code
* #define MY_MACRO 32
* CSTD_STR2N( MY_MACRO )
* > "32"
*
* #define MY_MACRO 32
* CSTD_STR2N( MY_MACRO )
* > "32"
* @endcode
*/
#define CSTD_STR2N( x ) CSTD_STR1N( _, x )
/* ============================================================================
Validate portability constructs
============================================================================ */
static INLINE void arm_cstd_compile_time_assertions( void )
{
CSTD_COMPILE_TIME_ASSERT( sizeof(uint8_t) == 1 );
CSTD_COMPILE_TIME_ASSERT( sizeof(int8_t) == 1 );
CSTD_COMPILE_TIME_ASSERT( sizeof(uint16_t) == 2 );
CSTD_COMPILE_TIME_ASSERT( sizeof(int16_t) == 2 );
CSTD_COMPILE_TIME_ASSERT( sizeof(uint32_t) == 4 );
CSTD_COMPILE_TIME_ASSERT( sizeof(int32_t) == 4 );
CSTD_COMPILE_TIME_ASSERT( sizeof(uint64_t) == 8 );
CSTD_COMPILE_TIME_ASSERT( sizeof(int64_t) == 8 );
CSTD_COMPILE_TIME_ASSERT( sizeof(intptr_t) == sizeof(uintptr_t) );
CSTD_COMPILE_TIME_ASSERT( 1 == TRUE );
CSTD_COMPILE_TIME_ASSERT( 0 == FALSE );
#if 1 == CSTD_CPU_32BIT
CSTD_COMPILE_TIME_ASSERT( sizeof(uintptr_t) == 4 );
#elif 1 == CSTD_CPU_64BIT
CSTD_COMPILE_TIME_ASSERT( sizeof(uintptr_t) == 8 );
#endif
}
/* ============================================================================
Useful function-like macro
============================================================================ */
/**
* @brief Return the lesser of two values.
* As a macro it may evaluate its arguments more than once.
* @see CSTD_MAX
*/
#define CSTD_MIN( x, y ) ((x) < (y) ? (x) : (y))
/**
* @brief Return the greater of two values.
* As a macro it may evaluate its arguments more than once.
* If called on the same two arguments as CSTD_MIN it is guaranteed to return
* the one that CSTD_MIN didn't return. This is significant for types where not
* all values are comparable e.g. NaNs in floating-point types. But if you want
* to retrieve the min and max of two values, consider using a conditional swap
* instead.
*/
#define CSTD_MAX( x, y ) ((x) < (y) ? (y) : (x))
/**
* @brief Clamp value @c x to within @c min and @c max inclusive.
*/
#define CSTD_CLAMP( x, min, max ) ((x)<(min) ? (min):((x)>(max) ? (max):(x)))
/**
* Flag a cast as a reinterpretation, usually of a pointer type.
*/
#define CSTD_REINTERPRET_CAST(type) (type)
/**
* Flag a cast as casting away const, usually of a pointer type.
*/
#define CSTD_CONST_CAST(type) (type)
/**
* Flag a cast as a (potentially complex) value conversion, usually of a
* numerical type.
*/
#define CSTD_STATIC_CAST(type) (type)
/* ============================================================================
Useful bit constants
============================================================================ */
/**
* @cond arm_cstd_utilities
*/
/* Common bit constant values, useful in embedded programming. */
#define F_BIT_0 ((uint32_t)0x00000001)
#define F_BIT_1 ((uint32_t)0x00000002)
#define F_BIT_2 ((uint32_t)0x00000004)
#define F_BIT_3 ((uint32_t)0x00000008)
#define F_BIT_4 ((uint32_t)0x00000010)
#define F_BIT_5 ((uint32_t)0x00000020)
#define F_BIT_6 ((uint32_t)0x00000040)
#define F_BIT_7 ((uint32_t)0x00000080)
#define F_BIT_8 ((uint32_t)0x00000100)
#define F_BIT_9 ((uint32_t)0x00000200)
#define F_BIT_10 ((uint32_t)0x00000400)
#define F_BIT_11 ((uint32_t)0x00000800)
#define F_BIT_12 ((uint32_t)0x00001000)
#define F_BIT_13 ((uint32_t)0x00002000)
#define F_BIT_14 ((uint32_t)0x00004000)
#define F_BIT_15 ((uint32_t)0x00008000)
#define F_BIT_16 ((uint32_t)0x00010000)
#define F_BIT_17 ((uint32_t)0x00020000)
#define F_BIT_18 ((uint32_t)0x00040000)
#define F_BIT_19 ((uint32_t)0x00080000)
#define F_BIT_20 ((uint32_t)0x00100000)
#define F_BIT_21 ((uint32_t)0x00200000)
#define F_BIT_22 ((uint32_t)0x00400000)
#define F_BIT_23 ((uint32_t)0x00800000)
#define F_BIT_24 ((uint32_t)0x01000000)
#define F_BIT_25 ((uint32_t)0x02000000)
#define F_BIT_26 ((uint32_t)0x04000000)
#define F_BIT_27 ((uint32_t)0x08000000)
#define F_BIT_28 ((uint32_t)0x10000000)
#define F_BIT_29 ((uint32_t)0x20000000)
#define F_BIT_30 ((uint32_t)0x40000000)
#define F_BIT_31 ((uint32_t)0x80000000)
/* Common 2^n size values, useful in embedded programming. */
#define C_SIZE_1B ((uint32_t)0x00000001)
#define C_SIZE_2B ((uint32_t)0x00000002)
#define C_SIZE_4B ((uint32_t)0x00000004)
#define C_SIZE_8B ((uint32_t)0x00000008)
#define C_SIZE_16B ((uint32_t)0x00000010)
#define C_SIZE_32B ((uint32_t)0x00000020)
#define C_SIZE_64B ((uint32_t)0x00000040)
#define C_SIZE_128B ((uint32_t)0x00000080)
#define C_SIZE_256B ((uint32_t)0x00000100)
#define C_SIZE_512B ((uint32_t)0x00000200)
#define C_SIZE_1KB ((uint32_t)0x00000400)
#define C_SIZE_2KB ((uint32_t)0x00000800)
#define C_SIZE_4KB ((uint32_t)0x00001000)
#define C_SIZE_8KB ((uint32_t)0x00002000)
#define C_SIZE_16KB ((uint32_t)0x00004000)
#define C_SIZE_32KB ((uint32_t)0x00008000)
#define C_SIZE_64KB ((uint32_t)0x00010000)
#define C_SIZE_128KB ((uint32_t)0x00020000)
#define C_SIZE_256KB ((uint32_t)0x00040000)
#define C_SIZE_512KB ((uint32_t)0x00080000)
#define C_SIZE_1MB ((uint32_t)0x00100000)
#define C_SIZE_2MB ((uint32_t)0x00200000)
#define C_SIZE_4MB ((uint32_t)0x00400000)
#define C_SIZE_8MB ((uint32_t)0x00800000)
#define C_SIZE_16MB ((uint32_t)0x01000000)
#define C_SIZE_32MB ((uint32_t)0x02000000)
#define C_SIZE_64MB ((uint32_t)0x04000000)
#define C_SIZE_128MB ((uint32_t)0x08000000)
#define C_SIZE_256MB ((uint32_t)0x10000000)
#define C_SIZE_512MB ((uint32_t)0x20000000)
#define C_SIZE_1GB ((uint32_t)0x40000000)
#define C_SIZE_2GB ((uint32_t)0x80000000)
/**
* @endcond
*/
/**
* @}
*/
/**
* @}
*/
#endif /* End (_ARM_CSTD_) */

View file

@ -0,0 +1,617 @@
/*
*
* (C) COPYRIGHT ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*
* A copy of the licence is included with the program, and can also be obtained
* from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef _ARM_CSTD_COMPILERS_H_
#define _ARM_CSTD_COMPILERS_H_
/* ============================================================================
Document default definitions - assuming nothing set at this point.
============================================================================ */
/**
* @addtogroup arm_cstd_coding_standard
* @{
*/
/**
* @hideinitializer
* Defined with value of 1 if toolchain is Microsoft Visual Studio, 0
* otherwise.
*/
#define CSTD_TOOLCHAIN_MSVC 0
/**
* @hideinitializer
* Defined with value of 1 if toolchain is the GNU Compiler Collection, 0
* otherwise.
*/
#define CSTD_TOOLCHAIN_GCC 0
/**
* @hideinitializer
* Defined with value of 1 if toolchain is ARM RealView Compiler Tools, 0
* otherwise. Note - if running RVCT in GCC mode this define will be set to 0;
* @c CSTD_TOOLCHAIN_GCC and @c CSTD_TOOLCHAIN_RVCT_GCC_MODE will both be
* defined as 1.
*/
#define CSTD_TOOLCHAIN_RVCT 0
/**
* @hideinitializer
* Defined with value of 1 if toolchain is ARM RealView Compiler Tools running
* in GCC mode, 0 otherwise.
*/
#define CSTD_TOOLCHAIN_RVCT_GCC_MODE 0
/**
* @hideinitializer
* Defined with value of 1 if processor is an x86 32-bit machine, 0 otherwise.
*/
#define CSTD_CPU_X86_32 0
/**
* @hideinitializer
* Defined with value of 1 if processor is an x86-64 (AMD64) machine, 0
* otherwise.
*/
#define CSTD_CPU_X86_64 0
/**
* @hideinitializer
* Defined with value of 1 if processor is an ARM machine, 0 otherwise.
*/
#define CSTD_CPU_ARM 0
/**
* @hideinitializer
* Defined with value of 1 if processor is an AARCH64 machine, 0 otherwise.
*/
#define CSTD_CPU_AARCH64 0
/**
* @hideinitializer
* Defined with value of 1 if processor is a MIPS machine, 0 otherwise.
*/
#define CSTD_CPU_MIPS 0
/**
* @hideinitializer
* Defined with value of 1 if CPU is 32-bit, 0 otherwise.
*/
#define CSTD_CPU_32BIT 0
/**
* @hideinitializer
* Defined with value of 1 if CPU is 64-bit, 0 otherwise.
*/
#define CSTD_CPU_64BIT 0
/**
* @hideinitializer
* Defined with value of 1 if processor configured as big-endian, 0 if it
* is little-endian.
*/
#define CSTD_CPU_BIG_ENDIAN 0
/**
* @hideinitializer
* Defined with value of 1 if operating system is a version of Windows, 0 if
* it is not.
*/
#define CSTD_OS_WINDOWS 0
/**
* @hideinitializer
* Defined with value of 1 if operating system is a 32-bit version of Windows,
* 0 if it is not.
*/
#define CSTD_OS_WIN32 0
/**
* @hideinitializer
* Defined with value of 1 if operating system is a 64-bit version of Windows,
* 0 if it is not.
*/
#define CSTD_OS_WIN64 0
/**
* @hideinitializer
* Defined with value of 1 if operating system is Linux, 0 if it is not.
*/
#define CSTD_OS_LINUX 0
/**
* @hideinitializer
* Defined with value of 1 if we are compiling Linux kernel code, 0 otherwise.
*/
#define CSTD_OS_LINUX_KERNEL 0
/**
* @hideinitializer
* Defined with value of 1 if operating system is a 32-bit version of Linux,
* 0 if it is not.
*/
#define CSTD_OS_LINUX32 0
/**
* @hideinitializer
* Defined with value of 1 if operating system is a 64-bit version of Linux,
* 0 if it is not.
*/
#define CSTD_OS_LINUX64 0
/**
* @hideinitializer
* Defined with value of 1 if operating system is Android, 0 if it is not.
*/
#define CSTD_OS_ANDROID 0
/**
* @hideinitializer
* Defined with value of 1 if we are compiling Android kernel code, 0 otherwise.
*/
#define CSTD_OS_ANDROID_KERNEL 0
/**
* @hideinitializer
* Defined with value of 1 if operating system is a 32-bit version of Android,
* 0 if it is not.
*/
#define CSTD_OS_ANDROID32 0
/**
* @hideinitializer
* Defined with value of 1 if operating system is a 64-bit version of Android,
* 0 if it is not.
*/
#define CSTD_OS_ANDROID64 0
/**
* @hideinitializer
* Defined with value of 1 if operating system is a version of Apple OS,
* 0 if it is not.
*/
#define CSTD_OS_APPLEOS 0
/**
* @hideinitializer
* Defined with value of 1 if operating system is a 32-bit version of Apple OS,
* 0 if it is not.
*/
#define CSTD_OS_APPLEOS32 0
/**
* @hideinitializer
* Defined with value of 1 if operating system is a 64-bit version of Apple OS,
* 0 if it is not.
*/
#define CSTD_OS_APPLEOS64 0
/**
* @def CSTD_OS_SYMBIAN
* @hideinitializer
* Defined with value of 1 if operating system is Symbian, 0 if it is not.
*/
#define CSTD_OS_SYMBIAN 0
/**
* @def CSTD_OS_NONE
* @hideinitializer
* Defined with value of 1 if there is no operating system (bare metal), 0
* otherwise
*/
#define CSTD_OS_NONE 0
/* ============================================================================
Determine the compiler in use
============================================================================ */
/* Default empty definitions of compiler-specific option enable/disable. This will be overridden
* if applicable by preprocessor defines below. */
#define CSTD_PUSH_WARNING_GCC_WADDRESS
#define CSTD_POP_WARNING_GCC_WADDRESS
#if defined(_MSC_VER)
#undef CSTD_TOOLCHAIN_MSVC
#define CSTD_TOOLCHAIN_MSVC 1
#elif defined(__GNUC__)
#undef CSTD_TOOLCHAIN_GCC
#define CSTD_TOOLCHAIN_GCC 1
/* Detect RVCT pretending to be GCC. */
#if defined(__ARMCC_VERSION)
#undef CSTD_TOOLCHAIN_RVCT_GCC_MODE
#define CSTD_TOOLCHAIN_RVCT_GCC_MODE 1
#endif
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6 && MALI_GCC_WORKAROUND_MIDCOM_4598 == 0)
/* As a workaround to MIDCOM-4598 (GCC internal defect), these pragmas are not compiled if the GCC version
* is within a certain range, or if a #define is enabled by the build system. For more, see a comment
* in the build system also referring to the MIDCOM issue mentioned, where the environment is updated
* for the GNU toolchain. */
#undef CSTD_PUSH_WARNING_GCC_WADDRESS
#define CSTD_PUSH_WARNING_GCC_WADDRESS \
do\
{\
_Pragma("GCC diagnostic push")\
_Pragma("GCC diagnostic ignored \"-Waddress\"")\
}while(MALI_FALSE)
#undef CSTD_POP_WARNING_GCC_WADDRESS
#define CSTD_POP_WARNING_GCC_WADDRESS \
do\
{\
_Pragma("GCC diagnostic pop")\
}while(MALI_FALSE)
#endif
#elif defined(__ARMCC_VERSION)
#undef CSTD_TOOLCHAIN_RVCT
#define CSTD_TOOLCHAIN_RVCT 1
#else
#warning "Unsupported or unknown toolchain"
#endif
/* ============================================================================
Determine the processor
============================================================================ */
#if 1 == CSTD_TOOLCHAIN_MSVC
#if defined(_M_IX86)
#undef CSTD_CPU_X86_32
#define CSTD_CPU_X86_32 1
#elif defined(_M_X64) || defined(_M_AMD64)
#undef CSTD_CPU_X86_64
#define CSTD_CPU_X86_64 1
#elif defined(_M_ARM)
#undef CSTD_CPU_ARM
#define CSTD_CPU_ARM 1
#elif defined(_M_MIPS)
#undef CSTD_CPU_MIPS
#define CSTD_CPU_MIPS 1
#else
#warning "Unsupported or unknown host CPU for MSVC tools"
#endif
#elif 1 == CSTD_TOOLCHAIN_GCC
#if defined(__amd64__)
#undef CSTD_CPU_X86_64
#define CSTD_CPU_X86_64 1
#elif defined(__i386__)
#undef CSTD_CPU_X86_32
#define CSTD_CPU_X86_32 1
#elif defined(__arm__)
#undef CSTD_CPU_ARM
#define CSTD_CPU_ARM 1
#elif defined(__aarch64__)
#undef CSTD_CPU_AARCH64
#define CSTD_CPU_AARCH64 1
#elif defined(__mips__)
#undef CSTD_CPU_MIPS
#define CSTD_CPU_MIPS 1
#else
#warning "Unsupported or unknown host CPU for GCC tools"
#endif
#elif 1 == CSTD_TOOLCHAIN_RVCT
#undef CSTD_CPU_ARM
#define CSTD_CPU_ARM 1
#else
#warning "Unsupported or unknown toolchain"
#endif
/* ============================================================================
Determine the Processor Endianness
============================================================================ */
#if ((1 == CSTD_CPU_X86_32) || (1 == CSTD_CPU_X86_64))
/* Note: x86 and x86-64 are always little endian, so leave at default. */
#elif 1 == CSTD_CPU_AARCH64
/* No big endian support? */
#elif 1 == CSTD_TOOLCHAIN_RVCT
#if defined(__BIG_ENDIAN)
#undef CSTD_ENDIAN_BIG
#define CSTD_ENDIAN_BIG 1
#endif
#elif ((1 == CSTD_TOOLCHAIN_GCC) && (1 == CSTD_CPU_ARM))
#if defined(__ARMEB__)
#undef CSTD_ENDIAN_BIG
#define CSTD_ENDIAN_BIG 1
#endif
#elif ((1 == CSTD_TOOLCHAIN_GCC) && (1 == CSTD_CPU_MIPS))
#if defined(__MIPSEB__)
#undef CSTD_ENDIAN_BIG
#define CSTD_ENDIAN_BIG 1
#endif
#elif 1 == CSTD_TOOLCHAIN_MSVC
/* Note: Microsoft only support little endian, so leave at default. */
#else
#warning "Unsupported or unknown CPU"
#endif
/* ============================================================================
Determine the operating system and addressing width
============================================================================ */
#if 1 == CSTD_TOOLCHAIN_MSVC
#if defined(_WIN32) && !defined(_WIN64)
#undef CSTD_OS_WINDOWS
#define CSTD_OS_WINDOWS 1
#undef CSTD_OS_WIN32
#define CSTD_OS_WIN32 1
#undef CSTD_CPU_32BIT
#define CSTD_CPU_32BIT 1
#elif defined(_WIN32) && defined(_WIN64)
#undef CSTD_OS_WINDOWS
#define CSTD_OS_WINDOWS 1
#undef CSTD_OS_WIN64
#define CSTD_OS_WIN64 1
#undef CSTD_CPU_64BIT
#define CSTD_CPU_64BIT 1
#else
#warning "Unsupported or unknown host OS for MSVC tools"
#endif
#elif 1 == CSTD_TOOLCHAIN_GCC
#if defined(_WIN32) && defined(_WIN64)
#undef CSTD_OS_WINDOWS
#define CSTD_OS_WINDOWS 1
#undef CSTD_OS_WIN64
#define CSTD_OS_WIN64 1
#undef CSTD_CPU_64BIT
#define CSTD_CPU_64BIT 1
#elif defined(_WIN32) && !defined(_WIN64)
#undef CSTD_OS_WINDOWS
#define CSTD_OS_WINDOWS 1
#undef CSTD_OS_WIN32
#define CSTD_OS_WIN32 1
#undef CSTD_CPU_32BIT
#define CSTD_CPU_32BIT 1
#elif defined(ANDROID)
#undef CSTD_OS_ANDROID
#define CSTD_OS_ANDROID 1
#if defined(__KERNEL__)
#undef CSTD_OS_ANDROID_KERNEL
#define CSTD_OS_ANDROID_KERNEL 1
#endif
#if defined(__LP64__) || defined(_LP64)
#undef CSTD_OS_ANDROID64
#define CSTD_OS_ANDROID64 1
#undef CSTD_CPU_64BIT
#define CSTD_CPU_64BIT 1
#else
#undef CSTD_OS_ANDROID32
#define CSTD_OS_ANDROID32 1
#undef CSTD_CPU_32BIT
#define CSTD_CPU_32BIT 1
#endif
#elif defined(__KERNEL__) || defined(__linux)
#undef CSTD_OS_LINUX
#define CSTD_OS_LINUX 1
#if defined(__KERNEL__)
#undef CSTD_OS_LINUX_KERNEL
#define CSTD_OS_LINUX_KERNEL 1
#endif
#if defined(__LP64__) || defined(_LP64)
#undef CSTD_OS_LINUX64
#define CSTD_OS_LINUX64 1
#undef CSTD_CPU_64BIT
#define CSTD_CPU_64BIT 1
#else
#undef CSTD_OS_LINUX32
#define CSTD_OS_LINUX32 1
#undef CSTD_CPU_32BIT
#define CSTD_CPU_32BIT 1
#endif
#elif defined(__APPLE__)
#undef CSTD_OS_APPLEOS
#define CSTD_OS_APPLEOS 1
#if defined(__LP64__) || defined(_LP64)
#undef CSTD_OS_APPLEOS64
#define CSTD_OS_APPLEOS64 1
#undef CSTD_CPU_64BIT
#define CSTD_CPU_64BIT 1
#else
#undef CSTD_OS_APPLEOS32
#define CSTD_OS_APPLEOS32 1
#undef CSTD_CPU_32BIT
#define CSTD_CPU_32BIT 1
#endif
#elif defined(__SYMBIAN32__)
#undef CSTD_OS_SYMBIAN
#define CSTD_OS_SYMBIAN 1
#undef CSTD_CPU_32BIT
#define CSTD_CPU_32BIT 1
#else
#undef CSTD_OS_NONE
#define CSTD_OS_NONE 1
#undef CSTD_CPU_32BIT
#define CSTD_CPU_32BIT 1
#endif
#elif 1 == CSTD_TOOLCHAIN_RVCT
#if defined(ANDROID)
#undef CSTD_OS_ANDROID
#undef CSTD_OS_ANDROID32
#define CSTD_OS_ANDROID 1
#define CSTD_OS_ANDROID32 1
#elif defined(__linux)
#undef CSTD_OS_LINUX
#undef CSTD_OS_LINUX32
#define CSTD_OS_LINUX 1
#define CSTD_OS_LINUX32 1
#elif defined(__SYMBIAN32__)
#undef CSTD_OS_SYMBIAN
#define CSTD_OS_SYMBIAN 1
#else
#undef CSTD_OS_NONE
#define CSTD_OS_NONE 1
#endif
#else
#warning "Unsupported or unknown host OS"
#endif
/* ============================================================================
Determine the correct linker symbol Import and Export Macros
============================================================================ */
/**
* @defgroup arm_cstd_linkage_specifiers Linkage Specifiers
* @{
*
* This set of macros contain system-dependent linkage specifiers which
* determine the visibility of symbols across DLL boundaries. A header for a
* particular DLL should define a set of local macros derived from these,
* and should not use these macros to decorate functions directly as there may
* be multiple DLLs being used.
*
* These DLL library local macros should be (with appropriate library prefix)
* <tt>[MY_LIBRARY]_API</tt>, <tt>[MY_LIBRARY]_IMPL</tt>, and
* <tt>[MY_LIBRARY]_LOCAL</tt>.
*
* - <tt>[MY_LIBRARY]_API</tt> should be use to decorate the function
* declarations in the header. It should be defined as either
* @c CSTD_LINK_IMPORT or @c CSTD_LINK_EXPORT, depending whether the
* current situation is a compile of the DLL itself (use export) or a
* compile of an external user of the DLL (use import).
* - <tt>[MY_LIBRARY]_IMPL</tt> should be defined as @c CSTD_LINK_IMPL
* and should be used to decorate the definition of functions in the C
* file.
* - <tt>[MY_LIBRARY]_LOCAL</tt> should be used to decorate function
* declarations which are exported across translation units within the
* DLL, but which are not exported outside of the DLL boundary.
*
* Functions which are @c static in either a C file or in a header file do not
* need any form of linkage decoration, and should therefore have no linkage
* macro applied to them.
*/
/**
* @def CSTD_LINK_IMPORT
* Specifies a function as being imported to a translation unit across a DLL
* boundary.
*/
/**
* @def CSTD_LINK_EXPORT
* Specifies a function as being exported across a DLL boundary by a
* translation unit.
*/
/**
* @def CSTD_LINK_IMPL
* Specifies a function which will be exported across a DLL boundary as
* being implemented by a translation unit.
*/
/**
* @def CSTD_LINK_LOCAL
* Specifies a function which is internal to a DLL, and which should not be
* exported outside of it.
*/
/**
* @}
*/
#if 1 == CSTD_OS_LINUX
#define CSTD_LINK_IMPORT __attribute__((visibility("default")))
#define CSTD_LINK_EXPORT __attribute__((visibility("default")))
#define CSTD_LINK_IMPL __attribute__((visibility("default")))
#define CSTD_LINK_LOCAL __attribute__((visibility("hidden")))
#elif 1 == CSTD_OS_WINDOWS
#define CSTD_LINK_IMPORT __declspec(dllimport)
#define CSTD_LINK_EXPORT __declspec(dllexport)
#define CSTD_LINK_IMPL __declspec(dllexport)
#define CSTD_LINK_LOCAL
#elif 1 == CSTD_OS_SYMBIAN
#define CSTD_LINK_IMPORT IMPORT_C
#define CSTD_LINK_EXPORT IMPORT_C
#define CSTD_LINK_IMPL EXPORT_C
#define CSTD_LINK_LOCAL
#elif 1 == CSTD_OS_APPLEOS
#define CSTD_LINK_IMPORT __attribute__((visibility("default")))
#define CSTD_LINK_EXPORT __attribute__((visibility("default")))
#define CSTD_LINK_IMPL __attribute__((visibility("default")))
#define CSTD_LINK_LOCAL __attribute__((visibility("hidden")))
#elif 1 == CSTD_OS_ANDROID
#define CSTD_LINK_IMPORT __attribute__((visibility("default")))
#define CSTD_LINK_EXPORT __attribute__((visibility("default")))
#define CSTD_LINK_IMPL __attribute__((visibility("default")))
#define CSTD_LINK_LOCAL __attribute__((visibility("hidden")))
#else /* CSTD_OS_NONE */
#define CSTD_LINK_IMPORT
#define CSTD_LINK_EXPORT
#define CSTD_LINK_IMPL
#define CSTD_LINK_LOCAL
#endif
/**
* @}
*/
#endif /* End (_ARM_CSTD_COMPILERS_H_) */

View file

@ -0,0 +1,27 @@
/*
*
* (C) COPYRIGHT ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*
* A copy of the licence is included with the program, and can also be obtained
* from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef _ARM_CSTD_PACK_POP_H_
#define _ARM_CSTD_PACK_POP_H_
#if 1 == CSTD_TOOLCHAIN_MSVC
#include <poppack.h>
#endif
#endif /* End (_ARM_CSTD_PACK_POP_H_) */

View file

@ -0,0 +1,27 @@
/*
*
* (C) COPYRIGHT ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*
* A copy of the licence is included with the program, and can also be obtained
* from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef _ARM_CSTD_PACK_PUSH_H_
#define _ARM_CSTD_PACK_PUSH_H_
#if 1 == CSTD_TOOLCHAIN_MSVC
#include <pshpack1.h>
#endif
#endif /* End (_ARM_CSTD_PACK_PUSH_H_) */

View file

@ -0,0 +1,33 @@
/*
*
* (C) COPYRIGHT ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*
* A copy of the licence is included with the program, and can also be obtained
* from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef _ARM_CSTD_TYPES_H_
#define _ARM_CSTD_TYPES_H_
#if 1 == CSTD_TOOLCHAIN_MSVC
#include "arm_cstd_types_msvc.h"
#elif 1 == CSTD_TOOLCHAIN_GCC
#include "arm_cstd_types_gcc.h"
#elif 1 == CSTD_TOOLCHAIN_RVCT
#include "arm_cstd_types_rvct.h"
#else
#error "Toolchain not recognized"
#endif
#endif /* End (_ARM_CSTD_TYPES_H_) */

View file

@ -0,0 +1,92 @@
/*
*
* (C) COPYRIGHT ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*
* A copy of the licence is included with the program, and can also be obtained
* from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef _ARM_CSTD_TYPES_GCC_H_
#define _ARM_CSTD_TYPES_GCC_H_
/* ============================================================================
Type definitions
============================================================================ */
/* All modern versions of GCC support stdint outside of C99 Mode. */
/* However, Linux kernel limits what headers are available! */
#if 1 == CSTD_OS_LINUX_KERNEL
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/stddef.h>
#include <linux/version.h>
/* Fix up any types which CSTD provdes but which Linux is missing. */
/* Note Linux assumes pointers are "long", so this is safe. */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
typedef unsigned long uintptr_t;
#endif
typedef long intptr_t;
#else
#include <stdint.h>
#include <stddef.h>
#include <limits.h>
#endif
typedef uint32_t bool_t;
#if !defined(TRUE)
#define TRUE ((bool_t)1)
#endif
#if !defined(FALSE)
#define FALSE ((bool_t)0)
#endif
/* ============================================================================
Keywords
============================================================================ */
/* Doxygen documentation for these is in the RVCT header. */
#define ASM __asm__
#define INLINE __inline__
#define FORCE_INLINE __attribute__((__always_inline__)) __inline__
#define NEVER_INLINE __attribute__((__noinline__))
#define PURE __attribute__((__pure__))
#define PACKED __attribute__((__packed__))
/* GCC does not support pointers to UNALIGNED data, so we do not define it to
* force a compile error if this macro is used. */
#define RESTRICT __restrict__
/* RVCT in GCC mode does not support the CHECK_RESULT attribute. */
#if 0 == CSTD_TOOLCHAIN_RVCT_GCC_MODE
#define CHECK_RESULT __attribute__((__warn_unused_result__))
#else
#define CHECK_RESULT
#endif
/* RVCT in GCC mode does not support the __func__ name outside of C99. */
#if (0 == CSTD_TOOLCHAIN_RVCT_GCC_MODE)
#define CSTD_FUNC __func__
#else
#define CSTD_FUNC __FUNCTION__
#endif
#endif /* End (_ARM_CSTD_TYPES_GCC_H_) */

View file

@ -0,0 +1,192 @@
/*
*
* (C) COPYRIGHT ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*
* A copy of the licence is included with the program, and can also be obtained
* from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef _ARM_CSTD_TYPES_RVCT_H_
#define _ARM_CSTD_TYPES_RVCT_H_
/* ============================================================================
Type definitions
============================================================================ */
#include <stddef.h>
#include <limits.h>
#if 199901L <= __STDC_VERSION__
#include <inttypes.h>
#else
typedef unsigned char uint8_t;
typedef signed char int8_t;
typedef unsigned short uint16_t;
typedef signed short int16_t;
typedef unsigned int uint32_t;
typedef signed int int32_t;
typedef unsigned __int64 uint64_t;
typedef signed __int64 int64_t;
typedef ptrdiff_t intptr_t;
typedef size_t uintptr_t;
#endif
typedef uint32_t bool_t;
#if !defined(TRUE)
#define TRUE ((bool_t)1)
#endif
#if !defined(FALSE)
#define FALSE ((bool_t)0)
#endif
/* ============================================================================
Keywords
============================================================================ */
/**
* @addtogroup arm_cstd_coding_standard
* @{
*/
/**
* @def ASM
* @hideinitializer
* Mark an assembler block. Such blocks are often compiler specific, so often
* need to be surrounded in appropriate @c ifdef and @c endif blocks
* using the relevant @c CSTD_TOOLCHAIN macro.
*/
#define ASM __asm
/**
* @def INLINE
* @hideinitializer
* Mark a definition as something which should be inlined. This is not always
* possible on a given compiler, and may be disabled at lower optimization
* levels.
*/
#define INLINE __inline
/**
* @def FORCE_INLINE
* @hideinitializer
* Mark a definition as something which should be inlined. This provides a much
* stronger hint to the compiler than @c INLINE, and if supported should always
* result in an inlined function being emitted. If not supported this falls
* back to using the @c INLINE definition.
*/
#define FORCE_INLINE __forceinline
/**
* @def NEVER_INLINE
* @hideinitializer
* Mark a definition as something which should not be inlined. This provides a
* stronger hint to the compiler than the function should not be inlined,
* bypassing any heuristic rules the compiler normally applies. If not
* supported by a toolchain this falls back to being an empty macro.
*/
#define NEVER_INLINE __declspec(noinline)
/**
* @def PURE
* @hideinitializer
* Denotes that a function's return is only dependent on its inputs, enabling
* more efficient optimizations. Falls back to an empty macro if not supported.
*/
#define PURE __pure
/**
* @def PACKED
* @hideinitializer
* Denotes that a structure should be stored in a packed form. This macro must
* be used in conjunction with the @c arm_cstd_pack_* headers for portability:
*
* @code
* #include <cstd/arm_cstd_pack_push.h>
*
* struct PACKED myStruct {
* ...
* };
*
* #include <cstd/arm_cstd_pack_pop.h>
* PACKED
* @endcode
*/
#define PACKED __packed
/**
* @def UNALIGNED
* @hideinitializer
* Denotes that a pointer points to a buffer with lower alignment than the
* natural alignment required by the C standard. This should only be used
* in extreme cases, as the emitted code is normally more efficient if memory
* is aligned.
*
* @warning This is \b NON-PORTABLE. The GNU tools are anti-unaligned pointers
* and have no support for such a construction.
*/
#define UNALIGNED __packed
/**
* @def RESTRICT
* @hideinitializer
* Denotes that a pointer does not overlap with any other points currently in
* scope, increasing the range of optimizations which can be performed by the
* compiler.
*
* @warning Specification of @c RESTRICT is a contract between the programmer
* and the compiler. If you place @c RESTICT on buffers which do actually
* overlap the behavior is undefined, and likely to vary at different
* optimization levels.!
*/
#define RESTRICT __restrict
/**
* @def CHECK_RESULT
* @hideinitializer
* Function attribute which causes a warning to be emitted if the compiler's
* return value is not used by the caller. Compiles to an empty macro if
* there is no supported mechanism for this check in the underlying compiler.
*
* @note At the time of writing this is only supported by GCC. RVCT does not
* support this attribute, even in GCC mode, so engineers are encouraged to
* compile their code using GCC even if primarily working with another
* compiler.
*
* @code
* CHECK_RESULT int my_func( void );
* @endcode
*/
#define CHECK_RESULT
/**
* @def CSTD_FUNC
* Specify the @c CSTD_FUNC macro, a portable construct containing the name of
* the current function. On most compilers it is illegal to use this macro
* outside of a function scope. If not supported by the compiler we define
* @c CSTD_FUNC as an empty string.
*
* @warning Due to the implementation of this on most modern compilers this
* expands to a magically defined "static const" variable, not a constant
* string. This makes injecting @c CSTD_FUNC directly in to compile-time
* strings impossible, so if you want to make the function name part of a
* larger string you must use a printf-like function with a @c @%s template
* which is populated with @c CSTD_FUNC
*/
#define CSTD_FUNC __FUNCTION__
/**
* @}
*/
#endif /* End (_ARM_CSTD_TYPES_RVCT_H_) */

View file

@ -0,0 +1,242 @@
/*
*
* (C) COPYRIGHT ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*
* A copy of the licence is included with the program, and can also be obtained
* from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef _MALISW_H_
#define _MALISW_H_
/**
* @file mali_malisw.h
* Driver-wide include for common macros and types.
*/
/**
* @defgroup malisw Mali software definitions and types
* @{
*/
#include <stddef.h>
#include "mali_stdtypes.h"
/** @brief Gets the container object when given a pointer to a member of an object. */
#define CONTAINER_OF(ptr, type, member) ((type *)((char *)(ptr) - offsetof(type,member)))
/** @brief Gets the number of elements of type s in a fixed length array of s */
#define NELEMS(s) (sizeof(s)/sizeof((s)[0]))
/**
* @brief The lesser of two values.
* May evaluate its arguments more than once.
* @see CSTD_MIN
*/
#define MIN(x,y) CSTD_MIN(x,y)
/**
* @brief The greater of two values.
* May evaluate its arguments more than once.
* @see CSTD_MAX
*/
#define MAX(x,y) CSTD_MAX(x,y)
/**
* @brief Clamp value x to within min and max inclusive
* May evaluate its arguments more than once.
* @see CSTD_CLAMP
*/
#define CLAMP( x, min, max ) CSTD_CLAMP( x, min, max )
/**
* @brief Convert a pointer into a u64 for storing in a data structure.
* This is commonly used when pairing a 32-bit CPU with a 64-bit peripheral,
* such as a Midgard GPU. C's type promotion is complex and a straight cast
* does not work reliably as pointers are often considered as signed.
*/
#define PTR_TO_U64( x ) CSTD_PTR_TO_U64( x )
/**
* @name Mali library linkage specifiers
* These directly map to the cstd versions described in detail here: @ref arm_cstd_linkage_specifiers
* @{
*/
#define MALI_IMPORT CSTD_LINK_IMPORT
#define MALI_EXPORT CSTD_LINK_EXPORT
#define MALI_IMPL CSTD_LINK_IMPL
#if defined(CONFIG_MALI_DEBUG) || !MALI_CUSTOMER_RELEASE
#define MALI_LOCAL CSTD_LINK_EXPORT
#else
#define MALI_LOCAL CSTD_LINK_LOCAL
#endif
/** @brief Decorate exported function prototypes.
*
* The file containing the implementation of the function should define this to be MALI_EXPORT before including
* malisw/mali_malisw.h.
*/
#ifndef MALI_API
#define MALI_API MALI_IMPORT
#endif
/** @} */
/** @name Testable static functions
* @{
*
* These macros can be used to allow functions to be static in release builds but exported from a shared library in unit
* test builds, allowing them to be tested or used to assist testing.
*
* Example mali_foo_bar.c containing the function to test:
*
* @code
* #define MALI_API MALI_EXPORT
*
* #include <malisw/mali_malisw.h>
* #include "mali_foo_testable_statics.h"
*
* MALI_TESTABLE_STATIC_IMPL void my_func()
* {
* //Implementation
* }
* @endcode
*
* Example mali_foo_testable_statics.h:
*
* @code
* #if 1 == MALI_UNIT_TEST
* #include <malisw/mali_malisw.h>
*
* MALI_TESTABLE_STATIC_API void my_func();
*
* #endif
* @endcode
*
* Example mali_foo_tests.c:
*
* @code
* #include <foo/src/mali_foo_testable_statics.h>
*
* void my_test_func()
* {
* my_func();
* }
* @endcode
*/
/** @brief Decorate testable static function implementations.
*
* A header file containing a MALI_TESTABLE_STATIC_API-decorated prototype for each static function will be required
* when MALI_UNIT_TEST == 1 in order to link the function from the test.
*/
#if 1 == MALI_UNIT_TEST
#define MALI_TESTABLE_STATIC_IMPL MALI_IMPL
#else
#define MALI_TESTABLE_STATIC_IMPL static
#endif
/** @brief Decorate testable static function prototypes.
*
* @note Prototypes should @em only be declared when MALI_UNIT_TEST == 1
*/
#define MALI_TESTABLE_STATIC_API MALI_API
/** @} */
/** @name Testable local functions
* @{
*
* These macros can be used to allow functions to be local to a shared library in release builds but be exported in unit
* test builds, allowing them to be tested or used to assist testing.
*
* Example mali_foo_bar.c containing the function to test:
*
* @code
* #define MALI_API MALI_EXPORT
*
* #include <malisw/mali_malisw.h>
* #include "mali_foo_bar.h"
*
* MALI_TESTABLE_LOCAL_IMPL void my_func()
* {
* //Implementation
* }
* @endcode
*
* Example mali_foo_bar.h:
*
* @code
* #include <malisw/mali_malisw.h>
*
* MALI_TESTABLE_LOCAL_API void my_func();
*
* @endcode
*
* Example mali_foo_tests.c:
*
* @code
* #include <foo/src/mali_foo_bar.h>
*
* void my_test_func()
* {
* my_func();
* }
* @endcode
*/
/** @brief Decorate testable local function implementations.
*
* This can be used to have a function normally local to the shared library except in debug builds where it will be
* exported.
*/
#ifdef CONFIG_MALI_DEBUG
#define MALI_TESTABLE_LOCAL_IMPL MALI_IMPL
#else
#define MALI_TESTABLE_LOCAL_IMPL MALI_LOCAL
#endif /* CONFIG_MALI_DEBUG */
/** @brief Decorate testable local function prototypes.
*
* This can be used to have a function normally local to the shared library except in debug builds where it will be
* exported.
*/
#ifdef CONFIG_MALI_DEBUG
#define MALI_TESTABLE_LOCAL_API MALI_API
#else
#define MALI_TESTABLE_LOCAL_API MALI_LOCAL
#endif /* CONFIG_MALI_DEBUG */
/** @} */
/**
* Flag a cast as a reinterpretation, usually of a pointer type.
* @see CSTD_REINTERPRET_CAST
*/
#define REINTERPRET_CAST(type) CSTD_REINTERPRET_CAST(type)
/**
* Flag a cast as casting away const, usually of a pointer type.
* @see CSTD_CONST_CAST
*/
#define CONST_CAST(type) (type) CSTD_CONST_CAST(type)
/**
* Flag a cast as a (potentially complex) value conversion, usually of a numerical type.
* @see CSTD_STATIC_CAST
*/
#define STATIC_CAST(type) (type) CSTD_STATIC_CAST(type)
/** @} */
#endif /* _MALISW_H_ */

View file

@ -0,0 +1,265 @@
/*
*
* (C) COPYRIGHT ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*
* A copy of the licence is included with the program, and can also be obtained
* from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef _MALISW_STDTYPES_H_
#define _MALISW_STDTYPES_H_
/**
* @file mali_stdtypes.h
* This file defines the standard types used by the Mali codebase.
*/
/**
* @addtogroup malisw
* @{
*/
/**
* @defgroup malisw_stdtypes Mali software standard types
*
* Basic driver-wide types.
*/
/**
* @addtogroup malisw_stdtypes
* @{
*/
#include "arm_cstd/arm_cstd.h"
/**
* @name Scalar types.
* These are the scalar types used within the mali driver.
* @{
*/
/* Note: if compiling the Linux kernel then avoid redefining these. */
#if 0 == CSTD_OS_LINUX_KERNEL
typedef uint64_t u64;
typedef uint32_t u32;
typedef uint16_t u16;
typedef uint8_t u8;
typedef int64_t s64;
typedef int32_t s32;
typedef int16_t s16;
typedef int8_t s8;
#endif
typedef double f64;
typedef float f32;
typedef u16 f16;
typedef u32 mali_fixed16_16;
/* @} */
/**
* @name Boolean types.
* The intended use is for bool8 to be used when storing boolean values in
* structures, casting to mali_bool to be used in code sections.
* @{
*/
typedef bool_t mali_bool;
typedef u8 mali_bool8;
#define MALI_FALSE FALSE
#define MALI_TRUE TRUE
/* @} */
/**
* @name Integer bounding values
* Maximum and minimum values for integer types
* @{
*/
#ifndef U64_MAX
#define U64_MAX UINT64_MAX
#endif
#ifndef U32_MAX
#define U32_MAX UINT32_MAX
#endif
#ifndef U16_MAX
#define U16_MAX UINT16_MAX
#endif
#ifndef U8_MAX
#define U8_MAX UINT8_MAX
#endif
#ifndef S64_MAX
#define S64_MAX INT64_MAX
#endif
#ifndef S64_MIN
#define S64_MIN INT64_MIN
#endif
#ifndef S32_MAX
#define S32_MAX INT32_MAX
#endif
#ifndef S32_MIN
#define S32_MIN INT32_MIN
#endif
#ifndef S16_MAX
#define S16_MAX INT16_MAX
#endif
#ifndef S16_MIN
#define S16_MIN INT16_MIN
#endif
#ifndef S8_MAX
#define S8_MAX INT8_MAX
#endif
#ifndef S8_MIN
#define S8_MIN INT8_MIN
#endif
/* @} */
/**
* @name GPU address types
* Types for integers which hold a GPU pointer or GPU pointer offsets.
* @{
*/
typedef u64 mali_addr64;
typedef u32 mali_addr32;
typedef u64 mali_size64;
typedef s64 mali_offset64;
/* 32 bit offsets and sizes are always for native types and so use ptrdiff_t and size_t respectively */
/* @} */
/**
* @name Mali error types
* @brief The common error type for the mali drivers
* The mali_error type, all driver error handling should be of this type unless
* it must deal with a specific APIs error type.
* @{
*/
typedef enum
{
/**
* @brief Common Mali errors for the entire driver
* MALI_ERROR_NONE is guaranteed to be 0.
* @{
*/
MALI_ERROR_NONE = 0,
MALI_ERROR_OUT_OF_GPU_MEMORY,
MALI_ERROR_OUT_OF_MEMORY,
MALI_ERROR_FUNCTION_FAILED,
/* @} */
/**
* @brief Mali errors for Client APIs to pass to EGL when creating EGLImages
* These errors must only be returned to EGL from one of the Client APIs as part of the
* (clientapi)_egl_image_interface.h
* @{
*/
MALI_ERROR_EGLP_BAD_ACCESS,
MALI_ERROR_EGLP_BAD_PARAMETER,
/* @} */
/**
* @brief Mali errors for the MCL module.
* These errors must only be used within the private components of the OpenCL implementation that report
* directly to API functions for cases where errors cannot be detected in the entrypoints file. They must
* not be passed between driver components.
* These are errors in the mali error space specifically for the MCL module, hence the MCLP prefix.
* @{
*/
MALI_ERROR_MCLP_DEVICE_NOT_FOUND,
MALI_ERROR_MCLP_DEVICE_NOT_AVAILABLE,
MALI_ERROR_MCLP_COMPILER_NOT_AVAILABLE,
MALI_ERROR_MCLP_MEM_OBJECT_ALLOCATION_FAILURE,
MALI_ERROR_MCLP_PROFILING_INFO_NOT_AVAILABLE,
MALI_ERROR_MCLP_MEM_COPY_OVERLAP,
MALI_ERROR_MCLP_IMAGE_FORMAT_MISMATCH,
MALI_ERROR_MCLP_IMAGE_FORMAT_NOT_SUPPORTED,
MALI_ERROR_MCLP_BUILD_PROGRAM_FAILURE,
MALI_ERROR_MCLP_MAP_FAILURE,
MALI_ERROR_MCLP_MISALIGNED_SUB_BUFFER_OFFSET,
MALI_ERROR_MCLP_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST,
MALI_ERROR_MCLP_INVALID_VALUE,
MALI_ERROR_MCLP_INVALID_DEVICE_TYPE,
MALI_ERROR_MCLP_INVALID_PLATFORM,
MALI_ERROR_MCLP_INVALID_DEVICE,
MALI_ERROR_MCLP_INVALID_CONTEXT,
MALI_ERROR_MCLP_INVALID_QUEUE_PROPERTIES,
MALI_ERROR_MCLP_INVALID_COMMAND_QUEUE,
MALI_ERROR_MCLP_INVALID_HOST_PTR,
MALI_ERROR_MCLP_INVALID_MEM_OBJECT,
MALI_ERROR_MCLP_INVALID_IMAGE_FORMAT_DESCRIPTOR,
MALI_ERROR_MCLP_INVALID_IMAGE_SIZE,
MALI_ERROR_MCLP_INVALID_SAMPLER,
MALI_ERROR_MCLP_INVALID_BINARY,
MALI_ERROR_MCLP_INVALID_BUILD_OPTIONS,
MALI_ERROR_MCLP_INVALID_PROGRAM,
MALI_ERROR_MCLP_INVALID_PROGRAM_EXECUTABLE,
MALI_ERROR_MCLP_INVALID_KERNEL_NAME,
MALI_ERROR_MCLP_INVALID_KERNEL_DEFINITION,
MALI_ERROR_MCLP_INVALID_KERNEL,
MALI_ERROR_MCLP_INVALID_ARG_INDEX,
MALI_ERROR_MCLP_INVALID_ARG_VALUE,
MALI_ERROR_MCLP_INVALID_ARG_SIZE,
MALI_ERROR_MCLP_INVALID_KERNEL_ARGS,
MALI_ERROR_MCLP_INVALID_WORK_DIMENSION,
MALI_ERROR_MCLP_INVALID_WORK_GROUP_SIZE,
MALI_ERROR_MCLP_INVALID_WORK_ITEM_SIZE,
MALI_ERROR_MCLP_INVALID_GLOBAL_OFFSET,
MALI_ERROR_MCLP_INVALID_EVENT_WAIT_LIST,
MALI_ERROR_MCLP_INVALID_EVENT,
MALI_ERROR_MCLP_INVALID_OPERATION,
MALI_ERROR_MCLP_INVALID_GL_OBJECT,
MALI_ERROR_MCLP_INVALID_BUFFER_SIZE,
MALI_ERROR_MCLP_INVALID_MIP_LEVEL,
MALI_ERROR_MCLP_INVALID_GLOBAL_WORK_SIZE,
MALI_ERROR_MCLP_INVALID_GL_SHAREGROUP_REFERENCE_KHR,
MALI_ERROR_MCLP_INVALID_EGL_OBJECT,
/* @} */
/**
* @brief Mali errors for the BASE module
* These errors must only be used within the private components of the Base implementation. They will not
* passed to other modules by the base driver.
* These are errors in the mali error space specifically for the BASE module, hence the BASEP prefix.
* @{
*/
MALI_ERROR_BASEP_INVALID_FUNCTION,
/* @} */
/** A dependency exists upon a resource that the client application wants to modify, so the driver must either
* create a copy of the resource (if possible) or block until the dependency has been satisfied.
*/
MALI_ERROR_RESOURCE_IN_USE,
/**
* @brief A stride value was too big.
*
* A surface descriptor can store strides of up to 2<sup>31</sup>-1 bytes but strides greater than
* 2<sup>28</sup>-1 bytes cannot be expressed in bits without overflow.
*/
MALI_ERROR_STRIDE_TOO_BIG
} mali_error;
/* @} */
/* @} */
/* @} */
#endif /* _MALISW_STDTYPES_H_ */