[Vm-dev] [commit][3730] Fix VFP execution and VFP register reset.

commits at squeakvm.org commits at squeakvm.org
Wed May 25 00:32:48 UTC 2016


Revision: 3730
Author:   eliot
Date:     2016-05-24 17:32:44 -0700 (Tue, 24 May 2016)
Log Message:
-----------
Fix VFP execution and VFP register reset.  XScale must not be included for VFP
execution.  Make sure processor's prog32Sig is set to HIGH.  Assert this in
runOnCPU.  Make runOnCPU inline for performance.  Requires r3729 of the Cog
tree to link on Mac OS X.

Modified Paths:
--------------
    trunk/platforms/Cross/plugins/GdbARMPlugin/sqGdbARMPlugin.c

Property Changed:
----------------
    trunk/platforms/Cross/plugins/sqPluginsSCCSVersion.h

Modified: trunk/platforms/Cross/plugins/GdbARMPlugin/sqGdbARMPlugin.c
===================================================================
--- trunk/platforms/Cross/plugins/GdbARMPlugin/sqGdbARMPlugin.c	2016-05-25 00:19:57 UTC (rev 3729)
+++ trunk/platforms/Cross/plugins/GdbARMPlugin/sqGdbARMPlugin.c	2016-05-25 00:32:44 UTC (rev 3730)
@@ -1,6 +1,7 @@
 #define COG 1
 #define FOR_COG_PLUGIN 1
 
+#include "sqAssert.h"
 #include "GdbARMPlugin.h"
 //disassembler
 #if __APPLE__ && __MACH__
@@ -35,11 +36,12 @@
 void
 print_state(ARMul_State* state)
 {
-	printf("NextInstr: %i\ttheMemory: 0x%p\tNumInstrs: 0x%p\tPC: 0x%p\tmode: %i\tEndCondition: %i\tEmulate: %i\n", 
+	printf("NextInstr: %i\ttheMemory: 0x%p\tNumInstrs: 0x%p\tPC: 0x%p\tmode: %i\tEndCondition: %i\tprog32Sig: %s\tEmulate: %i\n", 
 		state->NextInstr, state->MemDataPtr, 
 		state->NumInstrs, state->Reg[15], 
 		state->Mode, state->EndCondition, 
-		state->Emulate);
+		state->prog32Sig == LOW ? "LOW" : (state->prog32Sig == HIGH ? "HIGH" :
+		(state->prog32Sig == HIGHLOW ? "HIGHLOW" : "???")), state->Emulate);
 }
 
 void*
@@ -47,7 +49,11 @@
 {
 	if(lastCPU == NULL) ARMul_EmulateInit();
 	lastCPU = ARMul_NewState();
+#if 0 /* XScale seems to disable floating point */
 	ARMul_SelectProcessor (lastCPU, ARM_v5_Prop | ARM_v5e_Prop | ARM_XScale_Prop | ARM_v6_Prop);
+#else /* see sim_create_inferior in sim/arm/wrapper.c */
+	ARMul_SelectProcessor (lastCPU, ARM_v5_Prop | ARM_v5e_Prop | ARM_v6_Prop);
+#endif
 	return lastCPU;
 }
 
@@ -57,50 +63,54 @@
 	unsigned int i, j;
 	ARMul_State* state = (ARMul_State*) cpu;
 	// test whether the supplied instance is an ARMul type?
-	
+
 	gdblog_index = 0;
-	
+
 	// reset registers in all modes
-	for (i = 0; i < 16; i++)
-	{
+	for (i = 0; i < 16; i++) {
 		state->Reg[i] = 0;
 		for (j = 0; j < 7; j++)
 			state->RegBank[j][i] = 0;
 	}
 	for (i = 0; i < 7; i++)
 		state->Spsr[i] = 0;
-	
+	for (i = 0; i < 32; i++)
+		state->VFP_Reg[i].dword = 0ULL;
+	// make sure the processor is at least in 32-bit mode
+	if (!state->prog32Sig)
+		state->prog32Sig = HIGH;
 	ARMul_Reset(state);
 	return 0;
 }
 
-long
+static inline long
 runOnCPU(void *cpu, void *memory, 
 		ulong byteSize, ulong minAddr, ulong minWriteMaxExecAddr, ARMword (*run)(ARMul_State*))
 {
 	ARMul_State* state = (ARMul_State*) cpu;
 	lastCPU = state;
-	
+
+	assert(state->prog32Sig == HIGH || state->prog32Sig == HIGHLOW);
 	// test whether the supplied instance is an ARMul type?
 	state->MemDataPtr = (unsigned char*) memory;
 	state->MemSize = byteSize;
 	minReadAddress = minAddr;
 	minWriteAddress = minWriteMaxExecAddr;
-	
+
 	gdblog_index = 0;
-	
+
 	state->EndCondition = NoError;
 	state->NextInstr = RESUME;
-	
+
 	state->Reg[15] = run(state);
-	
+
 	// collect the PSR from their dedicated flags to have easy access from the image.
 	ARMul_SetCPSR(state, ARMul_GetCPSR(state));
-	
+
 	if(state->EndCondition != NoError){
 		return state->EndCondition;
 	}
-	
+
 	return gdblog_index == 0 ? 0 : SomethingLoggedError;
 }
 
@@ -135,7 +145,7 @@
 	va_list arg;
 	int n;
 	va_start(arg,format);
-	
+
 	if(stream == NULL){
 		n = vsnprintf((char*) (&gdb_log) + gdblog_index, LOGSIZE-gdblog_index, format, arg);
 		gdblog_index = gdblog_index + n;
@@ -153,29 +163,29 @@
 	// ignore the cpu
 	// start disassembling at laddr relative to memory
 	// stop disassembling at memory+byteSize
-	
+
 	disassemble_info* dis = (disassemble_info*) calloc(1, sizeof(disassemble_info));
 	// void init_disassemble_info (struct disassemble_info *dinfo, void *stream, fprintf_ftype fprintf_func)
 	init_disassemble_info ( dis, NULL, gdb_log_printf);
-	
+
 	dis->arch = bfd_arch_arm;
 	dis->mach = bfd_mach_arm_unknown;
-	
+
 	// sets some fields in the structure dis to architecture specific values
 	disassemble_init_for_target( dis );
-	
+
 	dis->buffer_vma = 0;
 	dis->buffer = memory;
 	dis->buffer_length = byteSize;
-	
+
 	// first print the address
 	gdb_log_printf( NULL, "%08lx: ", laddr);
 	//other possible functions are listed in opcodes/dissassemble.c
 	unsigned int size = print_insn_little_arm((bfd_vma) laddr, dis);
-	
+
 	free(dis);
 	gdb_log[gdblog_index+1] = 0;
-	
+
 	return size;
 }
 


Property changes on: trunk/platforms/Cross/plugins/sqPluginsSCCSVersion.h
___________________________________________________________________
Modified: checkindate
   - Thu Apr 28 22:05:49 PDT 2016
   + Tue May 24 17:24:39 PDT 2016



More information about the Vm-dev mailing list