2 Copyright (c) 2003 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
12 The above copyright notice and this permission notice shall be
13 included in all copies or substantial portions of the Software.
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.
30 #include "uwx_scoreboard.h"
32 #include "uwx_trace.h"
35 static struct uwx_env uwx_env;
36 #define free(p) /* nullified */
37 #define malloc(sz) ((sz == sizeof(uwx_env)) ? &uwx_env : NULL)
40 alloc_cb uwx_allocate_cb = 0;
41 free_cb uwx_free_cb = 0;
43 int uwx_register_alloc_cb(alloc_cb alloc, free_cb free)
45 uwx_allocate_cb = alloc;
50 int uwx_init_history(struct uwx_env *env)
57 for (i = 0; i < NSPECIALREG; i++)
58 env->history.special[i] = UWX_DISP_REG(i);;
59 for (i = 0; i < NPRESERVEDGR; i++)
60 env->history.gr[i] = UWX_DISP_REG(UWX_REG_GR(4+i));
61 for (i = 0; i < NPRESERVEDBR; i++)
62 env->history.br[i] = UWX_DISP_REG(UWX_REG_BR(1+i));
63 for (i = 0; i < 4; i++)
64 env->history.fr[i] = UWX_DISP_REG(UWX_REG_FR(2+i));
65 for ( ; i < NPRESERVEDFR; i++)
66 env->history.fr[i] = UWX_DISP_REG(UWX_REG_FR(12+i));
71 struct uwx_env *uwx_init()
76 if (uwx_allocate_cb == 0)
77 env = (struct uwx_env *) malloc(sizeof(struct uwx_env));
79 env = (struct uwx_env *) (*uwx_allocate_cb)(sizeof(struct uwx_env));
81 env->context.valid_regs = 0;
82 env->context.valid_frs = 0;
83 for (i = 0; i < NSPECIALREG; i++)
84 env->context.special[i] = 0;
85 for (i = 0; i < NPRESERVEDGR; i++)
86 env->context.gr[i] = 0;
87 for (i = 0; i < NPRESERVEDBR; i++)
88 env->context.br[i] = 0;
89 for (i = 0; i < NPRESERVEDFR; i++) {
90 env->context.fr[i].part0 = 0;
91 env->context.fr[i].part1 = 0;
95 env->function_offset = 0;
96 (void)uwx_init_history(env);
97 env->allocate_cb = uwx_allocate_cb;
98 env->free_cb = uwx_free_cb;
99 env->free_scoreboards = 0;
100 env->used_scoreboards = 0;
101 env->labeled_scoreboards = 0;
102 (void)uwx_init_str_pool(env);
103 env->module_name = 0;
104 env->function_name = 0;
110 env->abi_context = 0;
111 env->nsbreg = NSBREG_NOFR;
112 env->nscoreboards = 0;
115 for (i = 0; i < NSCOREBOARDS; i++)
116 (void) uwx_alloc_scoreboard(env);
121 int uwx_set_remote(struct uwx_env *env, int is_big_endian_target)
123 int is_big_endian_host;
127 return UWX_ERR_NOENV;
131 is_big_endian_host = 1;
132 p = (char *)&is_big_endian_host;
134 if (is_big_endian_target == is_big_endian_host)
142 int uwx_register_callbacks(
146 lookupip_cb lookupip)
149 return UWX_ERR_NOENV;
151 env->copyin = copyin;
152 env->lookupip = lookupip;
156 int uwx_get_abi_context_code(struct uwx_env *env)
159 return UWX_ERR_NOENV;
160 return env->abi_context;
163 int uwx_free(struct uwx_env *env)
166 uwx_free_scoreboards(env);
167 uwx_free_str_pool(env);
168 if (env->free_cb == 0)
171 (*env->free_cb)((void *)env);