--- trunk/src/cpus/cpu_alpha_instr_loadstore.c 2007/10/08 16:19:37 22 +++ trunk/src/cpus/cpu_alpha_instr_loadstore.c 2007/10/08 16:19:56 24 @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: cpu_alpha_instr_loadstore.c,v 1.3 2006/01/01 16:08:25 debug Exp $ + * $Id: cpu_alpha_instr_loadstore.c,v 1.4 2006/04/22 18:28:43 debug Exp $ * * Alpha load/store instructions. (Included from cpu_alpha_instr_inc.c.) * @@ -130,15 +130,34 @@ static void LS_N(struct cpu *cpu, struct alpha_instr_call *ic) { - int first, a, b, c; - uint64_t addr; - - addr = (*((uint64_t *)ic->arg[1])) + unsigned char *page; + uint64_t addr = (*((uint64_t *)ic->arg[1])) #ifndef LS_IGNORE_OFFSET + (int32_t)ic->arg[2] #endif ; + const uint32_t mask1 = (1 << DYNTRANS_L1N) - 1; + const uint32_t mask2 = (1 << DYNTRANS_L2N) - 1; + const uint32_t mask3 = (1 << DYNTRANS_L3N) - 1; + uint32_t x1, x2, x3, c; + struct DYNTRANS_L2_64_TABLE *l2; + struct DYNTRANS_L3_64_TABLE *l3; + x1 = (addr >> (64-DYNTRANS_L1N)) & mask1; + x2 = (addr >> (64-DYNTRANS_L1N-DYNTRANS_L2N)) & mask2; + x3 = (addr >> (64-DYNTRANS_L1N-DYNTRANS_L2N-DYNTRANS_L3N)) & mask3; + /* fatal("X3: addr=%016"PRIx64" x1=%x x2=%x x3=%x\n", + (uint64_t) addr, (int) x1, (int) x2, (int) x3); */ + l2 = cpu->cd.DYNTRANS_ARCH.l1_64[x1]; + /* fatal(" l2 = %p\n", l2); */ + l3 = l2->l3[x2]; + /* fatal(" l3 = %p\n", l3); */ +#ifdef LS_LOAD + page = l3->host_load[x3]; +#else + page = l3->host_store[x3]; +#endif + #ifdef LS_UNALIGNED addr &= ~7; #endif @@ -161,9 +180,6 @@ #endif #endif - first = addr >> ALPHA_TOPSHIFT; - a = (addr >> ALPHA_LEVEL0_SHIFT) & (ALPHA_LEVEL0 - 1); - b = (addr >> ALPHA_LEVEL1_SHIFT) & (ALPHA_LEVEL1 - 1); c = addr & 8191; #ifdef LS_ALIGN_CHECK @@ -186,196 +202,90 @@ #endif #endif - if (first == 0) { - struct alpha_vph_page *vph_p; - unsigned char *page; - vph_p = cpu->cd.alpha.vph_table0[a]; -#ifdef LS_LOAD - page = vph_p->host_load[b]; -#else - page = vph_p->host_store[b]; -#endif - if (page != NULL) { -#ifdef LS_LOAD -#ifdef HOST_BIG_ENDIAN - uint64_t data_x; - data_x = page[c]; -#ifndef LS_B - data_x += (page[c+1] << 8); -#ifndef LS_W - data_x += (page[c+2] << 16); - data_x += ((uint64_t)page[c+3] << 24); -#ifndef LS_L - data_x += ((uint64_t)page[c+4] << 32); - data_x += ((uint64_t)page[c+5] << 40); - data_x += ((uint64_t)page[c+6] << 48); - data_x += ((uint64_t)page[c+7] << 56); -#endif -#endif -#endif -#ifdef LS_L - *((uint64_t *)ic->arg[0]) = (int64_t)(int32_t)data_x; -#else - *((uint64_t *)ic->arg[0]) = data_x; -#endif -#else -#ifdef LS_B - *((uint64_t *)ic->arg[0]) = page[c]; -#endif -#ifdef LS_W - uint16_t d = *((uint16_t *) (page + c)); - *((uint64_t *)ic->arg[0]) = d; -#endif -#ifdef LS_L - int32_t d = *((int32_t *) (page + c)); - *((uint64_t *)ic->arg[0]) = (int64_t)d; -#endif -#ifdef LS_Q - uint64_t d = *((uint64_t *) (page + c)); - *((uint64_t *)ic->arg[0]) = d; -#endif -#endif -#else - /* Store: */ -#ifdef HOST_BIG_ENDIAN - uint64_t data_x = *((uint64_t *)ic->arg[0]); - page[c] = data_x; -#ifndef LS_B - page[c+1] = data_x >> 8; -#ifndef LS_W - page[c+2] = data_x >> 16; - page[c+3] = data_x >> 24; -#ifndef LS_L - page[c+4] = data_x >> 32; - page[c+5] = data_x >> 40; - page[c+6] = data_x >> 48; - page[c+7] = data_x >> 56; -#endif -#endif -#endif -#else - /* Native byte order: */ -#ifdef LS_B - page[c] = *((uint64_t *)ic->arg[0]); -#endif -#ifdef LS_W - uint32_t d = *((uint64_t *)ic->arg[0]); - *((uint16_t *) (page + c)) = d; -#endif -#ifdef LS_L - uint32_t d = *((uint64_t *)ic->arg[0]); - *((uint32_t *) (page + c)) = d; -#endif -#ifdef LS_Q - uint64_t d = *((uint64_t *)ic->arg[0]); - *((uint64_t *) (page + c)) = d; -#endif -#endif - -#ifdef LS_LLSC -#ifndef LS_LOAD - *((uint64_t *)ic->arg[0]) = 1; -#endif -#endif - -#endif /* !LS_LOAD */ - } else - LS_GENERIC_N(cpu, ic); - } else if (first == ALPHA_TOP_KERNEL) { - struct alpha_vph_page *vph_p; - unsigned char *page; - vph_p = cpu->cd.alpha.vph_table0_kernel[a]; -#ifdef LS_LOAD - page = vph_p->host_load[b]; -#else - page = vph_p->host_store[b]; -#endif - if (page != NULL) { + if (page != NULL) { #ifdef LS_LOAD #ifdef HOST_BIG_ENDIAN - uint64_t data_x; - data_x = page[c]; + uint64_t data_x; + data_x = page[c]; #ifndef LS_B - data_x += (page[c+1] << 8); + data_x += (page[c+1] << 8); #ifndef LS_W - data_x += (page[c+2] << 16); - data_x += ((uint64_t)page[c+3] << 24); + data_x += (page[c+2] << 16); + data_x += ((uint64_t)page[c+3] << 24); #ifndef LS_L - data_x += ((uint64_t)page[c+4] << 32); - data_x += ((uint64_t)page[c+5] << 40); - data_x += ((uint64_t)page[c+6] << 48); - data_x += ((uint64_t)page[c+7] << 56); + data_x += ((uint64_t)page[c+4] << 32); + data_x += ((uint64_t)page[c+5] << 40); + data_x += ((uint64_t)page[c+6] << 48); + data_x += ((uint64_t)page[c+7] << 56); #endif #endif #endif #ifdef LS_L - *((uint64_t *)ic->arg[0]) = (int64_t)(int32_t)data_x; + *((uint64_t *)ic->arg[0]) = (int64_t)(int32_t)data_x; #else - *((uint64_t *)ic->arg[0]) = data_x; + *((uint64_t *)ic->arg[0]) = data_x; #endif #else #ifdef LS_B - *((uint64_t *)ic->arg[0]) = page[c]; + *((uint64_t *)ic->arg[0]) = page[c]; #endif #ifdef LS_W - uint16_t d = *((uint16_t *) (page + c)); - *((uint64_t *)ic->arg[0]) = d; + uint16_t d = *((uint16_t *) (page + c)); + *((uint64_t *)ic->arg[0]) = d; #endif #ifdef LS_L - int32_t d = *((int32_t *) (page + c)); - *((uint64_t *)ic->arg[0]) = (int64_t)d; + int32_t d = *((int32_t *) (page + c)); + *((uint64_t *)ic->arg[0]) = (int64_t)d; #endif #ifdef LS_Q - uint64_t d = *((uint64_t *) (page + c)); - *((uint64_t *)ic->arg[0]) = d; + uint64_t d = *((uint64_t *) (page + c)); + *((uint64_t *)ic->arg[0]) = d; #endif #endif #else - /* Store: */ + /* Store: */ #ifdef HOST_BIG_ENDIAN - uint64_t data_x = *((uint64_t *)ic->arg[0]); - page[c] = data_x; + uint64_t data_x = *((uint64_t *)ic->arg[0]); + page[c] = data_x; #ifndef LS_B - page[c+1] = data_x >> 8; + page[c+1] = data_x >> 8; #ifndef LS_W - page[c+2] = data_x >> 16; - page[c+3] = data_x >> 24; + page[c+2] = data_x >> 16; + page[c+3] = data_x >> 24; #ifndef LS_L - page[c+4] = data_x >> 32; - page[c+5] = data_x >> 40; - page[c+6] = data_x >> 48; - page[c+7] = data_x >> 56; + page[c+4] = data_x >> 32; + page[c+5] = data_x >> 40; + page[c+6] = data_x >> 48; + page[c+7] = data_x >> 56; #endif #endif #endif #else - /* Native byte order: */ + /* Native byte order: */ #ifdef LS_B - page[c] = *((uint64_t *)ic->arg[0]); + page[c] = *((uint64_t *)ic->arg[0]); #endif #ifdef LS_W - uint32_t d = *((uint64_t *)ic->arg[0]); - *((uint16_t *) (page + c)) = d; + uint32_t d = *((uint64_t *)ic->arg[0]); + *((uint16_t *) (page + c)) = d; #endif #ifdef LS_L - uint32_t d = *((uint64_t *)ic->arg[0]); - *((uint32_t *) (page + c)) = d; + uint32_t d = *((uint64_t *)ic->arg[0]); + *((uint32_t *) (page + c)) = d; #endif #ifdef LS_Q - uint64_t d = *((uint64_t *)ic->arg[0]); - *((uint64_t *) (page + c)) = d; + uint64_t d = *((uint64_t *)ic->arg[0]); + *((uint64_t *) (page + c)) = d; #endif #endif #ifdef LS_LLSC #ifndef LS_LOAD - *((uint64_t *)ic->arg[0]) = 1; + *((uint64_t *)ic->arg[0]) = 1; #endif #endif #endif /* !LS_LOAD */ - } else - LS_GENERIC_N(cpu, ic); } else LS_GENERIC_N(cpu, ic); }