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