Statistics
| Branch: | Revision:

root / target-moxie / cpu.h @ 795ca114

History | View | Annotate | Download (4.2 kB)

1 525bd324 Anthony Green
/*
2 525bd324 Anthony Green
 *  Moxie emulation
3 525bd324 Anthony Green
 *
4 525bd324 Anthony Green
 *  Copyright (c) 2008, 2010, 2013 Anthony Green
5 525bd324 Anthony Green
 *
6 525bd324 Anthony Green
 * This library is free software; you can redistribute it and/or
7 525bd324 Anthony Green
 * modify it under the terms of the GNU Lesser General Public
8 525bd324 Anthony Green
 * License as published by the Free Software Foundation; either
9 525bd324 Anthony Green
 * version 2 of the License, or (at your option) any later version.
10 525bd324 Anthony Green
 *
11 525bd324 Anthony Green
 * This library is distributed in the hope that it will be useful,
12 525bd324 Anthony Green
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 525bd324 Anthony Green
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 525bd324 Anthony Green
 * Lesser General Public License for more details.
15 525bd324 Anthony Green
 *
16 525bd324 Anthony Green
 * You should have received a copy of the GNU General Public License
17 525bd324 Anthony Green
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 525bd324 Anthony Green
 */
19 525bd324 Anthony Green
#ifndef _CPU_MOXIE_H
20 525bd324 Anthony Green
#define _CPU_MOXIE_H
21 525bd324 Anthony Green
22 525bd324 Anthony Green
#include "config.h"
23 525bd324 Anthony Green
#include "qemu-common.h"
24 525bd324 Anthony Green
25 525bd324 Anthony Green
#define TARGET_LONG_BITS 32
26 525bd324 Anthony Green
27 525bd324 Anthony Green
#define CPUArchState struct CPUMoxieState
28 525bd324 Anthony Green
29 525bd324 Anthony Green
#define TARGET_HAS_ICE 1
30 525bd324 Anthony Green
31 525bd324 Anthony Green
#define ELF_MACHINE     0xFEED /* EM_MOXIE */
32 525bd324 Anthony Green
33 525bd324 Anthony Green
#define MOXIE_EX_DIV0        0
34 525bd324 Anthony Green
#define MOXIE_EX_BAD         1
35 525bd324 Anthony Green
#define MOXIE_EX_IRQ         2
36 525bd324 Anthony Green
#define MOXIE_EX_SWI         3
37 525bd324 Anthony Green
#define MOXIE_EX_MMU_MISS    4
38 525bd324 Anthony Green
#define MOXIE_EX_BREAK      16
39 525bd324 Anthony Green
40 525bd324 Anthony Green
#include "exec/cpu-defs.h"
41 525bd324 Anthony Green
#include "fpu/softfloat.h"
42 525bd324 Anthony Green
43 525bd324 Anthony Green
#define TARGET_PAGE_BITS 12     /* 4k */
44 525bd324 Anthony Green
45 525bd324 Anthony Green
#define TARGET_PHYS_ADDR_SPACE_BITS 32
46 525bd324 Anthony Green
#define TARGET_VIRT_ADDR_SPACE_BITS 32
47 525bd324 Anthony Green
48 525bd324 Anthony Green
#define NB_MMU_MODES 1
49 525bd324 Anthony Green
50 525bd324 Anthony Green
typedef struct CPUMoxieState {
51 525bd324 Anthony Green
52 525bd324 Anthony Green
    uint32_t flags;               /* general execution flags */
53 525bd324 Anthony Green
    uint32_t gregs[16];           /* general registers */
54 525bd324 Anthony Green
    uint32_t sregs[256];          /* special registers */
55 525bd324 Anthony Green
    uint32_t pc;                  /* program counter */
56 525bd324 Anthony Green
    /* Instead of saving the cc value, we save the cmp arguments
57 525bd324 Anthony Green
       and compute cc on demand.  */
58 525bd324 Anthony Green
    uint32_t cc_a;                /* reg a for condition code calculation */
59 525bd324 Anthony Green
    uint32_t cc_b;                /* reg b for condition code calculation */
60 525bd324 Anthony Green
61 525bd324 Anthony Green
    void *irq[8];
62 525bd324 Anthony Green
63 525bd324 Anthony Green
    CPU_COMMON
64 525bd324 Anthony Green
65 525bd324 Anthony Green
} CPUMoxieState;
66 525bd324 Anthony Green
67 525bd324 Anthony Green
#include "qom/cpu.h"
68 525bd324 Anthony Green
69 525bd324 Anthony Green
#define TYPE_MOXIE_CPU "moxie-cpu"
70 525bd324 Anthony Green
71 525bd324 Anthony Green
#define MOXIE_CPU_CLASS(klass) \
72 525bd324 Anthony Green
    OBJECT_CLASS_CHECK(MoxieCPUClass, (klass), TYPE_MOXIE_CPU)
73 525bd324 Anthony Green
#define MOXIE_CPU(obj) \
74 525bd324 Anthony Green
    OBJECT_CHECK(MoxieCPU, (obj), TYPE_MOXIE_CPU)
75 525bd324 Anthony Green
#define MOXIE_CPU_GET_CLASS(obj) \
76 525bd324 Anthony Green
    OBJECT_GET_CLASS(MoxieCPUClass, (obj), TYPE_MOXIE_CPU)
