1 /* emulos.c -- Small OS emulation
2 Copyright 1999, 2000 Free Software Foundation, Inc.
3 Written by Stephane Carrez (stcarrez@worldnet.fr)
5 This file is part of GDB, GAS, and the GNU binutils.
7 GDB, GAS, and the GNU binutils are free software; you can redistribute
8 them and/or modify them under the terms of the GNU General Public
9 License as published by the Free Software Foundation; either version
10 1, or (at your option) any later version.
12 GDB, GAS, and the GNU binutils are distributed in the hope that they
13 will be useful, but WITHOUT ANY WARRANTY; without even the implied
14 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
15 the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this file; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
27 #include <sys/types.h>
30 /* This file emulates some OS system calls.
31 It's basically used to give access to the host OS facilities
32 like: stdin, stdout, files, time of day. */
33 static int bench_mode
= -1;
34 static struct timeval bench_start
;
35 static struct timeval bench_stop
;
38 emul_bench (struct _sim_cpu
* cpu
)
47 gettimeofday (&bench_start
, 0);
51 gettimeofday (&bench_stop
, 0);
53 printf ("bench start not called...\n");
60 int addr
= cpu_get_x (cpu
);
61 double t_start
, t_stop
, t
;
65 t_start
= (double) (bench_start
.tv_sec
) * 1.0e6
;
66 t_start
+= (double) (bench_start
.tv_usec
);
67 t_stop
= (double) (bench_stop
.tv_sec
) * 1.0e6
;
68 t_stop
+= (double) (bench_stop
.tv_usec
);
72 buf
[sz
] = memory_read8 (cpu
, addr
);
82 printf ("bench_stop not called");
86 printf ("%-40.40s [%6d] %3.3f us\n", buf
,
87 op
, t
/ (double) (op
));
95 emul_write(struct _sim_cpu
* state
)
97 int addr
= cpu_get_x (state
) & 0x0FFFF;
98 int size
= cpu_get_d (state
) & 0x0FFFF;
100 if (addr
+ size
> 0x0FFFF) {
101 size
= 0x0FFFF - addr
;
103 state
->cpu_running
= 0;
106 uint8 val
= memory_read8 (state
, addr
);
114 /* emul_exit () is used by the default startup code of GCC to implement
115 the exit (). For a real target, this will create an ILLEGAL fault.
116 But doing an exit () on a real target is really a non-sense.
117 exit () is important for the validation of GCC. The exit status
118 is passed in 'D' register. */
120 emul_exit (sim_cpu
*cpu
)
122 sim_engine_halt (CPU_STATE (cpu
), cpu
,
123 NULL
, NULL_CIA
, sim_exited
,
128 emul_os (int code
, sim_cpu
*proc
)
130 proc
->cpu_current_cycle
= 8;
This page took 0.035796 seconds and 4 git commands to generate.