uwx_context.c (129059) | uwx_context.c (160157) |
---|---|
1/* | 1/* |
2Copyright (c) 2003 Hewlett-Packard Development Company, L.P. | 2Copyright (c) 2003-2006 Hewlett-Packard Development Company, L.P. |
3Permission is hereby granted, free of charge, to any person 4obtaining a copy of this software and associated documentation 5files (the "Software"), to deal in the Software without 6restriction, including without limitation the rights to use, 7copy, modify, merge, publish, distribute, sublicense, and/or sell 8copies of the Software, and to permit persons to whom the 9Software is furnished to do so, subject to the following 10conditions: --- 166 unchanged lines hidden (view full) --- 177 sor = (((int) env->context.special[UWX_REG_CFM] >> 14) & 0x0f) * 8; 178 rrb_gr = ((int) env->context.special[UWX_REG_CFM] >> 18) & 0x7f; 179 if (sor != 0 && rrb_gr != 0 && regid < sor) { 180 regid = (regid + rrb_gr) % sor; 181 } 182 bsp = uwx_add_to_bsp(bsp, regid); 183 natcollp = bsp | 0x01f8; 184 n = (*env->copyin)(UWX_COPYIN_RSTACK, (char *)&natcoll, | 3Permission is hereby granted, free of charge, to any person 4obtaining a copy of this software and associated documentation 5files (the "Software"), to deal in the Software without 6restriction, including without limitation the rights to use, 7copy, modify, merge, publish, distribute, sublicense, and/or sell 8copies of the Software, and to permit persons to whom the 9Software is furnished to do so, subject to the following 10conditions: --- 166 unchanged lines hidden (view full) --- 177 sor = (((int) env->context.special[UWX_REG_CFM] >> 14) & 0x0f) * 8; 178 rrb_gr = ((int) env->context.special[UWX_REG_CFM] >> 18) & 0x7f; 179 if (sor != 0 && rrb_gr != 0 && regid < sor) { 180 regid = (regid + rrb_gr) % sor; 181 } 182 bsp = uwx_add_to_bsp(bsp, regid); 183 natcollp = bsp | 0x01f8; 184 n = (*env->copyin)(UWX_COPYIN_RSTACK, (char *)&natcoll, |
185 bsp, DWORDSZ, env->cb_token); | 185 natcollp, DWORDSZ, env->cb_token); |
186 if (n != DWORDSZ) 187 return UWX_ERR_COPYIN_RSTK; 188 *natp = (int)(natcoll >> (((int)bsp >> 3) & 0x3f)) & 0x01; 189 } 190 else if (regid == UWX_REG_GR(0)) 191 *natp = 0; 192 else 193 status = UWX_ERR_BADREGID; 194 return status; 195} 196 197int uwx_get_spill_loc(struct uwx_env *env, int regid, uint64_t *dispp) 198{ 199 int status; 200 int sor; 201 int rrb_gr; 202 uint64_t bsp; | 186 if (n != DWORDSZ) 187 return UWX_ERR_COPYIN_RSTK; 188 *natp = (int)(natcoll >> (((int)bsp >> 3) & 0x3f)) & 0x01; 189 } 190 else if (regid == UWX_REG_GR(0)) 191 *natp = 0; 192 else 193 status = UWX_ERR_BADREGID; 194 return status; 195} 196 197int uwx_get_spill_loc(struct uwx_env *env, int regid, uint64_t *dispp) 198{ 199 int status; 200 int sor; 201 int rrb_gr; 202 uint64_t bsp; |
203 int n; |
|
203 204 if (env == 0) 205 return UWX_ERR_NOENV; 206 207 status = UWX_OK; 208 209 if (regid == UWX_REG_GR(12)) 210 regid = UWX_REG_SP; | 204 205 if (env == 0) 206 return UWX_ERR_NOENV; 207 208 status = UWX_OK; 209 210 if (regid == UWX_REG_GR(12)) 211 regid = UWX_REG_SP; |
211 if (regid < NSPECIALREG) | 212 if (regid < NSPECIALREG) { 213 if (regid == UWX_REG_PSP || regid == UWX_REG_RP || 214 regid == UWX_REG_PFS) { 215 if (!(env->context.valid_regs & (1 << regid))) { 216 status = uwx_restore_markers(env); 217 if (status != UWX_OK) 218 return status; 219 } 220 } |
212 *dispp = env->history.special[regid]; | 221 *dispp = env->history.special[regid]; |
222 } |
|
213 else if (regid >= UWX_REG_GR(4) && regid <= UWX_REG_GR(7)) 214 *dispp = env->history.gr[regid - UWX_REG_GR(4)]; 215 else if (regid >= UWX_REG_GR(32) && regid <= UWX_REG_GR(127)) { 216 bsp = env->context.special[UWX_REG_BSP]; 217 regid -= UWX_REG_GR(32); 218 sor = (((int) env->context.special[UWX_REG_CFM] >> 14) & 0x0f) * 8; 219 rrb_gr = ((int) env->context.special[UWX_REG_CFM] >> 18) & 0x7f; 220 if (sor != 0 && rrb_gr != 0 && regid < sor) --- 47 unchanged lines hidden (view full) --- 268 } 269 else 270 status = UWX_ERR_BADREGID; 271 return status; 272} 273 274int uwx_set_fr(struct uwx_env *env, int regid, uint64_t *val) 275{ | 223 else if (regid >= UWX_REG_GR(4) && regid <= UWX_REG_GR(7)) 224 *dispp = env->history.gr[regid - UWX_REG_GR(4)]; 225 else if (regid >= UWX_REG_GR(32) && regid <= UWX_REG_GR(127)) { 226 bsp = env->context.special[UWX_REG_BSP]; 227 regid -= UWX_REG_GR(32); 228 sor = (((int) env->context.special[UWX_REG_CFM] >> 14) & 0x0f) * 8; 229 rrb_gr = ((int) env->context.special[UWX_REG_CFM] >> 18) & 0x7f; 230 if (sor != 0 && rrb_gr != 0 && regid < sor) --- 47 unchanged lines hidden (view full) --- 278 } 279 else 280 status = UWX_ERR_BADREGID; 281 return status; 282} 283 284int uwx_set_fr(struct uwx_env *env, int regid, uint64_t *val) 285{ |
286 int status; |
|
276 277 if (regid >= UWX_REG_FR(2) && regid <= UWX_REG_FR(5)) 278 regid -= UWX_REG_FR(2); 279 else if (regid >= UWX_REG_FR(16) && regid <= UWX_REG_FR(31)) 280 regid -= UWX_REG_FR(16) - 4; 281 else 282 return UWX_ERR_BADREGID; 283 --- 24 unchanged lines hidden (view full) --- 308 * +---------------------------------------------------------------+ 309 * | X X| 310 * +---------------------------------------------------------------+ 311 * <-------- bias --------> 312 * <--- nslots ---> 313 * ^ 314 * | 315 * bsp | 287 288 if (regid >= UWX_REG_FR(2) && regid <= UWX_REG_FR(5)) 289 regid -= UWX_REG_FR(2); 290 else if (regid >= UWX_REG_FR(16) && regid <= UWX_REG_FR(31)) 291 regid -= UWX_REG_FR(16) - 4; 292 else 293 return UWX_ERR_BADREGID; 294 --- 24 unchanged lines hidden (view full) --- 319 * +---------------------------------------------------------------+ 320 * | X X| 321 * +---------------------------------------------------------------+ 322 * <-------- bias --------> 323 * <--- nslots ---> 324 * ^ 325 * | 326 * bsp |
316 * <------- adjusted (nslots + bias) -------> | 327 * <------------ nslots + bias -----------> |
317 318 * When subtracting from bsp, we avoid depending on the sign of 319 * the quotient by adding 63*8 before division and subtracting 8 320 * after division. (Assumes that we will never be called upon 321 * to subtract more than 504 slots from bsp.) 322 * 323 * 0 1f8 3f8 324 * +---------------------------------------------------------------+ 325 * | X X| 326 * +---------------------------------------------------------------+ 327 * <-- bias --> | 328 329 * When subtracting from bsp, we avoid depending on the sign of 330 * the quotient by adding 63*8 before division and subtracting 8 331 * after division. (Assumes that we will never be called upon 332 * to subtract more than 504 slots from bsp.) 333 * 334 * 0 1f8 3f8 335 * +---------------------------------------------------------------+ 336 * | X X| 337 * +---------------------------------------------------------------+ 338 * <-- bias --> |
328 * <--- |nslots| ---> | 339 * <--- (-nslots) ---> |
329 * ^ 330 * | 331 * bsp 332 * <-----------------> | 340 * ^ 341 * | 342 * bsp 343 * <-----------------> |
333 * adjusted |nslots + bias| | 344 * -(nslots + bias) |
334 */ 335 336 bias = ((unsigned int)bsp & 0x1f8) / DWORDSZ; 337 nslots += (nslots + bias + 63*8) / 63 - 8; 338 return bsp + nslots * DWORDSZ; 339} 340 | 345 */ 346 347 bias = ((unsigned int)bsp & 0x1f8) / DWORDSZ; 348 nslots += (nslots + bias + 63*8) / 63 - 8; 349 return bsp + nslots * DWORDSZ; 350} 351 |
341#if 0 | |
342int uwx_selftest_bsp_arithmetic() 343{ 344 int i; 345 int j; 346 int r; 347 uint64_t bstore[161]; 348 uint64_t *bsp; 349 uint64_t *p; --- 11 unchanged lines hidden (view full) --- 361 362 printf("uwx_selftest_bsp_arithmetic: plus tests...\n"); 363 bsp = bstore; 364 for (i = 0; i < 64; i++) { 365 r = (int)*bsp; 366 if (r >= 1000) 367 r -= 1000; 368 for (j = 0; j < 96; j++) { | 352int uwx_selftest_bsp_arithmetic() 353{ 354 int i; 355 int j; 356 int r; 357 uint64_t bstore[161]; 358 uint64_t *bsp; 359 uint64_t *p; --- 11 unchanged lines hidden (view full) --- 371 372 printf("uwx_selftest_bsp_arithmetic: plus tests...\n"); 373 bsp = bstore; 374 for (i = 0; i < 64; i++) { 375 r = (int)*bsp; 376 if (r >= 1000) 377 r -= 1000; 378 for (j = 0; j < 96; j++) { |
369 p = (uint64_t *)uwx_add_to_bsp((uint64_t)bsp, j); | 379 p = (uint64_t *)(intptr_t)uwx_add_to_bsp((uint64_t)bsp, j); |
370 if (*p != (r + j)) { 371 failed++; 372 printf("%d [%08lx] + %d -> %08lx ", 373 i, (unsigned int)bsp, j, (unsigned int)p); 374 printf("(read %d instead of %d)\n", (int)*p, r + j); 375 } 376 } 377 bsp++; 378 } 379 380 printf("uwx_selftest_bsp_arithmetic: minus tests...\n"); 381 bsp = &bstore[161]; 382 for (i = 63; i >= 0; i--) { 383 bsp--; 384 r = (int)*bsp; 385 if (r >= 1000) 386 r -= 1000; 387 for (j = 0; j < 96; j++) { | 380 if (*p != (r + j)) { 381 failed++; 382 printf("%d [%08lx] + %d -> %08lx ", 383 i, (unsigned int)bsp, j, (unsigned int)p); 384 printf("(read %d instead of %d)\n", (int)*p, r + j); 385 } 386 } 387 bsp++; 388 } 389 390 printf("uwx_selftest_bsp_arithmetic: minus tests...\n"); 391 bsp = &bstore[161]; 392 for (i = 63; i >= 0; i--) { 393 bsp--; 394 r = (int)*bsp; 395 if (r >= 1000) 396 r -= 1000; 397 for (j = 0; j < 96; j++) { |
388 p = (uint64_t *)uwx_add_to_bsp((uint64_t)bsp, -j); | 398 p = (uint64_t *)(intptr_t)uwx_add_to_bsp((uint64_t)bsp, -j); |
389 if (*p != (r - j)) { 390 failed++; 391 printf("%d [%08lx] - %d -> %08lx ", 392 i, (unsigned int)bsp, j, (unsigned int)p); 393 printf("(read %d instead of %d)\n", (int)*p, r - j); 394 } 395 } 396 } 397 398 return failed; 399} | 399 if (*p != (r - j)) { 400 failed++; 401 printf("%d [%08lx] - %d -> %08lx ", 402 i, (unsigned int)bsp, j, (unsigned int)p); 403 printf("(read %d instead of %d)\n", (int)*p, r - j); 404 } 405 } 406 } 407 408 return failed; 409} |
400#endif | |