os/kernelhwsrv/kernel/eka/compsupp/symaehabi/unwind_env.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/compsupp/symaehabi/unwind_env.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,382 @@
     1.4 +/* unwind_env.h
     1.5 + *
     1.6 + * Copyright 2003-2005 ARM Limited. All rights reserved.
     1.7 + */
     1.8 +/*
     1.9 +  Licence
    1.10 +  
    1.11 +  1. Subject to the provisions of clause 2, ARM hereby grants to LICENSEE a 
    1.12 +  perpetual, non-exclusive, nontransferable, royalty free, worldwide licence 
    1.13 +  to use this Example Implementation of Exception Handling solely for the 
    1.14 +  purpose of developing, having developed, manufacturing, having 
    1.15 +  manufactured, offering to sell, selling, supplying or otherwise 
    1.16 +  distributing products which comply with the Exception Handling ABI for the 
    1.17 +  ARM Architecture specification. All other rights are reserved to ARM or its 
    1.18 +  licensors.
    1.19 +  
    1.20 +  2. THIS EXAMPLE IMPLEMENTATION OF EXCEPTION HANDLING  IS PROVIDED "AS IS" 
    1.21 +  WITH NO WARRANTIES EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED 
    1.22 +  TO ANY WARRANTY OF SATISFACTORY QUALITY, MERCHANTABILITY, NONINFRINGEMENT 
    1.23 +  OR FITNESS FOR A PARTICULAR PURPOSE.
    1.24 +*/
    1.25 +
    1.26 +/* Portions copyright Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). */
    1.27 +
    1.28 +/*
    1.29 + * RCS $Revision: 92949 $
    1.30 + * Checkin $Date: 2005-10-12 11:07:03 +0100 (Wed, 12 Oct 2005) $
    1.31 + * Revising $Author: achapman $
    1.32 + */
    1.33 +
    1.34 +/* Environment definition - abstractions and requirements - to aid
    1.35 + * portability of the ARM exceptions code.
    1.36 + */
    1.37 +
    1.38 +#ifndef UNWINDENV_H
    1.39 +#define UNWINDENV_H
    1.40 +
    1.41 +/* ---------------------------------------------------------------------- */
    1.42 +
    1.43 +/* Source language
    1.44 + *
    1.45 + * The compiler is expected to define preprocessor symbols as follows:
    1.46 + * __cplusplus when compiling in C++ mode.
    1.47 + * __thumb when compiling to Thumb code.
    1.48 + *
    1.49 + * Some use is made of embedded assembly language, introduced by __asm.
    1.50 + * This is described in ARM's toolchain documentation. Some edits may be
    1.51 + * required for other compilers. The compiler should define one or more of:
    1.52 + * __TARGET_ARCH_4T __TARGET_ARCH_4TXM __TARGET_ARCH_5T __TARGET_ARCH_5TXM
    1.53 + * __TARGET_ARCH_5TE __TARGET_ARCH_6
    1.54 + * so the correct assembly wrappers are generated for certain functions.
    1.55 + *
    1.56 + * __APCS_INTERWORK should be defined if ARM/Thumb interworking is required.
    1.57 + *
    1.58 + * For all the above symbols, if your compiler does not provide appropriate
    1.59 + * definitions, add them here.
    1.60 + *
    1.61 + * Some source language extensions are also used.
    1.62 + */
    1.63 +
    1.64 +/* ---------------------------------------------------------------------- */
    1.65 +
    1.66 +/* Library structure
    1.67 + *
    1.68 + * ARM's private make system contains an automated facility for compiling
    1.69 + * source files multiple times to create multiple object files. The source
    1.70 + * regions intended to constitute object file xxx.o are delimited by
    1.71 + * #ifdef xxx_c / #endif directives. The exact preprocessor symbols used
    1.72 + * for this conditionalisation are described in a comment at the start of
    1.73 + * each file. When porting to a different system, compilations must be
    1.74 + * performed with these preprocessor symbols appropriately defined
    1.75 + * (or remove the conditionalisation).
    1.76 + *
    1.77 + */
    1.78 +#ifdef __EPOC32__ 
    1.79 +
    1.80 +#define ARM_EXCEPTIONS_ENABLED
    1.81 +
    1.82 +// turn on the source regions in unwinder.c
    1.83 +#define unwinder_c
    1.84 +#define unwind_activity_c
    1.85 +
    1.86 +// turn on the source regions in unwind_pr.c
    1.87 +#define pr0_c
    1.88 +#define pr1_c
    1.89 +#define pr2_c
    1.90 +#define prcommon_c
    1.91 +
    1.92 +// turn on the source regions in cppsemantics.cpp
    1.93 +#define arm_exceptions_globs_c
    1.94 +#define arm_exceptions_mem_c
    1.95 +#define arm_exceptions_uncaught_c
    1.96 +#define arm_exceptions_terminate_c
    1.97 +#define arm_exceptions_setterminate_c
    1.98 +#define arm_exceptions_unexpected_c
    1.99 +#define arm_exceptions_setunexpected_c
   1.100 +#define arm_exceptions_support_c
   1.101 +#define arm_exceptions_callterm_c
   1.102 +#define arm_exceptions_callunex_c
   1.103 +#define arm_exceptions_currenttype_c
   1.104 +#define arm_exceptions_alloc_c
   1.105 +#define arm_exceptions_free_c
   1.106 +#define arm_exceptions_throw_c
   1.107 +#define arm_exceptions_rethrow_c
   1.108 +#define arm_exceptions_foreign_c
   1.109 +#define arm_exceptions_cleanup_c
   1.110 +#define arm_exceptions_getexceptionptr_c
   1.111 +#define arm_exceptions_catchsemantics_c
   1.112 +#define arm_exceptions_begincatch_c
   1.113 +#define arm_exceptions_endcatch_c
   1.114 +#define arm_exceptions_bad_typeid_c
   1.115 +#define arm_exceptions_bad_cast_c
   1.116 +#endif
   1.117 +
   1.118 +/* ARM declares (or redeclares) some routines as weak in order that
   1.119 + * references to them are weak, so that the static linker will not load
   1.120 + * unwanted code. This is achieved by decorating routine declarations
   1.121 + * with appropriate language extensions. Note that compilers supporting
   1.122 + * similar features but via a different syntax may require edits to
   1.123 + * the library source.
   1.124 + *
   1.125 + * Define those decorations here (define as empty if not required):
   1.126 + */
   1.127 +
   1.128 +#ifndef __EPOC32__
   1.129 +#define WEAKDECL __weak        /* token in C and C++ */
   1.130 +#define WEAKASMDECL [WEAK]     /* token in assembler */
   1.131 +#else
   1.132 +// The symbian version needs all of these in the DLL, so don't make them weak
   1.133 +#define WEAKDECL 
   1.134 +#define WEAKASMDECL 
   1.135 +#endif
   1.136 +
   1.137 +/* ---------------------------------------------------------------------- */
   1.138 +
   1.139 +/* Source language support and language extensions */
   1.140 +
   1.141 +/* It is possible to compile the C++ semantics code using a compiler
   1.142 + * which does not support C++ exceptions; this was useful to ARM whilst
   1.143 + * ARM's compiler was being developed, and the facility has not been
   1.144 + * removed. C++ exceptions syntax is conditionalised by
   1.145 + * #ifdef ARM_EXCEPTIONS_ENABLED / #endif. Define ARM_EXCEPTIONS_ENABLED
   1.146 + * by some means here if you want a usable library:
   1.147 + */
   1.148 +
   1.149 +#ifdef __cplusplus
   1.150 +extern "C" {
   1.151 +  /* For conditionalisation, specifically on ARM_EXCEPTIONS_ENABLED */
   1.152 +#include "basics.h"
   1.153 +}
   1.154 +#endif
   1.155 +
   1.156 +/* The following definitions of syntax decoration may be empty if the
   1.157 + * facility is not required. Note that compilers supporting similar
   1.158 + * features but via a different syntax may require edits to the library
   1.159 + * source.
   1.160 + * 
   1.161 + * Define the decorations here (define as empty if not required):
   1.162 + */
   1.163 +  
   1.164 +/* If the compiler understands noreturn functions: */
   1.165 +#define NORETURNDECL __declspec(noreturn)
   1.166 +/* Inlining when compiling C */
   1.167 +#define INLINE __inline
   1.168 +/* Stronger encouragement to inline */
   1.169 +#define FORCEINLINE __forceinline
   1.170 +
   1.171 +/* ---------------------------------------------------------------------- */
   1.172 +
   1.173 +/* Types */
   1.174 +
   1.175 +/* The implementation requires types uint8_t, uint16_t, uint32_t and
   1.176 + * uint64_t to be defined as unsigned integers of the appropriate number
   1.177 + * of bits.
   1.178 + *
   1.179 + * Do that here:
   1.180 + */
   1.181 +
   1.182 +#ifndef __EPOC32__
   1.183 +#include <stdint.h>
   1.184 +#else
   1.185 +#include <e32def.h>
   1.186 +typedef TUint8 uint8_t;
   1.187 +typedef TUint16 uint16_t;
   1.188 +typedef TInt32 int32_t;
   1.189 +typedef TUint32 uint32_t;
   1.190 +typedef Uint64 uint64_t;
   1.191 +#endif
   1.192 +
   1.193 +/* The C++ semantics support requires definition of the RTTI object
   1.194 + * layout. We use the same structures and names as the generic C++
   1.195 + * ABI for Itanium.
   1.196 + *
   1.197 + * Define those structures here:
   1.198 + */
   1.199 +
   1.200 +#ifdef __cplusplus
   1.201 +extern "C" {
   1.202 +#include "cxxabi.h"
   1.203 +}
   1.204 +#endif
   1.205 +
   1.206 +/* ---------------------------------------------------------------------- */
   1.207 +
   1.208 +/* External requirements */
   1.209 +
   1.210 +/* The C++ exception-handling 'globals' should be allocated per-thread.
   1.211 + * The Exceptions ABI does not specify how this happens, but it is
   1.212 + * intended that the details are localised to __cxa_get_globals.
   1.213 + *
   1.214 + * In the ARM implementation of __cxa_get_globals, it is assumed that a
   1.215 + * zero-initialised location in a known per-thread place is somehow
   1.216 + * obtainable, and can be assigned (by __cxa_get_globals) a pointer to
   1.217 + * the allocated globals data structure. The macro EH_GLOBALS should be
   1.218 + * defined here to yield a suitable address of type void*. This is used
   1.219 + * only in __cxa_get_globals.
   1.220 + *
   1.221 + * Define it here:
   1.222 + */
   1.223 +
   1.224 +#ifdef __cplusplus
   1.225 +#ifndef __EPOC32__
   1.226 +extern "C" {
   1.227 +  /* for __user_libspace() machinery */
   1.228 +#include <interns.h>
   1.229 +#define EH_GLOBALS libspace.eh_globals
   1.230 +}
   1.231 +#else
   1.232 +#include <e32std.h>
   1.233 +#define EH_GLOBALS (Dll::Tls())
   1.234 +#endif
   1.235 +#endif
   1.236 +
   1.237 +/* A routine is required for C++ derived class to base class conversion.
   1.238 + * This is used once, in __cxa_type_match. It is likely that suitable
   1.239 + * code exists as part of the RTTI support code. Therefore access it
   1.240 + * via a macro:
   1.241 + * DERIVED_TO_BASE_CONVERSION(PTR, P_NEW_PTR, CLASS_INFO, BASE_INFO)
   1.242 + *   Convert PTR from a pointer to a derived class (described by
   1.243 + *   CLASS_INFO) to a pointer to a base class (described by BASE_INFO)
   1.244 + *   and store the resulting pointer in P_NEW_PTR. Return true (or
   1.245 + *   non-zero) if the base class was found and the conversion was done,
   1.246 + *   otherwise return false (or zero).
   1.247 + *
   1.248 + * Define the macro here:
   1.249 + */
   1.250 +
   1.251 +#ifdef __cplusplus
   1.252 +/* In the ARM implementation, a suitable routine exists elsewhere in the
   1.253 + * C++ runtime library, where it is part of the dynamic_cast mechanism.
   1.254 + */
   1.255 +#if !defined(__EPOC32__) || (__ARMCC_VERSION > 310000)
   1.256 +extern "C" int __derived_to_base_conversion(void** p_ptr, void** p_new_ptr,
   1.257 +                                            const std::type_info * class_info,
   1.258 +                                            const std::type_info * base_info,
   1.259 +                                            char** access_flags, int use_access_flags);
   1.260 +
   1.261 +#define DERIVED_TO_BASE_CONVERSION(PTR, P_NEW_PTR, CLASS_INFO, BASE_INFO) \
   1.262 +  __derived_to_base_conversion(&(PTR), (P_NEW_PTR), (CLASS_INFO), (BASE_INFO), NULL, 0)
   1.263 +#else
   1.264 +extern "C" TBool _DoDerivedToBaseConversion(const std::type_info* aDerivedType,
   1.265 +											const std::type_info* aBaseType,
   1.266 +			    							TAny** aDerivedObj,
   1.267 +			    							TAny** aBaseObj);
   1.268 +
   1.269 +#define DERIVED_TO_BASE_CONVERSION(PTR, P_NEW_PTR, CLASS_INFO, BASE_INFO) \
   1.270 +  _DoDerivedToBaseConversion(CLASS_INFO, BASE_INFO, &(PTR), P_NEW_PTR)
   1.271 +#endif
   1.272 +
   1.273 +#endif
   1.274 +
   1.275 +/* The effect of R_ARM_TARGET2 relocations is platform-specific. A
   1.276 + * routine is required for handling references created via such
   1.277 + * relocations.  The routine takes the address of a location that was
   1.278 + * relocated by R_ARM_TARGET2, and returns a pointer to the absolute
   1.279 + * address of the referenced entity.
   1.280 + */
   1.281 +
   1.282 +static FORCEINLINE void *__ARM_resolve_target2(void *p)
   1.283 +{
   1.284 +#ifdef __APCS_FPIC
   1.285 +  /* SVr4: R_ARM_TARGET2 is equivalent to R_ARM_GOT_PREL (placerel32 indirect) */
   1.286 +  return *(void **)(*(uint32_t *)p + (uint32_t)p);
   1.287 +#else
   1.288 +  /* Bare metal: R_ARM_TARGET2 is equivalent to R_ARM_ABS32 */
   1.289 +  return *(void **)p;
   1.290 +#endif
   1.291 +}
   1.292 +
   1.293 +/* ---------------------------------------------------------------------- */
   1.294 +
   1.295 +/* Runtime debug support
   1.296 + *
   1.297 + * Here we define the interface to a "bottleneck function" to be called
   1.298 + * by exception handling code at 'interesting' points during execution,
   1.299 + * and breakpointable by a debugger.
   1.300 + *
   1.301 + * This is not part of the Exceptions ABI but is expected to be
   1.302 + * standardised elsewhere, probably in a Debug ABI.
   1.303 + *
   1.304 + * If you don't want this, define DEBUGGER_BOTTLENECK as a dummy, e.g.
   1.305 + * #define DEBUGGER_BOTTLENECK(UCBP,LANG,ACTIVITY,ARG) (void)0
   1.306 + */
   1.307 +
   1.308 +#ifdef __cplusplus
   1.309 +extern "C" {
   1.310 +#endif
   1.311 +
   1.312 +  struct _Unwind_Control_Block;
   1.313 +
   1.314 +  typedef enum {
   1.315 +    _UASUBSYS_CPP      = 0x00,
   1.316 +    _UASUBSYS_UNWINDER = 0xff
   1.317 +  } _Unwind_Activity_subsystem;
   1.318 +
   1.319 +  typedef enum {
   1.320 +    _UAACT_STARTING     = 0x0,
   1.321 +    _UAACT_ENDING       = 0x1,
   1.322 +    _UAACT_BARRIERFOUND = 0x2,
   1.323 +    _UAACT_PADENTRY     = 0x3,
   1.324 +    _UAACT_CPP_TYPEINFO = 0x80
   1.325 +  } _Unwind_Activity_activity;
   1.326 +
   1.327 +  typedef enum {
   1.328 +    _UAARG_ENDING_UNSPECIFIED           = 0x0,
   1.329 +    _UAARG_ENDING_TABLECORRUPT          = 0x1,
   1.330 +    _UAARG_ENDING_NOUNWIND              = 0x2,
   1.331 +    _UAARG_ENDING_VRSFAILED             = 0x3,
   1.332 +    /* C++ only: */
   1.333 +    _UAARG_ENDING_CPP_BADOPCODE         = 0x4,
   1.334 +    /* Unwinder only: */
   1.335 +    _UAARG_ENDING_UNWINDER_LOOKUPFAILED = 0x4,
   1.336 +    _UAARG_ENDING_UNWINDER_BUFFERFAILED = 0x5
   1.337 +  } _Unwind_Activity_arg;
   1.338 +
   1.339 +  void _Unwind_Activity(struct _Unwind_Control_Block *ucbp, uint32_t reason, uint32_t arg);
   1.340 +#define DEBUGGER_BOTTLENECK(UCBP,LANG,ACTIVITY,ARG) \
   1.341 +  _Unwind_Activity((UCBP),((((uint32_t)(LANG))<<24)|ACTIVITY),(uint32_t)(ARG))
   1.342 +
   1.343 +#ifdef __cplusplus
   1.344 +}
   1.345 +#endif
   1.346 +
   1.347 +
   1.348 +/* ---------------------------------------------------------------------- */
   1.349 +
   1.350 +/* Printed diagnostics
   1.351 + *
   1.352 + * These may be useful for debugging purposes during development, provided
   1.353 + * the execution environment supports diagnostics via printf.
   1.354 + *
   1.355 + * #define PR_DIAGNOSTICS for printed diagnostics from the personality routine.
   1.356 + * #define VRS_DIAGNOSTICS for printed diagnostics about VRS operations.
   1.357 + * #define UNWIND_ACTIVITY_DIAGNOSTICS for printed information from _Unwind_Activity.
   1.358 + * #define CPP_DIAGNOSTICS for printed diagnostics from the C++ semantics routines.
   1.359 + */
   1.360 +
   1.361 +/* ---------------------------------------------------------------------- 
   1.362 + * Abstractions added for SymbianOS. A process is contructed from multiple
   1.363 + * executables each with their own RO segment and exception data structures. 
   1.364 + * SymbianOS caches pointers to two data structures in the UCB which it then 
   1.365 + * uses to speed up the retrieval of certain information including values returned
   1.366 + * by the functions below.
   1.367 + * ---------------------------------------------------------------------- */
   1.368 +#ifndef __EPOC32__
   1.369 +#define ADDR_TO_ER_RO_OFFSET(addr, ucbp) addr_to_ER_RO_offset(addr)
   1.370 +#define ER_RO_OFFSET_TO_ADDR(addr, ucbp)  ER_RO_offset_to_addr(addr)
   1.371 +#else
   1.372 +#define ADDR_TO_ER_RO_OFFSET(addr, ucbp) addr_to_ER_RO_offset(addr, ucbp)
   1.373 +#define ER_RO_OFFSET_TO_ADDR(addr, ucbp)  ER_RO_offset_to_addr(addr, ucbp)
   1.374 +#endif
   1.375 +
   1.376 +
   1.377 +#endif /* defined UNWINDENV_H */
   1.378 +
   1.379 +
   1.380 +
   1.381 +
   1.382 +
   1.383 +
   1.384 +
   1.385 +