]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/contrib/ia64/libuwx/src/uwx_env.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / sys / contrib / ia64 / libuwx / src / uwx_env.h
1 /*
2 Copyright (c) 2003-2006 Hewlett-Packard Development Company, L.P.
3 Permission is hereby granted, free of charge, to any person
4 obtaining a copy of this software and associated documentation
5 files (the "Software"), to deal in the Software without
6 restriction, including without limitation the rights to use,
7 copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the
9 Software is furnished to do so, subject to the following
10 conditions:
11
12 The above copyright notice and this permission notice shall be
13 included in all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 #include "uwx.h"
26
27 #define WORDSZ                  4
28 #define DWORDSZ                 8
29 #define BUNDLESZ                16
30 #define SLOTSPERBUNDLE          3
31
32 #define UNWIND_TBL_32BIT        0x8000000000000000LL
33
34 #define UNW_VER(x)              ((x) >> 48)
35 #define UNW_FLAG_MASK           0x0000ffff00000000LL
36 #define UNW_FLAG_EHANDLER       0x0000000100000000LL
37 #define UNW_FLAG_UHANDLER       0x0000000200000000LL
38 #define UNW_LENGTH(x)           ((x) & 0x00000000ffffffffLL)
39
40 struct uwx_scoreboard;
41
42 #define NSCOREBOARDS    8       /* Initial allocation of scoreboards */
43
44 #define NSPECIALREG     16      /* Must be even, so FRs are aligned */
45 #define NPRESERVEDGR    4
46 #define NPRESERVEDBR    5
47 #define NPRESERVEDFR    20
48
49 struct uwx_fpreg {
50     uint64_t part0;
51     uint64_t part1;
52 };
53
54 struct uwx_context {
55     unsigned int valid_regs;
56     unsigned int valid_frs;
57     uint64_t special[NSPECIALREG];
58     uint64_t gr[NPRESERVEDGR];
59     uint64_t br[NPRESERVEDBR];
60     struct uwx_fpreg fr[NPRESERVEDFR];
61 };
62
63 #define VALID_GR_SHIFT  NSPECIALREG
64 #define VALID_BR_SHIFT  (NSPECIALREG + NPRESERVEDGR)
65
66 #define VALID_BASIC4    0x0f    /* IP, SP, BSP, CFM */
67 #define VALID_MARKERS   0x70    /* RP, PSP, PFS */
68
69 struct uwx_history {
70     uint64_t special[NSPECIALREG];
71     uint64_t gr[NPRESERVEDGR];
72     uint64_t br[NPRESERVEDBR];
73     uint64_t fr[NPRESERVEDFR];
74 };
75
76 struct uwx_str_pool;
77
78 struct uwx_env {
79     struct uwx_context context;
80     uint64_t *rstate;
81     uint64_t remapped_ip;
82     int64_t function_offset;
83     uint64_t ptr_size;
84     uint64_t uinfo_hdr;
85     uint64_t uinfo_end;
86     uint64_t code_start;
87     uint64_t text_base;
88     struct uwx_history history;
89     alloc_cb allocate_cb;
90     free_cb free_cb;
91     struct uwx_scoreboard *free_scoreboards;
92     struct uwx_scoreboard *used_scoreboards;
93     struct uwx_scoreboard *labeled_scoreboards;
94     struct uwx_str_pool *string_pool;
95     char *module_name;
96     char *function_name;
97     intptr_t cb_token;
98     copyin_cb copyin;
99     lookupip_cb lookupip;
100     int remote;
101     int byte_swap;
102     int abi_context;
103     int nsbreg;
104     int nscoreboards;
105     int on_heap;
106     int trace;
107 };
108
109 extern alloc_cb uwx_allocate_cb;
110 extern free_cb uwx_free_cb;
111 extern int uwx_init_env(struct uwx_env *env, size_t total_size);