[K42-discussion] [PATCH] simulator cutthru opcode

Amos Waterland apw at us.ibm.com
Thu Sep 29 14:19:03 EST 2005


The systemsim full system simulator (Mambo) has recently deprecated the
illegal instruction K42 uses to invoke cutthru functions.  The old
opcode + rA + rB + rT could be encoded with:

        .long 0x7C0007CC

The new can be encoded with (turn the E's clockwise to get their pun):

        .long 0x000EAEB0

K42 in fact already had a routine to invoke the latter, we just were not
calling it.  Part of the reason for this is that the concept of
simulator is currently intertwined with the concept of SimOS
specifically.

This patch allows K42 to run on current Mambo CVS, and fixes the nightly
regression errors we just started hitting.  I am not committing
it yet because people might not like the approach.  Comments?


Index: lib/libc/misc/arch/powerpc/hardware.C
===================================================================
RCS file: /u/kitchawa/cvsroot/kitch-core/lib/libc/misc/arch/powerpc/hardware.C,v
retrieving revision 1.7
diff -u -r1.7 hardware.C
--- lib/libc/misc/arch/powerpc/hardware.C	8 Nov 2003 17:36:14 -0000	1.7
+++ lib/libc/misc/arch/powerpc/hardware.C	29 Sep 2005 03:33:25 -0000
@@ -20,7 +20,7 @@
 getInstrCount()
 {
     if (KernelInfo::OnSim()) {
-	return((uval)SimOSSupport(SimGetInstrCountK));
+	return((uval)SIM(SimGetInstrCountK));
     } else {
 	return((uval)0);
     }
Index: lib/libc/misc/arch/powerpc/simSupport.H
===================================================================
RCS file: /u/kitchawa/cvsroot/kitch-core/lib/libc/misc/arch/powerpc/simSupport.H,v
retrieving revision 1.17
diff -u -r1.17 simSupport.H
--- lib/libc/misc/arch/powerpc/simSupport.H	29 Sep 2004 08:32:53 -0000	1.17
+++ lib/libc/misc/arch/powerpc/simSupport.H	29 Sep 2005 03:33:25 -0000
@@ -85,6 +85,10 @@
 #define BD_INFO_DEVSZ  3
 #define BD_INFO_CHANGE 4
 
+#define SIM_MAMBO	2  /* running on Mambo */
+
+#define SIM (KernelInfo::OnSim() == SIM_MAMBO ? MamboSupport : SimOSSupport)
+
 #ifdef __cplusplus
 extern "C"
 #endif /* #ifdef __cplusplus */
Index: os/kernel/bilge/arch/powerpc/KernToyDisk.C
===================================================================
RCS file: /u/kitchawa/cvsroot/kitch-core/os/kernel/bilge/arch/powerpc/KernToyDisk.C,v
retrieving revision 1.12
diff -u -r1.12 KernToyDisk.C
--- os/kernel/bilge/arch/powerpc/KernToyDisk.C	8 Nov 2003 17:30:13 -0000	1.12
+++ os/kernel/bilge/arch/powerpc/KernToyDisk.C	29 Sep 2005 03:33:25 -0000
@@ -38,7 +38,7 @@
 	// put in a check here that disk is valid
 	*((uval*)(pageBufAddr)) = 0;
 	rc =
-	    SimOSSupport(SimDiskReadK42K, // code for "disk read"
+	    SIM(SimDiskReadK42K, // code for "disk read"
 			 simosDiskID,     // id of disk for this KernToyDisk
 			 0,		// byte offset which to read
 			 PageAllocatorKernPinned::virtToReal(
@@ -65,7 +65,7 @@
 #endif
     memcpy((void *)pageBufAddr, buf, length);
     dataWritten = 
-	SimOSSupport(SimDiskWriteK42K,	// code for "disk write"
+	SIM(SimDiskWriteK42K,	// code for "disk write"
 		     simosDiskID,
 		     offset,		// byte offset which to write
 		     PageAllocatorKernPinned::virtToReal(
@@ -92,7 +92,7 @@
     // touch the page to get in page table
     *((uval*)(pageBufAddr)) = 0;
     dataRead =
-	SimOSSupport (SimDiskReadK42K,	// code for "disk read"
+	SIM (SimDiskReadK42K,	// code for "disk read"
 		      simosDiskID,
 		      offset,		// byte offset which to read
 		      PageAllocatorKernPinned::virtToReal(
@@ -118,7 +118,7 @@
 KernToyDisk::_writePhys(uval offset, uval paddr)
 {
     // not dealing with errors
-    (void)SimOSSupport(SimDiskWriteK42K,// code for "disk write"
+    (void)SIM(SimDiskWriteK42K,// code for "disk write"
 		       simosDiskID,
 		       offset,		// byte offset which to write
 		       paddr,		//  address of buffer
@@ -130,7 +130,7 @@
 KernToyDisk::_readPhys(uval offset, uval paddr)
 {
     // not handling errors
-    (void)SimOSSupport (SimDiskReadK42K,// code for "disk read"
+    (void)SIM(SimDiskReadK42K,// code for "disk read"
 			simosDiskID,
 			offset,		// byte offset which to read
 			paddr,		// phys address of buffer
Index: os/kernel/bilge/arch/powerpc/simos.C
===================================================================
RCS file: /u/kitchawa/cvsroot/kitch-core/os/kernel/bilge/arch/powerpc/simos.C,v
retrieving revision 1.30
diff -u -r1.30 simos.C
--- os/kernel/bilge/arch/powerpc/simos.C	9 Feb 2005 18:45:43 -0000	1.30
+++ os/kernel/bilge/arch/powerpc/simos.C	29 Sep 2005 03:33:25 -0000
@@ -70,9 +70,9 @@
     // a kludge to determine whether we're in virtual mode assumes
     // we're called from the kernel
     if (((uval)lbuf) > (0x10000000)) {
-	SimOSSupport(SIMOS_CONS_FUN, lbuf, len, VIRT_MODE_SIMOS_CALL);
+	SIM(SIMOS_CONS_FUN, lbuf, len, VIRT_MODE_SIMOS_CALL);
     } else {
-	SimOSSupport(SIMOS_CONS_FUN, lbuf, len, REAL_MODE_SIMOS_CALL);
+	SIM(SIMOS_CONS_FUN, lbuf, len, REAL_MODE_SIMOS_CALL);
     }
 
 }
@@ -122,7 +122,7 @@
 	sval rc;
 	uval amt = MIN(length, SIMOS_THIN_IP_BUF_SIZE);
 	memcpy((void *) simosThinIPBufVirt, buf, amt);
-	rc = SimOSSupport(SimThinIPWriteK, simosThinIPBufPhys, amt);
+	rc = SIM(SimThinIPWriteK, simosThinIPBufPhys, amt);
 	if (rc < 0) return rc;
 	length -= amt;
 	buf += amt;
@@ -137,7 +137,7 @@
     sval rc;
 
     length = MIN(length, SIMOS_THIN_IP_BUF_SIZE);
-    rc = SimOSSupport(SimThinIPReadK, simosThinIPBufPhys, length);
+    rc = SIM(SimThinIPReadK, simosThinIPBufPhys, length);
     if (rc > 0) {
 	memcpy(buf, (void *) simosThinIPBufVirt, rc);
     }
@@ -149,7 +149,7 @@
 {
     sval ch;
 
-    ch = SimOSSupport(SimReadCharStdinK);
+    ch = SIM(SimReadCharStdinK);
     return ch;
 }
 
@@ -175,12 +175,12 @@
 	for (const char *p = buf; p < buf + length; p += PAGE_SIZE) {
 	    * (volatile char *) p;
 	}
-	SimOSSupport(SIMOS_CONS_FUN, buf, length, VIRT_MODE_SIMOS_CALL);
+	SIM(SIMOS_CONS_FUN, buf, length, VIRT_MODE_SIMOS_CALL);
 
 	if (reenable)
 	    enableHardwareInterrupts(is);
     } else {
-	SimOSSupport(SIMOS_CONS_FUN, buf, length, REAL_MODE_SIMOS_CALL);
+	SIM(SIMOS_CONS_FUN, buf, length, REAL_MODE_SIMOS_CALL);
     }
 }
 
@@ -189,7 +189,7 @@
 void *
 physmemcpy(void * t, const void * s, size_t len)
 {
-    return (void *)SimOSSupport(SimPhysMemCopyK, t, s, len);
+    return (void *)SIM(SimPhysMemCopyK, t, s, len);
 }
 
 void
@@ -197,7 +197,7 @@
 {
     uval64 fullTime;
 
-    fullTime = SimOSSupport(SimGetTimeK);
+    fullTime = SIM(SimGetTimeK);
 
     secs = fullTime>>32;
     usecs = fullTime&0x00000000ffffffff;
Index: os/kernel/init/KernelInit.C
===================================================================
RCS file: /u/kitchawa/cvsroot/kitch-core/os/kernel/init/KernelInit.C,v
retrieving revision 1.587
diff -u -r1.587 KernelInit.C
--- os/kernel/init/KernelInit.C	19 Sep 2005 18:34:30 -0000	1.587
+++ os/kernel/init/KernelInit.C	29 Sep 2005 03:33:25 -0000
@@ -1018,7 +1018,7 @@
   	    if (KernelInfo::OnSim() == SIM_SIMOSPPC) {
 		// whatever we wish to simos to return when it exits
 		uval code = 17;
-		SimOSSupport(SimExitCode, code);
+		SIM(SimExitCode, code);
 		cprintf("shutdown sim\n");
 	    } else if (KernelInfo::OnSim() == SIM_MAMBO) {
 	        // FIXME: needs to invoke proper mambo interface
@@ -2018,7 +2018,7 @@
 #ifdef FAST_REGRESS_ON_SIM
     err_printf("------------------ RUNNING REGRESSION TEST ------------\n");
     runRegression();
-    SimOSSupport(SimExitCode, 0);
+    SIM(SimExitCode, 0);
     err_printf("-----------DONE:   RUNNING REGRESSION TEST ------------\n");
 #else
 #ifndef START_PROMPT_EARLY
Index: os/kernel/init/arch/powerpc/KernelExit.C
===================================================================
RCS file: /u/kitchawa/cvsroot/kitch-core/os/kernel/init/arch/powerpc/KernelExit.C,v
retrieving revision 1.34
diff -u -r1.34 KernelExit.C
--- os/kernel/init/arch/powerpc/KernelExit.C	16 Feb 2005 00:06:24 -0000	1.34
+++ os/kernel/init/arch/powerpc/KernelExit.C	29 Sep 2005 03:33:25 -0000
@@ -215,7 +215,7 @@
     if (KernelInfo::OnSim()) {
 	// whatever we wish simos to return when it exits
 	uval code = 0;
-	SimOSSupport(SimExitCode, code);
+	SIM(SimExitCode, code);
 	// NOTREACHED
 	return;
     }
Index: os/servers/traced/arch/powerpc/trace2stream.H
===================================================================
RCS file: /u/kitchawa/cvsroot/kitch-core/os/servers/traced/arch/powerpc/trace2stream.H,v
retrieving revision 1.1
diff -u -r1.1 trace2stream.H
--- os/servers/traced/arch/powerpc/trace2stream.H	12 Apr 2004 16:59:36 -0000	1.1
+++ os/servers/traced/arch/powerpc/trace2stream.H	29 Sep 2005 03:33:25 -0000
@@ -19,12 +19,12 @@
 
 SysStatus
 trace2streamArchOpen(VPNum vp) {
-    return((SysStatus)SimOSSupport(SimTraceFileCtlK, SimTraceFileCtlOpenK, vp));
+    return((SysStatus)SIM(SimTraceFileCtlK, SimTraceFileCtlOpenK, vp));
 }
 
 SysStatus
 trace2streamArchClose(VPNum vp) {
-    return((SysStatus)SimOSSupport(SimTraceFileCtlK,SimTraceFileCtlCloseK, vp));
+    return((SysStatus)SIM(SimTraceFileCtlK,SimTraceFileCtlCloseK, vp));
 }
 
 SysStatusUval
@@ -38,7 +38,7 @@
     bufferAddrPhys = uval(trcInfo->traceArrayPhys) +
 				(bufferAddr - uval(trcArray));
 
-    return((SysStatusUval)SimOSSupport(SimTraceFileCtlK, SimTraceFileCtlWriteK,
+    return((SysStatusUval)SIM(SimTraceFileCtlK, SimTraceFileCtlWriteK,
 				       vp, bufferAddrPhys, size));
 }
 



More information about the K42-discussion mailing list