|
From: <sv...@va...> - 2005-06-30 12:08:50
|
Author: sewardj
Date: 2005-06-30 13:08:48 +0100 (Thu, 30 Jun 2005)
New Revision: 1234
Log:
Connect up the plumbing which allows the ppc32 front end to know the
cache line size it is supposed to simulate. Use this in
dis_cache_manage(). Finally reinstate 'dcbz'.
Modified:
trunk/priv/guest-ppc32/toIR.c
Modified: trunk/priv/guest-ppc32/toIR.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/priv/guest-ppc32/toIR.c 2005-06-30 11:49:14 UTC (rev 1233)
+++ trunk/priv/guest-ppc32/toIR.c 2005-06-30 12:08:48 UTC (rev 1234)
@@ -282,6 +282,7 @@
static DisResult disInstr ( /*IN*/ Bool resteerOK,
/*IN*/ Bool (*resteerOkFn) ( Addr64 ),
/*IN*/ UInt delta,=20
+ /*IN*/ VexArchInfo* archinfo,
/*OUT*/ Int* size,
/*OUT*/ Addr64* whereNext );
=20
@@ -351,7 +352,7 @@
}
=20
dres =3D disInstr( resteerOK, chase_into_ok,=20
- delta, &size, &guest_next );
+ delta, archinfo_guest, &size, &guest_next );
=20
/* Print the resulting IR, if needed. */
if (vex_traceflags & VEX_TRACE_FE) {
@@ -3290,7 +3291,9 @@
/*
Cache Management Instructions
*/
-static Bool dis_cache_manage ( UInt theInstr, DisResult* whatNext )
+static Bool dis_cache_manage ( UInt theInstr,=20
+ DisResult* whatNext,
+ VexArchInfo* guest_archinfo )
{
/* X-Form */
UChar opc1 =3D toUChar((theInstr >> 26) & 0x3F); /* theInstr[26:31=
] */
@@ -3299,11 +3302,15 @@
UChar Rb_addr =3D toUChar((theInstr >> 11) & 0x1F); /* theInstr[11:15=
] */
UInt opc2 =3D (theInstr >> 1) & 0x3FF; /* theInstr[1:10]=
*/
UChar b0 =3D toUChar((theInstr >> 0) & 1); /* theInstr[0] =
*/
+ Int lineszB =3D guest_archinfo-> ppc32_cache_line_szB;
=20
if (opc1 !=3D 0x1F || b21to25 !=3D 0 || b0 !=3D 0) {
vex_printf("dis_cache_manage(PPC32)(opc1|b21to25|b0)\n");
return False;
}
+
+ /* stay sane .. */
+ vassert(lineszB =3D=3D 32 || lineszB =3D=3D 128);
=20
switch (opc2) {
case 0x2F6: // dcba (Data Cache Block Allocate, PPC32 p380)
@@ -3333,14 +3340,10 @@
case 0x3F6: { // dcbz (Data Cache Block Clear to Zero, PPC32 p387)
/* This needs to be fixed. We absolutely have to know the=20
correct cache line size to implement it right. */
- vassert(0);
- /* Clear all bytes in cache block at (rA|0) + rB.
- Since we don't know the cache line size, let's assume 256
- - safe, as no I1 cache would have a line size that large. */
+ /* Clear all bytes in cache block at (rA|0) + rB. */
IRTemp EA =3D newTemp(Ity_I32);
IRTemp addr =3D newTemp(Ity_I32);
IRExpr* irx_addr;
- UInt assumed_line_size =3D 32;
UInt i;
DIP("dcbz r%d,r%d\n", Ra_addr, Rb_addr);
assign( EA,
@@ -3352,11 +3355,11 @@
assign( addr,
binop( Iop_And32,
mkexpr(EA),
- mkU32( ~(assumed_line_size-1) )) );
+ mkU32( ~(lineszB-1) )) );
=20
- for (i =3D 0; i < (assumed_line_size / 4); i++) {
- irx_addr =3D binop( Iop_Add32, mkexpr(addr), mkU32(i*4) );
- storeBE( irx_addr, mkU32(0) );
+ for (i =3D 0; i < lineszB / 4; i++) {
+ irx_addr =3D binop( Iop_Add32, mkexpr(addr), mkU32(i*4) );
+ storeBE( irx_addr, mkU32(0) );
}
break;
}
@@ -3364,11 +3367,8 @@
case 0x3D6: {=20
// icbi (Instruction Cache Block Invalidate, PPC32 p431)
/* Invalidate all translations containing code from the cache
- block at (rA|0) + rB. Since we don't know what the cache
- line size is, let's assume 256 -- no real I1 cache would ever
- have a line size that large, so that's safe. */
+ block at (rA|0) + rB. */
IRTemp addr =3D newTemp(Ity_I32);
- UInt assumed_line_size =3D 256;
DIP("icbi r%d,r%d\n", Ra_addr, Rb_addr);
=20
assign( addr,
@@ -3381,9 +3381,9 @@
OFFB_TISTART,
binop( Iop_And32,=20
mkexpr(addr),=20
- mkU32( ~(assumed_line_size-1) ))) );
+ mkU32( ~(lineszB-1) ))) );
=20
- stmt( IRStmt_Put(OFFB_TILEN, mkU32(assumed_line_size) ) );
+ stmt( IRStmt_Put(OFFB_TILEN, mkU32(lineszB) ) );
=20
/* be paranoid ... */
stmt( IRStmt_MFence() );
@@ -5649,6 +5649,7 @@
static DisResult disInstr ( /*IN*/ Bool resteerOK,
/*IN*/ Bool (*resteerOkFn) ( Addr64 ),
/*IN*/ UInt delta,=20
+ /*IN*/ VexArchInfo* archinfo,
/*OUT*/ Int* size,
/*OUT*/ Addr64* whereNext )
{
@@ -5976,7 +5977,8 @@
case 0x2F6: case 0x056: case 0x036: // dcba, dcbf, dcbst
case 0x116: case 0x0F6: case 0x3F6: // dcbt, dcbtst, dcbz
case 0x3D6: // icbi
- if (dis_cache_manage( theInstr, &whatNext )) goto decode_succes=
s;
+ if (dis_cache_manage( theInstr, &whatNext, archinfo ))=20
+ goto decode_success;
goto decode_failure;
=20
/* External Control Instructions */
|