os/kernelhwsrv/kernel/eka/compsupp/aehabi/unwind_env.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/* unwind_env.h
sl@0
     2
 *
sl@0
     3
 * Copyright 2003 ARM Limited.
sl@0
     4
 */
sl@0
     5
/*
sl@0
     6
  Licence
sl@0
     7
  
sl@0
     8
  1. Subject to the provisions of clause 2, ARM hereby grants to LICENSEE a 
sl@0
     9
  perpetual, non-exclusive, nontransferable, royalty free, worldwide licence 
sl@0
    10
  to use this Example Implementation of Exception Handling solely for the 
sl@0
    11
  purpose of developing, having developed, manufacturing, having 
sl@0
    12
  manufactured, offering to sell, selling, supplying or otherwise 
sl@0
    13
  distributing products which comply with the Exception Handling ABI for the 
sl@0
    14
  ARM Architecture specification. All other rights are reserved to ARM or its 
sl@0
    15
  licensors.
sl@0
    16
  
sl@0
    17
  2. THIS EXAMPLE IMPLEMENTATION OF EXCEPTION HANDLING  IS PROVIDED "AS IS" 
sl@0
    18
  WITH NO WARRANTIES EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED 
sl@0
    19
  TO ANY WARRANTY OF SATISFACTORY QUALITY, MERCHANTABILITY, NONINFRINGEMENT 
sl@0
    20
  OR FITNESS FOR A PARTICULAR PURPOSE.
sl@0
    21
*/
sl@0
    22
/*
sl@0
    23
 * RCS $Revision: 1.3 $
sl@0
    24
 * Checkin $Date: 2003/10/23 13:57:32 $
sl@0
    25
 * Revising $Author: agrant $
sl@0
    26
 */
sl@0
    27
sl@0
    28
/* Environment definition - abstractions and requirements - to aid
sl@0
    29
 * portability of the ARM exceptions code.
sl@0
    30
 */
sl@0
    31
sl@0
    32
#ifndef UNWINDENV_H
sl@0
    33
#define UNWINDENV_H
sl@0
    34
sl@0
    35
/* ---------------------------------------------------------------------- */
sl@0
    36
sl@0
    37
/* Source language
sl@0
    38
 *
sl@0
    39
 * The compiler is expected to define preprocessor symbols as follows:
sl@0
    40
 * __cplusplus when compiling in C++ mode.
sl@0
    41
 * __thumb when compiling to Thumb code.
sl@0
    42
 *
sl@0
    43
 * Some use is made of embedded assembly language, introduced by __asm.
sl@0
    44
 * This is described in ARM's toolchain documentation. Some edits may be
sl@0
    45
 * required for other compilers. The compiler should define one or more of:
sl@0
    46
 * __TARGET_ARCH_4T __TARGET_ARCH_4TXM __TARGET_ARCH_5T __TARGET_ARCH_5TXM
sl@0
    47
 * __TARGET_ARCH_5TE __TARGET_ARCH_6
sl@0
    48
 * so the correct assembly wrappers are generated for certain functions.
sl@0
    49
 *
sl@0
    50
 * __APCS_INTERWORK should be defined if ARM/Thumb interworking is required.
sl@0
    51
 *
sl@0
    52
 * For all the above symbols, if your compiler does not provide appropriate
sl@0
    53
 * definitions, add them here.
sl@0
    54
 *
sl@0
    55
 * Some source language extensions are also used.
sl@0
    56
 */
sl@0
    57
sl@0
    58
/* ---------------------------------------------------------------------- */
sl@0
    59
sl@0
    60
/* Library structure
sl@0
    61
 *
sl@0
    62
 * ARM's private make system contains an automated facility for compiling
sl@0
    63
 * source files multiple times to create multiple object files. The source
sl@0
    64
 * regions intended to constitute object file xxx.o are delimited by
sl@0
    65
 * #ifdef xxx_c / #endif directives. The exact preprocessor symbols used
sl@0
    66
 * for this conditionalisation are described in a comment at the start of
sl@0
    67
 * each file. When porting to a different system, compilations must be
sl@0
    68
 * performed with these preprocessor symbols appropriately defined
sl@0
    69
 * (or remove the conditionalisation).
sl@0
    70
 *
sl@0
    71
 * ARM declares (or redeclares) some routines as weak in order that
sl@0
    72
 * references to them are weak, so that the static linker will not load
sl@0
    73
 * unwanted code. This is achieved by decorating routine declarations
sl@0
    74
 * with appropriate language extensions. Note that compilers supporting
sl@0
    75
 * similar features but via a different syntax may require edits to
sl@0
    76
 * the library source.
sl@0
    77
 *
sl@0
    78
 * Define those decorations here (define as empty if not required):
sl@0
    79
 */
sl@0
    80
sl@0
    81
#define WEAKDECL __weak        /* token in C and C++ */
sl@0
    82
#define WEAKASMDECL [WEAK]     /* token in assembler */
sl@0
    83
sl@0
    84
/* ---------------------------------------------------------------------- */
sl@0
    85
