1 /* Simulator for the FT32 processor
3 Copyright (C) 2008-2024 Free Software Foundation, Inc.
4 Contributed by FTDI <support@ftdichip.com>
6 This file is part of simulators.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 /* This must come before any other includes. */
30 #include "sim/callback.h"
31 #include "libiberty.h"
35 #include "sim-options.h"
36 #include "sim-signal.h"
38 #include "opcode/ft32.h"
43 * FT32 is a Harvard architecture: RAM and code occupy
44 * different address spaces.
46 * sim and gdb model FT32 memory by adding 0x800000 to RAM
47 * addresses. This means that sim/gdb can treat all addresses
50 * The address space looks like:
52 * 00000 start of code memory
53 * 3ffff end of code memory
58 #define RAM_BIAS 0x800000 /* Bias added to RAM addresses. */
61 ft32_extract_unsigned_integer (const unsigned char *addr
, int len
)
65 unsigned char *startaddr
= (unsigned char *) addr
;
66 unsigned char *endaddr
= startaddr
+ len
;
68 /* Start at the most significant end of the integer, and work towards
69 the least significant. */
72 for (p
= endaddr
; p
> startaddr
;)
73 retval
= (retval
<< 8) | * -- p
;
79 ft32_store_unsigned_integer (unsigned char *addr
, int len
, unsigned long val
)
82 unsigned char *startaddr
= (unsigned char *)addr
;
83 unsigned char *endaddr
= startaddr
+ len
;
85 for (p
= startaddr
; p
< endaddr
; p
++)
93 * Align EA according to its size DW.
94 * The FT32 ignores the low bit of a 16-bit addresss,
95 * and the low two bits of a 32-bit address.
97 static uint32_t ft32_align (uint32_t dw
, uint32_t ea
)
113 /* Read an item from memory address EA, sized DW. */
115 ft32_read_item (SIM_DESC sd
, int dw
, uint32_t ea
)
117 sim_cpu
*cpu
= STATE_CPU (sd
, 0);
118 address_word cia
= CPU_PC_GET (cpu
);
120 ea
= ft32_align (dw
, ea
);
124 return sim_core_read_aligned_1 (cpu
, cia
, read_map
, ea
);
126 return sim_core_read_aligned_2 (cpu
, cia
, read_map
, ea
);
128 return sim_core_read_aligned_4 (cpu
, cia
, read_map
, ea
);
134 /* Write item V to memory address EA, sized DW. */
136 ft32_write_item (SIM_DESC sd
, int dw
, uint32_t ea
, uint32_t v
)
138 sim_cpu
*cpu
= STATE_CPU (sd
, 0);
139 address_word cia
= CPU_PC_GET (cpu
);
141 ea
= ft32_align (dw
, ea
);
145 sim_core_write_aligned_1 (cpu
, cia
, write_map
, ea
, v
);
148 sim_core_write_aligned_2 (cpu
, cia
, write_map
, ea
, v
);
151 sim_core_write_aligned_4 (cpu
, cia
, write_map
, ea
, v
);
159 sim_engine_halt (sd, cpu, NULL, insnpc, sim_signalled, SIM_SIGILL)
161 static uint32_t cpu_mem_read (SIM_DESC sd
, uint32_t dw
, uint32_t ea
)
163 sim_cpu
*cpu
= STATE_CPU (sd
, 0);
164 struct ft32_cpu_state
*ft32_cpu
= FT32_SIM_CPU (cpu
);
165 uint32_t insnpc
= ft32_cpu
->pc
;
170 /* Simulate some IO devices */
176 /* Read the simulator cycle timer. */
177 return ft32_cpu
->cycles
/ 100;
179 sim_io_eprintf (sd
, "Illegal IO read address %08x, pc %#x\n",
184 return ft32_read_item (sd
, dw
, RAM_BIAS
+ ea
);
187 static void cpu_mem_write (SIM_DESC sd
, uint32_t dw
, uint32_t ea
, uint32_t d
)
189 sim_cpu
*cpu
= STATE_CPU (sd
, 0);
190 struct ft32_cpu_state
*ft32_cpu
= FT32_SIM_CPU (cpu
);
194 /* Simulate some IO devices */
202 /* Unlock the PM write port */
203 ft32_cpu
->pm_unlock
= (d
== 0x1337f7d1);
206 /* Set the PM write address register */
207 ft32_cpu
->pm_addr
= d
;
210 if (ft32_cpu
->pm_unlock
)
213 ft32_write_item (sd
, dw
, ft32_cpu
->pm_addr
, d
);
214 ft32_cpu
->pm_addr
+= 4;
219 sim_engine_halt (sd
, cpu
, NULL
, ft32_cpu
->pc
, sim_exited
, ft32_cpu
->regs
[0]);
222 sim_io_printf (sd
, "Debug write %08x\n", d
);
225 sim_io_eprintf (sd
, "Unknown IO write %08x to to %08x\n", d
, ea
);
229 ft32_write_item (sd
, dw
, RAM_BIAS
+ ea
, d
);
232 #define GET_BYTE(ea) cpu_mem_read (sd, 0, (ea))
233 #define PUT_BYTE(ea, d) cpu_mem_write (sd, 0, (ea), (d))
235 /* LSBS (n) is a mask of the least significant N bits. */
236 #define LSBS(n) ((1U << (n)) - 1)
238 static void ft32_push (SIM_DESC sd
, uint32_t v
)
240 sim_cpu
*cpu
= STATE_CPU (sd
, 0);
241 struct ft32_cpu_state
*ft32_cpu
= FT32_SIM_CPU (cpu
);
242 ft32_cpu
->regs
[FT32_HARD_SP
] -= 4;
243 ft32_cpu
->regs
[FT32_HARD_SP
] &= 0xffff;
244 cpu_mem_write (sd
, 2, ft32_cpu
->regs
[FT32_HARD_SP
], v
);
247 static uint32_t ft32_pop (SIM_DESC sd
)
249 sim_cpu
*cpu
= STATE_CPU (sd
, 0);
250 struct ft32_cpu_state
*ft32_cpu
= FT32_SIM_CPU (cpu
);
251 uint32_t r
= cpu_mem_read (sd
, 2, ft32_cpu
->regs
[FT32_HARD_SP
]);
252 ft32_cpu
->regs
[FT32_HARD_SP
] += 4;
253 ft32_cpu
->regs
[FT32_HARD_SP
] &= 0xffff;
257 /* Extract the low SIZ bits of N as an unsigned number. */
258 static int nunsigned (int siz
, int n
)
260 return n
& LSBS (siz
);
263 /* Extract the low SIZ bits of N as a signed number. */
264 static int nsigned (int siz
, int n
)
266 int shift
= (sizeof (int) * 8) - siz
;
267 return (n
<< shift
) >> shift
;
270 /* Signed division N / D, matching hw behavior for (MIN_INT, -1). */
271 static uint32_t ft32sdiv (uint32_t n
, uint32_t d
)
273 if (n
== 0x80000000UL
&& d
== 0xffffffffUL
)
276 return (uint32_t)((int)n
/ (int)d
);
279 /* Signed modulus N % D, matching hw behavior for (MIN_INT, -1). */
280 static uint32_t ft32smod (uint32_t n
, uint32_t d
)
282 if (n
== 0x80000000UL
&& d
== 0xffffffffUL
)
285 return (uint32_t)((int)n
% (int)d
);
288 /* Circular rotate right N by B bits. */
289 static uint32_t ror (uint32_t n
, uint32_t b
)
292 return (n
>> b
) | (n
<< (32 - b
));
295 /* Implement the BINS machine instruction.
296 See FT32 Programmer's Reference for details. */
297 static uint32_t bins (uint32_t d
, uint32_t f
, uint32_t len
, uint32_t pos
)
299 uint32_t bitmask
= LSBS (len
) << pos
;
300 return (d
& ~bitmask
) | ((f
<< pos
) & bitmask
);
303 /* Implement the FLIP machine instruction.
304 See FT32 Programmer's Reference for details. */
305 static uint32_t flip (uint32_t x
, uint32_t b
)
308 x
= (x
& 0x55555555) << 1 | (x
& 0xAAAAAAAA) >> 1;
310 x
= (x
& 0x33333333) << 2 | (x
& 0xCCCCCCCC) >> 2;
312 x
= (x
& 0x0F0F0F0F) << 4 | (x
& 0xF0F0F0F0) >> 4;
314 x
= (x
& 0x00FF00FF) << 8 | (x
& 0xFF00FF00) >> 8;
316 x
= (x
& 0x0000FFFF) << 16 | (x
& 0xFFFF0000) >> 16;
321 step_once (SIM_DESC sd
)
323 sim_cpu
*cpu
= STATE_CPU (sd
, 0);
324 struct ft32_cpu_state
*ft32_cpu
= FT32_SIM_CPU (cpu
);
350 inst
= ft32_read_item (sd
, 2, ft32_cpu
->pc
);
351 ft32_cpu
->cycles
+= 1;
353 if ((STATE_ARCHITECTURE (sd
)->mach
== bfd_mach_ft32b
)
354 && ft32_decode_shortcode (ft32_cpu
->pc
, inst
, sc
))
356 if ((ft32_cpu
->pc
& 3) == 0)
365 /* Handle "call 8" (which is FT32's "break" equivalent) here. */
366 if (inst
== 0x00340002)
368 sim_engine_halt (sd
, cpu
, NULL
,
370 sim_stopped
, SIM_SIGTRAP
);
374 dw
= (inst
>> FT32_FLD_DW_BIT
) & LSBS (FT32_FLD_DW_SIZ
);
375 cb
= (inst
>> FT32_FLD_CB_BIT
) & LSBS (FT32_FLD_CB_SIZ
);
376 r_d
= (inst
>> FT32_FLD_R_D_BIT
) & LSBS (FT32_FLD_R_D_SIZ
);
377 cr
= (inst
>> FT32_FLD_CR_BIT
) & LSBS (FT32_FLD_CR_SIZ
);
378 cv
= (inst
>> FT32_FLD_CV_BIT
) & LSBS (FT32_FLD_CV_SIZ
);
379 bt
= (inst
>> FT32_FLD_BT_BIT
) & LSBS (FT32_FLD_BT_SIZ
);
380 r_1
= (inst
>> FT32_FLD_R_1_BIT
) & LSBS (FT32_FLD_R_1_SIZ
);
381 rimm
= (inst
>> FT32_FLD_RIMM_BIT
) & LSBS (FT32_FLD_RIMM_SIZ
);
382 r_2
= (inst
>> FT32_FLD_R_2_BIT
) & LSBS (FT32_FLD_R_2_SIZ
);
383 k20
= nsigned (20, (inst
>> FT32_FLD_K20_BIT
) & LSBS (FT32_FLD_K20_SIZ
));
384 pa
= (inst
>> FT32_FLD_PA_BIT
) & LSBS (FT32_FLD_PA_SIZ
);
385 aa
= (inst
>> FT32_FLD_AA_BIT
) & LSBS (FT32_FLD_AA_SIZ
);
386 k16
= (inst
>> FT32_FLD_K16_BIT
) & LSBS (FT32_FLD_K16_SIZ
);
387 k15
= (inst
>> FT32_FLD_K15_BIT
) & LSBS (FT32_FLD_K15_SIZ
);
392 al
= (inst
>> FT32_FLD_AL_BIT
) & LSBS (FT32_FLD_AL_SIZ
);
394 r_1v
= ft32_cpu
->regs
[r_1
];
395 rimmv
= (rimm
& 0x400) ? nsigned (10, rimm
) : ft32_cpu
->regs
[rimm
& 0x1f];
397 bit_pos
= rimmv
& 31;
398 bit_len
= 0xf & (rimmv
>> 5);
402 upper
= (inst
>> 27);
404 insnpc
= ft32_cpu
->pc
;
405 ft32_cpu
->pc
+= isize
;
411 int take
= (cr
== 3) || ((1 & (ft32_cpu
->regs
[28 + cr
] >> cb
)) == cv
);
414 ft32_cpu
->cycles
+= 1;
416 ft32_push (sd
, ft32_cpu
->pc
); /* this is a call. */
417 if (upper
== FT32_PAT_TOC
)
418 ft32_cpu
->pc
= pa
<< 2;
420 ft32_cpu
->pc
= ft32_cpu
->regs
[r_2
];
421 if (ft32_cpu
->pc
== 0x8)
433 case 0x0: result
= r_1v
+ rimmv
; break;
434 case 0x1: result
= ror (r_1v
, rimmv
); break;
435 case 0x2: result
= r_1v
- rimmv
; break;
436 case 0x3: result
= (r_1v
<< 10) | (1023 & rimmv
); break;
437 case 0x4: result
= r_1v
& rimmv
; break;
438 case 0x5: result
= r_1v
| rimmv
; break;
439 case 0x6: result
= r_1v
^ rimmv
; break;
440 case 0x7: result
= ~(r_1v
^ rimmv
); break;
441 case 0x8: result
= r_1v
<< rimmv
; break;
442 case 0x9: result
= r_1v
>> rimmv
; break;
443 case 0xa: result
= (int32_t)r_1v
>> rimmv
; break;
444 case 0xb: result
= bins (r_1v
, rimmv
>> 10, bit_len
, bit_pos
); break;
445 case 0xc: result
= nsigned (bit_len
, r_1v
>> bit_pos
); break;
446 case 0xd: result
= nunsigned (bit_len
, r_1v
>> bit_pos
); break;
447 case 0xe: result
= flip (r_1v
, rimmv
); break;
449 sim_io_eprintf (sd
, "Unhandled alu %#x\n", al
);
452 if (upper
== FT32_PAT_ALUOP
)
453 ft32_cpu
->regs
[r_d
] = result
;
473 case 0: dwsiz
= 7; dwmask
= 0xffU
; break;
474 case 1: dwsiz
= 15; dwmask
= 0xffffU
; break;
475 case 2: dwsiz
= 31; dwmask
= 0xffffffffU
; break;
478 zero
= (0 == (result
& dwmask
));
479 sign
= 1 & (result
>> dwsiz
);
480 ahi
= 1 & (r_1v
>> dwsiz
);
481 bhi
= 1 & (rimmv
>> dwsiz
);
482 overflow
= (sign
!= ahi
) & (ahi
== !bhi
);
488 case 0x0: carry
= 1 & ((ra
+ rb
) >> bit
); break;
489 case 0x2: carry
= 1 & ((ra
- rb
) >> bit
); break;
490 default: carry
= 0; break;
492 above
= (!carry
& !zero
);
493 greater
= (sign
== overflow
) & !zero
;
494 greatereq
= (sign
== overflow
);
496 ft32_cpu
->regs
[r_d
] = (
509 ft32_cpu
->regs
[r_d
] = k20
;
513 ft32_cpu
->regs
[r_d
] = ft32_read_item (sd
, dw
, pa
<< 2);
514 ft32_cpu
->cycles
+= 1;
518 ft32_cpu
->regs
[r_d
] = ft32_read_item (sd
, dw
, ft32_cpu
->regs
[r_1
] + k15
);
519 ft32_cpu
->cycles
+= 1;
523 cpu_mem_write (sd
, dw
, aa
, ft32_cpu
->regs
[r_d
]);
527 cpu_mem_write (sd
, dw
, ft32_cpu
->regs
[r_d
] + k15
, ft32_cpu
->regs
[r_1
]);
531 ft32_cpu
->regs
[r_d
] = cpu_mem_read (sd
, dw
, aa
);
532 ft32_cpu
->cycles
+= 1;
536 ft32_cpu
->regs
[r_d
] = cpu_mem_read (sd
, dw
, ft32_cpu
->regs
[r_1
] + k15
);
537 ft32_cpu
->cycles
+= 1;
543 tmp
= cpu_mem_read (sd
, dw
, aa
);
544 cpu_mem_write (sd
, dw
, aa
, ft32_cpu
->regs
[r_d
]);
545 ft32_cpu
->regs
[r_d
] = tmp
;
546 ft32_cpu
->cycles
+= 1;
553 tmp
= cpu_mem_read (sd
, dw
, ft32_cpu
->regs
[r_1
] + k15
);
554 cpu_mem_write (sd
, dw
, ft32_cpu
->regs
[r_1
] + k15
, ft32_cpu
->regs
[r_d
]);
555 ft32_cpu
->regs
[r_d
] = tmp
;
556 ft32_cpu
->cycles
+= 1;
561 ft32_push (sd
, r_1v
);
565 ft32_push (sd
, ft32_cpu
->regs
[r_d
]);
566 ft32_cpu
->regs
[r_d
] = ft32_cpu
->regs
[FT32_HARD_SP
];
567 ft32_cpu
->regs
[FT32_HARD_SP
] -= k16
;
568 ft32_cpu
->regs
[FT32_HARD_SP
] &= 0xffff;
571 case FT32_PAT_UNLINK
:
572 ft32_cpu
->regs
[FT32_HARD_SP
] = ft32_cpu
->regs
[r_d
];
573 ft32_cpu
->regs
[FT32_HARD_SP
] &= 0xffff;
574 ft32_cpu
->regs
[r_d
] = ft32_pop (sd
);
578 ft32_cpu
->cycles
+= 1;
579 ft32_cpu
->regs
[r_d
] = ft32_pop (sd
);
582 case FT32_PAT_RETURN
:
583 ft32_cpu
->pc
= ft32_pop (sd
);
590 ft32_cpu
->regs
[r_d
] = r_1v
/ rimmv
;
593 ft32_cpu
->regs
[r_d
] = r_1v
% rimmv
;
596 ft32_cpu
->regs
[r_d
] = ft32sdiv (r_1v
, rimmv
);
599 ft32_cpu
->regs
[r_d
] = ft32smod (r_1v
, rimmv
);
604 /* strcmp instruction. */
608 while ((GET_BYTE (a
+ i
) != 0) &&
609 (GET_BYTE (a
+ i
) == GET_BYTE (b
+ i
)))
611 ft32_cpu
->regs
[r_d
] = GET_BYTE (a
+ i
) - GET_BYTE (b
+ i
);
617 /* memcpy instruction. */
619 uint32_t dst
= ft32_cpu
->regs
[r_d
];
621 for (i
= 0; i
< (rimmv
& 0x7fff); i
++)
622 PUT_BYTE (dst
+ i
, GET_BYTE (src
+ i
));
627 /* strlen instruction. */
630 for (i
= 0; GET_BYTE (src
+ i
) != 0; i
++)
632 ft32_cpu
->regs
[r_d
] = i
;
637 /* memset instruction. */
638 uint32_t dst
= ft32_cpu
->regs
[r_d
];
640 for (i
= 0; i
< (rimmv
& 0x7fff); i
++)
641 PUT_BYTE (dst
+ i
, r_1v
);
645 ft32_cpu
->regs
[r_d
] = r_1v
* rimmv
;
648 ft32_cpu
->regs
[r_d
] = ((uint64_t)r_1v
* (uint64_t)rimmv
) >> 32;
652 /* stpcpy instruction. */
654 uint32_t dst
= ft32_cpu
->regs
[r_d
];
656 for (i
= 0; GET_BYTE (src
+ i
) != 0; i
++)
657 PUT_BYTE (dst
+ i
, GET_BYTE (src
+ i
));
658 PUT_BYTE (dst
+ i
, 0);
659 ft32_cpu
->regs
[r_d
] = dst
+ i
;
664 /* streamout instruction. */
666 uint32_t src
= ft32_cpu
->regs
[r_1
];
667 for (i
= 0; i
< rimmv
; i
+= (1 << dw
))
672 cpu_mem_read (sd
, dw
, src
));
678 sim_io_eprintf (sd
, "Unhandled ffu %#x at %08x\n", al
, insnpc
);
684 sim_io_eprintf (sd
, "Unhandled pattern %d at %08x\n", upper
, insnpc
);
694 sim_engine_run (SIM_DESC sd
,
695 int next_cpu_nr
, /* ignore */
696 int nr_cpus
, /* ignore */
697 int siggnal
) /* ignore */
699 SIM_ASSERT (STATE_MAGIC (sd
) == SIM_MAGIC_NUMBER
);
704 if (sim_events_tick (sd
))
705 sim_events_process (sd
);
710 ft32_lookup_register (SIM_CPU
*cpu
, int nr
)
712 /* Handle the register number translation here.
713 * Sim registers are 0-31.
714 * Other tools (gcc, gdb) use:
721 struct ft32_cpu_state
*ft32_cpu
= FT32_SIM_CPU (cpu
);
723 if ((nr
< 0) || (nr
> 32))
725 sim_io_eprintf (CPU_STATE (cpu
), "unknown register %i\n", nr
);
732 return &ft32_cpu
->regs
[FT32_HARD_FP
];
734 return &ft32_cpu
->regs
[FT32_HARD_SP
];
736 return &ft32_cpu
->regs
[FT32_HARD_CC
];
738 return &ft32_cpu
->pc
;
740 return &ft32_cpu
->regs
[nr
- 2];
745 ft32_reg_store (SIM_CPU
*cpu
,
750 if (0 <= rn
&& rn
<= 32)
753 *ft32_lookup_register (cpu
, rn
) = ft32_extract_unsigned_integer (memory
, 4);
762 ft32_reg_fetch (SIM_CPU
*cpu
,
767 if (0 <= rn
&& rn
<= 32)
770 ft32_store_unsigned_integer (memory
, 4, *ft32_lookup_register (cpu
, rn
));
779 ft32_pc_get (SIM_CPU
*cpu
)
781 return FT32_SIM_CPU (cpu
)->pc
;
785 ft32_pc_set (SIM_CPU
*cpu
, sim_cia newpc
)
787 FT32_SIM_CPU (cpu
)->pc
= newpc
;
790 /* Cover function of sim_state_free to free the cpu buffers as well. */
793 free_state (SIM_DESC sd
)
795 if (STATE_MODULES (sd
) != NULL
)
796 sim_module_uninstall (sd
);
797 sim_cpu_free_all (sd
);
802 sim_open (SIM_OPEN_KIND kind
,
809 SIM_DESC sd
= sim_state_alloc (kind
, cb
);
811 /* Set default options before parsing user options. */
812 current_alignment
= STRICT_ALIGNMENT
;
813 current_target_byte_order
= BFD_ENDIAN_LITTLE
;
815 /* The cpu data is kept in a separately allocated chunk of memory. */
816 if (sim_cpu_alloc_all_extra (sd
, 0, sizeof (struct ft32_cpu_state
))
823 if (sim_pre_argv_init (sd
, argv
[0]) != SIM_RC_OK
)
829 /* The parser will print an error message for us, so we silently return. */
830 if (sim_parse_args (sd
, argv
) != SIM_RC_OK
)
836 /* Allocate external memory if none specified by user.
837 Use address 4 here in case the user wanted address 0 unmapped. */
838 if (sim_core_read_buffer (sd
, NULL
, read_map
, &c
, 4, 1) == 0)
840 sim_do_command (sd
, "memory region 0x00000000,0x40000");
841 sim_do_command (sd
, "memory region 0x800000,0x10000");
844 /* Check for/establish the reference program image. */
845 if (sim_analyze_program (sd
, STATE_PROG_FILE (sd
), abfd
) != SIM_RC_OK
)
851 /* Configure/verify the target byte order and other runtime
852 configuration options. */
853 if (sim_config (sd
) != SIM_RC_OK
)
859 if (sim_post_argv_init (sd
) != SIM_RC_OK
)
865 /* CPU specific initialization. */
866 for (i
= 0; i
< MAX_NR_PROCESSORS
; ++i
)
868 SIM_CPU
*cpu
= STATE_CPU (sd
, i
);
870 CPU_REG_FETCH (cpu
) = ft32_reg_fetch
;
871 CPU_REG_STORE (cpu
) = ft32_reg_store
;
872 CPU_PC_FETCH (cpu
) = ft32_pc_get
;
873 CPU_PC_STORE (cpu
) = ft32_pc_set
;
880 sim_create_inferior (SIM_DESC sd
,
886 sim_cpu
*cpu
= STATE_CPU (sd
, 0);
887 struct ft32_cpu_state
*ft32_cpu
= FT32_SIM_CPU (cpu
);
888 host_callback
*cb
= STATE_CALLBACK (sd
);
892 addr
= bfd_get_start_address (abfd
);
896 /* Standalone mode (i.e. `run`) will take care of the argv for us in
897 sim_open() -> sim_parse_args(). But in debug mode (i.e. 'target sim'
898 with `gdb`), we need to handle it because the user can change the
899 argv on the fly via gdb's 'run'. */
900 if (STATE_PROG_ARGV (sd
) != argv
)
902 freeargv (STATE_PROG_ARGV (sd
));
903 STATE_PROG_ARGV (sd
) = dupargv (argv
);
906 if (STATE_PROG_ENVP (sd
) != env
)
908 freeargv (STATE_PROG_ENVP (sd
));
909 STATE_PROG_ENVP (sd
) = dupargv (env
);
912 cb
->argv
= STATE_PROG_ARGV (sd
);
913 cb
->envp
= STATE_PROG_ENVP (sd
);
915 ft32_cpu
->regs
[FT32_HARD_SP
] = addr
;
917 ft32_cpu
->cycles
= 0;
918 ft32_cpu
->next_tick_cycle
= 100000;