root / target-sh4 / cpu.h @ 36bb244b
History | View | Annotate | Download (4.7 kB)
1 | fdf9b3e8 | bellard | /*
|
---|---|---|---|
2 | fdf9b3e8 | bellard | * SH4 emulation
|
3 | fdf9b3e8 | bellard | *
|
4 | fdf9b3e8 | bellard | * Copyright (c) 2005 Samuel Tardieu
|
5 | fdf9b3e8 | bellard | *
|
6 | fdf9b3e8 | bellard | * This library is free software; you can redistribute it and/or
|
7 | fdf9b3e8 | bellard | * modify it under the terms of the GNU Lesser General Public
|
8 | fdf9b3e8 | bellard | * License as published by the Free Software Foundation; either
|
9 | fdf9b3e8 | bellard | * version 2 of the License, or (at your option) any later version.
|
10 | fdf9b3e8 | bellard | *
|
11 | fdf9b3e8 | bellard | * This library is distributed in the hope that it will be useful,
|
12 | fdf9b3e8 | bellard | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | fdf9b3e8 | bellard | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | fdf9b3e8 | bellard | * Lesser General Public License for more details.
|
15 | fdf9b3e8 | bellard | *
|
16 | fdf9b3e8 | bellard | * You should have received a copy of the GNU Lesser General Public
|
17 | fdf9b3e8 | bellard | * License along with this library; if not, write to the Free Software
|
18 | fdf9b3e8 | bellard | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19 | fdf9b3e8 | bellard | */
|
20 | fdf9b3e8 | bellard | #ifndef _CPU_SH4_H
|
21 | fdf9b3e8 | bellard | #define _CPU_SH4_H
|
22 | fdf9b3e8 | bellard | |
23 | fdf9b3e8 | bellard | #include "config.h" |
24 | fdf9b3e8 | bellard | |
25 | fdf9b3e8 | bellard | #define TARGET_LONG_BITS 32 |
26 | fdf9b3e8 | bellard | #define TARGET_HAS_ICE 1 |
27 | fdf9b3e8 | bellard | |
28 | 9042c0e2 | ths | #define ELF_MACHINE EM_SH
|
29 | 9042c0e2 | ths | |
30 | fdf9b3e8 | bellard | #include "cpu-defs.h" |
31 | fdf9b3e8 | bellard | |
32 | eda9b09b | bellard | #include "softfloat.h" |
33 | eda9b09b | bellard | |
34 | fdf9b3e8 | bellard | #define TARGET_PAGE_BITS 12 /* 4k XXXXX */ |
35 | fdf9b3e8 | bellard | |
36 | fdf9b3e8 | bellard | #define SR_MD (1 << 30) |
37 | fdf9b3e8 | bellard | #define SR_RB (1 << 29) |
38 | fdf9b3e8 | bellard | #define SR_BL (1 << 28) |
39 | fdf9b3e8 | bellard | #define SR_FD (1 << 15) |
40 | fdf9b3e8 | bellard | #define SR_M (1 << 9) |
41 | fdf9b3e8 | bellard | #define SR_Q (1 << 8) |
42 | fdf9b3e8 | bellard | #define SR_S (1 << 1) |
43 | fdf9b3e8 | bellard | #define SR_T (1 << 0) |
44 | fdf9b3e8 | bellard | |
45 | fdf9b3e8 | bellard | #define FPSCR_FR (1 << 21) |
46 | fdf9b3e8 | bellard | #define FPSCR_SZ (1 << 20) |
47 | fdf9b3e8 | bellard | #define FPSCR_PR (1 << 19) |
48 | fdf9b3e8 | bellard | #define FPSCR_DN (1 << 18) |
49 | fdf9b3e8 | bellard | |
50 | 9c2a9ea1 | pbrook | #define DELAY_SLOT (1 << 0) /* Must be the same as SR_T. */ |
51 | 9c2a9ea1 | pbrook | /* This flag is set if the next insn is a delay slot for a conditional jump.
|
52 | 9c2a9ea1 | pbrook | The dynamic value of the DELAY_SLOT determines whether the jup is taken. */
|
53 | fdf9b3e8 | bellard | #define DELAY_SLOT_CONDITIONAL (1 << 1) |
54 | fdf9b3e8 | bellard | /* Those are used in contexts only */
|
55 | fdf9b3e8 | bellard | #define BRANCH (1 << 2) |
56 | fdf9b3e8 | bellard | #define BRANCH_CONDITIONAL (1 << 3) |
57 | fdf9b3e8 | bellard | #define MODE_CHANGE (1 << 4) /* Potential MD|RB change */ |
58 | fdf9b3e8 | bellard | #define BRANCH_EXCEPTION (1 << 5) /* Branch after exception */ |
59 | fdf9b3e8 | bellard | |
60 | fdf9b3e8 | bellard | /* XXXXX The structure could be made more compact */
|
61 | fdf9b3e8 | bellard | typedef struct tlb_t { |
62 | fdf9b3e8 | bellard | uint8_t asid; /* address space identifier */
|
63 | fdf9b3e8 | bellard | uint32_t vpn; /* virtual page number */
|
64 | fdf9b3e8 | bellard | uint8_t v; /* validity */
|
65 | fdf9b3e8 | bellard | uint32_t ppn; /* physical page number */
|
66 | fdf9b3e8 | bellard | uint8_t sz; /* page size */
|
67 | fdf9b3e8 | bellard | uint32_t size; /* cached page size in bytes */
|
68 | fdf9b3e8 | bellard | uint8_t sh; /* share status */
|
69 | fdf9b3e8 | bellard | uint8_t c; /* cacheability */
|
70 | fdf9b3e8 | bellard | uint8_t pr; /* protection key */
|
71 | fdf9b3e8 | bellard | uint8_t d; /* dirty */
|
72 | fdf9b3e8 | bellard | uint8_t wt; /* write through */
|
73 | fdf9b3e8 | bellard | uint8_t sa; /* space attribute (PCMCIA) */
|
74 | fdf9b3e8 | bellard | uint8_t tc; /* timing control */
|
75 | fdf9b3e8 | bellard | } tlb_t; |
76 | fdf9b3e8 | bellard | |
77 | fdf9b3e8 | bellard | #define UTLB_SIZE 64 |
78 | fdf9b3e8 | bellard | #define ITLB_SIZE 4 |
79 | fdf9b3e8 | bellard | |
80 | fdf9b3e8 | bellard | typedef struct CPUSH4State { |
81 | fdf9b3e8 | bellard | uint32_t flags; /* general execution flags */
|
82 | fdf9b3e8 | bellard | uint32_t gregs[24]; /* general registers */ |
83 | fdf9b3e8 | bellard | uint32_t fregs[32]; /* floating point registers */ |
84 | fdf9b3e8 | bellard | uint32_t sr; /* status register */
|
85 | fdf9b3e8 | bellard | uint32_t ssr; /* saved status register */
|
86 | fdf9b3e8 | bellard | uint32_t spc; /* saved program counter */
|
87 | fdf9b3e8 | bellard | uint32_t gbr; /* global base register */
|
88 | fdf9b3e8 | bellard | uint32_t vbr; /* vector base register */
|
89 | fdf9b3e8 | bellard | uint32_t sgr; /* saved global register 15 */
|
90 | fdf9b3e8 | bellard | uint32_t dbr; /* debug base register */
|
91 | fdf9b3e8 | bellard | uint32_t pc; /* program counter */
|
92 | fdf9b3e8 | bellard | uint32_t delayed_pc; /* target of delayed jump */
|
93 | fdf9b3e8 | bellard | uint32_t mach; /* multiply and accumulate high */
|
94 | fdf9b3e8 | bellard | uint32_t macl; /* multiply and accumulate low */
|
95 | fdf9b3e8 | bellard | uint32_t pr; /* procedure register */
|
96 | fdf9b3e8 | bellard | uint32_t fpscr; /* floating point status/control register */
|
97 | fdf9b3e8 | bellard | uint32_t fpul; /* floating point communication register */
|
98 | fdf9b3e8 | bellard | |
99 | eda9b09b | bellard | /* temporary float registers */
|
100 | eda9b09b | bellard | float32 ft0, ft1; |
101 | eda9b09b | bellard | float64 dt0, dt1; |
102 | eda9b09b | bellard | |
103 | fdf9b3e8 | bellard | /* Those belong to the specific unit (SH7750) but are handled here */
|
104 | fdf9b3e8 | bellard | uint32_t mmucr; /* MMU control register */
|
105 | fdf9b3e8 | bellard | uint32_t pteh; /* page table entry high register */
|
106 | fdf9b3e8 | bellard | uint32_t ptel; /* page table entry low register */
|
107 | fdf9b3e8 | bellard | uint32_t ptea; /* page table entry assistance register */
|
108 | fdf9b3e8 | bellard | uint32_t ttb; /* tranlation table base register */
|
109 | fdf9b3e8 | bellard | uint32_t tea; /* TLB exception address register */
|
110 | fdf9b3e8 | bellard | uint32_t tra; /* TRAPA exception register */
|
111 | fdf9b3e8 | bellard | uint32_t expevt; /* exception event register */
|
112 | fdf9b3e8 | bellard | uint32_t intevt; /* interrupt event register */
|
113 | fdf9b3e8 | bellard | |
114 | fdf9b3e8 | bellard | jmp_buf jmp_env; |
115 | fdf9b3e8 | bellard | int user_mode_only;
|
116 | fdf9b3e8 | bellard | int interrupt_request;
|
117 | fdf9b3e8 | bellard | int exception_index;
|
118 | fdf9b3e8 | bellard | CPU_COMMON tlb_t utlb[UTLB_SIZE]; /* unified translation table */
|
119 | fdf9b3e8 | bellard | tlb_t itlb[ITLB_SIZE]; /* instruction translation table */
|
120 | fdf9b3e8 | bellard | } CPUSH4State; |
121 | fdf9b3e8 | bellard | |
122 | fdf9b3e8 | bellard | CPUSH4State *cpu_sh4_init(void);
|
123 | fdf9b3e8 | bellard | int cpu_sh4_exec(CPUSH4State * s);
|
124 | 5a7b542b | ths | int cpu_sh4_signal_handler(int host_signum, void *pinfo, |
125 | 5a7b542b | ths | void *puc);
|
126 | fdf9b3e8 | bellard | |
127 | fdf9b3e8 | bellard | #include "softfloat.h" |
128 | fdf9b3e8 | bellard | |
129 | fdf9b3e8 | bellard | #include "cpu-all.h" |
130 | fdf9b3e8 | bellard | |
131 | fdf9b3e8 | bellard | /* Memory access type */
|
132 | fdf9b3e8 | bellard | enum {
|
133 | fdf9b3e8 | bellard | /* Privilege */
|
134 | fdf9b3e8 | bellard | ACCESS_PRIV = 0x01,
|
135 | fdf9b3e8 | bellard | /* Direction */
|
136 | fdf9b3e8 | bellard | ACCESS_WRITE = 0x02,
|
137 | fdf9b3e8 | bellard | /* Type of instruction */
|
138 | fdf9b3e8 | bellard | ACCESS_CODE = 0x10,
|
139 | fdf9b3e8 | bellard | ACCESS_INT = 0x20
|
140 | fdf9b3e8 | bellard | }; |
141 | fdf9b3e8 | bellard | |
142 | fdf9b3e8 | bellard | /* MMU control register */
|
143 | fdf9b3e8 | bellard | #define MMUCR 0x1F000010 |
144 | fdf9b3e8 | bellard | #define MMUCR_AT (1<<0) |
145 | fdf9b3e8 | bellard | #define MMUCR_SV (1<<8) |
146 | fdf9b3e8 | bellard | |
147 | fdf9b3e8 | bellard | #endif /* _CPU_SH4_H */ |