uwx_env.h revision 129059
148905Srnordier/*
248905SrnordierCopyright (c) 2003 Hewlett-Packard Development Company, L.P.
348905SrnordierPermission is hereby granted, free of charge, to any person
448905Srnordierobtaining a copy of this software and associated documentation
548905Srnordierfiles (the "Software"), to deal in the Software without
648905Srnordierrestriction, including without limitation the rights to use,
748905Srnordiercopy, modify, merge, publish, distribute, sublicense, and/or sell
848905Srnordiercopies of the Software, and to permit persons to whom the
948905SrnordierSoftware is furnished to do so, subject to the following
1048905Srnordierconditions:
1148905Srnordier
1248905SrnordierThe above copyright notice and this permission notice shall be
1348905Srnordierincluded in all copies or substantial portions of the Software.
1448905Srnordier
1548905SrnordierTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1648905SrnordierEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
1748905SrnordierOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1848905SrnordierNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
1948905SrnordierHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
2048905SrnordierWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2148905SrnordierFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2248905SrnordierOTHER DEALINGS IN THE SOFTWARE.
2348905Srnordier*/
2448905Srnordier
2548905Srnordier#include "uwx.h"
2648905Srnordier
2748905Srnordier#define WORDSZ			4
2848905Srnordier#define DWORDSZ			8
2950479Speter#define BUNDLESZ		16
3048905Srnordier#define SLOTSPERBUNDLE		3
3148905Srnordier
3248905Srnordier#define UNWIND_TBL_32BIT	0x8000000000000000LL
3348905Srnordier
3464214Skris#define UNW_VER(x)		((x) >> 48)
3548905Srnordier#define UNW_FLAG_MASK		0x0000ffff00000000LL
3648905Srnordier#define UNW_FLAG_EHANDLER	0x0000000100000000LL
3748905Srnordier#define UNW_FLAG_UHANDLER	0x0000000200000000LL
3848905Srnordier#define UNW_LENGTH(x)		((x) & 0x00000000ffffffffLL)
3948905Srnordier
4048905Srnordierstruct uwx_scoreboard;
4148905Srnordier
4248905Srnordier#define NSCOREBOARDS	8	/* Initial allocation of scoreboards */
4348905Srnordier
4448905Srnordier#define NSPECIALREG	16	/* Must be even, so FRs are aligned */
4548905Srnordier#define NPRESERVEDGR	4
4648905Srnordier#define NPRESERVEDBR	5
4748905Srnordier#define NPRESERVEDFR	20
4848905Srnordier
4948905Srnordierstruct uwx_fpreg {
5048905Srnordier    uint64_t part0;
5148905Srnordier    uint64_t part1;
5248905Srnordier};
5356128Skris
5448905Srnordierstruct uwx_context {
5548905Srnordier    unsigned int valid_regs;
5648905Srnordier    unsigned int valid_frs;
5748905Srnordier    uint64_t special[NSPECIALREG];
5848905Srnordier    uint64_t gr[NPRESERVEDGR];
5948905Srnordier    uint64_t br[NPRESERVEDBR];
6048905Srnordier    struct uwx_fpreg fr[NPRESERVEDFR];
6148905Srnordier};
6248905Srnordier
6348905Srnordier#define VALID_GR_SHIFT	NSPECIALREG
6448905Srnordier#define VALID_BR_SHIFT	(NSPECIALREG + NPRESERVEDGR)
6548905Srnordier
6648905Srnordier#define VALID_BASIC4	0x0f	/* IP, SP, BSP, CFM */
6748905Srnordier#define VALID_MARKERS	0x70	/* RP, PSP, PFS */
6864214Skris
6948905Srnordierstruct uwx_history {
7048905Srnordier    uint64_t special[NSPECIALREG];
7164214Skris    uint64_t gr[NPRESERVEDGR];
7264214Skris    uint64_t br[NPRESERVEDBR];
7364214Skris    uint64_t fr[NPRESERVEDFR];
7456128Skris};
7548905Srnordier
7648905Srnordierstruct uwx_str_pool;
7748905Srnordier
7848905Srnordierstruct uwx_env {
7948905Srnordier    struct uwx_context context;
8048905Srnordier    uint64_t *rstate;
8148905Srnordier    uint64_t remapped_ip;
8248905Srnordier    int64_t function_offset;
8348905Srnordier    struct uwx_history history;
8448905Srnordier    alloc_cb allocate_cb;
8548905Srnordier    free_cb free_cb;
8648905Srnordier    struct uwx_scoreboard *free_scoreboards;
8748905Srnordier    struct uwx_scoreboard *used_scoreboards;
8848905Srnordier    struct uwx_scoreboard *labeled_scoreboards;
8948905Srnordier    struct uwx_str_pool *string_pool;
9048905Srnordier    char *module_name;
9148905Srnordier    char *function_name;
9248905Srnordier    intptr_t cb_token;
9348905Srnordier    copyin_cb copyin;
9448905Srnordier    lookupip_cb lookupip;
9548905Srnordier    int remote;
9648905Srnordier    int byte_swap;
9748905Srnordier    int abi_context;
9848905Srnordier    int nsbreg;
9948905Srnordier    int nscoreboards;
10048905Srnordier    int trace;
10148905Srnordier};
10248905Srnordier
10348905Srnordierextern alloc_cb uwx_allocate_cb;
10448905Srnordierextern free_cb uwx_free_cb;
10548905Srnordier