uwx_env.h revision 115013
1115013Smarcel/*
2115013Smarcel * Copyright (c) 2002,2003 Hewlett-Packard Company
3115013Smarcel *
4115013Smarcel * Permission is hereby granted, free of charge, to any person obtaining a
5115013Smarcel * copy of this software and associated documentation files (the "Software"),
6115013Smarcel * to deal in the Software without restriction, including without limitation
7115013Smarcel * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8115013Smarcel * and/or sell copies of the Software, and to permit persons to whom the
9115013Smarcel * Software is furnished to do so, subject to the following conditions:
10115013Smarcel *
11115013Smarcel * The above copyright notice and this permission notice shall be included
12115013Smarcel * in all copies or substantial portions of the Software.
13115013Smarcel *
14115013Smarcel * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15115013Smarcel * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16115013Smarcel * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17115013Smarcel * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18115013Smarcel * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19115013Smarcel * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20115013Smarcel * DEALINGS IN THE SOFTWARE.
21115013Smarcel */
22115013Smarcel
23115013Smarcel#include "uwx.h"
24115013Smarcel
25115013Smarcel#define WORDSZ			4
26115013Smarcel#define DWORDSZ			8
27115013Smarcel#define BUNDLESZ		16
28115013Smarcel#define SLOTSPERBUNDLE		3
29115013Smarcel
30115013Smarcel#define UNWIND_TBL_32BIT	0x8000000000000000LL
31115013Smarcel
32115013Smarcel#define UNW_VER(x)		((x) >> 48)
33115013Smarcel#define UNW_FLAG_MASK		0x0000ffff00000000LL
34115013Smarcel#define UNW_FLAG_EHANDLER	0x0000000100000000LL
35115013Smarcel#define UNW_FLAG_UHANDLER	0x0000000200000000LL
36115013Smarcel#define UNW_LENGTH(x)		((x) & 0x00000000ffffffffLL)
37115013Smarcel
38115013Smarcelstruct uwx_scoreboard;
39115013Smarcel
40115013Smarcel#define NSCOREBOARDS	8	/* Initial allocation of scoreboards */
41115013Smarcel
42115013Smarcel#define NSPECIALREG	14
43115013Smarcel#define NPRESERVEDGR	4
44115013Smarcel#define NPRESERVEDBR	5
45115013Smarcel#define NPRESERVEDFR	20
46115013Smarcel
47115013Smarcelstruct uwx_fpreg {
48115013Smarcel    uint64_t part0;
49115013Smarcel    uint64_t part1;
50115013Smarcel};
51115013Smarcel
52115013Smarcelstruct uwx_context {
53115013Smarcel    unsigned int valid_regs;
54115013Smarcel    unsigned int valid_frs;
55115013Smarcel    uint64_t special[NSPECIALREG];
56115013Smarcel    uint64_t gr[NPRESERVEDGR];
57115013Smarcel    uint64_t br[NPRESERVEDBR];
58115013Smarcel    struct uwx_fpreg fr[NPRESERVEDFR];
59115013Smarcel};
60115013Smarcel
61115013Smarcel#define VALID_GR_SHIFT	NSPECIALREG
62115013Smarcel#define VALID_BR_SHIFT	(NSPECIALREG + NPRESERVEDGR)
63115013Smarcel
64115013Smarcel#define VALID_BASIC4	0x0f	/* IP, SP, BSP, PFS */
65115013Smarcel
66115013Smarcelstruct uwx_history {
67115013Smarcel    uint64_t special[NSPECIALREG];
68115013Smarcel    uint64_t gr[NPRESERVEDGR];
69115013Smarcel    uint64_t br[NPRESERVEDBR];
70115013Smarcel    uint64_t fr[NPRESERVEDFR];
71115013Smarcel};
72115013Smarcel
73115013Smarcelstruct uwx_str_pool;
74115013Smarcel
75115013Smarcelstruct uwx_env {
76115013Smarcel    struct uwx_context context;
77115013Smarcel    uint64_t *rstate;
78115013Smarcel    int64_t function_offset;
79115013Smarcel    struct uwx_history history;
80115013Smarcel    alloc_cb allocate_cb;
81115013Smarcel    free_cb free_cb;
82115013Smarcel    struct uwx_scoreboard *free_scoreboards;
83115013Smarcel    struct uwx_scoreboard *used_scoreboards;
84115013Smarcel    struct uwx_scoreboard *labeled_scoreboards;
85115013Smarcel    struct uwx_str_pool *string_pool;
86115013Smarcel    char *module_name;
87115013Smarcel    char *function_name;
88115013Smarcel    intptr_t cb_token;
89115013Smarcel    copyin_cb copyin;
90115013Smarcel    lookupip_cb lookupip;
91115013Smarcel    int remote;
92115013Smarcel    int byte_swap;
93115013Smarcel    int abi_context;
94115013Smarcel    int nsbreg;
95115013Smarcel    int nscoreboards;
96115013Smarcel    int trace;
97115013Smarcel};
98115013Smarcel
99115013Smarcelextern alloc_cb uwx_allocate_cb;
100115013Smarcelextern free_cb uwx_free_cb;
101