xref: /netbsd-src/external/gpl3/gdb.old/dist/sim/bfin/sim-main.h (revision 479d8f7d843cc1b22d497efdf1f27a50ee8418d4)
1 /* Simulator for Analog Devices Blackfin processors.
2 
3    Copyright (C) 2005-2015 Free Software Foundation, Inc.
4    Contributed by Analog Devices, Inc.
5 
6    This file is part of simulators.
7 
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.
12 
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.
17 
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/>.  */
20 
21 #ifndef _BFIN_MAIN_SIM_H_
22 #define _BFIN_MAIN_SIM_H_
23 
24 #include "sim-basics.h"
25 #include "sim-signal.h"
26 
27 /* TODO: Delete this.  Need to convert bu32/etc... to common sim types
28          and unwind the bfin-sim.h/machs.h include below first though.  */
29 typedef struct _sim_cpu SIM_CPU;
30 
31 #include "bfin-sim.h"
32 
33 #include "machs.h"
34 
35 #include "sim-base.h"
36 
37 struct _sim_cpu {
38   /* ... simulator specific members ... */
39   struct bfin_cpu_state state;
40   sim_cpu_base base;
41 };
42 #define BFIN_CPU_STATE ((cpu)->state)
43 
44 struct sim_state {
45   sim_cpu *cpu[MAX_NR_PROCESSORS];
46 
47   /* ... simulator specific members ... */
48   struct bfin_board_data board;
49 #define STATE_BOARD_DATA(sd) (&(sd)->board)
50   sim_state_base base;
51 };
52 
53 #include "sim-config.h"
54 #include "sim-types.h"
55 #include "sim-engine.h"
56 #include "sim-options.h"
57 #include "dv-bfin_trace.h"
58 
59 #undef MAX
60 #undef MIN
61 #undef CLAMP
62 #undef ALIGN
63 #define MAX(a, b) ((a) > (b) ? (a) : (b))
64 #define MIN(a, b) ((a) < (b) ? (a) : (b))
65 #define CLAMP(a, b, c) MIN (MAX (a, b), c)
66 #define ALIGN(addr, size) (((addr) + ((size)-1)) & ~((size)-1))
67 
68 /* TODO: Move all this trace logic to the common code.  */
69 #define BFIN_TRACE_CORE(cpu, addr, size, map, val) \
70   do { \
71     TRACE_CORE (cpu, "%cBUS %s %i bytes @ 0x%08x: 0x%0*x", \
72 		map == exec_map ? 'I' : 'D', \
73 		map == write_map ? "STORE" : "FETCH", \
74 		size, addr, size * 2, val); \
75     PROFILE_COUNT_CORE (cpu, addr, size, map); \
76   } while (0)
77 #define BFIN_TRACE_BRANCH(cpu, oldpc, newpc, hwloop, fmt, ...) \
78   do { \
79     TRACE_BRANCH (cpu, fmt " to %#x", ## __VA_ARGS__, newpc); \
80     if (STATE_ENVIRONMENT (CPU_STATE (cpu)) == OPERATING_ENVIRONMENT) \
81       bfin_trace_queue (cpu, oldpc, newpc, hwloop); \
82   } while (0)
83 
84 /* Default memory size.  */
85 #define BFIN_DEFAULT_MEM_SIZE (128 * 1024 * 1024)
86 
87 #endif
88