sl@0
    86
/* Source language support and language extensions */
sl@0
    87
sl@0
    88
/* It is possible to compile the C++ semantics code using a compiler
sl@0
    89
 * which does not support C++ exceptions; this was useful to ARM whilst
sl@0
    90
 * ARM's compiler was being developed, and the facility has not been
sl@0
    91
 * removed. C++ exceptions syntax is conditionalised by
sl@0
    92
 * #ifdef ARM_EXCEPTIONS_ENABLED / #endif. Define ARM_EXCEPTIONS_ENABLED
sl@0
    93
 * by some means here if you want a usable library:
sl@0
    94
 */
sl@0
    95
sl@0
    96
#ifdef __cplusplus
sl@0
    97
extern "C" {
sl@0
    98
  /* For conditionalisation, specifically on ARM_EXCEPTIONS_ENABLED */
sl@0
    99
#include "basics.h"
sl@0
   100
}
sl@0
   101
#endif
sl@0
   102
sl@0
   103
/* The following definitions of syntax decoration may be empty if the
sl@0
   104
 * facility is not required. Note that compilers supporting similar
sl@0
   105
 * features but via a different syntax may require edits to the library
sl@0
   106
 * source.
sl@0
   107
 * 
sl@0
   108
 * Define the decorations here (define as empty if not required):
sl@0
   109
 */
sl@0
   110
  
sl@0
   111
/* If the compiler understands noreturn functions: */
sl@0
   112
#define NORETURNDECL __declspec(noreturn)
sl@0
   113
sl@0
   114
/* ---------------------------------------------------------------------- */
sl@0
   115
sl@0
   116
/* Types */
sl@0
   117
sl@0
   118
/* The implementation requires types uint8_t, uint16_t, uint32_t and
sl@0
   119
 * uint64_t to be defined as unsigned integers of the appropriate number
sl@0
   120
 * of bits.
sl@0
   121
 *
sl@0
   122
 * Do that here:
sl@0
   123
 */
sl@0
   124
sl@0
   125
#include <stdint.h>
sl@0
   126
sl@0
   127
/* The C++ semantics support requires definition of the RTTI object
sl@0
   128
 * layout. We use the same structures and names as the generic C++
sl@0
   129
 * ABI for Itanium.
sl@0
   130
 *
sl@0
   131
 * Define those structures here:
sl@0
   132
 */
sl@0
   133
sl@0
   134
#ifdef __cplusplus
sl@0
   135
extern "C" {
sl@0
   136
#include "cxxabi.h"
sl@0
   137
}
sl@0
   138
#endif
sl@0
   139
sl@0
   140
/* ---------------------------------------------------------------------- */
sl@0
   141
sl@0
   142
/* External requirements */
sl@0
   143
sl@0
   144
/* The C++ exception-handling 'globals' should be allocated per-thread.
sl@0
   145
 * The Exceptions ABI does not specify how this happens, but it is
sl@0
   146
 * intended that the details are localised to __cxa_get_globals.
sl@0
   147
 *
sl@0
   148
 * In the ARM implementation of __cxa_get_globals, it is assumed that a
sl@0
   149
 * zero-initialised location in a known per-thread place is somehow
sl@0
   150
 * obtainable, and can be assigned (by __cxa_get_globals) a pointer to
sl@0
   151
 * the allocated globals data structure. The macro EH_GLOBALS should be
sl@0
   152
 * defined here to yield a suitable address of type void*. This is used
sl@0
   153
 * only in __cxa_get_globals.
sl@0
   154
 *
sl@0
   155
 * Define it here:
sl@0
   156
 */
sl@0
   157
sl@0
   158
#ifdef __cplusplus
sl@0
   159
extern "C" {
sl@0
   160
  /* for __user_libspace() machinery */
sl@0
   161
#include <interns.h>
sl@0
   162
#define EH_GLOBALS libspace.eh_globals
sl@0
   163
}
sl@0
   164
#endif
sl@0
   165
sl@0
   166
sl@0
   167
/* A routine is required for C++ derived class to base class conversion.
sl@0
   168
 * This is used once, in __cxa_type_match. It is likely that suitable
sl@0
   169
 * code exists as part of the RTTI support code. Therefore access it
sl@0
   170
 * via a macro:
sl@0
   171
 * DERIVED_TO_BASE_CONVERSION(PTR, P_NEW_PTR, CLASS_INFO, BASE_INFO)
sl@0
   172
 *   Convert PTR from a pointer to a derived class (described by
sl@0
   173
 *   CLASS_INFO) to a pointer to a base class (described by BASE_INFO)
sl@0
   174
 *   and store the resulting pointer in P_NEW_PTR. Return true (or
sl@0
   175
 *   non-zero) if the base class was found and the conversion was done,
sl@0
   176
 *   otherwise return false (or zero).
sl@0
   177
 *
sl@0
   178
 * Define the macro here:
sl@0
   179
 */
sl@0
   180
sl@0
   181
#ifdef __cplusplus
sl@0
   182
