public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* MSP430 SIM: Add support for hardware multiply
@ 2014-05-08  7:53 Nick Clifton
  2014-08-02 14:54 ` Mike Frysinger
  2015-12-25  0:22 ` Mike Frysinger
  0 siblings, 2 replies; 9+ messages in thread
From: Nick Clifton @ 2014-05-08  7:53 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 541 bytes --]

Hi Guys,

  I am applying the attached patch to add support for simulating the
  hardware multiply feature found on some MSP430 MCUs.

Cheers
  Nick

sim/msp430/ChangeLog
2014-05-08  Nick Clifton  <nickc@redhat.com>

	* msp430-sim.c (sim_open): Do not allocate memory over the
	hardware multiply registers.
	(get_op): Add support for reads from the hardware multiply
	registers.
	(put_op): Add support for writes to the hardware multiply
	registers.
	(msp430_step_once): Add support for the RETI instruction used by
	the CPUX architecture.


[-- Attachment #2: msp430-sim.hw-mult.patch.xz --]
[-- Type: application/x-xz, Size: 1932 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: MSP430 SIM: Add support for hardware multiply
  2014-05-08  7:53 MSP430 SIM: Add support for hardware multiply Nick Clifton
@ 2014-08-02 14:54 ` Mike Frysinger
  2014-08-19  9:58   ` Nicholas Clifton
  2014-08-19 10:36   ` Nicholas Clifton
  2015-12-25  0:22 ` Mike Frysinger
  1 sibling, 2 replies; 9+ messages in thread
From: Mike Frysinger @ 2014-08-02 14:54 UTC (permalink / raw)
  To: gdb-patches; +Cc: Nick Clifton

[-- Attachment #1: Type: text/plain, Size: 851 bytes --]

On Thu 08 May 2014 08:52:49 Nick Clifton wrote:
>   I am applying the attached patch to add support for simulating the
>   hardware multiply feature found on some MSP430 MCUs.

any reason for the compression ?  its size doesn't seem to justify it at all.

> sim/msp430/ChangeLog
> 2014-05-08  Nick Clifton  <nickc@redhat.com>
> 
> 	* msp430-sim.c (sim_open): Do not allocate memory over the
> 	hardware multiply registers.
> 	(get_op): Add support for reads from the hardware multiply
> 	registers.
> 	(put_op): Add support for writes to the hardware multiply
> 	registers.
> 	(msp430_step_once): Add support for the RETI instruction used by
> 	the CPUX architecture.

the global static vars really look like they should be part of the cpu or sim 
state and not just global variables.  otherwise you can't easily reset them ?
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: MSP430 SIM: Add support for hardware multiply
  2014-08-02 14:54 ` Mike Frysinger
@ 2014-08-19  9:58   ` Nicholas Clifton
  2014-08-19 10:36   ` Nicholas Clifton
  1 sibling, 0 replies; 9+ messages in thread
From: Nicholas Clifton @ 2014-08-19  9:58 UTC (permalink / raw)
  To: Mike Frysinger, gdb-patches

Hi Mike,

[Sorry for the long time in replying to your email]

> any reason for the compression ?  its size doesn't seem to justify it at all.

Nope - just a snafu.


> the global static vars really look like they should be part of the cpu or sim
> state and not just global variables.  otherwise you can't easily reset them ?

True - I will fix that soon.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: MSP430 SIM: Add support for hardware multiply
  2014-08-02 14:54 ` Mike Frysinger
  2014-08-19  9:58   ` Nicholas Clifton
@ 2014-08-19 10:36   ` Nicholas Clifton
  2014-08-20  9:24     ` Mike Frysinger
  1 sibling, 1 reply; 9+ messages in thread
From: Nicholas Clifton @ 2014-08-19 10:36 UTC (permalink / raw)
  To: Mike Frysinger, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 479 bytes --]

Hi Mike,

> the global static vars really look like they should be part of the cpu or sim
> state and not just global variables.  otherwise you can't easily reset them ?

Done:
sim/msp430/ChangeLog

2014-08-19  Nick Clifton  <nickc@redhat.com>

	* msp430-sim.c: Move static hardware multiply support variables
	from here...
	* msp430-sim.h (msp430_cpu_state): ... into here ...
	* msp430-sim.c (get_op, put_op): ... and update references to use
	the msp430_cpu_state structure.


[-- Attachment #2: msp430.patch --]
[-- Type: text/x-patch, Size: 9679 bytes --]

diff --git a/sim/msp430/msp430-sim.c b/sim/msp430/msp430-sim.c
index 7812868..b9a6a7e 100644
--- a/sim/msp430/msp430-sim.c
+++ b/sim/msp430/msp430-sim.c
@@ -317,18 +317,6 @@ trace_reg_get (SIM_DESC sd, int n)
 #define REG_GET(N)   trace_reg_get (sd, N)
 
 /* Hardware multiply (and accumulate) support.  */
-static enum { UNSIGN_32, SIGN_32, UNSIGN_MAC_32, SIGN_MAC_32 } hwmult_type;
-static unsigned32 hwmult_op1;
-static unsigned32 hwmult_op2;
-static unsigned32 hwmult_result;
-static   signed32 hwmult_signed_result;
-static unsigned32 hwmult_accumulator;
-static   signed32 hwmult_signed_accumulator;
-
-static enum { UNSIGN_64, SIGN_64 } hw32mult_type;
-static unsigned64 hw32mult_op1;
-static unsigned64 hw32mult_op2;
-static unsigned64 hw32mult_result;
 
 static unsigned int
 zero_ext (unsigned int v, unsigned int bits)
@@ -413,65 +401,69 @@ get_op (SIM_DESC sd, MSP430_Opcode_Decoded *opc, int n)
 	  switch (addr)
 	    {
 	    case 0x13A:
-	      switch (hwmult_type)
+	      switch (HWMULT (sd, hwmult_type))
 		{
 		case UNSIGN_MAC_32:
-		case UNSIGN_32:     rv = zero_ext (hwmult_result, 16); break;
+		case UNSIGN_32:
+		  rv = zero_ext (HWMULT (sd, hwmult_result), 16);
+		  break;
 		case SIGN_MAC_32: 
-		case SIGN_32:       rv = sign_ext (hwmult_signed_result, 16); break;
+		case SIGN_32:
+		  rv = sign_ext (HWMULT (sd, hwmult_signed_result), 16);
+		  break;
 		}
 	      break;
 
 	    case 0x13C:
-	      switch (hwmult_type)
+	      switch (HWMULT (sd, hwmult_type))
 		{
 		case UNSIGN_MAC_32:
 		case UNSIGN_32:
-		  rv = zero_ext (hwmult_result >> 16, 16);
+		  rv = zero_ext (HWMULT (sd, hwmult_result) >> 16, 16);
 		  break;
 
 		case SIGN_MAC_32:
 		case SIGN_32:
-		  rv = sign_ext (hwmult_signed_result >> 16, 16);
+		  rv = sign_ext (HWMULT (sd, hwmult_signed_result) >> 16, 16);
 		  break;
 		}
 	      break;
 
 	    case 0x13E:
-	      switch (hwmult_type)
+	      switch (HWMULT (sd, hwmult_type))
 		{
 		case UNSIGN_32:
 		  rv = 0;
 		  break;
 		case SIGN_32:
-		  rv = hwmult_signed_result < 0 ? -1 : 0;
+		  rv = HWMULT (sd, hwmult_signed_result) < 0 ? -1 : 0;
 		  break;
 		case UNSIGN_MAC_32:
 		  rv = 0; /* FIXME: Should be carry of last accumulate.  */
 		  break;
 		case SIGN_MAC_32:
-		  rv = hwmult_signed_accumulator < 0 ? -1 : 0;
+		  rv = HWMULT (sd, hwmult_signed_accumulator) < 0 ? -1 : 0;
 		  break;
 		}
 	      break;
 
 	    case 0x154:
-	      rv = zero_ext (hw32mult_result, 16);
+	      rv = zero_ext (HWMULT (sd, hw32mult_result), 16);
 	      break;
 
 	    case 0x156:
-	      rv = zero_ext (hw32mult_result >> 16, 16);
+	      rv = zero_ext (HWMULT (sd, hw32mult_result) >> 16, 16);
 	      break;
 
 	    case 0x158:
-	      rv = zero_ext (hw32mult_result >> 32, 16);
+	      rv = zero_ext (HWMULT (sd, hw32mult_result) >> 32, 16);
 	      break;
 
 	    case 0x15A:
-	      switch (hw32mult_type)
+	      switch (HWMULT (sd, hw32mult_type))
 		{
-		case UNSIGN_64: rv = zero_ext (hw32mult_result >> 48, 16); break;
-		case   SIGN_64: rv = sign_ext (hw32mult_result >> 48, 16); break;
+		case UNSIGN_64: rv = zero_ext (HWMULT (sd, hw32mult_result) >> 48, 16); break;
+		case   SIGN_64: rv = sign_ext (HWMULT (sd, hw32mult_result) >> 48, 16); break;
 		}
 	      break;
 
@@ -582,77 +574,91 @@ put_op (SIM_DESC sd, MSP430_Opcode_Decoded *opc, int n, int val)
 
 	  switch (addr)
 	    {
-	    case 0x130: hwmult_op1 = val; hwmult_type = UNSIGN_32; break;
-	    case 0x132: hwmult_op1 = val; hwmult_type = SIGN_32; break;
-	    case 0x134: hwmult_op1 = val; hwmult_type = UNSIGN_MAC_32; break;
-	    case 0x136: hwmult_op1 = val; hwmult_type = SIGN_MAC_32; break;
+	    case 0x130: HWMULT (sd, hwmult_op1) = val; HWMULT (sd, hwmult_type) = UNSIGN_32; break;
+	    case 0x132: HWMULT (sd, hwmult_op1) = val; HWMULT (sd, hwmult_type) = SIGN_32; break;
+	    case 0x134: HWMULT (sd, hwmult_op1) = val; HWMULT (sd, hwmult_type) = UNSIGN_MAC_32; break;
+	    case 0x136: HWMULT (sd, hwmult_op1) = val; HWMULT (sd, hwmult_type) = SIGN_MAC_32; break;
 
-	    case 0x138: hwmult_op2 = val;
-	      switch (hwmult_type)
+	    case 0x138: HWMULT (sd, hwmult_op2) = val;
+	      switch (HWMULT (sd, hwmult_type))
 		{
 		case UNSIGN_32:
-		  hwmult_result = hwmult_op1 * hwmult_op2;
-		  hwmult_signed_result = (signed) hwmult_result;
-		  hwmult_accumulator = hwmult_signed_accumulator = 0;
+		  HWMULT (sd, hwmult_result) = HWMULT (sd, hwmult_op1) * HWMULT (sd, hwmult_op2);
+		  HWMULT (sd, hwmult_signed_result) = (signed) HWMULT (sd, hwmult_result);
+		  HWMULT (sd, hwmult_accumulator) = HWMULT (sd, hwmult_signed_accumulator) = 0;
 		  break;
 
 		case SIGN_32:
-		  a = sign_ext (hwmult_op1, 16);
-		  b = sign_ext (hwmult_op2, 16);
-		  hwmult_signed_result = a * b;
-		  hwmult_result = (unsigned) hwmult_signed_result;
-		  hwmult_accumulator = hwmult_signed_accumulator = 0;
+		  a = sign_ext (HWMULT (sd, hwmult_op1), 16);
+		  b = sign_ext (HWMULT (sd, hwmult_op2), 16);
+		  HWMULT (sd, hwmult_signed_result) = a * b;
+		  HWMULT (sd, hwmult_result) = (unsigned) HWMULT (sd, hwmult_signed_result);
+		  HWMULT (sd, hwmult_accumulator) = HWMULT (sd, hwmult_signed_accumulator) = 0;
 		  break;
 
 		case UNSIGN_MAC_32:
-		  hwmult_accumulator += hwmult_op1 * hwmult_op2;
-		  hwmult_signed_accumulator += hwmult_op1 * hwmult_op2;
-		  hwmult_result = hwmult_accumulator;
-		  hwmult_signed_result = hwmult_signed_accumulator;
+		  HWMULT (sd, hwmult_accumulator) += HWMULT (sd, hwmult_op1) * HWMULT (sd, hwmult_op2);
+		  HWMULT (sd, hwmult_signed_accumulator) += HWMULT (sd, hwmult_op1) * HWMULT (sd, hwmult_op2);
+		  HWMULT (sd, hwmult_result) = HWMULT (sd, hwmult_accumulator);
+		  HWMULT (sd, hwmult_signed_result) = HWMULT (sd, hwmult_signed_accumulator);
 		  break;
 
 		case SIGN_MAC_32:
-		  a = sign_ext (hwmult_op1, 16);
-		  b = sign_ext (hwmult_op2, 16);
-		  hwmult_accumulator += a * b;
-		  hwmult_signed_accumulator += a * b;
-		  hwmult_result = hwmult_accumulator;
-		  hwmult_signed_result = hwmult_signed_accumulator;
+		  a = sign_ext (HWMULT (sd, hwmult_op1), 16);
+		  b = sign_ext (HWMULT (sd, hwmult_op2), 16);
+		  HWMULT (sd, hwmult_accumulator) += a * b;
+		  HWMULT (sd, hwmult_signed_accumulator) += a * b;
+		  HWMULT (sd, hwmult_result) = HWMULT (sd, hwmult_accumulator);
+		  HWMULT (sd, hwmult_signed_result) = HWMULT (sd, hwmult_signed_accumulator);
 		  break;
 		}
 	      break;
 
 	    case 0x13a:
 	      /* Copy into LOW result...  */
-	      switch (hwmult_type)
+	      switch (HWMULT (sd, hwmult_type))
 		{
 		case UNSIGN_MAC_32:
 		case UNSIGN_32:
-		  hwmult_accumulator = hwmult_result = zero_ext (val, 16);
-		  hwmult_signed_accumulator = sign_ext (val, 16);
+		  HWMULT (sd, hwmult_accumulator) = HWMULT (sd, hwmult_result) = zero_ext (val, 16);
+		  HWMULT (sd, hwmult_signed_accumulator) = sign_ext (val, 16);
 		  break;
 		case SIGN_MAC_32:
 		case SIGN_32:
-		  hwmult_signed_accumulator = hwmult_result = sign_ext (val, 16);
-		  hwmult_accumulator = zero_ext (val, 16);
+		  HWMULT (sd, hwmult_signed_accumulator) = HWMULT (sd, hwmult_result) = sign_ext (val, 16);
+		  HWMULT (sd, hwmult_accumulator) = zero_ext (val, 16);
 		  break;
 		}
 	      break;
 		
-	    case 0x140: hw32mult_op1 = val; hw32mult_type = UNSIGN_64; break;
-	    case 0x142: hw32mult_op1 = (hw32mult_op1 & 0xFFFF) | (val << 16); break;
-	    case 0x144: hw32mult_op1 = val; hw32mult_type = SIGN_64; break;
-	    case 0x146: hw32mult_op1 = (hw32mult_op1 & 0xFFFF) | (val << 16); break;
-	    case 0x150: hw32mult_op2 = val; break;
-
-	    case 0x152: hw32mult_op2 = (hw32mult_op2 & 0xFFFF) | (val << 16);
-	      switch (hw32mult_type)
+	    case 0x140:
+	      HWMULT (sd, hw32mult_op1) = val;
+	      HWMULT (sd, hw32mult_type) = UNSIGN_64;
+	      break;
+	    case 0x142:
+	      HWMULT (sd, hw32mult_op1) = (HWMULT (sd, hw32mult_op1) & 0xFFFF) | (val << 16);
+	      break;
+	    case 0x144:
+	      HWMULT (sd, hw32mult_op1) = val;
+	      HWMULT (sd, hw32mult_type) = SIGN_64;
+	      break;
+	    case 0x146:
+	      HWMULT (sd, hw32mult_op1) = (HWMULT (sd, hw32mult_op1) & 0xFFFF) | (val << 16);
+	      break;
+	    case 0x150:
+	      HWMULT (sd, hw32mult_op2) = val;
+	      break;
+
+	    case 0x152:
+	      HWMULT (sd, hw32mult_op2) = (HWMULT (sd, hw32mult_op2) & 0xFFFF) | (val << 16);
+	      switch (HWMULT (sd, hw32mult_type))
 		{
 		case UNSIGN_64:
-		  hw32mult_result = hw32mult_op1 * hw32mult_op2;
+		  HWMULT (sd, hw32mult_result) = HWMULT (sd, hw32mult_op1) * HWMULT (sd, hw32mult_op2);
 		  break;
 		case SIGN_64:
-		  hw32mult_result = sign_ext (hw32mult_op1, 32) * sign_ext (hw32mult_op2, 32);
+		  HWMULT (sd, hw32mult_result) = sign_ext (HWMULT (sd, hw32mult_op1), 32)
+		    * sign_ext (HWMULT (sd, hw32mult_op2), 32);
 		  break;
 		}
 	      break;
diff --git a/sim/msp430/msp430-sim.h b/sim/msp430/msp430-sim.h
index 1865e4e..2a0912e 100644
--- a/sim/msp430/msp430-sim.h
+++ b/sim/msp430/msp430-sim.h
@@ -21,11 +21,29 @@
 #ifndef _MSP430_SIM_H_
 #define _MSP430_SIM_H_
 
+typedef enum { UNSIGN_32, SIGN_32, UNSIGN_MAC_32, SIGN_MAC_32 } hwmult_type;
+typedef enum { UNSIGN_64, SIGN_64 } hw32mult_type;
+
 struct msp430_cpu_state
 {
   int regs[16];
   int cio_breakpoint;
   int cio_buffer;
+
+  hwmult_type  hwmult_type;
+  unsigned32   hwmult_op1;
+  unsigned32   hwmult_op2;
+  unsigned32   hwmult_result;
+  signed32     hwmult_signed_result;
+  unsigned32   hwmult_accumulator;
+  signed32     hwmult_signed_accumulator;
+
+  hw32mult_type  hw32mult_type;
+  unsigned64     hw32mult_op1;
+  unsigned64     hw32mult_op2;
+  unsigned64     hw32mult_result;
 };
 
+#define HWMULT(SD, FIELD) MSP430_CPU (SD)->state.FIELD
+
 #endif

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: MSP430 SIM: Add support for hardware multiply
  2014-08-19 10:36   ` Nicholas Clifton
@ 2014-08-20  9:24     ` Mike Frysinger
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2014-08-20  9:24 UTC (permalink / raw)
  To: Nicholas Clifton; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 593 bytes --]

On Tue 19 Aug 2014 11:36:36 Nicholas Clifton wrote:
> > the global static vars really look like they should be part of the cpu or
> > sim state and not just global variables.  otherwise you can't easily
> > reset them ?
>
> Done:
> sim/msp430/ChangeLog
> 
> 2014-08-19  Nick Clifton  <nickc@redhat.com>
> 
> 	* msp430-sim.c: Move static hardware multiply support variables
> 	from here...
> 	* msp430-sim.h (msp430_cpu_state): ... into here ...
> 	* msp430-sim.c (get_op, put_op): ... and update references to use
> 	the msp430_cpu_state structure.

looks sane.  thanks!
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: MSP430 SIM: Add support for hardware multiply
  2014-05-08  7:53 MSP430 SIM: Add support for hardware multiply Nick Clifton
  2014-08-02 14:54 ` Mike Frysinger
@ 2015-12-25  0:22 ` Mike Frysinger
  2016-01-05 16:43   ` Nick Clifton
  1 sibling, 1 reply; 9+ messages in thread
From: Mike Frysinger @ 2015-12-25  0:22 UTC (permalink / raw)
  To: Nick Clifton; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1066 bytes --]

On 08 May 2014 08:52, Nick Clifton wrote:
>   I am applying the attached patch to add support for simulating the
>   hardware multiply feature found on some MSP430 MCUs.

this broke the testsuite:
Running ../../../../sim/testsuite/sim/msp430/allinsn.exp ...
Testing add.s on machine msp430.
Executing on host: /usr/local/src/gnu/gdb/build/build-msp430/gas/as-new ../../../../sim/testsuite/sim/msp430/add.s  -I../../../../sim/testsuite/sim/msp430  -o add.s.o    (timeout = 300)
spawn /usr/local/src/gnu/gdb/build/build-msp430/gas/as-new ../../../../sim/testsuite/sim/msp430/add.s -I../../../../sim/testsuite/sim/msp430 -o add.s.o
Executing on host: /usr/local/src/gnu/gdb/build/build-msp430/ld/ld-new 
add.s.o   -o add.s.x    (timeout = 300)
spawn /usr/local/src/gnu/gdb/build/build-msp430/ld/ld-new add.s.o -o add.s.x
/usr/local/src/gnu/gdb/build/build-msp430/sim/testsuite/../msp430/run     add.s.x 
spawn /usr/local/src/gnu/gdb/build/build-msp430/sim/testsuite/../msp430/run add.s.x
output:  
pattern: pass

FAIL: msp430 add.s (execution)
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: MSP430 SIM: Add support for hardware multiply
  2015-12-25  0:22 ` Mike Frysinger
@ 2016-01-05 16:43   ` Nick Clifton
  2016-01-05 19:16     ` Mike Frysinger
  0 siblings, 1 reply; 9+ messages in thread
From: Nick Clifton @ 2016-01-05 16:43 UTC (permalink / raw)
  To: vapier; +Cc: gdb-patches, binutils

[-- Attachment #1: Type: text/plain, Size: 1956 bytes --]

Hi Mike,

>>    I am applying the attached patch to add support for simulating the
>>    hardware multiply feature found on some MSP430 MCUs.

> this broke the testsuite:
> FAIL: msp430 add.s (execution)

Actually, as far as I can see this test never should have worked in the 
first place.  The problem is that the test harness code (in 
testutils.inc) assumes that the VMA and LMA addresses of the .data 
section are the same.  This is not the case (at least for the msp430), 
and without runtime code to copy data from the LMA address to the VMA 
address all the data addresses in the test executables are wrong.

So, I am checking in the following two patches.  The first patch updates 
the linker's built in link script so that it does not place data into 
the msp430's hardware address range, and so that that it provides a 
symbol (__romdatastart) with the LMA address of the .data section. 
[Note - as far as I can see only the sim tests actually use the linker's 
built in linker script.  Everyone else uses scripts explicitly provided 
on the linker command line].

The second patch updates the testutils.inc file so that it will use the 
LMA addresses of the strings in the .data section not the VMA addresses. 
  This makes the tests work, although it is a bit of a hack.  A proper 
solution would be to provide start-up code that copies the data from the 
LMA address to the VMA address before the test proper runs, but this 
seems like overkill to me.

Cheers
   Nick

ld/ChangeLog
2016-01-05  Nick Clifton  <nickc@redhat.com>

	* emulparams/msp430elf.sh (RAM_START): Move to 0x500 - above the
	MSP430 hardware multiply address range.
	* scripttempl/elf32msp430.sc (__romdatastart): Define.
	(__romdatacopysize): Define.
	* scripttempl/elf32msp430_3.sc: Likewise.

sim/testsuite/sim/msp430/ChangeLog
2016-01-05  Nick Clifton  <nickc@redhat.com>

	* testutils.inc (__pass): Use the LMA addresses of the _passmsg
	symbol.
	(__fail): Likewise.


[-- Attachment #2: msp430.sim.test.patch --]
[-- Type: text/x-patch, Size: 1546 bytes --]

diff --git a/sim/testsuite/sim/msp430/testutils.inc b/sim/testsuite/sim/msp430/testutils.inc
index 6c540b1..1ddef23 100644
--- a/sim/testsuite/sim/msp430/testutils.inc
+++ b/sim/testsuite/sim/msp430/testutils.inc
@@ -9,13 +9,43 @@
 	.global __pass
 	.type __pass, function
 __pass:
-	write 1, _passmsg, 5
+	# Note - we cannot just invoke:
+	#
+	#  write 1, _passmsg, 5
+	#
+	# here because _passmsg contains the run-time (VMA) address of
+	# the pass string (probably 0x500) not the load-time (LMA)
+	# address (probably 0x804c).  Normally using the VMA address
+	# would be the correct thing to do - *if* there was some start
+	# up code which copied data from LMA to VMA.  But we have no
+	# start up code, so the data still resides at the LMA
+	# address.  Hence we use __romdatastart instead.
+	#
+	# Note - we are cheating because the address that we pass to
+	# "write" should actually be:
+	#
+	#    __romdatastart + (_passmsg - __datastart)
+	#
+	# but the assembler cannot cope with this expression.  So we
+	# cheat and use the fact that we know that _passmsg is the
+	# first string in the .data section and so (_passmsg -
+	# __datastart) evaluates to zero.
+
+	write 1, __romdatastart, 5
 	exit 0
 
 	.global __fail
 	.type __fail, function
 __fail:
-	write 1, _failmsg, 5
+	# Note - see above.
+	#
+	#   write 1, _failmsg, 5
+	#
+	# This time we use the fact that _passmsg is aligned to a
+	# 16 byte boundary to work out that (_failmsg - __datastart)
+	# evaluates to 0x10.
+
+	write 1, __romdatastart + 0x10, 5
 	exit 1
 
 	.data

[-- Attachment #3: msp430.ld-scripts.patch --]
[-- Type: text/x-patch, Size: 1240 bytes --]

diff --git a/ld/emulparams/msp430elf.sh b/ld/emulparams/msp430elf.sh
index a76e9ee..e9d0237 100644
--- a/ld/emulparams/msp430elf.sh
+++ b/ld/emulparams/msp430elf.sh
@@ -13,6 +13,6 @@ EMBEDDED=yes
 ARCH=msp:14
 ROM_START=0x8000
 ROM_SIZE=0x7fe0
-RAM_START=0x0200
+RAM_START=0x0500
 RAM_SIZE=1K
 STACK=0x600
diff --git a/ld/scripttempl/elf32msp430.sc b/ld/scripttempl/elf32msp430.sc
index 78c7c12..50b7ddb 100644
--- a/ld/scripttempl/elf32msp430.sc
+++ b/ld/scripttempl/elf32msp430.sc
@@ -269,6 +269,9 @@ SECTIONS
     ${RELOCATING+ _edata = . ; }
   } ${RELOCATING+ > data ${RELOCATING+AT> text}}
 
+  __romdatastart = LOADADDR(.data);
+  __romdatacopysize = SIZEOF(.data);
+  
   .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} :
   {
     ${RELOCATING+. = ALIGN(2);}
diff --git a/ld/scripttempl/elf32msp430_3.sc b/ld/scripttempl/elf32msp430_3.sc
index 7a13081..7ad04e1 100644
--- a/ld/scripttempl/elf32msp430_3.sc
+++ b/ld/scripttempl/elf32msp430_3.sc
@@ -147,6 +147,9 @@ SECTIONS
     ${RELOCATING+ _edata = . ; }
   } ${RELOCATING+ > data ${RELOCATING+AT> text}}
   
+  __romdatastart = LOADADDR(.data);
+  __romdatacopysize = SIZEOF(.data);
+  
   .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} :
   {
     ${RELOCATING+. = ALIGN(2);}

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: MSP430 SIM: Add support for hardware multiply
  2016-01-05 16:43   ` Nick Clifton
@ 2016-01-05 19:16     ` Mike Frysinger
  2016-01-07 10:53       ` Nick Clifton
  0 siblings, 1 reply; 9+ messages in thread
From: Mike Frysinger @ 2016-01-05 19:16 UTC (permalink / raw)
  To: Nick Clifton; +Cc: gdb-patches, binutils

[-- Attachment #1: Type: text/plain, Size: 578 bytes --]

On 05 Jan 2016 16:43, Nick Clifton wrote:
> The second patch updates the testutils.inc file so that it will use the 
> LMA addresses of the strings in the .data section not the VMA addresses. 
>   This makes the tests work, although it is a bit of a hack.  A proper 
> solution would be to provide start-up code that copies the data from the 
> LMA address to the VMA address before the test proper runs, but this 
> seems like overkill to me.

you could update the test harness or the tests themselves to run the sim
with --load-vma if it'd make things easier
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: MSP430 SIM: Add support for hardware multiply
  2016-01-05 19:16     ` Mike Frysinger
@ 2016-01-07 10:53       ` Nick Clifton
  0 siblings, 0 replies; 9+ messages in thread
From: Nick Clifton @ 2016-01-07 10:53 UTC (permalink / raw)
  To: gdb-patches, binutils

Hi Mike,

>> The second patch updates the testutils.inc file so that it will use the
>> LMA addresses of the strings in the .data section not the VMA addresses.
>>    This makes the tests work, although it is a bit of a hack.  A proper
>> solution would be to provide start-up code that copies the data from the
>> LMA address to the VMA address before the test proper runs, but this
>> seems like overkill to me.
>
> you could update the test harness or the tests themselves to run the sim
> with --load-vma if it'd make things easier

Ah - good idea.  I will see about doing that in a future patch.

Cheers
   Nick

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-01-07 10:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-08  7:53 MSP430 SIM: Add support for hardware multiply Nick Clifton
2014-08-02 14:54 ` Mike Frysinger
2014-08-19  9:58   ` Nicholas Clifton
2014-08-19 10:36   ` Nicholas Clifton
2014-08-20  9:24     ` Mike Frysinger
2015-12-25  0:22 ` Mike Frysinger
2016-01-05 16:43   ` Nick Clifton
2016-01-05 19:16     ` Mike Frysinger
2016-01-07 10:53       ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).