2 * Copyright (c) 2011, Max Filippov, Open Source and Linux Lab.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the Open Source and Linux Lab nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "qemu-common.h"
32 #include "host-utils.h"
33 #if !defined(CONFIG_USER_ONLY)
34 #include "hw/loader.h"
37 void cpu_reset(CPUXtensaState
*env
)
39 env
->exception_taken
= 0;
40 env
->pc
= env
->config
->exception_vector
[EXC_RESET
];
41 env
->sregs
[PS
] = 0x1f;
44 static const XtensaConfig core_config
[] = {
46 .name
= "sample-xtensa-core",
52 [EXC_RESET
] = 0x5fff8000,
53 [EXC_WINDOW_OVERFLOW4
] = 0x5fff8400,
54 [EXC_WINDOW_UNDERFLOW4
] = 0x5fff8440,
55 [EXC_WINDOW_OVERFLOW8
] = 0x5fff8480,
56 [EXC_WINDOW_UNDERFLOW8
] = 0x5fff84c0,
57 [EXC_WINDOW_OVERFLOW12
] = 0x5fff8500,
58 [EXC_WINDOW_UNDERFLOW12
] = 0x5fff8540,
59 [EXC_KERNEL
] = 0x5fff861c,
60 [EXC_USER
] = 0x5fff863c,
61 [EXC_DOUBLE
] = 0x5fff865c,
66 CPUXtensaState
*cpu_xtensa_init(const char *cpu_model
)
68 static int tcg_inited
;
70 const XtensaConfig
*config
= NULL
;
73 for (i
= 0; i
< ARRAY_SIZE(core_config
); ++i
)
74 if (strcmp(core_config
[i
].name
, cpu_model
) == 0) {
75 config
= core_config
+ i
;
83 env
= g_malloc0(sizeof(*env
));
89 xtensa_translate_init();
97 void xtensa_cpu_list(FILE *f
, fprintf_function cpu_fprintf
)
100 cpu_fprintf(f
, "Available CPUs:\n");
101 for (i
= 0; i
< ARRAY_SIZE(core_config
); ++i
) {
102 cpu_fprintf(f
, " %s\n", core_config
[i
].name
);
106 target_phys_addr_t
cpu_get_phys_page_debug(CPUState
*env
, target_ulong addr
)
111 void do_interrupt(CPUState
*env
)
113 switch (env
->exception_index
) {
114 case EXC_WINDOW_OVERFLOW4
:
115 case EXC_WINDOW_UNDERFLOW4
:
116 case EXC_WINDOW_OVERFLOW8
:
117 case EXC_WINDOW_UNDERFLOW8
:
118 case EXC_WINDOW_OVERFLOW12
:
119 case EXC_WINDOW_UNDERFLOW12
:
123 if (env
->config
->exception_vector
[env
->exception_index
]) {
124 env
->pc
= env
->config
->exception_vector
[env
->exception_index
];
125 env
->exception_taken
= 1;
127 qemu_log("%s(pc = %08x) bad exception_index: %d\n",
128 __func__
, env
->pc
, env
->exception_index
);