/* In the ARM implementation, a suitable routine exists elsewhere in the
sl@0
   183
 * C++ runtime library, where it is part of the dynamic_cast mechanism.
sl@0
   184
 */
sl@0
   185
extern "C" int __derived_to_base_conversion(void** p_ptr, void** p_new_ptr,
sl@0
   186
                                            const std::type_info * class_info,
sl@0
   187
                                            const std::type_info * base_info,
sl@0
   188
                                            char** access_flags, int use_access_flags);
sl@0
   189
sl@0
   190
#define DERIVED_TO_BASE_CONVERSION(PTR, P_NEW_PTR, CLASS_INFO, BASE_INFO) \
sl@0
   191
  __derived_to_base_conversion(&(PTR), (P_NEW_PTR), (CLASS_INFO), (BASE_INFO), NULL, 0)
sl@0
   192
#endif
sl@0
   193
sl@0
   194
sl@0
   195
/* ---------------------------------------------------------------------- */
sl@0
   196
sl@0
   197
/* Runtime debug support
sl@0
   198
 *
sl@0
   199
 * Here we define the interface to a "bottleneck function" to be called
sl@0
   200
 * by exception handling code at 'interesting' points during execution,
sl@0
   201
 * and breakpointable by a debugger.
sl@0
   202
 *
sl@0
   203
 * This is not part of the Exceptions ABI but is expected to be
sl@0
   204
 * standardised elsewhere, probably in a Debug ABI.
sl@0
   205
 *
sl@0
   206
 * If you don't want this, define DEBUGGER_BOTTLENECK as a dummy, e.g.
sl@0
   207
 * #define DEBUGGER_BOTTLENECK(UCBP,LANG,ACTIVITY,ARG) (void)0
sl@0
   208
 */
sl@0
   209
sl@0
   210
#ifdef __cplusplus
sl@0
   211
extern "C" {
sl@0
   212
#endif
sl@0
   213
sl@0
   214
  struct _Unwind_Control_Block;
sl@0
   215
sl@0
   216
  typedef enum {
sl@0
   217
    _UASUBSYS_CPP      = 0x00,
sl@0
   218
    _UASUBSYS_UNWINDER = 0xff
sl@0
   219
  } _Unwind_Activity_subsystem;
sl@0
   220
sl@0
   221
  typedef enum {
sl@0
   222
    _UAACT_STARTING     = 0x0,
sl@0
   223
    _UAACT_ENDING       = 0x1,
sl@0
   224
    _UAACT_BARRIERFOUND = 0x2,
sl@0
   225
    _UAACT_PADENTRY     = 0x3,
sl@0
   226
    _UAACT_CPP_TYPEINFO = 0x80
sl@0
   227
  } _Unwind_Activity_activity;
sl@0
   228
sl@0
   229
  typedef enum {
sl@0
   230
    _UAARG_ENDING_UNSPECIFIED           = 0x0,
sl@0
   231
    _UAARG_ENDING_TABLECORRUPT          = 0x1,
sl@0
   232
    _UAARG_ENDING_NOUNWIND              = 0x2,
sl@0
   233
    _UAARG_ENDING_VRSFAILED             = 0x3,
sl@0
   234
    /* C++ only: */
sl@0
   235
    _UAARG_ENDING_CPP_BADOPCODE         = 0x4,
sl@0
   236
    /* Unwinder only: */
sl@0
   237
    _UAARG_ENDING_UNWINDER_LOOKUPFAILED = 0x4,
sl@0
   238
    _UAARG_ENDING_UNWINDER_BUFFERFAILED = 0x5
sl@0
   239
  } _Unwind_Activity_arg;
sl@0
   240
sl@0
   241
  void _Unwind_Activity(struct _Unwind_Control_Block *ucbp, uint32_t reason, uint32_t arg);
sl@0
   242
#define DEBUGGER_BOTTLENECK(UCBP,LANG,ACTIVITY,ARG) \
sl@0
   243
  _Unwind_Activity((UCBP),(((LANG)<<24)|ACTIVITY),(uint32_t)(ARG))
sl@0
   244
sl@0
   245
#ifdef __cplusplus
sl@0
   246
}
sl@0
   247
#endif
sl@0
   248
sl@0
   249
sl@0
   250
/* ---------------------------------------------------------------------- */
sl@0
   251
sl@0
   252
/* Printed diagnostics
sl@0
   253
 *
sl@0
   254
 * These may be useful for debugging purposes during development, provided
sl@0
   255
 * the execution environment supports diagnostics via printf.
sl@0
   256
 *
sl@0
   257
 * #define PR_DIAGNOSTICS for printed diagnostics from the personality routine.
sl@0
   258
 * #define VRS_DIAGNOSTICS for printed diagnostics about VRS operations.
sl@0
   259
 * #define UNWIND_ACTIVITY_DIAGNOSTICS for printed information from _Unwind_Activity.
sl@0
   260
 */
sl@0
   261
sl@0
   262
/* ---------------------------------------------------------------------- */
sl@0
   263
sl@0
   264
#endif /* defined UNWINDENV_H */