77 525bd324 Anthony Green
78 525bd324 Anthony Green
/**
79 525bd324 Anthony Green
 * MoxieCPUClass:
80 525bd324 Anthony Green
 * @parent_reset: The parent class' reset handler.
81 525bd324 Anthony Green
 *
82 525bd324 Anthony Green
 * A Moxie CPU model.
83 525bd324 Anthony Green
 */
84 525bd324 Anthony Green
typedef struct MoxieCPUClass {
85 525bd324 Anthony Green
    /*< private >*/
86 525bd324 Anthony Green
    CPUClass parent_class;
87 525bd324 Anthony Green
    /*< public >*/
88 525bd324 Anthony Green
89 525bd324 Anthony Green
    DeviceRealize parent_realize;
90 525bd324 Anthony Green
    void (*parent_reset)(CPUState *cpu);
91 525bd324 Anthony Green
} MoxieCPUClass;
92 525bd324 Anthony Green
93 525bd324 Anthony Green
/**
94 525bd324 Anthony Green
 * MoxieCPU:
95 525bd324 Anthony Green
 * @env: #CPUMoxieState
96 525bd324 Anthony Green
 *
97 525bd324 Anthony Green
 * A Moxie CPU.
98 525bd324 Anthony Green
 */
99 525bd324 Anthony Green
typedef struct MoxieCPU {
100 525bd324 Anthony Green
    /*< private >*/
101 525bd324 Anthony Green
    CPUState parent_obj;
102 525bd324 Anthony Green
    /*< public >*/
103 525bd324 Anthony Green
104 525bd324 Anthony Green
    CPUMoxieState env;
105 525bd324 Anthony Green
} MoxieCPU;
106 525bd324 Anthony Green
107 525bd324 Anthony Green
static inline MoxieCPU *moxie_env_get_cpu(CPUMoxieState *env)
108 525bd324 Anthony Green
{
109 6e42be7c Andreas Färber
    return container_of(env, MoxieCPU, env);
110 525bd324 Anthony Green
}
111 525bd324 Anthony Green
112 525bd324 Anthony Green
#define ENV_GET_CPU(e) CPU(moxie_env_get_cpu(e))
113 525bd324 Anthony Green
114 525bd324 Anthony Green
#define ENV_OFFSET offsetof(MoxieCPU, env)
115 525bd324 Anthony Green
116 525bd324 Anthony Green
MoxieCPU *cpu_moxie_init(const char *cpu_model);
117 525bd324 Anthony Green
int cpu_moxie_exec(CPUMoxieState *s);
118 53574064 Dunrong Huang
void moxie_cpu_do_interrupt(CPUState *cs);
119 878096ee Andreas Färber
void moxie_cpu_dump_state(CPUState *cpu, FILE *f,
120 878096ee Andreas Färber
                          fprintf_function cpu_fprintf, int flags);
121 00b941e5 Andreas Färber
hwaddr moxie_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
122 525bd324 Anthony Green
void moxie_translate_init(void);
123 525bd324 Anthony Green
int cpu_moxie_signal_handler(int host_signum, void *pinfo,
124 525bd324 Anthony Green
                             void *puc);
125 525bd324 Anthony Green
126 525bd324 Anthony Green
static inline CPUMoxieState *cpu_init(const char *cpu_model)
127 525bd324 Anthony Green
{
128 525bd324 Anthony Green
    MoxieCPU *cpu = cpu_moxie_init(cpu_model);
129 525bd324 Anthony Green
    if (cpu == NULL) {
130 525bd324 Anthony Green
        return NULL;
131 525bd324 Anthony Green
    }
132 525bd324 Anthony Green
    return &cpu->env;
133 525bd324 Anthony Green
}
134 525bd324 Anthony Green
135 525bd324 Anthony Green
#define cpu_exec cpu_moxie_exec
136 525bd324 Anthony Green
#define cpu_gen_code cpu_moxie_gen_code
137 525bd324 Anthony Green
#define cpu_signal_handler cpu_moxie_signal_handler
138 525bd324 Anthony Green
139 525bd324 Anthony Green
static inline int cpu_mmu_index(CPUMoxieState *env)
140 525bd324 Anthony Green
{
141 525bd324 Anthony Green
    return 0;
142 525bd324 Anthony Green
}
143 525bd324 Anthony Green
144 525bd324 Anthony Green
#include "exec/cpu-all.h"
145 525bd324 Anthony Green
#include "exec/exec-all.h"
146 525bd324 Anthony Green
147 525bd324 Anthony Green
static inline void cpu_get_tb_cpu_state(CPUMoxieState *env, target_ulong *pc,
148 525bd324 Anthony Green
                                        target_ulong *cs_base, int *flags)
149 525bd324 Anthony Green
{
150 525bd324 Anthony Green
    *pc = env->pc;
151 525bd324 Anthony Green
    *cs_base = 0;
152 525bd324 Anthony Green
    *flags = 0;
153 525bd324 Anthony Green
}
154 525bd324 Anthony Green
155 525bd324 Anthony Green
static inline int cpu_has_work(CPUState *cpu)
156 525bd324 Anthony Green
{
157 525bd324 Anthony Green
    return cpu->interrupt_request & CPU_INTERRUPT_HARD;
158 525bd324 Anthony Green
}
159 525bd324 Anthony Green
160 525bd324 Anthony Green
int cpu_moxie_handle_mmu_fault(CPUMoxieState *env, target_ulong address,
161 525bd324 Anthony Green
                               int rw, int mmu_idx);
162 525bd324 Anthony Green
163 525bd324 Anthony Green
#endif /* _CPU_MOXIE_H */